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] Make SAVED_PC_AFTER_CALL optional. Deprecate?


Hello,

This makes the SAVED_PC_AFTER_CALL optional; removing the d10v implementation. The comment that goes with the patch should explain the rationale.

I'll commit in a day or so.

Baring problems, it will be followed up with the deprecation of SAVED_PC_AFTER_CALL.

Andrew
2003-04-06  Andrew Cagney  <cagney at redhat dot com>

	* gdbarch.sh (SAVED_PC_AFTER_CALL): Add a predicate.
	* gdbarch.h, gdbarch.c: Re-generate.
	* d10v-tdep.c (d10v_saved_pc_after_call): Delete function.
	(d10v_gdbarch_init): Do not set saved_pc_after_call.
	* infrun.c (step_over_function): Call SAVED_PC_AFTER_CALL_P
	conditionally, using frame_pc_unwind as an alternative.  Add
	comments.
	* arch-utils.c (init_frame_pc_default): Only call
	SAVED_PC_AFTER_CALL when available.

Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.77
diff -u -r1.77 arch-utils.c
--- arch-utils.c	12 Mar 2003 16:50:42 -0000	1.77
+++ arch-utils.c	6 Apr 2003 16:55:37 -0000
@@ -383,7 +383,7 @@
 CORE_ADDR
 init_frame_pc_default (int fromleaf, struct frame_info *prev)
 {
-  if (fromleaf)
+  if (fromleaf && SAVED_PC_AFTER_CALL_P ())
     return SAVED_PC_AFTER_CALL (get_next_frame (prev));
   else if (get_next_frame (prev) != NULL)
     return DEPRECATED_FRAME_SAVED_PC (get_next_frame (prev));
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.104
diff -u -r1.104 d10v-tdep.c
--- d10v-tdep.c	5 Apr 2003 18:54:38 -0000	1.104
+++ d10v-tdep.c	6 Apr 2003 16:55:38 -0000
@@ -488,17 +488,6 @@
   return (addr | DMEM_START);
 }
 
-/* Immediately after a function call, return the saved pc.  We can't
-   use frame->return_pc beause that is determined by reading R13 off
-   the stack and that may not be written yet. */
-
-static CORE_ADDR
-d10v_saved_pc_after_call (struct frame_info *frame)
-{
-  return ((read_register (LR_REGNUM) << 2)
-	  | IMEM_START);
-}
-
 static int
 check_prologue (unsigned short op)
 {
@@ -1700,7 +1689,6 @@
   set_gdbarch_frame_args_skip (gdbarch, 0);
   set_gdbarch_frameless_function_invocation (gdbarch, frameless_look_for_prologue);
 
-  set_gdbarch_saved_pc_after_call (gdbarch, d10v_saved_pc_after_call);
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
   set_gdbarch_stack_align (gdbarch, d10v_stack_align);
 
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.222
diff -u -r1.222 gdbarch.sh
--- gdbarch.sh	6 Apr 2003 14:25:07 -0000	1.222
+++ gdbarch.sh	6 Apr 2003 16:55:51 -0000
@@ -599,7 +599,7 @@
 M::UNWIND_PC:CORE_ADDR:unwind_pc:struct frame_info *next_frame:next_frame:
 f:2:FRAME_ARGS_ADDRESS:CORE_ADDR:frame_args_address:struct frame_info *fi:fi::0:get_frame_base::0
 f:2:FRAME_LOCALS_ADDRESS:CORE_ADDR:frame_locals_address:struct frame_info *fi:fi::0:get_frame_base::0
-f:2:SAVED_PC_AFTER_CALL:CORE_ADDR:saved_pc_after_call:struct frame_info *frame:frame::0:0
+F::SAVED_PC_AFTER_CALL:CORE_ADDR:saved_pc_after_call:struct frame_info *frame:frame
 f:2:FRAME_NUM_ARGS:int:frame_num_args:struct frame_info *frame:frame::0:0
 #
 F:2:STACK_ALIGN:CORE_ADDR:stack_align:CORE_ADDR sp:sp::0:0
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.102
diff -u -r1.102 infrun.c
--- infrun.c	1 Apr 2003 14:38:49 -0000	1.102
+++ infrun.c	6 Apr 2003 16:55:53 -0000
@@ -2658,7 +2658,44 @@
   struct symtab_and_line sr_sal;
 
   init_sal (&sr_sal);		/* initialize to zeros */
-  sr_sal.pc = ADDR_BITS_REMOVE (SAVED_PC_AFTER_CALL (get_current_frame ()));
+
+  /* NOTE: cagney/2003-04-06:
+
+     At this point the equality get_frame_pc() == get_frame_func()
+     should hold.  This may make it possible for this code to tell the
+     frame where it's function is, instead of the reverse.  This would
+     avoid the need to search for the frame's function, which can get
+     very messy when there is no debug info available (look at the
+     heuristic find pc start code found in targets like the MIPS).  */
+
+  /* NOTE: cagney/2003-04-06: Deprecate SAVED_PC_AFTER_CALL?
+
+     The intent of SAVED_PC_AFTER_CALL was to:
+
+     - provide a very light weight equivalent to frame_unwind_pc()
+     (nee FRAME_SAVED_PC) that avoids the prologue analyzer
+
+     - avoid handling the case where the PC hasn't been saved in the
+     prologue analyzer
+
+     Unfortunatly, not five lines further down, is a call to
+     get_frame_id() and that is guarenteed to trigger the prologue
+     analyzer.
+     
+     The `correct fix' is for the prologe analyzer to handle the case
+     where the prologue is incomplete (PC in prologue) and,
+     consequently, the return pc has not yet been saved.  It should be
+     noted that the prologue analyzer needs to handle this case
+     anyway: frameless leaf functions that don't save the return PC;
+     single stepping through a prologue.
+
+     The d10v handles all this by bailing out of the prologue analsis
+     when it reaches the current instruction.  */
+
+  if (SAVED_PC_AFTER_CALL_P ())
+    sr_sal.pc = ADDR_BITS_REMOVE (SAVED_PC_AFTER_CALL (get_current_frame ()));
+  else
+    sr_sal.pc = ADDR_BITS_REMOVE (frame_pc_unwind (get_current_frame ()));
   sr_sal.section = find_pc_overlay (sr_sal.pc);
 
   check_for_old_step_resume_breakpoint ();

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