infcmd.c: Don't attempt to record a NULL value after a finish command.
authorKevin Buettner <kevinb@redhat.com>
Wed, 30 Sep 2015 12:54:15 +0000 (05:54 -0700)
committerKevin Buettner <kevinb@redhat.com>
Wed, 30 Sep 2015 12:56:03 +0000 (05:56 -0700)
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/ChangeLog
gdb/infcmd.c

index 667bf27fe129fd589260fa7555b5cafefe78e955..b6355e799b57f08842946c1e585dc8a6b7e67ad6 100644 (file)
@@ -1,3 +1,8 @@
+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,
index c4d7d8b5d6d0cce0aecd84209763f3e9861df27f..54aa1ef4cc49cfa01669972978bbc3ef33dca442 100644 (file)
@@ -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)