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]

[patch/obish] Use frame ID in breakpoint and thread


More cleanup. Use frame ID, instead of frame_relative_level, when saving / restoring a selected frame.

I'm still testing and will commit after that.

Andrew
2004-05-01  Andrew Cagney  <cagney@redhat.com>
 
	* breakpoint.c (insert_bp_location): Use get_frame_id, and
	frame_find_by_id instead of frame_relative_level.
	(do_enable_breakpoint): Ditto.
	* thread.c: Update copyright.
	(info_threads_command): Ditto, simplify.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.169
diff -p -u -r1.169 breakpoint.c
--- breakpoint.c	1 May 2004 16:52:29 -0000	1.169
+++ breakpoint.c	1 May 2004 20:50:58 -0000
@@ -910,18 +910,17 @@ insert_bp_location (struct bp_location *
 	 must watch.  As soon as a many-to-one mapping is available I'll
 	 convert this.  */
 
-      struct frame_info *saved_frame;
-      int saved_level, within_current_scope;
+      int within_current_scope;
       struct value *mark = value_mark ();
       struct value *v;
+      struct frame_id saved_frame_id;
 
-      /* Save the current frame and level so we can restore it after
+      /* 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 = deprecated_selected_frame;
-      saved_level = frame_relative_level (deprecated_selected_frame);
+      saved_frame_id = get_frame_id (deprecated_selected_frame);
 
       /* Determine if the watchpoint is within scope.  */
       if (bpt->owner->exp_valid_block == NULL)
@@ -1018,10 +1017,8 @@ insert_bp_location (struct bp_location *
 	  bpt->owner->disposition = disp_del_at_next_stop;
 	}
 
-      /* Restore the frame and level.  */
-      if (saved_frame != deprecated_selected_frame
-	  || saved_level != frame_relative_level (deprecated_selected_frame))
-	select_frame (saved_frame);
+      /* Restore the selected frame.  */
+      select_frame (frame_find_by_id (saved_frame_id));
 
       return val;
     }
@@ -7564,8 +7561,6 @@ disable_command (char *args, int from_tt
 static void
 do_enable_breakpoint (struct breakpoint *bpt, enum bpdisp disposition)
 {
-  struct frame_info *save_selected_frame = NULL;
-  int save_selected_frame_level = -1;
   int target_resources_ok, other_type_used;
   struct value *mark;
 
@@ -7612,6 +7607,9 @@ do_enable_breakpoint (struct breakpoint 
 	  bpt->type == bp_read_watchpoint || 
 	  bpt->type == bp_access_watchpoint)
 	{
+	  struct frame_id saved_frame_id;
+
+	  saved_frame_id = get_frame_id (get_selected_frame ());
 	  if (bpt->exp_valid_block != NULL)
 	    {
 	      struct frame_info *fr =
@@ -7624,9 +7622,6 @@ is valid is not currently in scope.\n", 
 		  bpt->enable_state = bp_disabled;
 		  return;
 		}
-	      
-	      save_selected_frame = deprecated_selected_frame;
-	      save_selected_frame_level = frame_relative_level (deprecated_selected_frame);
 	      select_frame (fr);
 	    }
 	  
@@ -7661,8 +7656,7 @@ have been allocated for other watchpoint
 		}
 	    }
 	  
-	  if (save_selected_frame_level >= 0)
-	    select_frame (save_selected_frame);
+	  select_frame (frame_find_by_id (saved_frame_id));
 	  value_free_to_mark (mark);
 	}
     }
Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.33
diff -p -u -r1.33 thread.c
--- thread.c	28 Apr 2004 16:36:25 -0000	1.33
+++ thread.c	1 May 2004 20:50:59 -0000
@@ -1,7 +1,7 @@
 /* Multi-process/thread control for GDB, the GNU debugger.
 
    Copyright 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    Contributed by Lynx Real-Time Systems, Inc.  Los Gatos, CA.
 
@@ -417,15 +417,9 @@ info_threads_command (char *arg, int fro
   struct thread_info *tp;
   ptid_t current_ptid;
   struct frame_info *cur_frame;
-  int saved_frame_level = frame_relative_level (get_selected_frame ());
-  int counter;
+  struct frame_id saved_frame_id = get_frame_id (get_selected_frame ());
   char *extra_info;
 
-  /* Check that there really is a frame.  This happens when a simulator
-     is connected but not loaded or running, for instance.  */
-  if (legacy_frame_p (current_gdbarch) && saved_frame_level < 0)
-    error ("No frame.");
-
   prune_threads ();
   target_find_new_threads ();
   current_ptid = inferior_ptid;
@@ -453,27 +447,23 @@ info_threads_command (char *arg, int fro
 
   switch_to_thread (current_ptid);
 
-  /* Code below copied from "up_silently_base" in "stack.c".
-   * It restores the frame set by the user before the "info threads"
-   * command.  We have finished the info-threads display by switching
-   * back to the current thread.  That switch has put us at the top
-   * of the stack (leaf frame).
-   */
-  counter = saved_frame_level;
-  cur_frame = find_relative_frame (get_selected_frame (), &counter);
-  if (counter != 0)
+  /* Restores the frame set by the user before the "info threads"
+     command.  We have finished the info-threads display by switching
+     back to the current thread.  That switch has put us at the top of
+     the stack (leaf frame).  */
+  cur_frame = frame_find_by_id (saved_frame_id);
+  if (cur_frame == NULL)
     {
-      /* Ooops, can't restore, tell user where we are. */
+      /* Ooops, can't restore, tell user where we are.  */
       warning ("Couldn't restore frame in current thread, at frame 0");
       print_stack_frame (get_selected_frame (), 0, LOCATION);
     }
   else
     {
       select_frame (cur_frame);
+      /* re-show current frame. */
+      show_stack_frame (cur_frame);
     }
-
-  /* re-show current frame. */
-  show_stack_frame (cur_frame);
 }
 
 /* Switch from one thread to another. */

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