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/rfc] step_frame_address -> step_frame_id


Hello,

When single stepping, GDB uses `step_frame_address' as an identifier of the frame it is single stepping in.

This patch converts that raw address into a frame ID. A frame ID lets GDB differentiate between frameless functions. It is closely linked to the breakpoint patch which contains the gem:

- step_resume_breakpoint->frame = step_frame_address;
+ /* Match any frame with the specified address but wild card on the
+ func (someone should change step_frame_address to
+ step_frame_id). */
+ step_resume_breakpoint->frame_id =
+ frame_id_build (step_frame_address, 0);

Two notes:

1. While the frame ID can be used to differentiate between frameless frames, the current code does not. I intend posting the patch to do that after all this infrastructure is in place (I've tested it and the i386 didn't show regressions :-).

2. One bit of code differentiates between frameless functions using the global `struct symtab *step_start_function'. But the only useful thing that code does is decide of the source code line should be printed :-( This patch (one note 1 is resolved) will make that test obsolete.

I'll look to commit in a few days,
Andrew
2002-12-03  Andrew Cagney  <ac131313@redhat.com>

	* gdbthread.h: Include "frame.h".
	(struct thread_info): Replace step_frame_address with
	step_frame_id.
	* inferior.h: Include "frame.h".
	(step_frame_id): Replace external variable step_frame_address.
	* gdbthread.h (save_infrun_state): Replace step_frame_address
	parameter with step_frame_id parameter.
	(load_infrun_state): Ditto.
	* Makefile.in (gdbthread_h, inferior_h): Add $(frame_h).
	* infcmd.c (step_frame_id, step_1, step_once): Update.
	* thread.c (load_infrun_state, save_infrun_state): Update.
	* infrun.c (clear_proceed_status, save_inferior_status): Update.
	(handle_inferior_event, step_over_function): Update.
	(normal_stop, context_switch, restore_inferior_status): Update.
	(struct inferior_status): Replace step_frame_address with
	step_frame_id.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.288
diff -u -r1.288 Makefile.in
--- Makefile.in	2 Dec 2002 23:30:34 -0000	1.288
+++ Makefile.in	4 Dec 2002 02:30:50 -0000
@@ -664,7 +664,7 @@
 gdbarch_h = gdbarch.h $(dis_asm_h) $(value_h) $(inferior_h)
 gdbcmd_h = gdbcmd.h $(command_h) $(ui_out_h)
 gdbcore_h = gdbcore.h $(bfd_h)
-gdbthread_h = gdbthread.h $(breakpoint_h)
+gdbthread_h = gdbthread.h $(breakpoint_h) $(frame_h)
 gdbtypes_h = gdbtypes.h
 gnu_nat_h = gnu-nat.h
 gregset_h = gregset.h
@@ -672,7 +672,7 @@
 i386_tdep_h = i386-tdep.h $(osabi_h)
 i387_tdep_h = i387-tdep.h
 inf_loop_h = inf-loop.h
-inferior_h = inferior.h $(breakpoint_h) $(target_h)
+inferior_h = inferior.h $(breakpoint_h) $(target_h) $(frame_h)
 jv_lang_h = jv-lang.h
 kod_h = kod.h
 language_h = language.h
Index: gdbthread.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbthread.h,v
retrieving revision 1.5
diff -u -r1.5 gdbthread.h
--- gdbthread.h	13 Jun 2001 22:56:16 -0000	1.5
+++ gdbthread.h	4 Dec 2002 02:30:50 -0000
@@ -28,6 +28,9 @@
 /* For bpstat */
 #include "breakpoint.h"
 
