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]

[commit] Do not change frames when checking global watchpoints


There are a couple of different ways to trigger the problem fixed by
the patch.  Here's the easiest, discovered by Pedro:

* Start your program.
* Set a watchpoint on a global variable.
* Run until the program exits.
* Use "file" to open a new program.  This leads to
breakpoint_re_set_one which tries to update the watchpoint.
There is no selected frame, and we do not actually need one,
but we try to get it anyway -> error.

This patch used to be sufficient to fix the problem.  It's an
optimization, and still necessary, so I've tested it and checked it in
(tested on arm-none-eabi and x86_64-linux).  But it's no longer
sufficient.

Pedro, the remaining problem is:

  frame_pspace = get_frame_program_space (get_selected_frame (NULL));

Any suggestions?  The pspace is only used if the watchpoint parses
successfully, but we can get here without a running program... what's
the appropriate pspace then?

2009-11-13  Maciej W. Rozycki  <macro@codesourcery.com>

	* breakpoint.c (update_watchpoint): Only fiddle with frames for
	local watchpoints.

---
 gdb/breakpoint.c |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Index: gdb/breakpoint.c
===================================================================
--- gdb/breakpoint.c.orig	2009-11-12 14:14:25.000000000 -0800
+++ gdb/breakpoint.c	2009-11-13 06:52:29.000000000 -0800
@@ -1000,6 +1000,7 @@ update_watchpoint (struct breakpoint *b,
   int within_current_scope;
   struct frame_id saved_frame_id;
   struct bp_location *loc;
+  int frame_saved;
   bpstat bs;
   struct program_space *frame_pspace;
 
@@ -1011,12 +1012,7 @@ update_watchpoint (struct breakpoint *b,
   if (b->disposition == disp_del_at_next_stop)
     return;
  
-  /* Save the current frame's ID so we can restore it after
-     evaluating the watchpoint expression on its own frame.  */
-  /* FIXME drow/2003-09-09: It would be nice if evaluate_expression
-     took a frame parameter, so that we didn't have to change the
-     selected frame.  */
-  saved_frame_id = get_frame_id (get_selected_frame (NULL));
+  frame_saved = 0;
 
   /* Determine if the watchpoint is within scope.  */
   if (b->exp_valid_block == NULL)
@@ -1024,6 +1020,15 @@ update_watchpoint (struct breakpoint *b,
   else
     {
       struct frame_info *fi;
+
+      /* Save the current frame's ID so we can restore it after
+         evaluating the watchpoint expression on its own frame.  */
+      /* FIXME drow/2003-09-09: It would be nice if evaluate_expression
+         took a frame parameter, so that we didn't have to change the
+         selected frame.  */
+      frame_saved = 1;
+      saved_frame_id = get_frame_id (get_selected_frame (NULL));
+
       fi = frame_find_by_id (b->watchpoint_frame);
       within_current_scope = (fi != NULL);
       if (within_current_scope)
@@ -1169,7 +1174,8 @@ in which its expression is valid.\n"),
     }
 
   /* Restore the selected frame.  */
-  select_frame (frame_find_by_id (saved_frame_id));
+  if (frame_saved)
+    select_frame (frame_find_by_id (saved_frame_id));
 }
 
 

-- 
Daniel Jacobowitz
CodeSourcery


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