This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] infcmd.c: Don't attempt to record a NULL value after a finish command.
- From: Kevin Buettner <kevinb at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 30 Sep 2015 12:58:04 -0000
- Subject: [binutils-gdb] infcmd.c: Don't attempt to record a NULL value after a finish command.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aca20ec47359776488863193660cf9fd2fe3cfe7
commit aca20ec47359776488863193660cf9fd2fe3cfe7
Author: Kevin Buettner <kevinb@redhat.com>
Date: Wed Sep 30 05:54:15 2015 -0700
infcmd.c: Don't attempt to record a NULL value after a finish command.
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.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/infcmd.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 667bf27..b6355e7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2015-09-29 Kevin Buettner <kevinb@redhat.com>
+ * infcmd.c (finish_command_fsm_should_stop): Don't attempt to
+ record a NULL value.
+
+2015-09-29 Kevin Buettner <kevinb@redhat.com>
+
* msp430-tdep.c (msp430_push_dummy_call): Treat reference, struct,
and union arguments the same as pointer arguments when determining
size of argument.
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index c4d7d8b..54aa1ef 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1794,7 +1794,8 @@ finish_command_fsm_should_stop (struct thread_fsm *self)
func = read_var_value (f->function, NULL, get_current_frame ());
rv->value = get_return_value (func, rv->type);
- rv->value_history_index = record_latest_value (rv->value);
+ if (rv->value != NULL)
+ rv->value_history_index = record_latest_value (rv->value);
}
}
else if (tp->control.stop_step)