+/* For struct frame_id.  */
+#include "frame.h"
+
 struct thread_info
 {
   struct thread_info *next;
@@ -43,7 +46,7 @@
   struct breakpoint *through_sigtramp_breakpoint;
   CORE_ADDR step_range_start;
   CORE_ADDR step_range_end;
-  CORE_ADDR step_frame_address;
+  struct frame_id step_frame_id;
   CORE_ADDR step_sp;
   int current_line;
   struct symtab *current_symtab;
@@ -118,7 +121,7 @@
 			       struct breakpoint *through_sigtramp_breakpoint,
 			       CORE_ADDR step_range_start,
 			       CORE_ADDR step_range_end,
-			       CORE_ADDR step_frame_address,
+			       const struct frame_id *step_frame_id,
 			       int       handling_longjmp,
 			       int       another_trap,
 			       int       stepping_through_solib_after_catch,
@@ -139,7 +142,7 @@
 			       struct breakpoint **through_sigtramp_breakpoint,
 			       CORE_ADDR *step_range_start,
 			       CORE_ADDR *step_range_end,
-			       CORE_ADDR *step_frame_address,
+			       struct frame_id *step_frame_id,
 			       int       *handling_longjmp,
 			       int       *another_trap,
 			       int       *stepping_through_solib_affter_catch,
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.65
diff -u -r1.65 infcmd.c
--- infcmd.c	3 Dec 2002 12:25:11 -0000	1.65
+++ infcmd.c	4 Dec 2002 02:30:50 -0000
@@ -182,7 +182,7 @@
    This is how we know when we step into a subroutine call,
    and how to set the frame for the breakpoint used to step out.  */
 
-CORE_ADDR step_frame_address;
+struct frame_id step_frame_id;
 
 /* Our notion of the current stack pointer.  */
 
@@ -627,7 +627,7 @@
 	  frame = get_current_frame ();
 	  if (!frame)		/* Avoid coredump here.  Why tho? */
 	    error ("No current frame");
-	  step_frame_address = get_frame_base (frame);
+	  step_frame_id = get_frame_id (frame);
 	  step_sp = read_sp ();
 
 	  if (!single_inst)
@@ -742,7 +742,7 @@
       frame = get_current_frame ();
       if (!frame)		/* Avoid coredump here.  Why tho? */
 	error ("No current frame");
-      step_frame_address = get_frame_base (frame);
+      step_frame_id = get_frame_id (frame);
       step_sp = read_sp ();
 
       if (!single_inst)
@@ -1105,7 +1105,7 @@
     }
 
   step_over_calls = STEP_OVER_ALL;
-  step_frame_address = get_frame_base (frame);
+  step_frame_id = get_frame_id (frame);
   step_sp = read_sp ();
 
   step_multi = 0;		/* Only one call to proceed */
Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.36
diff -u -r1.36 inferior.h
--- inferior.h	1 Dec 2002 19:07:15 -0000	1.36
+++ inferior.h	4 Dec 2002 02:30:50 -0000
@@ -32,6 +32,9 @@
 /* For enum target_signal.  */
 #include "target.h"
 
+/* For struct frame_id.  */
+#include "frame.h"
+
 /* Structure in which to save the status of the inferior.  Create/Save
    through "save_inferior_status", restore through
    "restore_inferior_status".
@@ -369,7 +372,7 @@
    This is how we know when we step into a subroutine call,
    and how to set the frame for the breakpoint used to step out.  */
 
-extern CORE_ADDR step_frame_address;
+extern struct frame_id step_frame_id;
 
 /* Our notion of the current stack pointer.  */
 
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.81
diff -u -r1.81 infrun.c
--- infrun.c	4 Dec 2002 00:05:53 -0000	1.81
+++ infrun.c	4 Dec 2002 02:30:51 -0000
@@ -822,7 +822,7 @@
   trap_expected = 0;
   step_range_start = 0;
   step_range_end = 0;
-  step_frame_address = 0;
+  step_frame_id = null_frame_id;
   step_over_calls = STEP_OVER_UNDEBUGGABLE;
   stop_after_trap = 0;
   stop_soon_quietly = 0;
@@ -1291,7 +1291,7 @@
 			 prev_func_start, prev_func_name,
 			 trap_expected, step_resume_breakpoint,
 			 through_sigtramp_breakpoint, step_range_start,
-			 step_range_end, step_frame_address,
+			 step_range_end, &step_frame_id,
 			 ecs->handling_longjmp, ecs->another_trap,
 			 ecs->stepping_through_solib_after_catch,
 			 ecs->stepping_through_solib_catchpoints,
@@ -1303,7 +1303,7 @@
 			 &prev_func_start, &prev_func_name,
 			 &trap_expected, &step_resume_breakpoint,
 			 &through_sigtramp_breakpoint, &step_range_start,
-			 &step_range_end, &step_frame_address,
+			 &step_range_end, &step_frame_id,
 			 &ecs->handling_longjmp, &ecs->another_trap,
 			 &ecs->stepping_through_solib_after_catch,
 			 &ecs->stepping_through_solib_catchpoints,
