diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1c70fac304f..0c61c89642e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2013-10-23 Pedro Alves + + * common/gdb_signals.h (gdb_signal_to_symbol_string): Declare. + * common/signals.c: Include "gdb_assert.h". + (signals): New field 'symbol'. + (SET): Use the 'symbol' parameter. + (gdb_signal_to_symbol_string): New function. + * infrun.c (handle_inferior_event) : In debug + output, print the random signal enum as string in addition to its + number. + * target/waitstatus.c (target_waitstatus_to_string): Print the + signal's enum value as string instead of the (POSIX) signal name. + 2013-10-23 Gary Benson PR 16013 diff --git a/gdb/common/gdb_signals.h b/gdb/common/gdb_signals.h index 76e64f83b93..e02d1ee7f94 100644 --- a/gdb/common/gdb_signals.h +++ b/gdb/common/gdb_signals.h @@ -42,6 +42,10 @@ extern int gdb_signal_to_host_p (enum gdb_signal signo); extern enum gdb_signal gdb_signal_from_host (int); extern int gdb_signal_to_host (enum gdb_signal); +/* Return the enum symbol name of SIG as a string, to use in debug + output. */ +extern const char *gdb_signal_to_symbol_string (enum gdb_signal sig); + /* Return the string for a signal. */ extern const char *gdb_signal_to_string (enum gdb_signal); diff --git a/gdb/common/signals.c b/gdb/common/signals.c index 8fe4bedcb4d..1f3e3a4e0b8 100644 --- a/gdb/common/signals.c +++ b/gdb/common/signals.c @@ -29,6 +29,7 @@ #endif #include "gdb_signals.h" +#include "gdb_assert.h" struct gdbarch; @@ -50,15 +51,23 @@ struct gdbarch; gdb_signal. */ static const struct { + const char *symbol; const char *name; const char *string; } signals [] = { -#define SET(symbol, constant, name, string) { name, string }, +#define SET(symbol, constant, name, string) { #symbol, name, string }, #include "gdb/signals.def" #undef SET }; +const char * +gdb_signal_to_symbol_string (enum gdb_signal sig) +{ + gdb_assert ((int) sig >= GDB_SIGNAL_FIRST && (int) sig <= GDB_SIGNAL_LAST); + + return signals[sig].symbol; +} /* Return the string for a signal. */ const char * diff --git a/gdb/infrun.c b/gdb/infrun.c index c1cb99fe32e..4f7068c8996 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1749,9 +1749,10 @@ resume (int step, enum gdb_signal sig) if (debug_infrun) fprintf_unfiltered (gdb_stdlog, - "infrun: resume (step=%d, signal=%d), " + "infrun: resume (step=%d, signal=%s), " "trap_expected=%d, current thread [%s] at %s\n", - step, sig, tp->control.trap_expected, + step, gdb_signal_to_symbol_string (sig), + tp->control.trap_expected, target_pid_to_str (inferior_ptid), paddress (gdbarch, pc)); @@ -2200,8 +2201,9 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal, int step) if (debug_infrun) fprintf_unfiltered (gdb_stdlog, - "infrun: proceed (addr=%s, signal=%d, step=%d)\n", - paddress (gdbarch, addr), siggnal, step); + "infrun: proceed (addr=%s, signal=%s, step=%d)\n", + paddress (gdbarch, addr), + gdb_signal_to_symbol_string (siggnal), step); if (non_stop) /* In non-stop, each thread is handled individually. The context @@ -4313,10 +4315,11 @@ Cannot fill $_exitsignal with the correct signal number.\n")); /* Signal not for debugging purposes. */ int printed = 0; struct inferior *inf = find_inferior_pid (ptid_get_pid (ecs->ptid)); + enum gdb_signal stop_signal = ecs->event_thread->suspend.stop_signal; if (debug_infrun) - fprintf_unfiltered (gdb_stdlog, "infrun: random signal %d\n", - ecs->event_thread->suspend.stop_signal); + fprintf_unfiltered (gdb_stdlog, "infrun: random signal (%s)\n", + gdb_signal_to_symbol_string (stop_signal)); stopped_by_random_signal = 1; diff --git a/gdb/target/waitstatus.c b/gdb/target/waitstatus.c index e6b850268b6..4e5e8d6a0ba 100644 --- a/gdb/target/waitstatus.c +++ b/gdb/target/waitstatus.c @@ -40,10 +40,12 @@ target_waitstatus_to_string (const struct target_waitstatus *ws) kind_str, ws->value.integer); case TARGET_WAITKIND_STOPPED: return xstrprintf ("%sstopped, signal = %s", - kind_str, gdb_signal_to_name (ws->value.sig)); + kind_str, + gdb_signal_to_symbol_string (ws->value.sig)); case TARGET_WAITKIND_SIGNALLED: return xstrprintf ("%ssignalled, signal = %s", - kind_str, gdb_signal_to_name (ws->value.sig)); + kind_str, + gdb_signal_to_symbol_string (ws->value.sig)); case TARGET_WAITKIND_LOADED: return xstrprintf ("%sloaded", kind_str); case TARGET_WAITKIND_FORKED: