From patchwork Wed Sep 30 04:43:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 8884 Received: (qmail 129350 invoked by alias); 30 Sep 2015 04:43:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 129159 invoked by uid 89); 30 Sep 2015 04:43:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 30 Sep 2015 04:43:53 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id BD08A8E715 for ; Wed, 30 Sep 2015 04:43:52 +0000 (UTC) Received: from pinnacle.lan ([10.3.113.5]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8U4hpJF022389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO) for ; Wed, 30 Sep 2015 00:43:52 -0400 Date: Tue, 29 Sep 2015 21:43:50 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH] infcmd.c: Don't attempt to record a NULL value after a finish command Message-ID: <20150929214350.44b076c7@pinnacle.lan> MIME-Version: 1.0 X-IsSubscribed: yes Architectures which use RETURN_VALUE_STRUCT_CONVENTION will have a NULL return value after executing a finish command. See get_return_value() in infcmd.c. This patch avoids an eventual SIGSEV (caused by attempting to derefrence a NULL pointer) by adding a suitable test to finish_command_fsm_should_stop(). I encountered this problem while testing msp430: (gdb) PASS: gdb.base/structs.exp: zed L for finish; return 1 structs-tc finish Run till exit from #0 fun1 () at /ironwood1/sourceware-git/msp430-elf/../binutils-gdb/gdb/testsuite/gdb.base/structs.c:125 ERROR: Process no longer exists gdb/ChangeLog: * infcmd.c (finish_command_fsm_should_stop): Don't attempt to record a NULL value. --- gdb/infcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index c4d7d8b..6be95e4 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1788,7 +1788,7 @@ finish_command_fsm_should_stop (struct thread_fsm *self) internal_error (__FILE__, __LINE__, _("finish_command: function has no target type")); - if (TYPE_CODE (rv->type) != TYPE_CODE_VOID) + if (rv->value != NULL && TYPE_CODE (rv->type) != TYPE_CODE_VOID) { struct value *func;