Setjmp

Hi ,

I am trying to port a free JVM to QNX 6.1.0 for i386. I need to use
setjmp/longjmp calls. However i don’t know the offsets of various registers
in the jmpbuf. I am mainly intrested in stack pointer.

Any help or clues are welcome.

tia

Sandy

Not only that, but gcc actually implements setjmp/longjmp as a builtin,
so unless you are specifying -fno-builtin you may be looking at the
wrong stuff!

none <none@none.com> wrote:

“Sandeep Khurana” <> skhurana@noida.hcltech.com> > wrote in message
news:9nus5j$sf4$> 1@nntp.qnx.com> …

I am trying to port a free JVM to QNX 6.1.0 for i386. I need to use
setjmp/longjmp calls. However i don’t know the offsets of various
registers
in the jmpbuf. I am mainly intrested in stack pointer.

Taking a look at the header file for setjmp.h you can do a loop to dump out
the contents and then compare them to registers (using a debugger) to find
out the exact offsets. I believe that the 2nd element is the ESI register.
This is very x86 specific, the offsets/registers change for each platform
that Neutrino runs on (arm, mips etc).

eg.
jmp_buf env;
int retval;

retval = setjmp(env);

for (c=0 ; c < __JMPBUFSIZE ; c++)
{
fprintf(stderr, “0x%08x “, env[0].__jmpbuf_un.__savearea[c]);
if ((c+1)%5) fprintf(stderr,”\n”); /* silly little formating */
}
fprintf(stderr,"\n");


cburgess@qnx.com

“Sandeep Khurana” <skhurana@noida.hcltech.com> wrote in message
news:9nus5j$sf4$1@nntp.qnx.com

I am trying to port a free JVM to QNX 6.1.0 for i386. I need to use
setjmp/longjmp calls. However i don’t know the offsets of various
registers
in the jmpbuf. I am mainly intrested in stack pointer.

Taking a look at the header file for setjmp.h you can do a loop to dump out
the contents and then compare them to registers (using a debugger) to find
out the exact offsets. I believe that the 2nd element is the ESI register.
This is very x86 specific, the offsets/registers change for each platform
that Neutrino runs on (arm, mips etc).

eg.
jmp_buf env;
int retval;

retval = setjmp(env);

for (c=0 ; c < __JMPBUFSIZE ; c++)
{
fprintf(stderr, “0x%08x “, env[0].__jmpbuf_un.__savearea[c]);
if ((c+1)%5) fprintf(stderr,”\n”); /* silly little formating */
}
fprintf(stderr,"\n");

none <none@none.com> wrote:

“Colin Burgess” <> cburgess@qnx.com> > wrote in message
news:9o5mbn$6oj$> 1@nntp.qnx.com> …
Not only that, but gcc actually implements setjmp/longjmp as a builtin,
so unless you are specifying -fno-builtin you may be looking at the
wrong stuff!

Is the list of built-in’s in the GCC docs? My previous post might have
benefited from that information > :slight_smile: > (had I even put my name down on it, I
wonder how that happend)

There’s this, but it doesn’t seem to be a complete list. Note that some
of the builtins can vary by processor architecture. :frowning:

-fno-builtin Don’t recognize builtin functions that do not begin with
`_builtin’ as prefix. Currently, the functions affected include abort,
abs, alloca, cos, exit, fabs, ffs, labs, memcmp, memcpy, sin, sqrt,
strcmp, strcpy, and strlen.

GCC normally generates special code to handle certain builtin functions
more efficiently; for instance, calls to alloca may become single
instructions that adjust the stack directly, and calls to memcpy may
become inline copy loops. The resulting code is often both smaller and
faster, but since the function calls no longer appear as such, you
cannot set a breakpoint on those calls, nor can you change the behavior
of the functions by linking with a different library.
The `-ansi’ option prevents alloca and ffs from being builtin functions,
since these functions do not have an ANSI standard meaning.

cburgess@qnx.com

“Colin Burgess” <cburgess@qnx.com> wrote in message
news:9o5mbn$6oj$1@nntp.qnx.com

Not only that, but gcc actually implements setjmp/longjmp as a builtin,
so unless you are specifying -fno-builtin you may be looking at the
wrong stuff!

Is the list of built-in’s in the GCC docs? My previous post might have
benefited from that information :slight_smile: (had I even put my name down on it, I
wonder how that happend)

-Adam