gdb on cygwin and debugging assert() or program segmentation faults
Kris Thielemans
kris.thielemans@csc.mrc.ac.uk
Tue Jul 19 22:40:00 GMT 2005
Hi all,
I need to debug a C++ program that throws up an assert(). On Linux, I'm used to
be able to run the program in gdb, and when the assert happens, the program
stops (in the assert function) and I can do a back trace (e.g. info stack).
On cygwin on the other hand, I just get the assert message, and then gdb
says "Program exited normally". No backtrace possible.
The same difference in behaviour between Linux and cygwin with segmentation
faults.
It would be incredibly useful to be able to see where the
assert/segmentation fault happened.
On the cygwin list, Dave Korn suggested the following work-around (for asserts
only): do 'break __assert'. See end of email for more on this. However, that
still doesn't solve the segmentation fault problem
I have
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
Any other suggestions?
Many thanks
Kris Thielemans
Hammersmith Imanet, part of GE Healthcare
United Kingdom
-------------
PS: more on "break __assert trick"
This works on cygwin because assert is defined in terms of __assert.
This trick did work until I updated my cygwin (it now uses gcc 3.4.4 and some
other stuff changed).
In fact, it will now break before entering main() (in
__static_initialization_and_destruction_0 ) but not when the assert is
called.
Using "break __assert" says
(gdb) break __assert
Breakpoint 1 at 0x4ac3e6: file /usr/lib/gcc/i686-pc-
cygwin/3.4.4/include/c++/iostream, line 77.
(gdb) r
Starting program: /home/kris/MyDocuments/mytest.exe
Breakpoint 1, __static_initialization_and_destruction_0 (__initialize_p=1,
__priority=65535)
at /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iostream:77
(gdb) c
assertion "overlap>-epsilon" failed:
file "./include/stir/numerics/overlap_interpolate.inl", line 108
Program exited normally.
(I might be able to #define assert to my own function and break there.)
More information about the Gdb
mailing list