From e37a6e9c8a53dec0d1b122ae3cd218cb594643d2 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Tue, 23 Jun 1992 00:25:11 +0000 Subject: [PATCH] * 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). --- gdb/ChangeLog | 7 +++++ gdb/configure.in | 2 ++ gdb/infrun.c | 79 +++++++++++++++++++++++++----------------------- gdb/tm-linux.h | 27 +++++++++++++++++ gdb/xm-linux.h | 23 ++++++++++++++ 5 files changed, 100 insertions(+), 38 deletions(-) create mode 100644 gdb/tm-linux.h create mode 100644 gdb/xm-linux.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index da68bdda7f1..24f3deb1921 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +Mon Jun 22 17:19:02 1992 Per Bothner (bothner@cygnus.com) + + * 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). + Sat Jun 20 19:19:52 1992 John Gilmore (gnu at cygnus.com) COFF changes for dealing better with EPI 29K C compiler output. diff --git a/gdb/configure.in b/gdb/configure.in index ace1ba07203..b53ee7769a8 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -108,6 +108,7 @@ i386) sysv*) gdb_host=i386v ;; scosysv*) gdb_host=i386sco ;; mach) gdb_host=i386mach ;; + linux) gdb_host=linux ;; esac ;; esac @@ -316,6 +317,7 @@ i386) mach) gdb_target=i386mach ;; coff) gdb_target=i386v ;; aout) gdb_target=i386aout ;; + linux) gdb_target=linux ;; esac esac ;; diff --git a/gdb/infrun.c b/gdb/infrun.c index 98e7227e580..e23f5016d05 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; diff --git a/gdb/tm-linux.h b/gdb/tm-linux.h new file mode 100644 index 00000000000..f36505f5ac1 --- /dev/null +++ b/gdb/tm-linux.h @@ -0,0 +1,27 @@ +/* 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) */ diff --git a/gdb/xm-linux.h b/gdb/xm-linux.h new file mode 100644 index 00000000000..771c3db1992 --- /dev/null +++ b/gdb/xm-linux.h @@ -0,0 +1,23 @@ +/* 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 -- 2.30.2