Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sources.redhat.com
Cc: rearnsha@arm.com
Subject: [rfa/arm] Handle bx and blx
Date: Sat, 28 Feb 2004 18:35:00 -0000	[thread overview]
Message-ID: <20040228183508.GA17481@nevyn.them.org> (raw)

The software single-step implementation in GDB doesn't know either BX or
BLX.  This results in losing control of the inferior when we single-step
over them.  I based this on the ARM ARM, so I'm pretty sure I've got the
numbers correct.

OK to check in?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-02-28  Daniel Jacobowitz  <drow@mvista.com>

	* arm-tdep.c (thumb_get_next_pc): Handle BX.
	(arm_get_next_pc): Handle BX and BLX.

Index: gdb/arm-tdep.c
===================================================================
RCS file: /big/fsf/rsync/src-cvs/src/gdb/arm-tdep.c,v
retrieving revision 1.164
diff -u -p -r1.164 arm-tdep.c
--- gdb/arm-tdep.c	16 Feb 2004 21:49:21 -0000	1.164
+++ gdb/arm-tdep.c	28 Feb 2004 03:37:18 -0000
@@ -1657,6 +1658,17 @@ thumb_get_next_pc (CORE_ADDR pc)
       offset = (sbits (inst1, 0, 10) << 12) + (bits (inst2, 0, 10) << 1);
       nextpc = pc_val + offset;
     }
+  else if ((inst1 & 0xff80) == 0x4700)	/* branch and exchange (bx) */
+    {
+      if (bits (inst1, 3, 6) == 0x0f)
+	nextpc = pc_val;
+      else
+	nextpc = read_register (bits (inst1, 3, 6));
+
+      nextpc = ADDR_BITS_REMOVE (nextpc);
+      if (nextpc == pc)
+	error ("Infinite loop detected");
+    }
 
   return nextpc;
 }
@@ -1697,6 +1709,20 @@ arm_get_next_pc (CORE_ADDR pc)
 		&& bits (this_instr, 4, 7) == 9)	/* multiply */
 	      error ("Illegal update to pc in instruction");
 
+	    /* BX <reg>, BLX <reg> */
+	    if (bits (this_instr, 4, 28) == 0x12fff1
+		|| bits (this_instr, 4, 28) == 0x12fff3)
+	      {
+		rn = bits (this_instr, 0, 3);
+		result = (rn == 15) ? pc_val + 8 : read_register (rn);
+		nextpc = (CORE_ADDR) ADDR_BITS_REMOVE (result);
+
+		if (nextpc == pc)
+		  error ("Infinite loop detected");
+
+		return nextpc;
+	      }
+
 	    /* Multiply into PC */
 	    c = (status & FLAG_C) ? 1 : 0;
 	    rn = bits (this_instr, 16, 19);
@@ -1862,6 +1888,10 @@ arm_get_next_pc (CORE_ADDR pc)
 	  {
 	    nextpc = BranchDest (pc, this_instr);
 
+	    /* BLX */
+	    if (bits (this_instr, 28, 31) == INST_NV)
+	      nextpc |= bit (this_instr, 24) << 1;
+
 	    nextpc = ADDR_BITS_REMOVE (nextpc);
 	    if (nextpc == pc)
 	      error ("Infinite loop detected");


             reply	other threads:[~2004-02-28 18:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-28 18:35 Daniel Jacobowitz [this message]
2004-03-03 16:02 ` Richard Earnshaw
2004-03-07 20:15   ` Daniel Jacobowitz
2004-03-08 10:18     ` Richard Earnshaw
2004-03-19  0:09       ` Daniel Jacobowitz
2004-03-08 14:09         ` Daniel Jacobowitz
2004-03-19  0:09         ` Richard Earnshaw
2004-03-08 14:19           ` Richard Earnshaw
2004-03-08 14:25           ` Daniel Jacobowitz
2004-03-19  0:09             ` Daniel Jacobowitz
2004-03-19  0:09             ` Richard Earnshaw
2004-03-08 14:28               ` Richard Earnshaw
2004-03-09 15:47               ` Daniel Jacobowitz
2004-03-19  0:09                 ` Daniel Jacobowitz
2004-03-19  0:09       ` Richard Earnshaw
2004-03-19  0:09     ` Daniel Jacobowitz
2004-03-19  0:09   ` Richard Earnshaw

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=20040228183508.GA17481@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=rearnsha@arm.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