Thanks for the responses... I guess my problem has more to do with USING gdb
(I thought possibly it wasn't able to inspect the states of variables in a
dump due to the problems I describe below). Anyway:
When I do a bt on the core dump, it shows the following:
(gdb) bt
#0 0xc0b7ed9 in memmove ()
#1 0x0 in ?? ()
memmove is called in only one place in my program, in a function called
deal_with_data.
Here's what the call stack should look like:
main->read_socks->deal_with_data->memmove()
Here's what the call to memmove looks like:
memmove(currentbuffer,
terminatorpos + strlen(terminator),
usedbuffer - (terminatorpos - currentbuffer +
strlen(terminator)) + 1)
**NOTE: via other methods I determined that it was my usedbuffer variable
that was incorrect and that's what was causing my segfault... so I've solved
the programming problem but I still want to figure out how to use gdb in
this situation.
If I try to look at the parms to memmove, it shows:
(gdb) p currentbuffer
No symbol "currentbuffer" in current context.
(gdb) p terminatorpos
No symbol "terminatorpos" in current context.
(gdb) p terminator
No symbol "terminator" in current context.
(gdb) p usedbuffer
No symbol "usedbuffer" in current context.
Doing "info variable" shows all the globals I've defined. However, doing
info local shows the following:
(gdb) info local
No symbol table info available.
Also, if I do a print on the global variables, they all appear to be
unitialized...
examples:
(gdb) p port
$7 = 0
(gdb) p listeningSocket
$8 = 0
(Both are int's and are assigned right at the beginning of the program).
It's almost as if I'd invoked gdb WITHOUT the core file, except that the
backtrace shows the memmove, and when I invoke info frame, I get:
(gdb) info frame
Stack level 0, frame at 0x8047b18:
eip = 0xc0b7ed9 in memmove; saved eip 0x33313937
(FRAMELESS), called by frame at 0x8047b18
Arglist at 0x8047b18, args:
Locals at 0x8047b18, Previous frame's sp is 0x0
Saved registers:
ebp at 0x8047b18, eip at 0x8047b1c
(gdb) up
#1 0x0 in ?? ()
(gdb) info frame
Stack level 1, frame at 0x8047b18:
eip = 0x0; saved eip 0x33313937
caller of frame at 0x8047b18
Arglist at 0x8047b18, args:
Locals at 0x8047b18, Previous frame's sp is 0x0
Saved registers:
ebp at 0x8047b18, eip at 0x8047b1c
Any ideas what I'm doing wrong (not in the programming, but in the use of
gdb)?
> I have a program that gets a segmentation fault after running for an
> extremely long time (like 4 days). I've used gdb to determine the exact
> statement at which it died. However, I'd like to determine the state of
> some of the variables at that point. Is there a way to do this using
> the core dump?
> I've looked high and low for references to analyzing core dumps and all
> I can find is that "gdb will show you the statement at which it died".
> But the core file must be more useful than that! Any pointers to some
> reference material on this gratefully appreciated.... thx.
> Sent via Deja.com http://www.deja.com/
> Before you buy.