@@ -2255,8 +2255,8 @@
 #if 0
 	/* FIXME - Need to implement nested temporary breakpoints */
 	if (step_over_calls
-	    && (INNER_THAN (get_frame_base (get_current_frame ()),
-			    step_frame_address)))
+	    && (frame_id_inner (get_frame_id (get_current_frame ()),
+				step_frame_id)))
 	  {
 	    ecs->another_trap = 1;
 	    keep_going (ecs);
@@ -2567,9 +2567,9 @@
 
 
       {
-	CORE_ADDR current_frame = get_frame_base (get_current_frame ());
+	struct frame_id current_frame = get_frame_id (get_current_frame ());
 
-	if (INNER_THAN (current_frame, step_frame_address))
+	if (frame_id_inner (current_frame, step_frame_id))
 	  {
 	    /* We have just taken a signal; go until we are back to
 	       the point where we took it and one more.  */
@@ -2589,8 +2589,7 @@
 	    sr_sal.line = 0;
 	    sr_sal.pc = prev_pc;
 	    /* We could probably be setting the frame to
-	       step_frame_address; I don't think anyone thought to
-	       try it.  */
+	       step_frame_id; I don't think anyone thought to try it.  */
 	    check_for_old_step_resume_breakpoint ();
 	    step_resume_breakpoint =
 	      set_momentary_breakpoint (sr_sal, NULL, bp_step_resume);
@@ -2664,17 +2663,17 @@
 	  /* We're doing a "next".  */
 
 	  if (PC_IN_SIGTRAMP (stop_pc, ecs->stop_func_name)
-	      && INNER_THAN (step_frame_address, read_sp ()))
+	      && frame_id_inner (step_frame_id,
+				 frame_id_build (read_sp (), 0)))
 	    /* We stepped out of a signal handler, and into its
 	       calling trampoline.  This is misdetected as a
 	       subroutine call, but stepping over the signal
-	       trampoline isn't such a bad idea.  In order to do
-	       that, we have to ignore the value in
-	       step_frame_address, since that doesn't represent the
-	       frame that'll reach when we return from the signal
-	       trampoline.  Otherwise we'll probably continue to the
-	       end of the program.  */
-	    step_frame_address = 0;
+	       trampoline isn't such a bad idea.  In order to do that,
+	       we have to ignore the value in step_frame_id, since
+	       that doesn't represent the frame that'll reach when we
+	       return from the signal trampoline.  Otherwise we'll
+	       probably continue to the end of the program.  */
+	    step_frame_id = null_frame_id;
 
 	  step_over_function (ecs);
 	  keep_going (ecs);
@@ -2838,17 +2837,17 @@
     }
   step_range_start = ecs->sal.pc;
   step_range_end = ecs->sal.end;
-  step_frame_address = get_frame_base (get_current_frame ());
+  step_frame_id = get_frame_id (get_current_frame ());
   ecs->current_line = ecs->sal.line;
   ecs->current_symtab = ecs->sal.symtab;
 
-  /* In the case where we just stepped out of a function into the middle
-     of a line of the caller, continue stepping, but step_frame_address
-     must be modified to current frame */
+  /* In the case where we just stepped out of a function into the
+     middle of a line of the caller, continue stepping, but
+     step_frame_id must be modified to current frame */
   {
-    CORE_ADDR current_frame = get_frame_base (get_current_frame ());
-    if (!(INNER_THAN (current_frame, step_frame_address)))
-      step_frame_address = current_frame;
+    struct frame_id current_frame = get_frame_id (get_current_frame ());
+    if (!(frame_id_inner (current_frame, step_frame_id)))
+      step_frame_id = current_frame;
   }
 
   keep_going (ecs);
@@ -2971,7 +2970,7 @@
    of the call.
 
    To do this, we set the step_resume bp's frame to our current
-   caller's frame (step_frame_address, which is set by the "next" or
+   caller's frame (step_frame_id, which is set by the "next" or
    "until" command, before execution begins).  */
 
 static void
@@ -2987,8 +2986,11 @@
   step_resume_breakpoint =
     set_momentary_breakpoint (sr_sal, get_current_frame (), bp_step_resume);
 
-  if (step_frame_address && !IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal.pc))
-    step_resume_breakpoint->frame = step_frame_address;
+  if (frame_id_p (step_frame_id)
+      && !IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal.pc))
+    /* FIXME: cagney/2002-12-01: Someone should modify the breakpoint
+       code so that it uses a frame ID, instead of a frame address.  */
+    step_resume_breakpoint->frame = step_frame_id.base;
 
   if (breakpoints_inserted)
     insert_breakpoints ();
