From 8601f500c85902a5ea5134cd9de8adf8bcd27c6b Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Sat, 2 Jun 2001 00:36:20 +0000 Subject: [PATCH] 2001-06-01 Michael Snyder * thread.c (delete_step_resume_breakpoint): New function. Maintain internal consistency of the thread list while deleting a step_resume_breakpoint. * gdbthread.h (delete_step_resume_breakpoint): Export. * breakpoint.c (bpstat_find_step_resume_breakpoint): Make thread-aware: don't return a step_resume_breakpoint for the wrong thread. * infrun.c (wait_for_inferior): Call delete_step_resume_breakpoint instead of delete_breakpoint_current_contents. (fetch_inferior_event): Ditto. (handle_inferior_event): Call delete_step_resume_breakpoint instead of delete_breakpoint. --- gdb/ChangeLog | 12 ++++++++++++ gdb/breakpoint.c | 8 +++++++- gdb/gdbthread.h | 3 +++ gdb/infrun.c | 10 ++++------ gdb/thread.c | 17 +++++++++++++++++ 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c213315d4a2..a737322f75f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2001-06-01 Michael Snyder + * thread.c (delete_step_resume_breakpoint): New function. + Maintain internal consistency of the thread list while deleting + a step_resume_breakpoint. + * gdbthread.h (delete_step_resume_breakpoint): Export. + * breakpoint.c (bpstat_find_step_resume_breakpoint): + Make thread-aware: don't return a step_resume_breakpoint + for the wrong thread. + * infrun.c (wait_for_inferior): Call delete_step_resume_breakpoint + instead of delete_breakpoint_current_contents. + (fetch_inferior_event): Ditto. + (handle_inferior_event): Call delete_step_resume_breakpoint + instead of delete_breakpoint. * infrun.c (handle_inferior_event): After singlestepping over a thread-specific breakpoint, use currently_stepping() to decide whether to step or continue. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 4fffa53260d..cb51a5559f5 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1719,13 +1719,19 @@ bpstat_find_breakpoint (bpstat bsp, struct breakpoint *breakpoint) struct breakpoint * bpstat_find_step_resume_breakpoint (bpstat bsp) { + int current_thread; + if (bsp == NULL) error ("Internal error (bpstat_find_step_resume_breakpoint)"); + current_thread = pid_to_thread_id (inferior_ptid); + for (; bsp != NULL; bsp = bsp->next) { if ((bsp->breakpoint_at != NULL) && - (bsp->breakpoint_at->type == bp_step_resume)) + (bsp->breakpoint_at->type == bp_step_resume) && + (bsp->breakpoint_at->thread == current_thread || + bsp->breakpoint_at->thread == -1)) return bsp->breakpoint_at; } diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 7483a53eb4b..0c6fb84b8cd 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -78,6 +78,9 @@ extern struct thread_info *add_thread (ptid_t ptid); /* Delete an existing thread list entry. */ extern void delete_thread (ptid_t); +/* Delete a step_resume_breakpoint from the thread database. */ +extern void delete_step_resume_breakpoint (void *); + /* Translate the integer thread id (GDB's homegrown id, not the system's) into a "pid" (which may be overloaded with extra thread information). */ extern ptid_t thread_id_to_pid (int); diff --git a/gdb/infrun.c b/gdb/infrun.c index aa93cf56a02..09cf494142d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1277,7 +1277,7 @@ wait_for_inferior (void) struct execution_control_state ecss; struct execution_control_state *ecs; - old_cleanups = make_cleanup (delete_breakpoint_current_contents, + old_cleanups = make_cleanup (delete_step_resume_breakpoint, &step_resume_breakpoint); make_cleanup (delete_breakpoint_current_contents, &through_sigtramp_breakpoint); @@ -1341,7 +1341,7 @@ fetch_inferior_event (void *client_data) if (!async_ecs->wait_some_more) { - old_cleanups = make_exec_cleanup (delete_breakpoint_current_contents, + old_cleanups = make_exec_cleanup (delete_step_resume_breakpoint, &step_resume_breakpoint); make_exec_cleanup (delete_breakpoint_current_contents, &through_sigtramp_breakpoint); @@ -2362,8 +2362,7 @@ handle_inferior_event (struct execution_control_state *ecs) interferes with us */ if (step_resume_breakpoint != NULL) { - delete_breakpoint (step_resume_breakpoint); - step_resume_breakpoint = NULL; + delete_step_resume_breakpoint (&step_resume_breakpoint); } /* Not sure whether we need to blow this away too, but probably it is like the step-resume breakpoint. */ @@ -2461,8 +2460,7 @@ handle_inferior_event (struct execution_control_state *ecs) step_resume_breakpoint = bpstat_find_step_resume_breakpoint (stop_bpstat); } - delete_breakpoint (step_resume_breakpoint); - step_resume_breakpoint = NULL; + delete_step_resume_breakpoint (&step_resume_breakpoint); break; case BPSTAT_WHAT_THROUGH_SIGTRAMP: diff --git a/gdb/thread.c b/gdb/thread.c index 70dcb3705b3..7a942769134 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -65,6 +65,23 @@ static void restore_current_thread (ptid_t); static void switch_to_thread (ptid_t ptid); static void prune_threads (void); +void +delete_step_resume_breakpoint (void *arg) +{ + struct breakpoint **breakpointp = (struct breakpoint **) arg; + struct thread_info *tp; + + if (*breakpointp != NULL) + { + delete_breakpoint (*breakpointp); + for (tp = thread_list; tp; tp = tp->next) + if (tp->step_resume_breakpoint == *breakpointp) + tp->step_resume_breakpoint = NULL; + + *breakpointp = NULL; + } +} + static void free_thread (struct thread_info *tp) { -- 2.30.2