Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] rs6000_software_single_step() cleanup / bug fix
Date: Mon, 08 Apr 2002 18:52:00 -0000	[thread overview]
Message-ID: <1020409015207.ZM22771@localhost.localdomain> (raw)

I've just committed the patch below.  Thanks again to Jimi for yet another
cleanup.  (Note too that it fixes 64-bit software singlestep support.)

	From Jimi X <jimix@watson.ibm.com>:
	* rs6000-tdep.c (rs6000_software_single_step): Use
	rs6000_breakpoint_from_pc() to fetch breakpoint instruction
	and size.  Use target_insert_breakpoint() and
	target_remove_breakpoint() to insert and remove breakpoints
	instead of explicit memory reads and writes.

Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.47
diff -u -p -r1.47 rs6000-tdep.c
--- rs6000-tdep.c	9 Apr 2002 00:53:28 -0000	1.47
+++ rs6000-tdep.c	9 Apr 2002 01:40:07 -0000
@@ -299,11 +299,9 @@ void
 rs6000_software_single_step (enum target_signal signal,
 			     int insert_breakpoints_p)
 {
-#define	INSNLEN(OPCODE)	 4
-
-  static char le_breakp[] = LITTLE_BREAKPOINT;
-  static char be_breakp[] = BIG_BREAKPOINT;
-  char *breakp = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? be_breakp : le_breakp;
+  CORE_ADDR dummy;
+  int breakp_sz;
+  char *breakp = rs6000_breakpoint_from_pc (&dummy, &breakp_sz);
   int ii, insn;
   CORE_ADDR loc;
   CORE_ADDR breaks[2];
@@ -316,7 +314,7 @@ rs6000_software_single_step (enum target
 
       insn = read_memory_integer (loc, 4);
 
-      breaks[0] = loc + INSNLEN (insn);
+      breaks[0] = loc + breakp_sz;
       opcode = insn >> 26;
       breaks[1] = branch_dest (opcode, insn, loc, breaks[0]);
 
@@ -332,10 +330,7 @@ rs6000_software_single_step (enum target
 	  /* ignore invalid breakpoint. */
 	  if (breaks[ii] == -1)
 	    continue;
-
-	  read_memory (breaks[ii], stepBreaks[ii].data, 4);
-
-	  write_memory (breaks[ii], breakp, 4);
+	  target_insert_breakpoint (breaks[ii], stepBreaks[ii].data);
 	  stepBreaks[ii].address = breaks[ii];
 	}
 
@@ -346,9 +341,8 @@ rs6000_software_single_step (enum target
       /* remove step breakpoints. */
       for (ii = 0; ii < 2; ++ii)
 	if (stepBreaks[ii].address != 0)
-	  write_memory
-	    (stepBreaks[ii].address, stepBreaks[ii].data, 4);
-
+	  target_remove_breakpoint (stepBreaks[ii].address,
+				    stepBreaks[ii].data);
     }
   errno = 0;			/* FIXME, don't ignore errors! */
   /* What errors?  {read,write}_memory call error().  */


                 reply	other threads:[~2002-04-09  1:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1020409015207.ZM22771@localhost.localdomain \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox