#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"
/* Prototypes for local functions */
static void
-signals_info PARAMS ((char *));
+signals_info PARAMS ((char *, int));
static void
handle_command PARAMS ((char *, 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
/* 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. */
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);
}
#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? "))
{
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
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;
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)
#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);
}
{
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");
}
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");
}
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. */
{
/* 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);
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.");
}
}
/* 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 ();
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. */
_initialize_infrun ()
{
register int i;
+ register int numsigs;
add_info ("signals", signals_info,
"What debugger does when program gets various signals.\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;
--- /dev/null
+/* Macro definitions for linux.
+ Copyright (C) 1992 Free Software Foundation, Inc.
+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 2 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, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#if !defined (TM_LINUX_H)
+#define TM_LINUX_H 1
+/* number of traps that happen between exec'ing the shell
+ * to run an inferior, and when we finally get to
+ * the inferior code. This is 2 on most implementations.
+ */
+#define START_INFERIOR_TRAPS_EXPECTED 2
+#include "tm-i386v.h"
+/* Define this if the C compiler puts an underscore at the front
+ of external names before giving them to the linker. */
+#define NAMES_HAVE_UNDERSCORE
+#endif /* !defined (TM_LINUX_H) */
--- /dev/null
+/* Macro defintions for linux.
+ Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+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 2 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, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "xm-i386v.h"
+/* Tell gdb that we can attach and detach other processes */
+#define ATTACH_DETACH
+/* This is the amount to subtract from u.u_ar0
+ to get the offset in the core file of the register values. */
+#undef KERNEL_U_ADDR
+#define KERNEL_U_ADDR 0x0
+#define U_REGS_OFFSET 0