binutils-gdb/gdb/common
Pedro Alves c9737c08e7 infrun debug output: print enum gdb_signal symbol names instead of POSIX signal names.
The other day while debugging something related to random signals, I
got confused with "set debug infrun 1" output, for it said:

 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x323d4e8b94
 infrun: random signal 20

On GNU/Linux, 20 is SIGTSTP.  For some reason, it took me a few
minutes to realize that 20 is actually a GDB signal number, not a
target signal number (duh!).  In any case, I propose making GDB's
output clearer here:

One way would be to use gdb_signal_to_name, like already used
elsewhere:

 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x323d4e8b94
 infrun: random signal SIGCHLD (20)

but I think that might confuse someone too ("20? Why does GDB believe
SIGCHLD is 20?").  So I thought of printing the enum string instead:

 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x323d4e8b94
 infrun: random signal GDB_SIGNAL_CHLD (20)

Looking at a more complete infrun debug log, we had actually printed
the (POSIX) signal name name a bit before:

 infrun: target_wait (-1, status) =
 infrun:   9300 [Thread 0x7ffff7fcb740 (LWP 9300)],
 infrun:   status->kind = stopped, signal = SIGCHLD
 ...
 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x323d4e8b94
 infrun: random signal 20

So I'm now thinking that it'd be even better to make infrun output
consistently use the enum symbol string, like so:

 infrun: clear_proceed_status_thread (Thread 0x7ffff7fca700 (LWP 25663))
 infrun: clear_proceed_status_thread (Thread 0x7ffff7fcb740 (LWP 25659))
- infrun: proceed (addr=0xffffffffffffffff, signal=144, step=1)
+ infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT, step=1)
- infrun: resume (step=1, signal=0), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700
+ infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700
 infrun: wait_for_inferior ()
 infrun: target_wait (-1, status) =
 infrun:   25659 [Thread 0x7ffff7fcb740 (LWP 25659)],
- infrun:   status->kind = stopped, signal = SIGCHLD
+ infrun:   status->kind = stopped, signal = GDB_SIGNAL_CHLD
 infrun: infwait_normal_state
 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x400700
- infrun: random signal 20
+ infrun: random signal (GDB_SIGNAL_CHLD)
 infrun: random signal, keep going
- infrun: resume (step=1, signal=20), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700
+ infrun: resume (step=1, signal=GDB_SIGNAL_CHLD), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700
 infrun: prepare_to_wait
 infrun: target_wait (-1, status) =
 infrun:   25659 [Thread 0x7ffff7fcb740 (LWP 25659)],
- infrun:   status->kind = stopped, signal = SIGTRAP
+ infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
 infrun: infwait_normal_state
 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x400704
 infrun: stepi/nexti
 infrun: stop_stepping

GDB's signal numbers are public and hardcoded (see
include/gdb/signals.h), so there's really no need to clutter the
output with numeric values in some places while others not.  Replacing
the magic "144" with GDB_SIGNAL_DEFAULT in "proceed"'s debug output
(see above) I think is quite nice.

I posit that all this makes it clearer to newcomers that GDB has its
own signal numbering (and that there must be some mapping going on).

Tested on x86_64 Fedora 17.

gdb/
2013-10-23  Pedro Alves  <palves@redhat.com>

	* 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) <random signal>: 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-25 14:02:59 +00:00
..
agent.c PR gdb/7912: 2013-04-22 16:46:15 +00:00
agent.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
ax.def Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
break-common.h gdb/ 2013-07-27 07:11:46 +00:00
btrace-common.h Add branch trace information to struct thread_info. 2013-03-11 08:17:08 +00:00
buffer.c Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
buffer.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
common-utils.c Move savestring to common/common-utils.c, make gdbserver use it. 2013-02-14 17:11:41 +00:00
common-utils.h Move savestring to common/common-utils.c, make gdbserver use it. 2013-02-14 17:11:41 +00:00
create-version.sh gdb/ 2013-07-04 01:22:38 +00:00
filestuff.c Minor O_CLOEXEC optimization, "regression" fix 2013-10-09 16:00:54 +00:00
filestuff.h 2013-05-10 Joel Brobecker <brobecker@adacore.com> 2013-05-10 17:01:00 +00:00
format.c Handle '#' flag for printf of pointer types. 2013-08-13 16:05:23 +00:00
format.h * ada-lang.c (ada_read_renaming_var_value): Pass const 2013-03-12 17:39:45 +00:00
gdb_assert.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb_dirent.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb_locale.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb_signals.h infrun debug output: print enum gdb_signal symbol names instead of POSIX signal names. 2013-10-25 14:02:59 +00:00
gdb_stat.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb_string.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb_thread_db.h Move fallback thread_db.h to a separate file. 2013-04-16 18:14:55 +00:00
gdb_vecs.c Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb_vecs.h gdb/ 2013-06-26 08:01:57 +00:00
gdb_wait.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
glibc_thread_db.h Update glibc_thread_db.h from upstream. 2013-04-16 18:17:11 +00:00
host-defs.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
i386-cpuid.h gdb: clean up x86 cpuid implementations 2013-06-19 22:29:36 +00:00
i386-gcc-cpuid.h gdb: clean up x86 cpuid implementations 2013-06-19 22:29:36 +00:00
i386-xstate.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
linux-btrace.c gdb: btrace: fix build errors on older glibc builds 2013-09-29 03:57:34 +00:00
linux-btrace.h Implement branch tracing on Linux based on perf_event such that it can be shared 2013-03-11 08:24:07 +00:00
linux-osdata.c Fix off-by-one errors in *scanf format strings. 2013-10-25 14:02:59 +00:00
linux-osdata.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
linux-procfs.c PR gdb/7912: 2013-04-22 16:46:15 +00:00
linux-procfs.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
linux-ptrace.c Always run the PTRACE_O_TRACESYSGOOD tests even if PTRACE_O_TRACEFORK is not supported. 2013-10-03 10:13:34 +00:00
linux-ptrace.h Unify ptrace options discovery code and make both GDB and 2013-08-22 23:46:30 +00:00
mips-linux-watch.c gdb/ 2013-07-27 07:49:05 +00:00
mips-linux-watch.h gdb/ 2013-07-27 07:49:05 +00:00
ptid.c Clean up ptid.h/ptid.c. 2013-10-04 10:04:14 +00:00
ptid.h Clean up ptid.h/ptid.c. 2013-10-04 10:04:14 +00:00
queue.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
signals.c infrun debug output: print enum gdb_signal symbol names instead of POSIX signal names. 2013-10-25 14:02:59 +00:00
vec.c Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
vec.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
version.h don't keep a gdb-specific date 2013-06-24 15:06:27 +00:00
xml-utils.c Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
xml-utils.h Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00