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]

Re: [RFA] Add mips_software_single_step


On Thu, Jul 05, 2001 at 06:50:26PM -0400, Andrew Cagney wrote:
> > On Thu, Jul 05, 2001 at 05:50:14PM -0400, Andrew Cagney wrote:
> > 
> >> > This function's pretty straightforward; the Linux port uses it.  Ok to
> >> > commit?
> > 
> >> 
> >> 
> >> How does the linux port use it?  As a tweek to the multi-arch vector or 
> >> as a macro/function?  If the former then it should be static, if the 
> >> latter than a declaration in mips-tdep.h or tm-mips.h (?) is needed.
> > 
> > 
> > As a macro:
> > 
> > #define SOFTWARE_SINGLE_STEP_P() 1
> > extern void mips_software_single_step (unsigned int, int);
> > #define SOFTWARE_SINGLE_STEP(sig,bp_p) mips_software_single_step (sig, bp_p)
> 
> 
> The macro definition appearing in config/mips/tm-linux.h but the 
> function declaration appearing in config/mips/tm-mips.h?  The function 
> declaration is in tm-mips.h so that mips-tdep.c always sees it.


Right.  My source right now has the declaration in tm-linux.h, but
tm-mips.h is more appropriate; I'll move it before I commit.

> > I'm sensing that this belongs in the multi-arch vector, though.  I'll
> > change that.
> 
> 
> For the moment the above is ok.

OK, then.  Is the style-corrected version below OK?

> We're getting into the relm of theory :-)  No one has so far tried to do 
> this.  (Well, ok I think Eli is setting himself up for the challenge on 
> IRIX.)

I guess I'll revisit this along with Eli once I get the port settled in
some basic state, then.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2001-07-04  Daniel Jacobowitz  <drow@mvista.com>

	* mips-tdep.c (mips_software_single_step): New function.
	* config/mips/tm-mips.h: Add prototype for
	mips_software_single_step.

Index: config/mips/tm-mips.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-mips.h,v
retrieving revision 1.20
diff -u -r1.20 tm-mips.h
--- tm-mips.h	2001/06/15 23:10:55	1.20
+++ tm-mips.h	2001/07/05 23:00:08
@@ -502,3 +502,6 @@
 /* MIPS sign extends addresses */
 #define POINTER_TO_ADDRESS(TYPE,BUF) (signed_pointer_to_address (TYPE, BUF))
 #define ADDRESS_TO_POINTER(TYPE,BUF,ADDR) (address_to_signed_pointer (TYPE, BUF, ADDR))
+
+/* Single step based on where the current instruction will take us.  */
+extern void mips_software_single_step (enum target_signal, int);
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.54
diff -u -r1.54 mips-tdep.c
--- mips-tdep.c	2001/06/16 20:00:24	1.54
+++ mips-tdep.c	2001/07/05 23:00:09
@@ -1379,6 +1392,33 @@
   return addr;
 }
 
+/* mips_software_single_step() is called just before we want to resume
+   the inferior, if we want to single-step it but there is no hardware
+   or kernel single-step support (MIPS on Linux for example).  We find
+   the target of the coming instruction and breakpoint it.
+
+   single_step is also called just after the inferior stops.  If we had
+   set up a simulated single-step, we undo our damage.  */
+
+void
+mips_software_single_step (enum target_signal sig, int insert_breakpoints_p)
+{
+  static CORE_ADDR next_pc;
+  typedef char binsn_quantum[BREAKPOINT_MAX];
+  static binsn_quantum break_mem;
+  CORE_ADDR pc;
+
+  if (insert_breakpoints_p)
+    {
+      pc = read_register (PC_REGNUM);
+      next_pc = mips_next_pc (pc);
+
+      target_insert_breakpoint (next_pc, break_mem);
+    }
+  else
+    target_remove_breakpoint (next_pc, break_mem);
+}
+
 static void
 mips_init_frame_pc_first (int fromleaf, struct frame_info *prev)
 {


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