From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29232 invoked by alias); 27 Oct 2004 17:35:45 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 29183 invoked from network); 27 Oct 2004 17:35:42 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 27 Oct 2004 17:35:42 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id i9RHZgQ2022676 for ; Wed, 27 Oct 2004 13:35:42 -0400 Received: from localhost.redhat.com (to-dhcp51.toronto.redhat.com [172.16.14.151]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i9RHZYr15278; Wed, 27 Oct 2004 13:35:35 -0400 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 37188129D8B; Wed, 27 Oct 2004 13:34:13 -0400 (EDT) Message-ID: <417FDC11.7060700@gnu.org> Date: Wed, 27 Oct 2004 17:35:00 -0000 From: Andrew Cagney User-Agent: Mozilla Thunderbird 0.8 (X11/20041020) MIME-Version: 1.0 To: Felix Lee Cc: gdb-patches@sources.redhat.com Subject: Re: backtrace changes current source location References: <20041026075115.4A2C354AAB5@stray.canids> <20041026132924.GA26886@nevyn.them.org> <20041026150127.6ED3E54AAB5@stray.canids> In-Reply-To: <20041026150127.6ED3E54AAB5@stray.canids> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-10/txt/msg00454.txt.bz2 Felix Lee wrote: > patch for > http://sources.redhat.com/ml/gdb/2004-10/msg00414.html > > gdb/ChangeLog > 2004-10-26 Felix Lee > > * stack.c (backtrace_command_1): Backtrace shouldn't > change current source location. Felix, can you find out where current_sal is being trashed? GDB's trying to get away from all this global state - the code at that level shouldn't need to meddle with current_sal. (Don't forget to consider the error case - if an error is thrown a restore would be lost) > gdb/testsuite/ChangeLog > 2004-10-26 Felix Lee > > * gdb.base/break.exp: Add test for line number after > backtrace. Thanks for remembering this. However, as a separate test, it should be in a separate file. Andrew > Index: gdb/stack.c > =================================================================== > RCS file: /cvs/src/src/gdb/stack.c,v > retrieving revision 1.112 > diff -u -p -r1.112 stack.c > --- gdb/stack.c 3 Aug 2004 00:57:26 -0000 1.112 > +++ gdb/stack.c 26 Oct 2004 14:59:06 -0000 > @@ -1170,8 +1170,13 @@ backtrace_command_1 (char *count_exp, in > fi && count--; > i++, fi = get_prev_frame (fi)) > { > + struct symtab_and_line savesal; > QUIT; > > + /* print_frame_info changes the current sal, which is not > + useful behavior when user asks for a backtrace. */ > + savesal = get_current_source_symtab_and_line (); > + > /* Don't use print_stack_frame; if an error() occurs it probably > means further attempts to backtrace would fail (on the other > hand, perhaps the code does or could be fixed to make sure > @@ -1179,6 +1184,8 @@ backtrace_command_1 (char *count_exp, in > print_frame_info (fi, 1, LOCATION, 1); > if (show_locals) > print_frame_local_vars (fi, 1, gdb_stdout); > + > + set_current_source_symtab_and_line (&savesal); > } > > /* If we've stopped before the end, mention that. */ > Index: gdb/testsuite/gdb.base/break.exp > =================================================================== > RCS file: /cvs/src/src/gdb/testsuite/gdb.base/break.exp,v > retrieving revision 1.19 > diff -u -p -r1.19 break.exp > --- gdb/testsuite/gdb.base/break.exp 9 Dec 2003 18:19:20 -0000 1.19 > +++ gdb/testsuite/gdb.base/break.exp 26 Oct 2004 14:59:06 -0000 > @@ -238,6 +238,21 @@ for {set i 6} {$i >= 1} {incr i -1} { > "run until file:function($i) breakpoint" > } > > +# make sure backtrace doesn't change current source location. > + > +gdb_test "set listsize 1" \ > + ".*" \ > + "set listsize 1" > +gdb_test "list $bp_location7" \ > + ".*" \ > + "list before backtrace" > +gdb_test "backtrace" \ > + "\#0 factorial .*" \ > + "backtrace at breakpoint" > +gdb_test "list -1" \ > + "$bp_location7\[\t ].*" \ > + "list after backtrace" > + > # > # Run until the breakpoint set at a quoted function > # >