This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC 0/3] Use reinsert breakpoint for vCont;s
- From: Antoine Tremblay <antoine dot tremblay at ericsson dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Tue, 17 May 2016 10:08:33 -0400
- Subject: Re: [RFC 0/3] Use reinsert breakpoint for vCont;s
- Authentication-results: sourceware.org; auth=none
- References: <1462530736-25117-1-git-send-email-yao dot qi at linaro dot org>
Yao Qi writes:
> Nowadays, reinsert breakpoint is used in GDBserver to step over a
> breakpoint. I want to use it to handle vCont;s. The motivation
> of this work is to exercise software single step in GDBserver side.
> In the past two weeks, I am fixing various test fails, but still
> can't fix all of them. I want to post something here, and hope
> people can help me on this area.
>
> Suppose GDB is able to send vCont;s to GDBserver using software
> single step (done by patch 3), what should GDBserver do? It call
> function single_step if lwp->resume->kind is resume_step. See
> patch 2.
>
> With this change, reinsert breakpoint is used for two purposes,
> 1) step over GDBserver breakpoint, 2) handle vCont;s. Here are some
> facts or assumptions in my mind,
>
> - reinsert breakpoints can be inserted for both step over and
> vCont;s together. GDBserver should finish all step-overs
> before resuming the threads, see scenario b) below,
> - GDB doesn't send more than one vCont s actions in one vCont
> packet, although RSP doc doesn't say this.
>
> It is straightforward to insert reinsert breakpoints for vCont;s,
> but I am not sure when to delete them. Here are some scenarios,
>
> a) vCont;s thread A, and vCont;c thread B. Thread A hits the reinsert
> breakpoints, and GDBserver can remove them. What is the proper
> place to remove them?
>
I think like you did in patch 2 before we know we're reporting to GDB
the right place too, but adding a
prepare_to_access_memory/done_accessing_memory lock around the delete /
insert reinsert breakpoints is needed.
I think this is better than waiting to know that we're going to
report, since this an unrelated condition.
> b) vCont;s thread A, and vCont;c thread B. Thread B hits breakpoints
> (not reinsert), do we remove reinsert breakpoints? My answer is
> no. In the following step-over, reinsert breakpoints for step-over
> are deleted, but reinsert breakpoints for vCont;s (thread A) are still
> there.
>
Right.
> c) vCont;s thread A, and vCont;c thread B. Thread B hits the reinsert
> breakpoints (for thread A vCont;s), do we remove reinsert breakpoints?
> I think no, we can just step over it for thread B.
>
Indeed.
> d) vCont;s thread A, and vCont;c thread B. A signal arrives, do we remove
> reinsert breakpoints? Yes, I think so.
Indeed.
>
> IMO, b) requires reinsert breakpoint thread specific, so that we can delete
> reinsert breakpoints for step-over of thread B, but keep reinsert breakpoints
> for vCont;s of thread A. That is what patch 1 does.
>
Indeed.
> I tried different ways to remove reinsert breakpoints in GDBserver, but still
> can't fix fails in gdb.threads/schedlock.exp, that the program gets SIGILL or
> SIGSEGV. These fails can't happen in every run, and they are disappeared
> when I turn on debugging output in GDBserver. I suspect they are about the
> improper management to reinsert breakpoints.
>
> (gdb) PASS: gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=1: next to increment (5)
> next^M
> 78 while (*myp > 0)^M
> (gdb) next^M
> ^M
> Thread 1 "schedlock" received signal SIGILL, Illegal instruction.^M
> [Switching to Thread 3797.3797]^M
> 0x000087f8 in thread_function (arg=0x0) at /home/yao/SourceCode/gnu/gdb/git/gdb/testsuite/gdb.threads/schedlock.c:78^M
> 78 while (*myp > 0)^M
> (gdb) FAIL: gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=1: next to increment (6)
>
> Any ideas on the overall design, how to handle vCont;s in GDBserver using
> software single step? or is it a completely wrong thing to handle vCont;s
> using software single step?
>
Actually pretty much the only thing that single step reinsert breakpoints have
in common with step over reinsert breakpoints is that they're
inserted as a GDBServer breakpoint. No other code path is the same, afaick.
I think it would be more clear to have a different kind of breakpoint so that :
- We can protect these breakpoints with prepare_to_access_memory
without affecting the step over reinsert breakpoints, that do not need this.
- Have these breakpoints thread specific, again something that
step-over breakpoints do not need.
The added logic to the control flow should be about the same or less
than by sharing the reinsert_breakpoints.
Also, when changing code related to either of the 2 scenarios we would not
fear breaking one or the other. Things are already mangled enough
in that area ?
I'm testing this out...