gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Thu, 30 Sep 2010 10:24:40 +0000 (10:24 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Thu, 30 Sep 2010 10:24:40 +0000 (10:24 +0000)
PR corefiles/12071.
* inferior.c (have_live_inferiors): New variables old_chain, inf and
tp.  Iterate INFERIOR_LIST and call target_has_execution.

gdb/testsuite/
PR corefiles/12071.
* gdb.base/corefile.exp (quit with a process, no question: load core)
(quit with a core file): New tests.

gdb/ChangeLog
gdb/inferior.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/corefile.exp

index fc02717a88e817ff30b552c08b112cd3a9ab28ed..f7cd9cf2d316a2f09fd9a2f1a0ee454673a5571f 100644 (file)
@@ -1,3 +1,9 @@
+2010-09-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       PR corefiles/12071.
+       * inferior.c (have_live_inferiors): New variables old_chain, inf and
+       tp.  Iterate INFERIOR_LIST and call target_has_execution.
+
 2010-09-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Fix GDB crash on inferior calls with self-referencing classes.
index 28c586792b8bc63219242809ee602c4b192a7487..0f94f189f309848b266da7cc459a9133bd17e421 100644 (file)
@@ -461,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
index a8a27fb5c4497155e9a787783c045c0196966e66..ba20ffeb18baf9ab8a62d3bd9e7f8f6c508f60e4 100644 (file)
@@ -1,3 +1,9 @@
+2010-09-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       PR corefiles/12071.
+       * gdb.base/corefile.exp (quit with a process, no question: load core)
+       (quit with a core file): New tests.
+
 2010-09-29  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Fix GDB crash on inferior calls with self-referencing classes.
index 09204e85a39998ecae62ef5a27928a9ef4b239c9..eb1c957939d52a5b8120903e3a1a1a3971274079 100644 (file)
@@ -201,8 +201,33 @@ gdb_test_multiple "info files" $test {
     }
 }
 
+set test "quit with a process"
+gdb_test_multiple "quit" $test {
+    -re "A debugging session is active.\r\n.*\r\nQuit anyway\\? \\(y or n\\) $" {
+       pass $test
+       gdb_test "n" {Not confirmed\.} "quit with processes: n"
+    }
+}
+
 gdb_exit
 
+# Verify there is no question if only a core file is loaded.
+
+gdb_start
+gdb_test "core-file $corefile" "Core was generated by .*" "no question: load core"
+
+set test "quit with a core file"
+gdb_test_multiple "quit" $test {
+    -re "A debugging session is active.\r\n.*\r\nQuit anyway\\? \\(y or n\\) $" {
+       fail $test
+       gdb_test "n" {Not confirmed\.} "quit with processes: n"
+    }
+    eof {
+       pass $test
+    }
+}
+
+gdb_exit
 
 # Test an attach command will clear any loaded core file.
 
This page took 0.045541 seconds and 4 git commands to generate.