forked from Imagelibrary/binutils-gdb
detach in all-stop with threads running
A following patch will add a testcase that has a number of threads constantly stepping over a breakpoint, and then has GDB detach the process, while threads are running. If we have more than one inferior running, and we detach from just one of the inferiors, we expect that the remaining inferior continues running. However, in all-stop, if GDB needs to pause the target for the detach, nothing is re-resuming the other inferiors after the detach. "info threads" shows the threads as running, but they really aren't. This fixes it. gdb/ChangeLog: * infcmd.c (detach_command): Hold strong reference to target, and if all-stop on entry, restart threads on exit. * infrun.c (switch_back_to_stepped_thread): Factor out bits to ... (restart_stepped_thread): ... this new function. Also handle trap_expected. (restart_after_all_stop_detach): New function. * infrun.h (restart_after_all_stop_detach): Declare.
This commit is contained in:
13
gdb/infcmd.c
13
gdb/infcmd.c
@@ -2750,6 +2750,16 @@ detach_command (const char *args, int from_tty)
|
||||
|
||||
disconnect_tracing ();
|
||||
|
||||
/* Hold a strong reference to the target while (maybe)
|
||||
detaching the parent. Otherwise detaching could close the
|
||||
target. */
|
||||
auto target_ref
|
||||
= target_ops_ref::new_reference (current_inferior ()->process_target ());
|
||||
|
||||
/* Save this before detaching, since detaching may unpush the
|
||||
process_stratum target. */
|
||||
bool was_non_stop_p = target_is_non_stop_p ();
|
||||
|
||||
target_detach (current_inferior (), from_tty);
|
||||
|
||||
/* The current inferior process was just detached successfully. Get
|
||||
@@ -2766,6 +2776,9 @@ detach_command (const char *args, int from_tty)
|
||||
|
||||
if (deprecated_detach_hook)
|
||||
deprecated_detach_hook ();
|
||||
|
||||
if (!was_non_stop_p)
|
||||
restart_after_all_stop_detach (as_process_stratum_target (target_ref.get ()));
|
||||
}
|
||||
|
||||
/* Disconnect from the current target without resuming it (leaving it
|
||||
|
||||
Reference in New Issue
Block a user