Re: examining a jump buffer



Allan Adler <ara@xxxxxxxxxxxxxxxxxxxx> writes:

Jean-David Beyer <jeandavid8@xxxxxxxxxxx> writes:

Allan Adler wrote:
Thanks for the suggestions. I'm never sure what one can look at and
what one can't. For example, I think gdb can't really let you examine
kernel stuff. I think we (collectively) once had a thread here in which
I wanted to examine the innards of a FILE using gdb. Anyway, I'll try
what you suggest.

That would not matter, since "env" is in your user space.

OK, thanks. I wrote a naive little program and tested it in gdb:
main()
{
setjmp(env);
longjump(env,1);
return 0;
}

It compiled ok and hung when it ran. I looked at it in gdb and printed env
and realized eventually that I was stepping through an infinite loop in which
the program was executing longjump(env,1) over and over again. Can someone
please explain why? I can sort of guess, but my guesses in a matter about
which I understand so little aren't worth much.

It appears that you don't understand how setjmp/longjmp work.
They are doing exactly what they should be doing.

The man pages for both functions are pretty clear.

What part of:

After longjmp() is completed, program exe-
cution continues as if the corresponding call of setjmp() had just
returned the value val.

don't you understand?

It's trying to tell you longjump goes to the instruction
right after setjmp.

This is probably not the best forum to learn C on.
.



Relevant Pages

  • Re: examining a jump buffer
    ... For stuff like fork, signal, setjmp and longjmp, I found the ... one thing you might try to keep in mind when answering my questions ... to think of library functions in the context of UNIX. ... in gdb, I wrote the stupid program, not caring whether it was the right ...
    (comp.os.linux.misc)
  • Re: examining a jump buffer
    ... I wanted to examine the innards of a FILE using gdb. ... That would not matter, since "env" is in your user space. ... I looked at it in gdb and printed env ... It appears that you don't understand how setjmp/longjmp work. ...
    (comp.os.linux.misc)
  • Re: examining a jump buffer
    ... I wanted to examine the innards of a FILE using gdb. ... That would not matter, since "env" is in your user space. ... I looked at it in gdb and printed env ... It appears that you don't understand how setjmp/longjmp work. ...
    (comp.os.linux.misc)
  • Re: 8.2 + apache == a LOT of sigprocmask
    ... Reading symbols from /libexec/ld-elf.so.1...done. ... on sigprocmask. ... use of setjmp or sigsetjmp, ...
    (freebsd-stable)
  • Re: Core dumps not containing Symbols
    ... > I have a box that is dumping cores, and I would like to look into the ... > matter further, but my output in gdb does not appear to contain symbols. ... You need to use the right kernel image. ...
    (freebsd-questions)