This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: backtrace changes current source location


patch for
    http://sources.redhat.com/ml/gdb/2004-10/msg00414.html

gdb/ChangeLog
2004-10-26  Felix Lee  <felix+log1@specifixinc.com>

        * stack.c (backtrace_command_1): Backtrace shouldn't
        change current source location.

gdb/testsuite/ChangeLog
2004-10-26  Felix Lee  <felix+log1@specifixinc.com>

        * gdb.base/break.exp: Add test for line number after
        backtrace.

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
 #


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]