X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Finferior.c;h=0f94f189f309848b266da7cc459a9133bd17e421;hb=cd2effb255e6018687256a2d10072a1e4da0c6c5;hp=a48972140b25bb072833cc1cfe353f202223737a;hpb=c6913b7d1e1863c208fb6495b227ef5ea119243e;p=binutils-gdb.git diff --git a/gdb/inferior.c b/gdb/inferior.c index a48972140b2..0f94f189f30 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -68,6 +68,7 @@ static void restore_inferior (void *arg) { struct inferior *saved_inferior = arg; + set_current_inferior (saved_inferior); } @@ -80,6 +81,7 @@ save_current_inferior (void) { struct cleanup *old_chain = make_cleanup (restore_inferior, current_inferior_); + return old_chain; } @@ -283,6 +285,7 @@ void exit_inferior (int pid) { struct inferior *inf = find_inferior_pid (pid); + exit_inferior_1 (inf, 0); if (print_inferior_events) @@ -293,6 +296,7 @@ void exit_inferior_silent (int pid) { struct inferior *inf = find_inferior_pid (pid); + exit_inferior_1 (inf, 1); } @@ -308,6 +312,7 @@ void detach_inferior (int pid) { struct inferior *inf = find_inferior_pid (pid); + exit_inferior_1 (inf, 1); if (print_inferior_events) @@ -456,16 +461,29 @@ have_inferiors (void) int have_live_inferiors (void) { - struct target_ops *t; + struct cleanup *old_chain; + struct inferior *inf; - /* The check on stratum suffices, as GDB doesn't currently support - multiple target interfaces. */ - if (have_inferiors ()) - for (t = current_target.beneath; t != NULL; t = t->beneath) - if (t->to_stratum == process_stratum) - return 1; + old_chain = make_cleanup_restore_current_thread (); - return 0; + for (inf = inferior_list; inf; inf = inf->next) + if (inf->pid != 0) + { + struct thread_info *tp; + + tp = any_thread_of_process (inf->pid); + if (tp) + { + switch_to_thread (tp->ptid); + + if (target_has_execution) + break; + } + } + + do_cleanups (old_chain); + + return inf != NULL; } /* Prune away automatically added program spaces that aren't required