From: Luis Machado <luisgpm@linux.vnet.ibm.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] "single step" atomic instruction sequences as a whole on PPC
Date: Mon, 07 May 2007 19:28:00 -0000 [thread overview]
Message-ID: <1178566107.4427.16.camel@localhost> (raw)
In-Reply-To: <200705071811.l47IBmSk013161@d12av02.megacenter.de.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
Ulrich,
> It's much better, thanks. Unfortunately there's still a number of
> issues -- thanks for you patience in dealing with those.
Looks like i missed some. I'm getting used to the standard, however.
Thanks for reviewing.
> I guess that's OK with me. I'm wondering why we need the one message
> that's still in there then -- I'd say either we warn whenever we find
> a sequence we don't understand, or we never warn.
In order to make it more transparent to the user, i removed the messages
during the process.
Best Regards,
Luis
[-- Attachment #2: ppc-atomic-single-stepping.diff --]
[-- Type: text/x-patch, Size: 4686 bytes --]
2007-04-13 Paul Gilliam <pgilliam@us.ibm.com>
Luis Machado <luisgpm@br.ibm.com>
* rs6000-tdep.c: Defines masks for POWER instructions that set
and use the reservation flag (LWARX,LDARX,STWCX,STDCX).
* rs6000-tdep.c (deal_with_atomic_sequence): Handles single
stepping through an atomic sequence of instructions.
* rs6000-tdep.c (rs6000_software_single_step): Added a function
call to check if we are stepping through an atomic sequence of
instructions.
* rs6000-tdep.c (rs6000_gdbarch_init): Initializes a function to
check for atomic instruction sequences while single stepping.
Index: gdb/rs6000-tdep.c
===================================================================
--- gdb.orig/rs6000-tdep.c 2007-05-07 07:20:39.000000000 -0700
+++ gdb/rs6000-tdep.c 2007-05-07 12:27:10.000000000 -0700
@@ -706,8 +706,89 @@
return little_breakpoint;
}
+#define LWARX_MASK 0xfc0007fe
+#define LWARX_INSTRUCTION 0x7c000028
+#define LDARX_INSTRUCTION 0x7c0000A8
+#define STWCX_MASK 0xfc0007ff
+#define STWCX_INSTRUCTION 0x7c00012d
+#define STDCX_INSTRUCTION 0x7c0001ad
+#define BC_MASK 0xfc000000
+#define BC_INSTRUCTION 0x40000000
+
+static int
+deal_with_atomic_sequence (struct regcache *regcache)
+{
+ CORE_ADDR pc = read_pc ();
+ CORE_ADDR breaks[2] = {-1, -1};
+ CORE_ADDR loc = pc;
+ CORE_ADDR branch_bp; /* Breakpoint at branch instruction's destination. */
+ int insn = read_memory_integer (loc, PPC_INSN_SIZE);
+ int insn_count;
+ int index; /* Index used for the "breaks" array. */
+ int last_breakpoint = 0; /* Defaults to 0 (no breakpoints placed). */
+ const int atomic_sequence_length = 16; /* Instruction sequence length. */
+ const int opcode = BC_INSTRUCTION; /* Branch instruction's OPcode. */
+ int bc_insn_count = 0; /* Conditional branch instruction count. */
+
+ /* Assume all atomic sequences start with an lwarx/ldarx instruction. */
+ if ((insn & LWARX_MASK) != LWARX_INSTRUCTION
+ && (insn & LWARX_MASK) != LDARX_INSTRUCTION)
+ return 0;
+
+ /* Assume that no atomic sequence is longer than "atomic_sequence_length"
+ instructions. */
+ for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
+ {
+ loc += PPC_INSN_SIZE;
+ insn = read_memory_integer (loc, PPC_INSN_SIZE);
+
+ /* Assume that there is at most one conditional branch in the atomic
+ sequence. If a conditional branch is found, put a breakpoint in
+ its destination address. */
+ if ((insn & BC_MASK) == BC_INSTRUCTION)
+ {
+ if (bc_insn_count >= 1)
+ return 0; /* More than one conditional branch found, fallback
+ to the standard single-step code. */
+
+ branch_bp = branch_dest (opcode, insn, pc, breaks[0]);
+
+ if (branch_bp != -1)
+ {
+ breaks[1] = branch_bp;
+ bc_insn_count++;
+ last_breakpoint++;
+ }
+ }
+
+ if ((insn & STWCX_MASK) == STWCX_INSTRUCTION
+ || (insn & STWCX_MASK) == STDCX_INSTRUCTION)
+ break;
+ }
+
+ /* Assume that the atomic sequence ends with a stwcx/stdcx instruction. */
+ if ((insn & STWCX_MASK) != STWCX_INSTRUCTION
+ && (insn & STWCX_MASK) != STDCX_INSTRUCTION)
+ return 0;
+
+ loc += PPC_INSN_SIZE;
+ insn = read_memory_integer (loc, PPC_INSN_SIZE);
+
+ /* Insert a breakpoint right after the end of the atomic sequence. */
+ breaks[0] = loc;
+
+ /* Check for duplicated breakpoints. */
+ if (last_breakpoint && (breaks[1] == breaks[0]))
+ last_breakpoint = 0;
+
+ /* Effectively inserts the breakpoints. */
+ for (index = 0; index <= last_breakpoint; index++)
+ insert_single_step_breakpoint (breaks[index]);
+
+ return 1;
+}
-/* AIX does not support PT_STEP. Simulate it. */
+/* AIX does not support PT_STEP. Simulate it. */
int
rs6000_software_single_step (struct regcache *regcache)
@@ -724,6 +805,9 @@
insn = read_memory_integer (loc, 4);
+ if (deal_with_atomic_sequence (regcache))
+ return 1;
+
breaks[0] = loc + breakp_sz;
opcode = insn >> 26;
breaks[1] = branch_dest (opcode, insn, loc, breaks[0]);
@@ -3448,6 +3532,9 @@
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
set_gdbarch_breakpoint_from_pc (gdbarch, rs6000_breakpoint_from_pc);
+ /* Handles single stepping of atomic sequences. */
+ set_gdbarch_software_single_step (gdbarch, deal_with_atomic_sequence);
+
/* Handle the 64-bit SVR4 minimal-symbol convention of using "FN"
for the descriptor and ".FN" for the entry-point -- a user
specifying "break FN" will unexpectedly end up with a breakpoint
next prev parent reply other threads:[~2007-05-07 19:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1177964763.15264.45.camel@localhost>
2007-05-02 14:08 ` uweigand
2007-05-03 14:51 ` Luis Machado
2007-05-06 21:20 ` Ulrich Weigand
2007-05-07 15:14 ` Luis Machado
2007-05-07 18:11 ` Ulrich Weigand
2007-05-07 19:28 ` Luis Machado [this message]
2007-05-07 22:47 ` Ulrich Weigand
2007-05-07 23:23 ` Luis Machado
2007-05-08 12:50 ` Ulrich Weigand
2007-05-09 14:33 ` Ulrich Weigand
2007-05-09 18:05 ` Luis Machado
2007-05-09 18:12 ` Daniel Jacobowitz
2007-05-09 18:21 ` Luis Machado
2007-05-09 18:34 ` Jan Kratochvil
2007-05-09 18:46 ` Daniel Jacobowitz
2007-05-09 19:10 ` Ulrich Weigand
2007-05-09 19:14 ` Luis Machado
2007-05-10 10:57 ` Emi SUZUKI
2007-05-10 21:31 ` Ulrich Weigand
2007-05-10 21:36 ` Daniel Jacobowitz
2007-05-10 22:58 ` Ulrich Weigand
2007-05-10 23:25 ` Daniel Jacobowitz
2007-05-11 7:34 ` Emi SUZUKI
2007-05-11 12:46 ` Ulrich Weigand
2007-05-09 19:45 ` Ulrich Weigand
2007-05-10 0:48 ` Luis Machado
2007-05-10 20:29 ` Ulrich Weigand
2007-04-09 2:13 Patch for gdb build on hppa hp-ux Daniel Jacobowitz
2007-04-09 23:25 ` Steve Ellcey
2007-04-10 12:05 ` Daniel Jacobowitz
2007-04-10 19:03 ` Eli Zaretskii
2007-04-10 20:22 ` Daniel Jacobowitz
2007-04-13 14:04 ` Daniel Jacobowitz
2007-04-13 17:07 ` [patch] "single step" atomic instruction sequences as a whole on PPC Luis Machado
2007-04-28 23:34 ` [RFC] " Luis Machado
2007-04-28 23:45 ` Ulrich Weigand
2007-04-29 1:53 ` Luis Machado
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=1178566107.4427.16.camel@localhost \
--to=luisgpm@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.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