@@ -3352,8 +3354,12 @@
 	  switch (bpstat_ret)
 	    {
 	    case PRINT_UNKNOWN:
+	      /* FIXME: cagney/2002-12-01: Given that a frame ID does
+		 (or should) carry around the function and does (or
+		 should) use that when doing a frame comparison.  */
 	      if (stop_step
-		  && step_frame_address == get_frame_base (get_current_frame ())
+		  && frame_id_eq (step_frame_id,
+				  get_frame_id (get_current_frame ()))
 		  && step_start_function == find_pc_function (stop_pc))
 		source_flag = SRC_LINE;	/* finished step, just print source line */
 	      else
@@ -3791,7 +3797,7 @@
   int trap_expected;
   CORE_ADDR step_range_start;
   CORE_ADDR step_range_end;
-  CORE_ADDR step_frame_address;
+  struct frame_id step_frame_id;
   enum step_over_calls_kind step_over_calls;
   CORE_ADDR step_resume_break_address;
   int stop_after_trap;
@@ -3838,7 +3844,7 @@
   inf_status->trap_expected = trap_expected;
   inf_status->step_range_start = step_range_start;
   inf_status->step_range_end = step_range_end;
-  inf_status->step_frame_address = step_frame_address;
+  inf_status->step_frame_id = step_frame_id;
   inf_status->step_over_calls = step_over_calls;
   inf_status->stop_after_trap = stop_after_trap;
   inf_status->stop_soon_quietly = stop_soon_quietly;
@@ -3868,8 +3874,8 @@
 
   frame = frame_find_by_id (*fid);
 
-  /* If inf_status->selected_frame_address is NULL, there was no
-     previously selected frame.  */
+  /* If inf_status->selected_frame_id is NULL, there was no previously
+     selected frame.  */
   if (frame == NULL)
     {
       warning ("Unable to restore previously selected frame.\n");
@@ -3892,7 +3898,7 @@
   trap_expected = inf_status->trap_expected;
   step_range_start = inf_status->step_range_start;
   step_range_end = inf_status->step_range_end;
-  step_frame_address = inf_status->step_frame_address;
+  step_frame_id = inf_status->step_frame_id;
   step_over_calls = inf_status->step_over_calls;
   stop_after_trap = inf_status->stop_after_trap;
   stop_soon_quietly = inf_status->stop_soon_quietly;
Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.24
diff -u -r1.24 thread.c
--- thread.c	29 Nov 2002 19:15:15 -0000	1.24
+++ thread.c	4 Dec 2002 02:30:55 -0000
@@ -296,7 +296,7 @@
 		   struct breakpoint **through_sigtramp_breakpoint,
 		   CORE_ADDR *step_range_start, 
 		   CORE_ADDR *step_range_end,
-		   CORE_ADDR *step_frame_address, 
+		   struct frame_id *step_frame_id, 
 		   int *handling_longjmp,
 		   int *another_trap, 
 		   int *stepping_through_solib_after_catch,
@@ -322,7 +322,7 @@
   *through_sigtramp_breakpoint = tp->through_sigtramp_breakpoint;
   *step_range_start = tp->step_range_start;
   *step_range_end = tp->step_range_end;
-  *step_frame_address = tp->step_frame_address;
+  *step_frame_id = tp->step_frame_id;
   *handling_longjmp = tp->handling_longjmp;
   *another_trap = tp->another_trap;
   *stepping_through_solib_after_catch = tp->stepping_through_solib_after_catch;
@@ -345,7 +345,7 @@
 		   struct breakpoint *through_sigtramp_breakpoint,
 		   CORE_ADDR step_range_start, 
 		   CORE_ADDR step_range_end,
-		   CORE_ADDR step_frame_address, 
+		   const struct frame_id *step_frame_id, 
 		   int handling_longjmp,
 		   int another_trap, 
 		   int stepping_through_solib_after_catch,
@@ -371,7 +371,7 @@
   tp->through_sigtramp_breakpoint = through_sigtramp_breakpoint;
   tp->step_range_start = step_range_start;
   tp->step_range_end = step_range_end;
-  tp->step_frame_address = step_frame_address;
+  tp->step_frame_id = (*step_frame_id);
   tp->handling_longjmp = handling_longjmp;
   tp->another_trap = another_trap;
   tp->stepping_through_solib_after_catch = stepping_through_solib_after_catch;

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