This is the mail archive of the gdb-patches@sourceware.org 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: fix list/edit command in hook-stop


On Tue, Feb 28, 2006 at 10:08:41PM +0200, Eli Zaretskii wrote:
> Thanks.  However, I thought we should explain why
> set_current_sal_from_frame is called here.  I believe the reason is
> that without the call, the current sal will not be up to date if
> `edit' or `list' are called inside a hook-stop.

I think the patch ought to set the sal regardless of whether a stop
hook is defined.  However, there's something more complicated going on. 
The obvious patch from my description causes lots of test failures like
this one:

(gdb) PASS: gdb.base/call-ar-st.exp: run until breakpoint set at a line
print print_double_array(double_array)
array_d :
=========

0.000000  
23.456700  46.913400  70.370100  93.826800  117.283500  140.740200
164.196900  187.653600  


$1 = void
(gdb) PASS: gdb.base/call-ar-st.exp: print
print_double_array(double_array)
print print_char_array(char_array)
array_c :
=========

Z
aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ
aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ
aZaZaZaZaZaZaZaZaZa

$2 = void
(gdb) PASS: gdb.base/call-ar-st.exp: print print_char_array(char_array)
tbreak 1216
No line 1216 in file "../sysdeps/x86_64/elf/start.S".
(gdb) FAIL: gdb.base/call-ar-st.exp: tbreakpoint line 1216

The reason we're suddenly in start.S is that the breakpoint we hit
after calling print_double_array is in _start.  So the right patch
would actually look like the attached.

Is this better?

-- 
Daniel Jacobowitz
CodeSourcery

2006-03-01  Daniel Jacobowitz  <dan@codesourcery.com>
 
	* frame.h (set_current_sal_from_frame): New prototype.
	* stack.c (set_current_sal_from_frame): Make global.
	* infrun.c (normal_stop): Call set_current_sal_from_frame.

Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.147
diff -u -p -r1.147 frame.h
--- frame.h	17 Dec 2005 22:33:59 -0000	1.147
+++ frame.h	1 Mar 2006 17:53:12 -0000
@@ -300,6 +300,12 @@ extern CORE_ADDR get_frame_func (struct 
 extern void find_frame_sal (struct frame_info *frame,
 			    struct symtab_and_line *sal);
 
+/* Set the current source and line to the location given by frame
+   FRAME, if possible.  When CENTER is true, adjust so the relevant
+   line is in the center of the next 'list'.  */
+
+void set_current_sal_from_frame (struct frame_info *, int);
+
 /* Return the frame base (what ever that is) (DEPRECATED).
 
    Old code was trying to use this single method for two conflicting
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.209
diff -u -p -r1.209 infrun.c
--- infrun.c	4 Jan 2006 19:34:58 -0000	1.209
+++ infrun.c	1 Mar 2006 17:53:13 -0000
@@ -3044,6 +3044,12 @@ Further execution is probably impossible
 
   target_terminal_ours ();
 
+  /* Set the current source location.  This will also happen if we
+     display the frame below, but the current SAL will be incorrect
+     during a user hook-stop function.  */
+  if (target_has_stack && !stop_stack_dummy)
+    set_current_sal_from_frame (get_current_frame (), 1);
+
   /* Look up the hook_stop and run it (CLI internally handles problem
      of stop_command's pre-hook not existing).  */
   if (stop_command)
Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.137
diff -u -p -r1.137 stack.c
--- stack.c	17 Dec 2005 22:34:03 -0000	1.137
+++ stack.c	1 Mar 2006 17:53:14 -0000
@@ -61,8 +61,6 @@ static void print_frame (struct frame_in
 			 enum print_what print_what,  int print_args,
 			 struct symtab_and_line sal);
 
-static void set_current_sal_from_frame (struct frame_info *, int);
-
 /* Zero means do things normally; we are interacting directly with the
    user.  One means print the full filename and linenumber when a
    frame is printed, and do so in a format emacs18/emacs19.22 can
@@ -373,7 +371,7 @@ print_args_stub (void *args)
    FRAME, if possible.  When CENTER is true, adjust so the relevant
    line is in the center of the next 'list'.  */
 
-static void
+void
 set_current_sal_from_frame (struct frame_info *frame, int center)
 {
   struct symtab_and_line sal;


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