This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug threads/19471] unexpected stop in multi-inferior debugging


https://sourceware.org/bugzilla/show_bug.cgi?id=19471

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
I tripped over this again -- in fact I re-reported it, but the bug
was lost in the sourceware disk corruption.
This patch seems to fix the problem but I tend to doubt it is correct.
I haven't tested some scenarios, like one process exiting while stepping
in another; in fact I only tried this test program:

#include <unistd.h>
int main () {
  if (fork () == 0) {
    sleep(10);
  }
  return 0;
}



Here's the patch so far:

diff --git a/gdb/infrun.c b/gdb/infrun.c
index c51bec6..1416a48 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5127,13 +5127,32 @@ Cannot fill $_exitsignal with the correct signal
number.\n"));

       gdb_flush (gdb_stdout);
       target_mourn_inferior (inferior_ptid);
-      stop_print_frame = 0;
       /* In multi-inferior, there might still be other processes
         running.  Only stop waiting if everything has exited.  */
       if (have_live_inferiors ())
-       prepare_to_wait (ecs);
+       {
+         if (!(non_stop && target_is_non_stop_p ()))
+           {
+             struct inferior *inf;
+
+             ALL_NON_EXITED_INFERIORS (inf)
+               {
+                 thread_info *tp = any_live_thread_of_process (inf->pid);
+                 inferior_ptid = tp->ptid;
+                 set_current_inferior (inf);
+                 target_terminal_inferior ();
+                 target_resume (RESUME_ALL, 0, GDB_SIGNAL_0);
+                 target_commit_resume ();
+                 break;
+               }
+           }
+         prepare_to_wait (ecs);
+       }
       else
-       stop_waiting (ecs);
+       {
+         stop_print_frame = 0;
+         stop_waiting (ecs);
+       }
       return;

       /* The following are the only cases in which we keep going;

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]