summaryrefslogtreecommitdiff
path: root/gdb/corelow.c
diff options
context:
space:
mode:
authorsergiodj <sergiodj>2013-10-07 05:34:10 +0000
committersergiodj <sergiodj>2013-10-07 05:34:10 +0000
commit16fd332e4240cce47a1a990d2b2b8190cd5ee5f8 (patch)
tree0d5f8f299db3ddf4279a3d7bd637f01be65c2b6d /gdb/corelow.c
parent5133593f601eb6ef05152cec1ecf4bf34acd206b (diff)
downloadgdb-16fd332e4240cce47a1a990d2b2b8190cd5ee5f8.tar.gz
This patch adds a new convenience variable called "$_exitsignal", which
will hold the signal number when the inferior terminates due to the uncaught signal. I've made modifications on infrun.c:handle_inferior_event such that $_exitcode gets cleared when the inferior signalled, and vice-versa. This assumption was made because the variables are mutually exclusive, i.e., when the inferior terminates because of an uncaught signal it is not possible for it to return. I have also made modifications such that when a corefile is loaded, $_exitsignal gets set to the uncaught signal that "killed" the inferior, and $_exitcode is cleared. The patch also adds a NEWS entry, documentation bits, and a testcase. The documentation entry explains how to use $_exitsignal and $_exitcode in a GDB script, by making use of the new $_isvoid convenience function. gdb/ 2013-10-06 Sergio Durigan Junior <sergiodj@redhat.com> * NEWS: Mention new convenience variable $_exitsignal. * corelow.c (core_open): Reset exit convenience variables. Set $_exitsignal to the uncaught signal which generated the corefile. * infrun.c (handle_inferior_event): Reset exit convenience variables. Set $_exitsignal for TARGET_WAITKIND_SIGNALLED. (clear_exit_convenience_vars): New function. * inferior.h (clear_exit_convenience_vars): New prototype. gdb/testsuite/ 2013-10-06 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/corefile.exp: Test whether $_exitsignal is set and $_exitcode is void when opening a corefile. * gdb.base/exitsignal.exp: New file. * gdb.base/segv.c: Likewise. * gdb.base/normal.c: Likewise. gdb/doc/ 2013-10-06 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.texinfo (Convenience Variables): Document $_exitsignal. Update entry for $_exitcode.
Diffstat (limited to 'gdb/corelow.c')
-rw-r--r--gdb/corelow.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 7a5aaabf7c6..d1e7f6ae7df 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -429,6 +429,9 @@ core_open (char *filename, int from_tty)
if (p)
printf_filtered (_("Core was generated by `%s'.\n"), p);
+ /* Clearing any previous state of convenience variables. */
+ clear_exit_convenience_vars ();
+
siggy = bfd_core_file_failing_signal (core_bfd);
if (siggy > 0)
{
@@ -446,6 +449,11 @@ core_open (char *filename, int from_tty)
printf_filtered (_("Program terminated with signal %s, %s.\n"),
gdb_signal_to_name (sig), gdb_signal_to_string (sig));
+
+ /* Set the value of the internal variable $_exitsignal,
+ which holds the signal uncaught by the inferior. */
+ set_internalvar_integer (lookup_internalvar ("_exitsignal"),
+ siggy);
}
/* Fetch all registers from core file. */