From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7137 invoked by alias); 2 Sep 2009 14:22:51 -0000 Received: (qmail 7119 invoked by uid 22791); 2 Sep 2009 14:22:49 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f188.google.com (HELO mail-px0-f188.google.com) (209.85.216.188) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Sep 2009 14:22:44 +0000 Received: by pxi26 with SMTP id 26so849962pxi.13 for ; Wed, 02 Sep 2009 07:22:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.202.21 with SMTP id z21mr163804wff.235.1251901363066; Wed, 02 Sep 2009 07:22:43 -0700 (PDT) From: Hui Zhu Date: Wed, 02 Sep 2009 14:22:00 -0000 Message-ID: Subject: Does gdb can handle longjmp in i386 and amd64 now? To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-09/txt/msg00016.txt.bz2 Hi guys, I try the following code with gdb in i386 and amd64: #include #include jmp_buf j; void raise_exception (void) { //printf ("exception raised\n"); longjmp (j, 1); /* jump to exception handler */ printf ("this line should never appear\n"); } int main (void) { if (setjmp (j) == 0) { printf ("''setjmp'' is initializing ''j''\n"); raise_exception (); printf ("this line should never appear\n"); } else { printf ("''setjmp'' was just jumped into\n"); /* this code is the exception handler */ } return 0; } In i386, what I got is: (gdb) start Temporary breakpoint 1 at 0x80483ff: file 1.c, line 16. Starting program: /home/teawater/gdb/a.out Temporary breakpoint 1, main () at 1.c:16 16 if (setjmp (j) == 0) (gdb) s 18 printf ("''setjmp'' is initializing ''j''\n"); (gdb) s ''setjmp'' is initializing ''j'' 19 raise_exception (); (gdb) raise_exception () at 1.c:9 9 longjmp (j, 1); /* jump to exception handler */ (gdb) 0xb7ea3e61 in siglongjmp () from /lib/tls/i686/cmov/libc.so.6 (gdb) s Single stepping until exit from function siglongjmp, which has no line number information. ''setjmp'' was just jumped into Program exited normally. In amd64, what I got is: (gdb) start Temporary breakpoint 1 at 0x4005c3: file 1.c, line 16. Starting program: /home/teawater/gdb/a.out Temporary breakpoint 1, main () at 1.c:16 warning: Source file is more recent than executable. 16 if (setjmp (j) == 0) (gdb) s 18 printf ("''setjmp'' is initializing ''j''\n"); (gdb) s ''setjmp'' is initializing ''j'' 19 raise_exception (); (gdb) raise_exception () at 1.c:9 9 longjmp (j, 1); /* jump to exception handler */ (gdb) ''setjmp'' was just jumped into Program exited normally. Are this right? Thanks, Hui