From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11103 invoked by alias); 22 Jun 2010 13:18:43 -0000 Received: (qmail 11093 invoked by uid 22791); 22 Jun 2010 13:18:42 -0000 X-SWARE-Spam-Status: No, hits=0.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from e24smtp03.br.ibm.com (HELO e24smtp03.br.ibm.com) (32.104.18.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Jun 2010 13:18:35 +0000 Received: from mailhub3.br.ibm.com (mailhub3.br.ibm.com [9.18.232.110]) by e24smtp03.br.ibm.com (8.14.4/8.13.1) with ESMTP id o5MD7OV3001322 for ; Tue, 22 Jun 2010 10:07:24 -0300 Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.8.31.93]) by mailhub3.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5MDNAmT1863832 for ; Tue, 22 Jun 2010 10:23:10 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o5MAIWhX012504 for ; Tue, 22 Jun 2010 07:18:32 -0300 Received: from evol ([9.78.139.164]) by d24av02.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o5MAIW5X012501 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 22 Jun 2010 07:18:32 -0300 Received: from emachado by evol with local (Exim 4.71) (envelope-from ) id 1OR3N0-0002tv-81 for gdb-patches@sourceware.org; Tue, 22 Jun 2010 10:18:30 -0300 From: Edjunior Barbosa Machado To: gdb-patches@sourceware.org Subject: [PATCH] Quit after debugging corefiles Date: Tue, 22 Jun 2010 13:18:00 -0000 Message-Id: <1277212708-11125-1-git-send-email-emachado@linux.vnet.ibm.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00478.txt.bz2 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 * 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