aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1992-06-23 00:25:11 +0000
committerPer Bothner <per@bothner.com>1992-06-23 00:25:11 +0000
commite37a6e9c8a53dec0d1b122ae3cd218cb594643d2 (patch)
treee88ccd1bc3d0749939a16d216e9653ca796bffd1 /gdb/infrun.c
parentdefb51a7222598ac26e96593ad69659226ad218e (diff)
downloadgdb-e37a6e9c8a53dec0d1b122ae3cd218cb594643d2.zip
gdb-e37a6e9c8a53dec0d1b122ae3cd218cb594643d2.tar.gz
gdb-e37a6e9c8a53dec0d1b122ae3cd218cb594643d2.tar.bz2
* infrun.c (wait_for_inferior): Don't test for SIGEMT
(which is not a Posix signal) if it isn't defined. * tm-linux.h, xm-linux.h, config/linux.m[ht], configure.in: New port to Linux (a free Unix clone for 386 machines).
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 98e7227..e23f501 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -109,7 +109,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "breakpoint.h"
#include "wait.h"
#include "gdbcore.h"
-#include "signame.h"
#include "command.h"
#include "terminal.h" /* For #ifdef TIOCGPGRP and new_tty */
#include "target.h"
@@ -133,7 +132,7 @@ extern int original_stack_limit;
/* Prototypes for local functions */
static void
-signals_info PARAMS ((char *));
+signals_info PARAMS ((char *, int));
static void
handle_command PARAMS ((char *, int));
@@ -158,9 +157,6 @@ resume_cleanups PARAMS ((int));
extern char **environ;
-extern int sys_nerr;
-extern char *sys_errlist[];
-
extern struct target_ops child_ops; /* In inftarg.c */
/* Sigtramp is a routine that the kernel calls (which then calls the
@@ -215,9 +211,9 @@ extern dc_dcontext_t current_context;
/* Tables of how to react to signals; the user sets them. */
-static char signal_stop[NSIG];
-static char signal_print[NSIG];
-static char signal_program[NSIG];
+static char *signal_stop;
+static char *signal_print;
+static char *signal_program;
/* Nonzero if breakpoints are now inserted in the inferior. */
/* Nonstatic for initialization during xxx_create_inferior. FIXME. */
@@ -599,7 +595,7 @@ child_create_inferior (exec_file, allargs, env)
execlp (shell_file, shell_file, "-c", shell_command, (char *)0);
fprintf (stderr, "Cannot exec %s: %s.\n", shell_file,
- errno < sys_nerr ? sys_errlist[errno] : "unknown error");
+ safe_strerror (errno));
fflush (stderr);
_exit (0177);
}
@@ -735,6 +731,9 @@ child_attach (args, from_tty)
#else
pid = atoi (args);
+ if (pid == getpid()) /* Trying to masturbate? */
+ error ("I refuse to debug myself!");
+
if (target_has_execution)
{
if (query ("A program is being debugged already. Kill it? "))
@@ -817,11 +816,11 @@ wait_for_inferior ()
{
target_terminal_ours (); /* Must do this before mourn anyway */
if (WEXITSTATUS (w))
- printf ("\nProgram exited with code 0%o.\n",
+ printf_filtered ("\nProgram exited with code 0%o.\n",
(unsigned int)WEXITSTATUS (w));
else
if (!batch_mode())
- printf ("\nProgram exited normally.\n");
+ printf_filtered ("\nProgram exited normally.\n");
fflush (stdout);
target_mourn_inferior ();
#ifdef NO_SINGLE_STEP
@@ -837,16 +836,13 @@ wait_for_inferior ()
target_terminal_ours (); /* Must do this before mourn anyway */
target_kill (); /* kill mourns as well */
#ifdef PRINT_RANDOM_SIGNAL
- printf ("\nProgram terminated: ");
+ printf_filtered ("\nProgram terminated: ");
PRINT_RANDOM_SIGNAL (stop_signal);
#else
- printf ("\nProgram terminated with signal %d, %s\n",
- stop_signal,
- stop_signal < NSIG
- ? sys_siglist[stop_signal]
- : "(undocumented)");
+ printf_filtered ("\nProgram terminated with signal %d, %s\n",
+ stop_signal, safe_strsignal (stop_signal));
#endif
- printf ("The inferior process no longer exists.\n");
+ printf_filtered ("The inferior process no longer exists.\n");
fflush (stdout);
#ifdef NO_SINGLE_STEP
one_stepped = 0;
@@ -902,7 +898,10 @@ wait_for_inferior ()
if (stop_signal == SIGTRAP
|| (breakpoints_inserted &&
(stop_signal == SIGILL
- || stop_signal == SIGEMT))
+#ifdef SIGEMT
+ || stop_signal == SIGEMT
+#endif
+ ))
|| stop_soon_quietly)
{
if (stop_signal == SIGTRAP && stop_after_trap)
@@ -1007,11 +1006,8 @@ wait_for_inferior ()
#ifdef PRINT_RANDOM_SIGNAL
PRINT_RANDOM_SIGNAL (stop_signal);
#else
- printf ("\nProgram received signal %d, %s\n",
- stop_signal,
- stop_signal < NSIG
- ? sys_siglist[stop_signal]
- : "(undocumented)");
+ printf_filtered ("\nProgram received signal %d, %s\n",
+ stop_signal, safe_strsignal (stop_signal));
#endif /* PRINT_RANDOM_SIGNAL */
fflush (stdout);
}
@@ -1493,7 +1489,7 @@ normal_stop ()
{
target_terminal_ours_for_output ();
print_sys_errmsg ("ptrace", breakpoints_failed);
- printf ("Stopped; cannot insert breakpoints.\n\
+ printf_filtered ("Stopped; cannot insert breakpoints.\n\
The same program may be running in another process.\n");
}
@@ -1504,7 +1500,7 @@ The same program may be running in another process.\n");
if (remove_breakpoints ())
{
target_terminal_ours_for_output ();
- printf ("Cannot remove breakpoints because program is no longer writable.\n\
+ printf_filtered ("Cannot remove breakpoints because program is no longer writable.\n\
It might be running in another process.\n\
Further execution is probably impossible.\n");
}
@@ -1614,15 +1610,16 @@ static void
sig_print_info (number)
int number;
{
- char *abbrev = sig_abbrev(number);
- if (abbrev == NULL)
+ char *name;
+
+ if ((name = strsigno (number)) == NULL)
printf_filtered ("%d\t\t", number);
else
- printf_filtered ("SIG%s (%d)\t", abbrev, number);
+ printf_filtered ("%s (%d)\t", name, number);
printf_filtered ("%s\t", signal_stop[number] ? "Yes" : "No");
printf_filtered ("%s\t", signal_print[number] ? "Yes" : "No");
printf_filtered ("%s\t\t", signal_program[number] ? "Yes" : "No");
- printf_filtered ("%s\n", sys_siglist[number]);
+ printf_filtered ("%s\n", safe_strsignal (number));
}
/* Specify how various signals in the inferior should be handled. */
@@ -1666,7 +1663,7 @@ handle_command (args, from_tty)
{
/* Numeric. */
signum = atoi (p);
- if (signum <= 0 || signum >= NSIG)
+ if (signum <= 0 || signum > signo_max ())
{
p[wordlen] = '\0';
error ("Invalid signal %s given as argument to \"handle\".", p);
@@ -1675,14 +1672,14 @@ handle_command (args, from_tty)
else
{
/* Symbolic. */
- signum = sig_number (p);
- if (signum == -1)
+ signum = strtosigno (p);
+ if (signum == 0)
error ("No such signal \"%s\"", p);
}
if (signum == SIGTRAP || signum == SIGINT)
{
- if (!query ("SIG%s is used by the debugger.\nAre you sure you want to change it? ", sig_abbrev (signum)))
+ if (!query ("%s is used by the debugger.\nAre you sure you want to change it? ", strsigno (signum)))
error ("Not confirmed.");
}
}
@@ -1734,8 +1731,9 @@ handle_command (args, from_tty)
/* Print current contents of the tables set by the handle command. */
static void
-signals_info (signum_exp)
+signals_info (signum_exp, from_tty)
char *signum_exp;
+ int from_tty;
{
register int i;
sig_print_header ();
@@ -1743,8 +1741,8 @@ signals_info (signum_exp)
if (signum_exp)
{
/* First see if this is a symbol name. */
- i = sig_number (signum_exp);
- if (i == -1)
+ i = strtosigno (signum_exp);
+ if (i == 0)
{
/* Nope, maybe it's an address which evaluates to a signal
number. */
@@ -1872,6 +1870,7 @@ void
_initialize_infrun ()
{
register int i;
+ register int numsigs;
add_info ("signals", signals_info,
"What debugger does when program gets various signals.\n\
@@ -1887,7 +1886,11 @@ Stop means reenter debugger if this signal happens (implies print).\n\
Pass means let program see this signal; otherwise program doesn't know.\n\
Pass and Stop may be combined.");
- for (i = 0; i < NSIG; i++)
+ numsigs = signo_max () + 1;
+ signal_stop = xmalloc (sizeof (signal_stop[0]) * numsigs);
+ signal_print = xmalloc (sizeof (signal_print[0]) * numsigs);
+ signal_program = xmalloc (sizeof (signal_program[0]) * numsigs);
+ for (i = 0; i < numsigs; i++)
{
signal_stop[i] = 1;
signal_print[i] = 1;