Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] infcmd.c: Don't attempt to record a NULL value after a finish command
Date: Wed, 30 Sep 2015 04:43:00 -0000	[thread overview]
Message-ID: <20150929214350.44b076c7@pinnacle.lan> (raw)

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<n> 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;
 


             reply	other threads:[~2015-09-30  4:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30  4:43 Kevin Buettner [this message]
2015-09-30 10:27 ` Pedro Alves
2015-09-30 12:17   ` Kevin Buettner
2015-09-30 12:21     ` Pedro Alves
2015-09-30 13:02       ` Kevin Buettner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150929214350.44b076c7@pinnacle.lan \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox