From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 8/9] Use reinsert_breakpoint for vCont;s
Date: Tue, 05 Jul 2016 08:15:00 -0000 [thread overview]
Message-ID: <861t38zekw.fsf@gmail.com> (raw)
In-Reply-To: <c9c52445-0d03-51fa-b4d4-cb94d1e74471@redhat.com> (Pedro Alves's message of "Fri, 1 Jul 2016 16:07:26 +0100")
Pedro Alves <palves@redhat.com> writes:
>> if thread 1 doesn't hit the reinsert breakpoint, we don't have to
>> remove them, because GDB will send vCont;s:1 next time, and GDBserver
>
> There's no guarantee GDB will send vCont;s:1 next time.
> The user may do "continue" instead of "step".
>
>> can only install reinsert breakpoints if they are not installed yet.
>
> The user may even do "return + continue" or "jump", or an infcall,
> all of which resume the thread at a different address from the address
> the thread last stopped. So there's no guarantee that the
> reinsert breakpoint address makes any sense for the next step request,
> or even that the next resume request is a step in the first place.
>
> Basically the previous step request must be completely forgotten after
> gdb has seen the thread stop. In all-stop, gdb "sees "all threads
> stopped on each and every event reported to gdb, for any thread.
> A stop reply cancels any and all previous resume requests.
I add some code to delete all reinsert breakpoints for all threads in
all-stop. See the patch below,
>
>> if thread hits the reinsert breakpoint, but the event is not reported.
>> It becomes pending, and GDBserver will delete the reinsert breakpoints
>> next time when this pending event is reported back to GDB.
>
> I don't follow. I'm talking about the case where the thread does _not_
> hit the reinsert breakpoint. Instead some other thread hits some unrelated
> event.
In your review to V2, your words are about other threads hit a breakpoint, but
doesn't mention "thread 1" (requested for resume_step) hits reinsert
breakpoint or not. I just list two possible results (not hit vs
hit). You didn't talk about the latter, so we don't have to follow it.
--
Yao (齐尧)
From f4aa0593190e7e78831532c03177d8264b7dd1c1 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Thu, 19 May 2016 17:07:49 +0100
Subject: [PATCH] Use reinsert_breakpoint for vCont;s
V4: remove all reinsert breakpoints before sending event back to GDB
in all-stop mode,
V3: install breakpoints in proceed_one_lwp,
no longer stop all threads when installing breakpoints,
delete reinsert breakpoints when GDBserver wants to report event,
V2: fix spaces in changelog entry,
use maybe_hw_step,
cancel step-over if signal arrives (!maybe_internal_trap),
This patch is to teach GDBserver using software single step to handle
vCont;s. Simply speaking, if the thread's resume request is resume_step,
install reinsert breakpoint at the next pcs when GDBserver is about to
resume threads. These reinsert breakpoints of a thread are removed,
when GDBserver gets an event from that thread and reports it back to
GDB.
gdb/gdbserver:
2016-07-05 Yao Qi <yao.qi@linaro.org>
* linux-low.c (resume_stopped_resumed_lwps): If resume request
is resume_step, call maybe_hw_step.
(linux_wait_1): Stop all threads, remove reinsert breakpoints,
and unstop them.
(linux_resume_one_lwp_throw): Don't assert the thread has reinsert
breakpoints or not.
(proceed_one_lwp): If resume request is resume_step, install
reinsert breakpoints and call maybe_hw_step.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index abaf288..b579b4d 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -2563,7 +2563,10 @@ resume_stopped_resumed_lwps (struct inferior_list_entry *entry)
&& !lp->status_pending_p
&& thread->last_status.kind == TARGET_WAITKIND_IGNORE)
{
- int step = thread->last_resume_kind == resume_step;
+ int step = 0;
+
+ if (thread->last_resume_kind == resume_step)
+ step = maybe_hw_step (thread);
if (debug_threads)
debug_printf ("RSRL: resuming stopped-resumed LWP %s at %s: step=%d\n",
@@ -3622,6 +3625,66 @@ linux_wait_1 (ptid_t ptid,
/* Alright, we're going to report a stop. */
+ /* Remove reinsert breakpoints. */
+ if (can_software_single_step ())
+ {
+ /* Remove reinsert breakpoints or not. It it is true, stop all
+ lwps, so that other threads won't hit the breakpoint in the
+ staled memory. */
+ int remove_reinsert_breakpoints_p = 0;
+
+ if (non_stop)
+ {
+ remove_reinsert_breakpoints_p
+ = has_reinsert_breakpoints (current_thread);
+ }
+ else
+ {
+ /* In all-stop, a stop reply cancels all previous resume
+ requests. Delete all reinsert breakpoints. */
+ struct inferior_list_entry *inf, *tmp;
+
+ ALL_INFERIORS (&all_threads, inf, tmp)
+ {
+ struct thread_info *thread = (struct thread_info *) inf;
+
+ if (has_reinsert_breakpoints (thread))
+ {
+ remove_reinsert_breakpoints_p = 1;
+ break;
+ }
+ }
+ }
+
+ if (remove_reinsert_breakpoints_p)
+ {
+ /* If we remove reinsert breakpoints from memory, stop all lwps,
+ so that other threads won't hit the breakpoint in the staled
+ memory. */
+ stop_all_lwps (0, event_child);
+
+ if (non_stop)
+ {
+ gdb_assert (has_reinsert_breakpoints (current_thread));
+ delete_reinsert_breakpoints (current_thread);
+ }
+ else
+ {
+ struct inferior_list_entry *inf, *tmp;
+
+ ALL_INFERIORS (&all_threads, inf, tmp)
+ {
+ struct thread_info *thread = (struct thread_info *) inf;
+
+ if (has_reinsert_breakpoints (thread))
+ delete_reinsert_breakpoints (thread);
+ }
+ }
+
+ unstop_all_lwps (0, event_child);
+ }
+ }
+
if (!stabilizing_threads)
{
/* In all-stop, stop all threads. */
@@ -4275,12 +4338,6 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp,
step = maybe_hw_step (thread);
}
- else
- {
- /* If the thread isn't doing step-over, there shouldn't be any
- reinsert breakpoints. */
- gdb_assert (!has_reinsert_breakpoints (thread));
- }
if (fast_tp_collecting == 1)
{
@@ -5088,7 +5145,14 @@ proceed_one_lwp (struct inferior_list_entry *entry, void *except)
if (debug_threads)
debug_printf (" stepping LWP %ld, client wants it stepping\n",
lwpid_of (thread));
- step = 1;
+
+ /* If resume_step is requested by GDB, install reinsert
+ breakpoints when the thread is about to be actually resumed if
+ the reinsert breakpoints weren't removed. */
+ if (can_software_single_step () && !has_reinsert_breakpoints (thread))
+ install_software_single_step_breakpoints (lwp);
+
+ step = maybe_hw_step (thread);
}
else if (lwp->bp_reinsert != 0)
{
next prev parent reply other threads:[~2016-07-05 8:15 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-30 14:09 [PATCH 0/9 V3] Use reinsert breakpoint " Yao Qi
2016-06-30 14:09 ` [PATCH 4/9] Make reinsert_breakpoint thread specific Yao Qi
2016-06-30 14:09 ` [PATCH 8/9] Use reinsert_breakpoint for vCont;s Yao Qi
2016-07-01 15:07 ` Pedro Alves
2016-07-05 8:15 ` Yao Qi [this message]
2016-07-21 8:38 ` Yao Qi
2016-07-21 10:02 ` Pedro Alves
2016-06-30 14:09 ` [PATCH 2/9] Create sub classes of 'struct breakpoint' Yao Qi
2016-06-30 14:09 ` [PATCH 6/9] Use enqueue_pending_signal in linux_resume_one_thread Yao Qi
2016-06-30 14:09 ` [PATCH 5/9] Switch current_thread to lwp's thread in install_software_single_step_breakpoints Yao Qi
2016-06-30 14:09 ` [PATCH 9/9] Support vCont s and S actions with software single step Yao Qi
2016-06-30 14:09 ` [PATCH 3/9] Refactor clone_all_breakpoints Yao Qi
2016-06-30 14:09 ` [PATCH 1/9] Pass breakpoint type in set_breakpoint_at Yao Qi
2016-06-30 14:09 ` [PATCH 7/9] Enqueue signal even when resuming threads Yao Qi
2016-07-01 15:06 ` Pedro Alves
2016-07-01 16:45 ` Yao Qi
2016-07-01 16:55 ` Pedro Alves
2016-07-01 17:01 ` Pedro Alves
2016-07-21 11:18 ` [PATCH 0/9 V3] Use reinsert breakpoint for vCont;s Yao Qi
2016-11-14 19:14 ` Antoine Tremblay
2016-11-21 12:08 ` Yao Qi
[not found] ` <wwok37ikrgmq.fsf@ericsson.com>
2016-11-23 19:03 ` Antoine Tremblay
2016-11-24 21:55 ` Yao Qi
2016-11-25 12:22 ` Antoine Tremblay
2016-11-25 13:13 ` Antoine Tremblay
2016-11-25 13:35 ` Antoine Tremblay
2016-11-25 13:44 ` Pedro Alves
2016-11-25 13:57 ` Antoine Tremblay
2016-11-25 14:28 ` 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=861t38zekw.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@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