gdb/ * common/gdb_signals.h (struct gdb_signal_desc): New. * common/signals.c: Move gdb-specific part to ... * signals.c: ... here. New. * Makefile.in (COMMON_OBS): Add signals.o diff --git a/gdb/Makefile.in b/gdb/Makefile.in index c6049fa..7ce68ff 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -866,6 +866,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ memattr.o mem-break.o target.o parse.o language.o buildsym.o \ findcmd.o \ std-regs.o \ + signals.o \ exec.o reverse.o \ bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o \ dbxread.o coffread.o coff-pe-read.o \ diff --git a/gdb/common/gdb_signals.h b/gdb/common/gdb_signals.h index c04d795..09dd120 100644 --- a/gdb/common/gdb_signals.h +++ b/gdb/common/gdb_signals.h @@ -24,6 +24,12 @@ #include "gdb/signals.h" +struct gdb_signal_desc +{ + const char *name; + const char *string; +}; + /* Predicate to target_signal_to_host(). Return non-zero if the enum targ_signal SIGNO has an equivalent ``host'' representation. */ /* FIXME: cagney/1999-11-22: The name below was chosen in preference diff --git a/gdb/common/signals.c b/gdb/common/signals.c index 3c7ffe4..f87842b 100644 --- a/gdb/common/signals.c +++ b/gdb/common/signals.c @@ -19,13 +19,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef GDBSERVER -#include "server.h" -#else -#include "defs.h" -#include "gdb_string.h" -#endif +#include +#include "../config.h" #ifdef HAVE_SIGNAL_H #include #endif @@ -51,10 +47,7 @@ struct gdbarch; /* This table must match in order and size the signals in enum target_signal. */ -static const struct { - const char *name; - const char *string; - } signals [] = +const struct gdb_signal_desc signals [] = { #define SET(symbol, constant, name, string) { name, string }, #include "gdb/signals.def" @@ -651,45 +644,3 @@ target_signal_to_host (enum target_signal oursig) else return targ_signo; } - -#ifndef GDBSERVER - -/* In some circumstances we allow a command to specify a numeric - signal. The idea is to keep these circumstances limited so that - users (and scripts) develop portable habits. For comparison, - POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a - numeric signal at all is obsolescent. We are slightly more - lenient and allow 1-15 which should match host signal numbers on - most systems. Use of symbolic signal names is strongly encouraged. */ - -enum target_signal -target_signal_from_command (int num) -{ - if (num >= 1 && num <= 15) - return (enum target_signal) num; - error ("Only signals 1-15 are valid as numeric signals.\n\ -Use \"info signals\" for a list of symbolic signals."); -} - -extern initialize_file_ftype _initialize_signals; /* -Wmissing-prototype */ - -void -_initialize_signals (void) -{ - if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0) - internal_error (__FILE__, __LINE__, "failed internal consistency check"); -} - -int -default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts) -{ - return target_signal_to_host (ts); -} - -enum target_signal -default_target_signal_from_host (struct gdbarch *gdbarch, int signo) -{ - return target_signal_from_host (signo); -} - -#endif /* ! GDBSERVER */ diff --git a/gdb/signals.c b/gdb/signals.c new file mode 100644 index 0000000..512fcfb --- /dev/null +++ b/gdb/signals.c @@ -0,0 +1,64 @@ +/* Target signal translation functions for GDB. + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. + Contributed by Cygnus Support. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "gdb_string.h" +#include "gdb_signals.h" + +extern struct gdb_signal_desc *signals; + +/* In some circumstances we allow a command to specify a numeric + signal. The idea is to keep these circumstances limited so that + users (and scripts) develop portable habits. For comparison, + POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a + numeric signal at all is obsolescent. We are slightly more + lenient and allow 1-15 which should match host signal numbers on + most systems. Use of symbolic signal names is strongly encouraged. */ + +enum target_signal +target_signal_from_command (int num) +{ + if (num >= 1 && num <= 15) + return (enum target_signal) num; + error ("Only signals 1-15 are valid as numeric signals.\n\ +Use \"info signals\" for a list of symbolic signals."); +} + +extern initialize_file_ftype _initialize_signals; /* -Wmissing-prototype */ + +void +_initialize_signals (void) +{ + if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0) + internal_error (__FILE__, __LINE__, "failed internal consistency check"); +} + +int +default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts) +{ + return target_signal_to_host (ts); +} + +enum target_signal +default_target_signal_from_host (struct gdbarch *gdbarch, int signo) +{ + return target_signal_from_host (signo); +}