I have some code, that I'm currently porting from OS X to Linux (console tool).
Somewhere in this code, I get a segmentation fault. The problem is, that if I run the program without GDB, I clearly see the segmentation fault, and the program is killed. But when I'm running GDB it just halts, and GDB never returns to the prompt. S开发者_如何学运维o I'm not really able to examine what's going on.
C++ is the code. Compiled with the -g option in g++.
Btw. Pretty new to GDB, so excuse me if this is obvious.
Any ideas? Thanks in advance.
Trenskow
gdb will suspend your program when the seg fault signal is received
type where
to see the stack trace and start inspecting what's going on from there.
Also consider enabling core dumps, that way you can load the core dump in GDB and investigate what is going on
you can then load the core dump like this
> gdb your_program the_core_dump
The behaviour you describe is not typical - I suspect the stack may have been trashed.
Try sending various signals directly via the 'kill' command.
Might be worth you running a test program in gdb with an abort() in it so that you can learn what the expected behaviour is for gdb.
I've seen this before when my stack was too large. Try moving stack variables onto the heap (make them globals), recompile, and see if you still get the error.
精彩评论