public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdb on cygwin and debugging assert() or program segmentation faults
@ 2005-07-19 22:40 Kris Thielemans
  2005-07-20  2:09 ` Brian Dessent
  0 siblings, 1 reply; 4+ messages in thread
From: Kris Thielemans @ 2005-07-19 22:40 UTC (permalink / raw)
  To: gdb

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.)



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-20 10:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-19 22:40 gdb on cygwin and debugging assert() or program segmentation faults Kris Thielemans
2005-07-20  2:09 ` Brian Dessent
2005-07-20  2:37   ` Christopher Faylor
2005-07-20 10:28     ` Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).