This is the mail archive of the gdb-patches@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]

[PATCH] Quit after debugging corefiles


Hello,

when quitting after a successful debug using a corefile, gdb returns the following internal error:

...
(gdb) cont
Continuing.

Program exited normally.
(gdb) quit
../../git/gdb/inferior.c:362: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
../../git/gdb/inferior.c:362: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

Please consider the following patch containing a fix and a new test for the gcore.exp testcase. It also proposes a change in the function called by gdb_test_multiple that deals with internal error (proc gdb_internal_error_resync{}, in gdb.exp) in order to recognize that gdb is finished.

Comments/suggestions are welcome.

Thanks,
-- 
Edjunior Barbosa Machado
IBM Linux Technology Center

2010-06-22  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* gdb/corelow.c (core_close): check if 'ptid' is still valid.
	* gdb/testsuite/gdb.base/gcore.exp: check if gdb quits successfully.
	* gdb/testsuite/lib/gbd.exp: add pattern 'eof', in order to allow
	gdb_test_multiple to detect that gdb is finished.

diff --git a/gdb/corelow.c b/gdb/corelow.c
index 9523f32..4ec2416 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -208,9 +208,11 @@ core_close (int quitting)
 
   if (core_bfd)
     {
-      int pid = ptid_get_pid (inferior_ptid);
+      ptid_t ptid = inferior_ptid;
       inferior_ptid = null_ptid;	/* Avoid confusion from thread stuff */
-      exit_inferior_silent (pid);
+
+      if (!ptid_equal (ptid, null_ptid))
+	  exit_inferior_silent (ptid_get_pid (ptid));
 
       /* Clear out solib state while the bfd is still open. See
          comments in clear_solib in solib.c. */
diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index 0da0c75..e0e5243 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -211,3 +211,11 @@ if ![string compare $pre_corefile_backtrace $post_corefile_backtrace]  {
 } else {
     fail "corefile restored backtrace"
 }
+
+# checking if gdb quits successfully
+gdb_test "run" ".*Starting program.*"
+gdb_test_multiple "quit" "quitting gdb" {
+    eof {
+	pass "gdb quit sucessfully"
+    }
+}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 833fbf2..6292610 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -526,6 +526,10 @@ proc gdb_internal_error_resync {} {
 		# We're resynchronized.
 		return 1
 	    }
+	    eof {
+		# gdb is finished.
+		return 1
+	    }
 	    timeout {
 		perror "Could not resync from internal error (timeout)"
 		return 0


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