From: PAUL GILLIAM <pgilliam@us.ibm.com>
To: gdb@sources.redhat.com
Subject: Instrcutions that must not be stepped.
Date: Thu, 08 Jun 2006 02:27:00 -0000 [thread overview]
Message-ID: <1149726000.10016.71.camel@dufur.beaverton.ibm.com> (raw)
On the PowerPC, there is a provision for an atomic read-modify-right
sequence that is implemented using the "lwarx" and "stwcx" instructions.
These do not guarantee an atomic operation, but will detect its failure.
If threads are being used, then glibc functions use this sequence to
implement a lock by looping back to the start of the sequence if it was
not atomic.
When gdb is stepping through a library function, which it does under
some circumstances if there is no source for the function, it gets stuck
in this loop because the sequence will never be recognized as atomic.
The only solution is to check each instruction about to be stepped to
see if it's an "lwarx". If not, step as usual. If it is, then analyze
the instructions that follow; set a temporary breakpoint after the loop,
do a 'continue' and then continue stepping normally after it's been hit.
Does there currently exist an arch. independent way to detect
instruction sequences that must not be single stepped? Failing that, is
there some hook I can use to implement this for just the PowerPC?
Should there be a new gdbarch member like 'single_step_nonstepable' that
will detect and handle non-stepable sequences?. Or maybe a gdbarch
member like 'find_end_of_nonstepable_sequence' that returns 0 if the
instruction about be be stepped is not the the start of a non-stepable
sequence and the address of the end of the sequence (where to set a
temp. break) if it is.
Thanks for your help,
-=# Paul #=-
PS: The following hack prevents single-stepping a "lwarx" instruction.
The user can then manually find the end of the sequence, put a temp.
break there, continue, and then go back to stepping as normal. Before
you get upset, remember I did say it was a hack and it actually allowed
a teammate to make progress on an unrelated glibc bug.
--- inf-ptrace.c 2006-01-24 14:34:34.000000000 -0800
+++ new.inf-ptrace.c 2006-06-07 13:59:02.000000000 -0700
@@ -326,6 +326,14 @@
if (step)
{
+ /* Horrible hack: See if we are about to step an "lwarx"
+ instruction and abort with an error message if so. */
+ long pc = (long) read_register (PC_REGNUM);
+ long inst = ptrace (PT_READ_I, pid, pc, 0);
+
+ if ((inst & 0xfc0007fe) == 0x7C000028)
+ perror_with_name (("(barf) lwarx (barf)"));
+
/* If this system does not support PT_STEP, a higher level
function will have called single_step() to transmute the step
request into a continue request (by setting breakpoints on
next reply other threads:[~2006-06-08 1:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-08 2:27 PAUL GILLIAM [this message]
2006-06-08 3:50 ` Daniel Jacobowitz
2006-06-16 4:36 ` PAUL GILLIAM
2006-06-17 12:26 ` PAUL GILLIAM
2006-06-18 4:57 ` Mark Kettenis
2006-06-20 20:13 ` PAUL GILLIAM
2006-06-20 22:53 ` Paul Koning
2006-06-20 23:34 ` PAUL GILLIAM
2006-06-21 1:17 ` Daniel Jacobowitz
2006-06-09 14:12 John Yates
2006-06-09 14:28 ` Daniel Jacobowitz
2006-06-10 0:33 ` PAUL GILLIAM
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=1149726000.10016.71.camel@dufur.beaverton.ibm.com \
--to=pgilliam@us.ibm.com \
--cc=gdb@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