From: PAUL GILLIAM <pgilliam@us.ibm.com>
To: gdb-patches@sourceware.org
Subject: Re: [patch] "single step" atomic instruction sequences as a whole.
Date: Thu, 22 Jun 2006 21:53:00 -0000 [thread overview]
Message-ID: <1151009330.7608.68.camel@dufur.beaverton.ibm.com> (raw)
In-Reply-To: <1151005894.7608.63.camel@dufur.beaverton.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
On Thu, 2006-06-22 at 12:51 -0700, PAUL GILLIAM wrote:
> You may ask "but what if an architecture needs the old
> software_single_step functionality *and* has sequences of instructions
> that need to be atomic?"
It turns out, there *is* such an architecture and it can have the *same*
sequences instruction that need to be atomic as PPC: the RS6000!
So here is a patch that adds dealing with atomic sequences for the
RS6000.
The attach patch assumes that the 'change-software-single-step.diff'
patch has been applied.
OK to commit?
-=# Paul #=-
[-- Attachment #2: rs6000-atomic-single-step.diff --]
[-- Type: text/x-patch, Size: 2854 bytes --]
--- old_rs6000-tdep.c 2006-06-22 13:16:03.000000000 -0700
+++ rs6000-tdep.c 2006-06-22 13:41:10.000000000 -0700
@@ -701,8 +701,81 @@
return little_breakpoint;
}
+#define LWARX_MASK 0xfc0007fe
+#define LWARX_INSTRUCTION 0x7C000028
+#define STWCX_MASK 0xfc0007ff
+#define STWCX_INSTRUCTION 0x7c00012d
+#define BC_MASK 0xfc000000
+#define BC_INSTRUCTION 0x40000000
+#define IMMEDIATE_PART(insn) (((insn & ~3) << 16) >> 16)
+#define ABSOLUTE_P(insn) ((int) ((insn >> 1) & 1))
+
+static int
+deal_with_atomic_sequence (enum target_signal sig)
+{
+ CORE_ADDR pc = read_pc ();
+ CORE_ADDR breaks[2] = {-1, -1};
+ CORE_ADDR loc = pc;
+ int insn = read_memory_integer (loc, 4);
+ int last_break = 0;
+ int i;
+
+
+ /* Assume all atomic sequences start with an lwarx instruction. */
+ if ((insn & LWARX_MASK) != LWARX_INSTRUCTION)
+ return 0;
-/* AIX does not support PT_STEP. Simulate it. */
+ /* Assume that no atomic sequence is longer than 6 instructions. */
+ for (i= 1; i < 5; ++i)
+ {
+ loc += PPC_INSN_SIZE;
+ insn = read_memory_integer (loc, 4);
+
+ /* Assume at most one conditional branch instruction between
+ the lwarx and stwcx instructions.*/
+ if ((insn & BC_MASK) == BC_INSTRUCTION)
+ {
+ last_break = 1;
+ breaks[1] = IMMEDIATE_PART (insn);
+ if ( ! ABSOLUTE_P(insn))
+ breaks[1] += loc;
+ continue;
+ }
+
+ if ((insn & STWCX_MASK) == STWCX_INSTRUCTION)
+ break;
+ }
+
+ /* Assume that the atomic sequence ends with a stwcx instruction
+ followed by a conditional branch instruction. */
+ if ((insn & STWCX_MASK) != STWCX_INSTRUCTION)
+ error (_("Tried to step over an atomic sequence of instructions but could not find the end of the sequence."));
+
+ loc += PPC_INSN_SIZE;
+ insn = read_memory_integer (loc, 4);
+
+ if ((insn & BC_MASK) != BC_INSTRUCTION)
+ error (_("Tried to step over an atomic sequence of instructions but it did not end as expected."));
+
+ breaks[0] = loc;
+
+ /* This should never happen, but make sure we don't but
+ two breakpoints on the same address. */
+ if (last_break && breaks[1] == breaks[0])
+ last_break = 0;
+
+ for (i= 0; i < last_break; ++i)
+ insert_single_step_breakpoint (breaks[i]);
+
+ printf_unfiltered (_("Stepping over an atomic sequence of instructions beginning at %s\n"),
+ core_addr_to_string (pc));
+ gdb_flush (gdb_stdout);
+
+ return 1;
+}
+
+/* AIX does not support PT_STEP. Simulate it, dealing with any sequence of
+ instructions that must be atomic. */
int
rs6000_software_single_step (enum target_signal signal,
@@ -722,6 +795,9 @@
insn = read_memory_integer (loc, 4);
+ if (deal_with_atomic_sequence (signal))
+ return 1;
+
breaks[0] = loc + breakp_sz;
opcode = insn >> 26;
breaks[1] = branch_dest (opcode, insn, loc, breaks[0]);
next prev parent reply other threads:[~2006-06-22 21:53 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-22 20:56 PAUL GILLIAM
2006-06-22 21:53 ` PAUL GILLIAM [this message]
2006-06-22 22:20 ` PAUL GILLIAM
2006-11-10 21:18 ` Daniel Jacobowitz
2006-09-18 11:59 emin ak
2006-11-09 13:07 ` [patch] " emin ak
2007-02-06 11:02 Luis Machado
2007-02-06 12:11 ` Emi SUZUKI
2007-02-07 13:10 ` Luis Machado
2007-02-08 13:00 ` Emi SUZUKI
2007-02-17 2:24 Luis Machado
2007-02-27 13:00 ` Emi SUZUKI
2007-02-27 13:17 ` Daniel Jacobowitz
2007-02-28 8:08 ` Emi SUZUKI
2007-02-28 11:46 ` Daniel Jacobowitz
2007-02-28 16:09 ` Luis Machado
2007-03-02 12:47 ` Emi SUZUKI
2007-03-06 11:00 ` Andreas Schwab
2007-03-06 12:24 ` Daniel Jacobowitz
2007-03-08 8:50 ` Emi SUZUKI
2007-03-08 16:15 ` Ulrich Weigand
2007-03-13 6:12 ` SUZUKI Emi
2007-03-15 22:24 Luis Machado
2007-04-10 20:40 ` Daniel Jacobowitz
2007-04-12 12:09 ` Luis Machado
2007-04-12 12:15 ` Daniel Jacobowitz
2007-04-12 12:54 ` Luis Machado
2007-04-12 12:58 ` Daniel Jacobowitz
2007-04-12 13:30 ` Luis Machado
2007-04-12 13:35 ` Daniel Jacobowitz
2007-04-12 14:58 ` Ulrich Weigand
2007-04-12 15:33 ` Daniel Jacobowitz
2007-04-12 17:16 ` Ulrich Weigand
2007-04-12 18:25 ` Daniel Jacobowitz
2007-04-12 20:09 ` Ulrich Weigand
2007-04-12 20:16 ` Mark Kettenis
2007-04-12 20:43 ` Ulrich Weigand
2007-04-14 15:20 ` Mark Kettenis
2007-04-14 18:13 ` Ulrich Weigand
2007-04-12 20:49 ` Daniel Jacobowitz
2007-04-12 20:48 ` Daniel Jacobowitz
2007-04-12 14:32 ` Ulrich Weigand
2007-04-12 14:47 ` Luis Machado
2007-04-12 15:00 ` Ulrich Weigand
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=1151009330.7608.68.camel@dufur.beaverton.ibm.com \
--to=pgilliam@us.ibm.com \
--cc=gdb-patches@sourceware.org \
/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