From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12370 invoked by alias); 14 Mar 2011 16:17:10 -0000 Received: (qmail 12353 invoked by uid 22791); 14 Mar 2011 16:17:07 -0000 X-SWARE-Spam-Status: No, hits=0.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from lon1-post-2.mail.demon.net (HELO lon1-post-2.mail.demon.net) (195.173.77.149) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Mar 2011 16:16:58 +0000 Received: from [80.177.246.162] (helo=hestia.halldom.com) by lon1-post-2.mail.demon.net with esmtp (Exim 4.69) id 1PzARz-0003Gq-cZ; Mon, 14 Mar 2011 16:16:56 +0000 Received: from hyperion.halldom.com ([80.177.246.170] helo=HYPERION) by hestia.halldom.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) (envelope-from ) id 1PzARy-0000UD-MC; Mon, 14 Mar 2011 16:16:55 +0000 From: To: "'Pedro Alves'" , Cc: "'Chris Hall'" References: <014b01cbe252$f0f736c0$d2e5a440$@highwayman.com> <201103141452.25262.pedro@codesourcery.com> In-Reply-To: <201103141452.25262.pedro@codesourcery.com> Subject: RE: Non-stop mode disfunctional ? Date: Mon, 14 Mar 2011 16:17:00 -0000 Message-ID: <015801cbe263$3c04ac50$b40e04f0$@highwayman.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: 2011-03/txt/msg00098.txt.bz2 Pedro Alves wrote (on Mon 14-Mar-2011 at 14:52): > > ... I'm hoping to discover if the fact that non-stop doesn't work > > is (a) because I'm not using it correctly, or (b) a well known > > problem I should know about, or (c) an actual bug, or > > (d) something else ? > I only read your original post diagonally, but I'd suspect a problem > with displaced-stepping. Try with both non-stop and target-async > off (the default), but enabling "set breakpoint always-inserted on", > and "set displaced-stepping on". I tried: set non-stop off set target-async off set breakpoint always-inserted on set displaced-stepping on and gdb worked just fine. I note that "breakpoint always-inserted" and "displaced-stepping" default to "on" for "non-stop", so I tried: set non-stop on set target-async on set breakpoint always-inserted off set displaced-stepping off and gdb goes BANG (SIGSEGV). As far as I can tell, with "non-stop" "on", single stepping is borked (at least on leaving a void function immediately after calling another function). In case it makes a difference, I am running AMD Phenom II X6 1090T (Stepping 0). Thanks, Chris > -- > Pedro Alves > > > > > Thanks, > > > > Chris > > > > > -----Original Message----- > > > From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] > On > > > Behalf Of Chris Hall > > > Sent: 07 March 2011 11:01 > > > To: gdb@sourceware.org > > > Subject: SIGSEGV on exit from subroutines -- problem with non- > stop ? > > > > > > Hi, > > > > > > I am using gdb 7.2-14.fc14 to work on a large multi-threaded > > > application, in C, x86-64. > > > > > > I have .gdbinit, per the book: > > > > > > set target async 1 > > > set pagination off > > > set non-stop on > > > > > > When I step using 's' or 'n', as it leaves some subroutines I > keep > > > getting SIGSEGV, such as: > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > signal_set (signo=Cannot access memory at address > > > 0xffffffffffffff5c) > > > at ... > > > > > > When I 'disass' the current instruction is a leaveq. Examining > the > > > registers I observe that rbp is zero, which is clearly nonsense. > > > > > > I found one instance which was repeatable, which happened to be > > > before any threads were started: if I 'ni' through a particular > > > function, it gets to the leaveq, and gets stuck there. Each > time I > > > do ni, the rsp and the rbp are updated by the repeated leaveq, > until > > > it goes bang. > > > > > > So... I began to think this isn't something complicated to do > with > > > multiple threads... so here is a test: > > > > > > <<--test.c----------------------------------------------- > > > #include > > > #include > > > > > > static void > > > target(const char* message) { > > > printf("%s ...BANG!\n", message) ; > > > } > > > > > > int main(int argc, char* argv[]) { > > > > > > target("Light the blue touch paper") ; > > > > > > return 0 ; > > > } > > > ------------------------------------------------------->> > > > > > > Compiled by gcc 4.5.1 "-g -O0". > > > > > > If I do "gdb test", stepping by "n": > > > > > > <<------------------------------------------------------- > > > (gdb) show non-stop > > > Controlling the inferior in non-stop mode is on. > > > (gdb) b target > > > Breakpoint 1 at 0x4004d0: file test.c, line 6. > > > (gdb) run > > > Starting program: ...........test > > > > > > Breakpoint 1, target (message=0x400615 "Light the blue touch > paper") > > > at test.c:6 > > > 6 printf("%s ...BANG!\n", message) ; > > > (gdb) n > > > Light the blue touch paper ...BANG! > > > 7 } > > > (gdb) n > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > target (message=Cannot access memory at address > 0xfffffffffffffff8 > > > ) at test.c:7 > > > 7 } > > > (gdb) info reg > > > .... > > > rbp 0x0 0x0 > > > rsp 0x7fffffffe248 0x7fffffffe248 > > > .... > > > rip 0x4004e9 0x4004e9 > > > .... > > > ------------------------------------------------------->> > > > > > > Or, stepping by 'ni': > > > > > > <<------------------------------------------------------- > > > (gdb) show non-stop > > > Controlling the inferior in non-stop mode is on. > > > (gdb) b target > > > Breakpoint 1 at 0x4004d0: file test.c, line 6. > > > (gdb) disass target > > > Dump of assembler code for function target: > > > 0x00000000004004c4 <+0>: push %rbp > > > 0x00000000004004c5 <+1>: mov %rsp,%rbp > > > 0x00000000004004c8 <+4>: sub $0x10,%rsp > > > 0x00000000004004cc <+8>: mov %rdi,-0x8(%rbp) > > > 0x00000000004004d0 <+12>: mov $0x400608,%eax > > > 0x00000000004004d5 <+17>: mov -0x8(%rbp),%rdx > > > 0x00000000004004d9 <+21>: mov %rdx,%rsi > > > 0x00000000004004dc <+24>: mov %rax,%rdi > > > 0x00000000004004df <+27>: mov $0x0,%eax > > > 0x00000000004004e4 <+32>: callq 0x4003b8 > > > 0x00000000004004e9 <+37>: leaveq > > > 0x00000000004004ea <+38>: retq > > > End of assembler dump. > > > (gdb) disp/i $pc > > > (gdb) run > > > Starting program: .......test > > > > > > Breakpoint 1, target (message=0x400615 "Light the blue touch > paper") > > > at test.c:6 > > > 6 printf("%s ...BANG!\n", message) ; > > > ..... > > > 1: x/i $pc > > > => 0x4004e4 : callq 0x4003b8 > > > (gdb) ni > > > Light the blue touch paper ...BANG! > > > 7 } > > > 1: x/i $pc > > > => 0x4004e9 : leaveq > > > (gdb) ni > > > target (message=0x100000000
) > at > > > test.c:7 > > > 7 } > > > 1: x/i $pc > > > => 0x4004e9 : leaveq > > > (gdb) ni > > > Cannot access memory at address 0x8 > > > (gdb) ni > > > The program is not being run. > > > ------------------------------------------------------->> > > > > > > I note that if I turn off the "non-stop" option, it works. So > this > > > is something to do with debugging multi-threaded ! > > > > > > I note also that if I change the target to: > > > > > > static int > > > target(const char* message) { > > > printf("%s ...BANG!\n", message) ; > > > return 0 ; > > > } > > > > > > the problem goes away... so one extra instruction between the > callq > > > and the leaveq makes a difference: > > > > > > 0x00000000004004dc <+24>: mov %rax,%rdi > > > 0x00000000004004df <+27>: mov $0x0,%eax > > > 0x00000000004004e4 <+32>: callq 0x4003b8 > > > 0x00000000004004e9 <+37>: mov $0x0,%eax > > > 0x00000000004004ee <+42>: leaveq > > > 0x00000000004004ef <+43>: retq > > > > > > This goes some way to explaining why it appeared to be a > sporadic > > > problem. > > > > > > Is this me, or is this a bug ? It used to work :-( > > > > > > Thanks, > > > > > > Chris > > > >