From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Cc: palves@redhat.com, simon.marchi@ericsson.com
Subject: Move threads out of jumppad without single step
Date: Fri, 27 Nov 2015 10:55:00 -0000 [thread overview]
Message-ID: <86zixzvhj1.fsf@gmail.com> (raw)
Hi Pedro,
Can we move threads out of jumppad without using single step? I mean,
supposing GDBserver can compute the next PCs of the instruction on which
fast tracepoint is set, GDBserver can insert breakpoints at the next PCs
of the instruction fast tracepoint is set on, and resume the thread
which is in jumppad.
In the recent discussion about ARM fast tracepoint support, I pointed
out that missing hardware single step may be a showstopper to ARM fast
tracepoint support, but Simon wants to convince me that we can have a
non-perfect fast tracepoint support on ARM with software single step.
After I think about the possible issues of using software single step, I
don't have any outcomes, but I wonder why do we need to single step
thread out of jumppad? Here is my understanding, in the jumppad, the
instructions are like,
saved registers
spin lock
call gdb_collect
spin unlock
restore registers
<----- [1]
relocated instructions
jump back
If PC is within the range above, GDBserver needs to move the thread
out. GDBserver can single step instructions one by one until PC is out
of this range, but we have an optimization here that GDBserver can
insert breakpoint and resume rather than single step one by one if PC
doesn't point to the relocated instructions yet [1]. Afterwards,
GDBserver will single step, but there aren't many instructions. Unless
I miss something, the code comments explain why do we move threads out
of jumppad, but they do *not* explain why do we move threads out of
jumppad in this way. IMO, the reason is that instructions before [1]
are sequentially executed (except call gdb_collect), but instructions
after [1] may not. We can safely insert breakpoint on [1], and thread
must hit the breakpoint. However, the original instruction on which the
fast tracepoint is set may be a branch instruction, so the relocated
instructions may jump back to the target address. At the moment we add
fast tracepoint support (for x86), we rely on hardware single step so
that we don't have to compute the next PCs (that is also the reason why
qRelocInsn packet was added).
Now, the situation in GDBserver changed a little bit, as GDBserver will
be able to accurately compute the next PCs. Under this assumption,
GDBserver can compute the next PCs of the original instruction, and set
breakpoints there when threads are in jumppad. In this way, we don't
need to single step thread out jumppad at all for targets which support
software single step in GDBserver.
--
Yao (齐尧)
next reply other threads:[~2015-11-27 10:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 10:55 Yao Qi [this message]
2015-11-30 14:42 ` Pedro Alves
2015-11-30 19:04 ` Simon Marchi
2015-11-30 19:39 ` Pedro Alves
2015-12-01 11:36 ` Yao Qi
2016-01-27 16:47 ` Antoine Tremblay
2016-01-29 20:43 ` Antoine Tremblay
2016-02-04 16:58 ` Yao Qi
2016-02-04 18:24 ` Antoine Tremblay
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=86zixzvhj1.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.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