From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5355 invoked by alias); 19 Jul 2005 22:40:45 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 5310 invoked by uid 22791); 19 Jul 2005 22:40:38 -0000 Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 19 Jul 2005 22:40:38 +0000 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1Dv0lJ-0004g9-L1 for gdb@sources.redhat.com; Wed, 20 Jul 2005 00:40:29 +0200 Received: from thiefob.plus.com ([84.92.102.145]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 20 Jul 2005 00:40:29 +0200 Received: from kris.thielemans by thiefob.plus.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 20 Jul 2005 00:40:29 +0200 To: gdb@sources.redhat.com From: Kris Thielemans Subject: gdb on cygwin and debugging assert() or program segmentation faults Date: Tue, 19 Jul 2005 22:40:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-SW-Source: 2005-07/txt/msg00202.txt.bz2 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.)