From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 09/12] Make reinsert_breakpoint thread specific
Date: Thu, 02 Jun 2016 09:31:00 -0000 [thread overview]
Message-ID: <1464859846-15619-10-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1464859846-15619-1-git-send-email-yao.qi@linaro.org>
V2: rewrite commit log to make it easy to read,
"id" -> "ptid",
This patch makes reinsert_breakpoint thread specific, which means we
insert and remove reinsert_breakpoint breakpoints for a specific
thread. This motivation of this change is that I'll use
reinsert_breakpoint for vCont;s on software single step target, so that
GDBserver may insert one reinsert_breakpoint for one thread doing
step-over, and insert one reinsert_breakpoint for another thread doing
vCont;s. After the operation of one thread is finished, GDBserver must
remove reinsert_breakpoint for that thread only.
On the other hand, reinsert_breakpoint is used for step-over nowadays.
GDBserver inserts reinsert_breakpoint, and wait only from the thread
doing step-over. After the step-over is done, GDBserver removes the
reinsert_breakpoint. If there is still any threads need step-over, do
the same again until all threads are finished step-over. In other words,
reinsert_breakpoint is globally thread specific, but in an implicit way.
It is natural to make it explicitly thread specific.
gdb/gdbserver:
2016-05-20 Yao Qi <yao.qi@linaro.org>
* mem-break.c (struct reinsert_breakpoint) <ptid>: New field.
(set_reinsert_breakpoint): New parameter ptid. Callers updated.
(delete_reinsert_breakpoints): Likewise.
(has_reinsert_breakpoints): Change parameter to thread. Callers
updated.
(clone_one_breakpoint): Likewise.
(uninsert_reinsert_breakpoints): Likewise.
(reinsert_reinsert_breakpoints): Likewise.
* mem-break.h (set_reinsert_breakpoint): Update declaration.
(delete_reinsert_breakpoints): Likewise.
(reinsert_reinsert_breakpoints): Likewise.
(uninsert_reinsert_breakpoints): Likewise.
(has_reinsert_breakpoints): Likewise.
---
gdb/gdbserver/linux-low.c | 25 +++++++++++--------------
gdb/gdbserver/mem-break.c | 44 +++++++++++++++++++++++++++++++-------------
gdb/gdbserver/mem-break.h | 23 ++++++++++++-----------
3 files changed, 54 insertions(+), 38 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index b0af178..414117b 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -555,7 +555,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
hit it, so uninsert reinsert breakpoints from parent
(and child). Once vfork child is done, reinsert
them back to parent. */
- uninsert_reinsert_breakpoints ();
+ uninsert_reinsert_breakpoints (ptid_of_lwp (event_lwp));
current_thread = saved_thread;
}
@@ -597,11 +597,11 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
to access its memory without stopping all other threads
from other processes. */
current_thread = child_thr;
- delete_reinsert_breakpoints ();
+ delete_reinsert_breakpoints (ptid);
current_thread = saved_thread;
- gdb_assert (has_reinsert_breakpoints (parent_proc));
- gdb_assert (!has_reinsert_breakpoints (child_proc));
+ gdb_assert (has_reinsert_breakpoints (event_thr));
+ gdb_assert (!has_reinsert_breakpoints (child_thr));
}
/* Report the event. */
@@ -656,13 +656,12 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
if (event_lwp->bp_reinsert != 0 && can_software_single_step ())
{
struct thread_info *saved_thread = current_thread;
- struct process_info *proc = get_thread_process (event_thr);
current_thread = event_thr;
- reinsert_reinsert_breakpoints ();
+ reinsert_reinsert_breakpoints (ptid_of_lwp (event_lwp));
current_thread = saved_thread;
- gdb_assert (has_reinsert_breakpoints (proc));
+ gdb_assert (has_reinsert_breakpoints (event_thr));
}
/* Report the event. */
@@ -2559,11 +2558,9 @@ maybe_hw_step (struct thread_info *thread)
return 1;
else
{
- struct process_info *proc = get_thread_process (thread);
-
/* GDBserver must insert reinsert breakpoint for software
single step. */
- gdb_assert (has_reinsert_breakpoints (proc));
+ gdb_assert (has_reinsert_breakpoints (thread));
return 0;
}
}
@@ -4153,7 +4150,7 @@ install_software_single_step_breakpoints (struct lwp_info *lwp)
next_pcs = (*the_low_target.get_next_pcs) (regcache);
for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); ++i)
- set_reinsert_breakpoint (pc);
+ set_reinsert_breakpoint (pc, current_ptid);
do_cleanups (old_chain);
}
@@ -4296,7 +4293,7 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp,
{
/* If the thread isn't doing step-over, there shouldn't be any
reinsert breakpoints. */
- gdb_assert (!has_reinsert_breakpoints (proc));
+ gdb_assert (!has_reinsert_breakpoints (thread));
}
if (fast_tp_collecting == 1)
@@ -4789,8 +4786,8 @@ finish_step_over (struct lwp_info *lwp)
threads but LWP stopped while doing that. */
if (!can_hardware_single_step ())
{
- gdb_assert (has_reinsert_breakpoints (current_process ()));
- delete_reinsert_breakpoints ();
+ gdb_assert (has_reinsert_breakpoints (current_thread));
+ delete_reinsert_breakpoints (ptid_of_lwp (lwp));
}
step_over_bkpt = null_ptid;
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index 6a38e6a..e85309d 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -211,6 +211,9 @@ struct other_breakpoint
struct reinsert_breakpoint
{
struct breakpoint base;
+
+ /* Thread the reinsert breakpoint belongs to. */
+ ptid_t ptid;
};
/* Return the breakpoint size from its kind. */
@@ -1476,25 +1479,32 @@ gdb_breakpoint_here (CORE_ADDR where)
}
void
-set_reinsert_breakpoint (CORE_ADDR stop_at)
+set_reinsert_breakpoint (CORE_ADDR stop_at, ptid_t ptid)
{
- struct breakpoint *bp;
+ struct reinsert_breakpoint *bp;
+
+ gdb_assert (ptid_get_pid (current_ptid) == ptid_get_pid (ptid));
- bp = set_breakpoint_type_at (reinsert_breakpoint, stop_at, NULL);
+ bp = (struct reinsert_breakpoint *) set_breakpoint_type_at (reinsert_breakpoint,
+ stop_at, NULL);
+ bp->ptid = ptid;
}
void
-delete_reinsert_breakpoints (void)
+delete_reinsert_breakpoints (ptid_t ptid)
{
struct process_info *proc = current_process ();
struct breakpoint *bp, **bp_link;
+ gdb_assert (ptid_get_pid (current_ptid) == ptid_get_pid (ptid));
+
bp = proc->breakpoints;
bp_link = &proc->breakpoints;
while (bp)
{
- if (bp->type == reinsert_breakpoint)
+ if (bp->type == reinsert_breakpoint
+ && ptid_equal (((struct reinsert_breakpoint *) bp)->ptid, ptid))
{
*bp_link = bp->next;
release_breakpoint (proc, bp);
@@ -1578,14 +1588,15 @@ uninsert_all_breakpoints (void)
}
void
-uninsert_reinsert_breakpoints (void)
+uninsert_reinsert_breakpoints (ptid_t ptid)
{
struct process_info *proc = current_process ();
struct breakpoint *bp;
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
- if (bp->type == reinsert_breakpoint)
+ if (bp->type == reinsert_breakpoint
+ && ptid_equal (((struct reinsert_breakpoint *) bp)->ptid, ptid))
{
gdb_assert (bp->raw->inserted > 0);
@@ -1642,8 +1653,9 @@ reinsert_breakpoints_at (CORE_ADDR pc)
}
int
-has_reinsert_breakpoints (struct process_info *proc)
+has_reinsert_breakpoints (struct thread_info *thread)
{
+ struct process_info *proc = get_thread_process (thread);
struct breakpoint *bp, **bp_link;
bp = proc->breakpoints;
@@ -1651,7 +1663,9 @@ has_reinsert_breakpoints (struct process_info *proc)
while (bp)
{
- if (bp->type == reinsert_breakpoint)
+ if (bp->type == reinsert_breakpoint
+ && ptid_equal (((struct reinsert_breakpoint *) bp)->ptid,
+ ptid_of (thread)))
return 1;
else
{
@@ -1677,14 +1691,15 @@ reinsert_all_breakpoints (void)
}
void
-reinsert_reinsert_breakpoints (void)
+reinsert_reinsert_breakpoints (ptid_t ptid)
{
struct process_info *proc = current_process ();
struct breakpoint *bp;
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
- if (bp->type == reinsert_breakpoint)
+ if (bp->type == reinsert_breakpoint
+ && ptid_equal (((struct reinsert_breakpoint *) bp)->ptid, ptid))
{
gdb_assert (bp->raw->inserted > 0);
@@ -2113,7 +2128,7 @@ clone_agent_expr (const struct agent_expr *src_ax)
/* Deep-copy the contents of one breakpoint to another. */
static struct breakpoint *
-clone_one_breakpoint (const struct breakpoint *src)
+clone_one_breakpoint (const struct breakpoint *src, ptid_t ptid)
{
struct breakpoint *dest;
struct raw_breakpoint *dest_raw;
@@ -2174,6 +2189,9 @@ clone_one_breakpoint (const struct breakpoint *src)
= XCNEW (struct reinsert_breakpoint);
dest = (struct breakpoint *) reinsert_dest;
+ /* Since reinsert breakpoint is thread specific, don't copy
+ thread id from SRC, use ID instead. */
+ reinsert_dest->ptid = ptid;
}
else
gdb_assert_not_reached ("unhandled breakpoint type");
@@ -2201,7 +2219,7 @@ clone_all_breakpoints (struct thread_info *child_thread,
for (bp = parent_proc->breakpoints; bp != NULL; bp = bp->next)
{
- new_bkpt = clone_one_breakpoint (bp);
+ new_bkpt = clone_one_breakpoint (bp, ptid_of (child_thread));
APPEND_TO_LIST (new_list, new_bkpt, bkpt_tail);
APPEND_TO_LIST (new_raw_list, new_bkpt->raw, raw_bkpt_tail);
}
diff --git a/gdb/gdbserver/mem-break.h b/gdb/gdbserver/mem-break.h
index d4af890..aff0c32 100644
--- a/gdb/gdbserver/mem-break.h
+++ b/gdb/gdbserver/mem-break.h
@@ -152,31 +152,32 @@ struct breakpoint *set_breakpoint_at (CORE_ADDR where,
int delete_breakpoint (struct breakpoint *bkpt);
-/* Set a reinsert breakpoint at STOP_AT. */
+/* Set a reinsert breakpoint at STOP_AT for thread represented by
+ PTID. */
-void set_reinsert_breakpoint (CORE_ADDR stop_at);
+void set_reinsert_breakpoint (CORE_ADDR stop_at, ptid_t ptid);
-/* Delete all reinsert breakpoints. */
+/* Delete all reinsert breakpoints of thread represented by PTID. */
-void delete_reinsert_breakpoints (void);
+void delete_reinsert_breakpoints (ptid_t ptid);
-/* Reinsert all reinsert breakpoints of the current process. */
+/* Reinsert all reinsert breakpoints of thread represented by PTID. */
-void reinsert_reinsert_breakpoints (void);
+void reinsert_reinsert_breakpoints (ptid_t ptid);
-/* Uninsert all reinsert breakpoints of the current process. This
- still leaves the reinsert breakpoints in the table. */
+/* Uninsert all reinsert breakpoints of thread represented by PTID.
+ This still leaves the reinsert breakpoints in the table. */
-void uninsert_reinsert_breakpoints (void);
+void uninsert_reinsert_breakpoints (ptid_t ptid);
/* Reinsert breakpoints at WHERE (and change their status to
inserted). */
void reinsert_breakpoints_at (CORE_ADDR where);
-/* Process PROC has reinsert breakpoints or not. */
+/* The THREAD has reinsert breakpoints or not. */
-int has_reinsert_breakpoints (struct process_info *proc);
+int has_reinsert_breakpoints (struct thread_info *thread);
/* Uninsert breakpoints at WHERE (and change their status to
uninserted). This still leaves the breakpoints in the table. */
--
1.9.1
next prev parent reply other threads:[~2016-06-02 9:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 9:31 [PATCH 00/12 V2] Use reinsert breakpoint for vCont;s Yao Qi
2016-06-02 9:31 ` [PATCH 01/12] Switch to current thread in finish_step_over Yao Qi
2016-06-13 14:25 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 07/12] Create sub classes of 'struct breakpoint' Yao Qi
2016-06-13 15:09 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 08/12] Refactor clone_all_breakpoints Yao Qi
2016-06-13 15:14 ` Pedro Alves
2016-06-02 9:31 ` Yao Qi [this message]
[not found] ` <71a5322e-41e3-9e23-df73-e14b14c1d656@redhat.com>
2016-06-14 12:52 ` [PATCH 09/12] Make reinsert_breakpoint thread specific Yao Qi
2016-06-14 12:57 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 03/12] Step over exit with reinsert breakpoints Yao Qi
2016-06-13 14:37 ` Pedro Alves
2016-06-13 14:52 ` Yao Qi
2016-06-13 15:01 ` Pedro Alves
2016-06-17 9:50 ` Yao Qi
2016-06-02 9:31 ` [PATCH 06/12] Pass breakpoint type in set_breakpoint_at Yao Qi
2016-06-13 15:07 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 05/12] Handle reinsert breakpoints for vforked child Yao Qi
2016-06-13 15:07 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 10/12] Switch current_thread to lwp's thread in install_software_single_step_breakpoints Yao Qi
2016-06-13 15:26 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 04/12] Delete reinsert breakpoints from forked child Yao Qi
2016-06-13 15:02 ` Pedro Alves
2016-06-13 16:53 ` Yao Qi
2016-06-13 17:29 ` Pedro Alves
2016-06-14 11:17 ` Yao Qi
2016-06-14 11:40 ` Pedro Alves
2016-06-17 9:53 ` Yao Qi
2016-06-02 9:31 ` [PATCH 02/12] More assert checks on reinsert breakpoint Yao Qi
2016-06-13 14:25 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 12/12] Support vCont s and S actions with software single step Yao Qi
2016-06-13 15:56 ` Pedro Alves
2016-06-02 9:31 ` [PATCH 11/12] Use reinsert_breakpoint for vCont;s Yao Qi
2016-06-13 15:55 ` Pedro Alves
2016-06-14 13:14 ` Yao Qi
2016-06-14 15:48 ` Pedro Alves
2016-06-15 16:41 ` Yao Qi
2016-06-17 15:10 ` Pedro Alves
2016-06-20 18:09 ` 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=1464859846-15619-10-git-send-email-yao.qi@linaro.org \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
/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