From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6585 invoked by alias); 20 May 2009 20:28:02 -0000 Received: (qmail 6574 invoked by uid 22791); 20 May 2009 20:28:01 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_32,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 May 2009 20:27:55 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4KKRske005759 for ; Wed, 20 May 2009 16:27:54 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4KKRrAM020875 for ; Wed, 20 May 2009 16:27:53 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4KKRp9Y015664 for ; Wed, 20 May 2009 16:27:52 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n4KKRoIc018178 for ; Wed, 20 May 2009 22:27:51 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id n4KKRoHF018168 for gdb-patches@sourceware.org; Wed, 20 May 2009 22:27:50 +0200 Date: Wed, 20 May 2009 20:28:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Fix gdb.mi internal_error on killing inferior Message-ID: <20090520202749.GA17984@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) 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: 2009-05/txt/msg00432.txt.bz2 Hi, currently GDB crashes on killing multithreaded inferior. Just it will happen only on quitting GDB because dejagnu already closed the communication with GDB. With the included testcase without the fix it will print: (gdb) ^M PASS: gdb.mi/mi-console.exp: finished step over hello 998-target-attach^M ~"A program is being debugged already. Kill it? (y or n) "y^M ^M &"Recursive internal problem.\n"^M ERROR: Error testminating GDB. testcase ../.././gdb/testsuite/gdb.mi/mi-console.exp completed in 1 seconds Thanks, Jan gdb/ 2009-05-20 Jan Kratochvil * inflow.c (terminal_ours_1): Return if INFERIOR_PTID is NULL_PTID. Gdb/testsuite/ 2009-05-20 Jan Kratochvil * lib/mi-support.exp (mi_uncatched_gdb_exit): Explicitly terminate the inferior. --- gdb/inflow.c 19 May 2009 10:08:19 -0000 1.50 +++ gdb/inflow.c 20 May 2009 20:00:30 -0000 @@ -361,6 +361,9 @@ terminal_ours_1 (int output_only) if (terminal_is_ours) return; + if (ptid_equal (inferior_ptid, null_ptid)) + return; + /* Checking inferior->run_terminal is necessary so that if GDB is running in the background, it won't block trying to do the ioctl()'s below. Checking gdb_has_a_terminal --- gdb/testsuite/lib/mi-support.exp 2 Apr 2009 15:43:10 -0000 1.83 +++ gdb/testsuite/lib/mi-support.exp 20 May 2009 20:00:31 -0000 @@ -61,6 +61,28 @@ proc mi_uncatched_gdb_exit {} { verbose "Quitting $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS" + # Test successful termination of the inferior. It is an optional check, + # inferior would get also terminated by -gdb-exit or remote_close below. + + if { [board_info host exists fileid] } { + send_gdb "998-target-attach\n"; + gdb_expect 10 { + -re "y or n" { + send_gdb "y\n"; + exp_continue; + } + -re "Undefined command.*$gdb_prompt $" { + send_gdb "quit\n" + exp_continue; + } + -re "998\\^error,msg=\"Argument required \\(process-id to attach\\).\".*$gdb_prompt \r\n$" { + } + default { + perror "Error terminating the inferior." + } + } + } + if { [is_remote host] && [board_info host exists fileid] } { send_gdb "999-gdb-exit\n"; gdb_expect 10 {