[RFC 1/3] make reinsert breakpoint thread specific

Yao Qi
2016-05-06T10:32:45Z

gdb/gdbserver:

2016-05-06 Yao Qi <yao.qi@linaro.org>

* mem-break.c (struct breakpoint) <thread>: New field.
(set_reinsert_breakpoint): New parameter thread. Callers
updated.
(delete_reinsert_breakpoints): Likewise.
* mem-break.h (set_reinsert_breakpoint): Update declaration.
(delete_reinsert_breakpoints): Likewise.
---
gdb/gdbserver/linux-low.c | 4 ++--
gdb/gdbserver/mem-break.c | 11 ++++++++---
gdb/gdbserver/mem-break.h | 8 ++++----
3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 8e1e2fc..e539e34 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4080,7 +4080,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_thread);

do_cleanups (old_chain);
}
@@ -4705,7 +4705,7 @@ finish_step_over (struct lwp_info *lwp)
because we were stepping over a breakpoint, and we hold all
threads but LWP stopped while doing that. */
if (!can_hardware_single_step ())
- delete_reinsert_breakpoints ();
+ delete_reinsert_breakpoints (get_lwp_thread (lwp));

step_over_bkpt = null_ptid;
return 1;
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index 363d7ca..197d7a1 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -190,6 +190,10 @@ struct breakpoint
the breakpoint shall be deleted; 0 or if this callback is NULL,
it will be left inserted. */
int (*handler) (CORE_ADDR);
+
+ /* The owner of this breakpoint if it is not NULL. It is only used
+ by reinsert breakpoint so far. */
+ struct thread_info *thread;
};

/* Return the breakpoint size from its kind. */
@@ -1407,16 +1411,17 @@ gdb_breakpoint_here (CORE_ADDR where)
}

void
-set_reinsert_breakpoint (CORE_ADDR stop_at)
+set_reinsert_breakpoint (CORE_ADDR stop_at, struct thread_info *thread)
{
struct breakpoint *bp;

bp = set_breakpoint_at (stop_at, NULL);
bp->type = reinsert_breakpoint;
+ bp->thread = thread;
}

void
-delete_reinsert_breakpoints (void)
+delete_reinsert_breakpoints (struct thread_info *thread)
{
struct process_info *proc = current_process ();
struct breakpoint *bp, **bp_link;
@@ -1426,7 +1431,7 @@ delete_reinsert_breakpoints (void)

while (bp)
{
- if (bp->type == reinsert_breakpoint)
+ if (bp->type == reinsert_breakpoint && bp->thread == thread)
{
*bp_link = bp->next;
release_breakpoint (proc, bp);
diff --git a/gdb/gdbserver/mem-break.h b/gdb/gdbserver/mem-break.h
index 4d9a76c..2744584 100644
--- a/gdb/gdbserver/mem-break.h
+++ b/gdb/gdbserver/mem-break.h
@@ -150,13 +150,13 @@ 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. */

-void set_reinsert_breakpoint (CORE_ADDR stop_at);
+void set_reinsert_breakpoint (CORE_ADDR stop_at, struct thread_info *thread);

-/* Delete all reinsert breakpoints. */
+/* Delete all reinsert breakpoints of THREAD. */

-void delete_reinsert_breakpoints (void);
+void delete_reinsert_breakpoints (struct thread_info *thread);

/* Reinsert breakpoints at WHERE (and change their status to
inserted). */
--
1.9.1