-/* Start (run) and stop the inferior process, for GDB.
+/* Target-struct-independent code to start (run) and stop an inferior process.
Copyright 1986, 1987, 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include <string.h>
+#include <ctype.h>
#include "symtab.h"
#include "frame.h"
#include "inferior.h"
#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 "gdbcmd.h"
#include "target.h"
#include <signal.h>
#include <sys/file.h>
#endif
-#ifdef SET_STACK_LIMIT_HUGE
-#include <sys/time.h>
-#include <sys/resource.h>
-
-extern int original_stack_limit;
-#endif /* SET_STACK_LIMIT_HUGE */
-
/* Prototypes for local functions */
static void
-signals_info PARAMS ((char *));
+signals_info PARAMS ((char *, int));
static void
handle_command PARAMS ((char *, int));
static void
insert_step_breakpoint PARAMS ((void));
-static void
-resume PARAMS ((int, int));
-
static void
resume_cleanups PARAMS ((int));
-extern char **environ;
-
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-extern struct target_ops child_ops; /* In inftarg.c */
+static int
+hook_stop_stub PARAMS ((char *));
/* Sigtramp is a routine that the kernel calls (which then calls the
signal handler). On most machines it is a library routine that
#define IN_SOLIB_TRAMPOLINE(pc,name) 0
#endif
-/* Notify other parts of gdb that might care that signal handling may
- have changed for one or more signals. */
-#ifndef NOTICE_SIGNAL_HANDLING_CHANGE
-#define NOTICE_SIGNAL_HANDLING_CHANGE /* No actions */
+/* On some systems, the PC may be left pointing at an instruction that won't
+ actually be executed. This is usually indicated by a bit in the PSW. If
+ we find ourselves in such a state, then we step the target beyond the
+ nullified instruction before returning control to the user so as to avoid
+ confusion. */
+
+#ifndef INSTRUCTION_NULLIFIED
+#define INSTRUCTION_NULLIFIED 0
#endif
#ifdef TDESC
/* 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 unsigned char *signal_stop;
+static unsigned char *signal_print;
+static unsigned char *signal_program;
+
+#define SET_SIGS(nsigs,sigs,flags) \
+ do { \
+ int signum = (nsigs); \
+ while (signum-- > 0) \
+ if ((sigs)[signum]) \
+ (flags)[signum] = 1; \
+ } while (0)
+
+#define UNSET_SIGS(nsigs,sigs,flags) \
+ do { \
+ int signum = (nsigs); \
+ while (signum-- > 0) \
+ if ((sigs)[signum]) \
+ (flags)[signum] = 0; \
+ } while (0)
+
+
+/* Command list pointer for the "stop" placeholder. */
+
+static struct cmd_list_element *stop_command;
/* Nonzero if breakpoints are now inserted in the inferior. */
-/* Nonstatic for initialization during xxx_create_inferior. FIXME. */
-/*static*/ int breakpoints_inserted;
+static int breakpoints_inserted;
/* Function inferior was in as of last step command. */
STEP nonzero if we should step (zero to continue instead).
SIG is the signal to give the inferior (zero for none). */
-static void
+void
resume (step, sig)
int step;
int sig;
static char *prev_func_name;
\f
-/* Start an inferior Unix child process and sets inferior_pid to its pid.
- EXEC_FILE is the file to run.
- ALLARGS is a string containing the arguments to the program.
- ENV is the environment vector to pass. Errors reported with error(). */
-
-#ifndef SHELL_FILE
-#define SHELL_FILE "/bin/sh"
-#endif
-
-void
-child_create_inferior (exec_file, allargs, env)
- char *exec_file;
- char *allargs;
- char **env;
-{
- int pid;
- char *shell_command;
- char *shell_file;
- static char default_shell_file[] = SHELL_FILE;
- int len;
- int pending_execs;
- /* Set debug_fork then attach to the child while it sleeps, to debug. */
- static int debug_fork = 0;
- /* This is set to the result of setpgrp, which if vforked, will be visible
- to you in the parent process. It's only used by humans for debugging. */
- static int debug_setpgrp = 657473;
- char **save_our_env;
-
- /* The user might want tilde-expansion, and in general probably wants
- the program to behave the same way as if run from
- his/her favorite shell. So we let the shell run it for us.
- FIXME, this should probably search the local environment (as
- modified by the setenv command), not the env gdb inherited. */
- shell_file = getenv ("SHELL");
- if (shell_file == NULL)
- shell_file = default_shell_file;
-
- len = 5 + strlen (exec_file) + 1 + strlen (allargs) + 1 + /*slop*/ 10;
- /* If desired, concat something onto the front of ALLARGS.
- SHELL_COMMAND is the result. */
-#ifdef SHELL_COMMAND_CONCAT
- shell_command = (char *) alloca (strlen (SHELL_COMMAND_CONCAT) + len);
- strcpy (shell_command, SHELL_COMMAND_CONCAT);
-#else
- shell_command = (char *) alloca (len);
- shell_command[0] = '\0';
-#endif
- strcat (shell_command, "exec ");
- strcat (shell_command, exec_file);
- strcat (shell_command, " ");
- strcat (shell_command, allargs);
-
- /* exec is said to fail if the executable is open. */
- close_exec_file ();
-
- /* Retain a copy of our environment variables, since the child will
- replace the value of environ and if we're vforked, we have to
- restore it. */
- save_our_env = environ;
-
- /* Tell the terminal handling subsystem what tty we plan to run on;
- it will just record the information for later. */
-
- new_tty_prefork (inferior_io_terminal);
-
- /* It is generally good practice to flush any possible pending stdio
- output prior to doing a fork, to avoid the possibility of both the
- parent and child flushing the same data after the fork. */
-
- fflush (stdout);
- fflush (stderr);
-
-#if defined(USG) && !defined(HAVE_VFORK)
- pid = fork ();
-#else
- if (debug_fork)
- pid = fork ();
- else
- pid = vfork ();
-#endif
-
- if (pid < 0)
- perror_with_name ("vfork");
-
- if (pid == 0)
- {
- if (debug_fork)
- sleep (debug_fork);
-
-#ifdef TIOCGPGRP
- /* Run inferior in a separate process group. */
-#ifdef NEED_POSIX_SETPGID
- debug_setpgrp = setpgid (0, 0);
-#else
-#if defined(USG) && !defined(SETPGRP_ARGS)
- debug_setpgrp = setpgrp ();
-#else
- debug_setpgrp = setpgrp (getpid (), getpid ());
-#endif /* USG */
-#endif /* NEED_POSIX_SETPGID */
- if (debug_setpgrp == -1)
- perror("setpgrp failed in child");
-#endif /* TIOCGPGRP */
-
-#ifdef SET_STACK_LIMIT_HUGE
- /* Reset the stack limit back to what it was. */
- {
- struct rlimit rlim;
-
- getrlimit (RLIMIT_STACK, &rlim);
- rlim.rlim_cur = original_stack_limit;
- setrlimit (RLIMIT_STACK, &rlim);
- }
-#endif /* SET_STACK_LIMIT_HUGE */
-
- /* Ask the tty subsystem to switch to the one we specified earlier
- (or to share the current terminal, if none was specified). */
-
- new_tty ();
-
- /* Changing the signal handlers for the inferior after
- a vfork can also change them for the superior, so we don't mess
- with signals here. See comments in
- initialize_signals for how we get the right signal handlers
- for the inferior. */
-
-#ifdef USE_PROC_FS
- proc_set_exec_trap (); /* Use SVR4 /proc interface */
-#else
- call_ptrace (0, 0, 0, 0); /* "Trace me, Dr. Memory!" */
-#endif
-
- /* There is no execlpe call, so we have to set the environment
- for our child in the global variable. If we've vforked, this
- clobbers the parent, but environ is restored a few lines down
- in the parent. By the way, yes we do need to look down the
- path to find $SHELL. Rich Pixley says so, and I agree. */
- environ = 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");
- fflush (stderr);
- _exit (0177);
- }
-
- /* Restore our environment in case a vforked child clob'd it. */
- environ = save_our_env;
-
- /* Now that we have a child process, make it our target. */
- push_target (&child_ops);
-
-#ifdef CREATE_INFERIOR_HOOK
- CREATE_INFERIOR_HOOK (pid);
-#endif
-
-/* The process was started by the fork that created it,
- but it will have stopped one instruction after execing the shell.
- Here we must get it up to actual execution of the real program. */
-
- inferior_pid = pid; /* Needed for wait_for_inferior stuff below */
-
- clear_proceed_status ();
-
- /* We will get a trace trap after one instruction.
- Continue it automatically. Eventually (after shell does an exec)
- it will get another trace trap. Then insert breakpoints and continue. */
-
-#ifdef START_INFERIOR_TRAPS_EXPECTED
- pending_execs = START_INFERIOR_TRAPS_EXPECTED;
-#else
- pending_execs = 2;
-#endif
-
- init_wait_for_inferior ();
-
- /* Set up the "saved terminal modes" of the inferior
- based on what modes we are starting it with. */
- target_terminal_init ();
-
- /* Install inferior's terminal modes. */
- target_terminal_inferior ();
-
- while (1)
- {
- stop_soon_quietly = 1; /* Make wait_for_inferior be quiet */
- wait_for_inferior ();
- if (stop_signal != SIGTRAP)
- {
- /* Let shell child handle its own signals in its own way */
- /* FIXME, what if child has exit()ed? Must exit loop somehow */
- resume (0, stop_signal);
- }
- else
- {
- /* We handle SIGTRAP, however; it means child did an exec. */
- if (0 == --pending_execs)
- break;
- resume (0, 0); /* Just make it go on */
- }
- }
- stop_soon_quietly = 0;
-
- /* We are now in the child process of interest, having exec'd the
- correct program, and are poised at the first instruction of the
- new program. */
-#ifdef SOLIB_CREATE_INFERIOR_HOOK
- SOLIB_CREATE_INFERIOR_HOOK (pid);
-#endif
-
- /* Should this perhaps just be a "proceed" call? FIXME */
- insert_step_breakpoint ();
- breakpoints_failed = insert_breakpoints ();
- if (!breakpoints_failed)
- {
- breakpoints_inserted = 1;
- target_terminal_inferior();
- /* Start the child program going on its first instruction, single-
- stepping if we need to. */
- resume (bpstat_should_step (), 0);
- wait_for_inferior ();
- normal_stop ();
- }
-}
-
/* Start remote-debugging of a machine over a serial link. */
void
}
-/* Attach to process PID, then initialize for debugging it
- and wait for the trace-trap that results from attaching. */
-
-void
-child_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- char *exec_file;
- int pid;
-
- dont_repeat();
-
- if (!args)
- error_no_arg ("process-id to attach");
-
-#ifndef ATTACH_DETACH
- error ("Can't attach to a process on this machine.");
-#else
- pid = atoi (args);
-
- if (target_has_execution)
- {
- if (query ("A program is being debugged already. Kill it? "))
- target_kill ();
- else
- error ("Inferior not killed.");
- }
-
- exec_file = (char *) get_exec_file (1);
-
- if (from_tty)
- {
- printf ("Attaching program: %s pid %d\n",
- exec_file, pid);
- fflush (stdout);
- }
-
- attach (pid);
- inferior_pid = pid;
- push_target (&child_ops);
-
- mark_breakpoints_out ();
- target_terminal_init ();
- clear_proceed_status ();
- stop_soon_quietly = 1;
- /*proceed (-1, 0, -2);*/
- target_terminal_inferior ();
- wait_for_inferior ();
-#ifdef SOLIB_ADD
- SOLIB_ADD ((char *)0, from_tty, (struct target_ops *)0);
-#endif
- normal_stop ();
-#endif /* ATTACH_DETACH */
-}
\f
/* Wait for control to return from inferior to debugger.
If inferior gets a signal, we may decide to start it up again
int remove_breakpoints_on_following_step = 0;
int current_line;
int handling_longjmp = 0; /* FIXME */
+ struct symtab *symtab;
sal = find_pc_line(prev_pc, 0);
current_line = sal.line;
{
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;
single_step (0); /* This actually cleans up the ss */
#endif /* NO_SINGLE_STEP */
+/* If PC is pointing at a nullified instruction, then step beyond it so that
+ the user won't be confused when GDB appears to be ready to execute it. */
+
+ if (INSTRUCTION_NULLIFIED)
+ {
+ resume (1, 0);
+ continue;
+ }
+
stop_pc = read_pc ();
set_current_frame ( create_new_frame (read_register (FP_REGNUM),
read_pc ()));
stop_func_name = 0;
/* Don't care about return value; stop_func_start and stop_func_name
will both be 0 if it doesn't work. */
- (void) find_pc_partial_function (stop_pc, &stop_func_name,
- &stop_func_start);
+ find_pc_partial_function (stop_pc, &stop_func_name, &stop_func_start);
stop_func_start += FUNCTION_START_OFFSET;
another_trap = 0;
bpstat_clear (&stop_bpstat);
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);
}
if (tmp != 0)
stop_func_start = tmp;
- if (find_pc_function (stop_func_start) != 0)
- goto step_into_function;
+ symtab = find_pc_symtab (stop_func_start);
+ if (symtab && LINETABLE (symtab))
+ goto step_into_function;
step_over_function:
/* A subroutine call has happened. */
{
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");
}
target_terminal_ours ();
+ /* Look up the hook_stop and run it if it exists. */
+
+ if (stop_command->hook)
+ {
+ catch_errors (hook_stop_stub, (char *)stop_command->hook,
+ "Error while running hook_stop:\n");
+ }
+
if (!target_has_stack)
return;
select_frame (get_current_frame (), 0);
}
}
+
+static int
+hook_stop_stub (cmd)
+ char *cmd;
+{
+ execute_user_command ((struct cmd_list_element *)cmd, 0);
+ return (0);
+}
+
\f
static void
insert_step_breakpoint ()
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. */
char *args;
int from_tty;
{
- register char *p = args;
- int signum = 0;
- register int digits, wordlen;
- char *nextarg;
+ char **argv;
+ int digits, wordlen;
+ int sigfirst, signum, siglast;
+ int allsigs;
+ int nsigs;
+ unsigned char *sigs;
+ struct cleanup *old_chain;
+
+ if (args == NULL)
+ {
+ error_no_arg ("signal to handle");
+ }
- if (!args)
- error_no_arg ("signal to handle");
+ /* Allocate and zero an array of flags for which signals to handle. */
- while (*p)
+ nsigs = signo_max () + 1;
+ sigs = (unsigned char *) alloca (nsigs);
+ memset (sigs, 0, nsigs);
+
+ /* Break the command line up into args. */
+
+ argv = buildargv (args);
+ if (argv == NULL)
{
- /* Find the end of the next word in the args. */
- for (wordlen = 0;
- p[wordlen] && p[wordlen] != ' ' && p[wordlen] != '\t';
- wordlen++);
- /* Set nextarg to the start of the word after the one we just
- found, and null-terminate this one. */
- if (p[wordlen] == '\0')
- nextarg = p + wordlen;
- else
- {
- p[wordlen] = '\0';
- nextarg = p + wordlen + 1;
- }
-
+ nomem (0);
+ }
+ old_chain = make_cleanup (freeargv, (char *) argv);
- for (digits = 0; p[digits] >= '0' && p[digits] <= '9'; digits++);
+ /* Walk through the args, looking for signal numbers, signal names, and
+ actions. Signal numbers and signal names may be interspersed with
+ actions, with the actions being performed for all signals cumulatively
+ specified. Signal ranges can be specified as <LOW>-<HIGH>. */
- if (signum == 0)
+ while (*argv != NULL)
+ {
+ wordlen = strlen (*argv);
+ for (digits = 0; isdigit ((*argv)[digits]); digits++) {;}
+ allsigs = 0;
+ sigfirst = siglast = -1;
+
+ if (wordlen >= 1 && !strncmp (*argv, "all", wordlen))
+ {
+ /* Apply action to all signals except those used by the
+ debugger. Silently skip those. */
+ allsigs = 1;
+ sigfirst = 0;
+ siglast = nsigs - 1;
+ }
+ else if (wordlen >= 1 && !strncmp (*argv, "stop", wordlen))
+ {
+ SET_SIGS (nsigs, sigs, signal_stop);
+ SET_SIGS (nsigs, sigs, signal_print);
+ }
+ else if (wordlen >= 1 && !strncmp (*argv, "ignore", wordlen))
+ {
+ UNSET_SIGS (nsigs, sigs, signal_program);
+ }
+ else if (wordlen >= 2 && !strncmp (*argv, "print", wordlen))
+ {
+ SET_SIGS (nsigs, sigs, signal_print);
+ }
+ else if (wordlen >= 2 && !strncmp (*argv, "pass", wordlen))
{
- /* It is the first argument--must be the signal to operate on. */
- if (digits == wordlen)
+ SET_SIGS (nsigs, sigs, signal_program);
+ }
+ else if (wordlen >= 3 && !strncmp (*argv, "nostop", wordlen))
+ {
+ UNSET_SIGS (nsigs, sigs, signal_stop);
+ }
+ else if (wordlen >= 3 && !strncmp (*argv, "noignore", wordlen))
+ {
+ SET_SIGS (nsigs, sigs, signal_program);
+ }
+ else if (wordlen >= 4 && !strncmp (*argv, "noprint", wordlen))
+ {
+ UNSET_SIGS (nsigs, sigs, signal_print);
+ UNSET_SIGS (nsigs, sigs, signal_stop);
+ }
+ else if (wordlen >= 4 && !strncmp (*argv, "nopass", wordlen))
+ {
+ UNSET_SIGS (nsigs, sigs, signal_program);
+ }
+ else if (digits > 0)
+ {
+ sigfirst = siglast = atoi (*argv);
+ if ((*argv)[digits] == '-')
{
- /* Numeric. */
- signum = atoi (p);
- if (signum <= 0 || signum >= NSIG)
- {
- p[wordlen] = '\0';
- error ("Invalid signal %s given as argument to \"handle\".", p);
- }
+ siglast = atoi ((*argv) + digits + 1);
}
- else
+ if (sigfirst > siglast)
{
- /* Symbolic. */
- signum = sig_number (p);
- if (signum == -1)
- error ("No such signal \"%s\"", p);
+ /* Bet he didn't figure we'd think of this case... */
+ signum = sigfirst;
+ sigfirst = siglast;
+ siglast = signum;
}
-
- if (signum == SIGTRAP || signum == SIGINT)
+ if (sigfirst < 0 || sigfirst >= nsigs)
{
- if (!query ("SIG%s is used by the debugger.\nAre you sure you want to change it? ", sig_abbrev (signum)))
- error ("Not confirmed.");
+ error ("Signal %d not in range 0-%d", sigfirst, nsigs - 1);
+ }
+ if (siglast < 0 || siglast >= nsigs)
+ {
+ error ("Signal %d not in range 0-%d", siglast, nsigs - 1);
}
}
- /* Else, if already got a signal number, look for flag words
- saying what to do for it. */
- else if (!strncmp (p, "stop", wordlen))
+ else if ((signum = strtosigno (*argv)) != 0)
{
- signal_stop[signum] = 1;
- signal_print[signum] = 1;
+ sigfirst = siglast = signum;
}
- else if (wordlen >= 2 && !strncmp (p, "print", wordlen))
- signal_print[signum] = 1;
- else if (wordlen >= 2 && !strncmp (p, "pass", wordlen))
- signal_program[signum] = 1;
- else if (!strncmp (p, "ignore", wordlen))
- signal_program[signum] = 0;
- else if (wordlen >= 3 && !strncmp (p, "nostop", wordlen))
- signal_stop[signum] = 0;
- else if (wordlen >= 4 && !strncmp (p, "noprint", wordlen))
+ else
{
- signal_print[signum] = 0;
- signal_stop[signum] = 0;
+ /* Not a number and not a recognized flag word => complain. */
+ error ("Unrecognized or ambiguous flag word: \"%s\".", *argv);
}
- else if (wordlen >= 4 && !strncmp (p, "nopass", wordlen))
- signal_program[signum] = 0;
- else if (wordlen >= 3 && !strncmp (p, "noignore", wordlen))
- signal_program[signum] = 1;
- /* Not a number and not a recognized flag word => complain. */
- else
+
+ /* If any signal numbers or symbol names were found, set flags for
+ which signals to apply actions to. */
+
+ for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
{
- error ("Unrecognized or ambiguous flag word: \"%s\".", p);
+ switch (signum)
+ {
+ case SIGTRAP:
+ case SIGINT:
+ if (!allsigs && !sigs[signum])
+ {
+ if (query ("%s is used by the debugger.\nAre you sure you want to change it? ", strsigno (signum)))
+ {
+ sigs[signum] = 1;
+ }
+ else
+ {
+ printf ("Not confirmed, unchanged.\n");
+ fflush (stdout);
+ }
+ }
+ break;
+ default:
+ sigs[signum] = 1;
+ break;
+ }
}
- /* Find start of next word. */
- p = nextarg;
- while (*p == ' ' || *p == '\t') p++;
+ argv++;
}
- NOTICE_SIGNAL_HANDLING_CHANGE;
+ target_notice_signals();
if (from_tty)
{
/* Show the results. */
sig_print_header ();
- sig_print_info (signum);
+ for (signum = 0; signum < nsigs; signum++)
+ {
+ if (sigs[signum])
+ {
+ sig_print_info (signum);
+ }
+ }
}
+
+ do_cleanups (old_chain);
}
/* 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. */
inf_status->restore_stack_info = restore_stack_info;
inf_status->proceed_to_finish = proceed_to_finish;
- bcopy (stop_registers, inf_status->stop_registers, REGISTER_BYTES);
+ memcpy (inf_status->stop_registers, stop_registers, REGISTER_BYTES);
record_selected_frame (&(inf_status->selected_frame_address),
&(inf_status->selected_level));
breakpoint_proceeded = inf_status->breakpoint_proceeded;
proceed_to_finish = inf_status->proceed_to_finish;
- bcopy (inf_status->stop_registers, stop_registers, REGISTER_BYTES);
+ memcpy (stop_registers, inf_status->stop_registers, REGISTER_BYTES);
/* The inferior can be gone if the user types "print exit(0)"
(and perhaps other times). */
_initialize_infrun ()
{
register int i;
+ register int numsigs;
add_info ("signals", signals_info,
"What debugger does when program gets various signals.\n\
Specify a signal number as argument to print info on that signal only.");
+ add_info_alias ("handle", "signals", 0);
add_com ("handle", class_run, handle_command,
"Specify how to handle a signal.\n\
-Args are signal number followed by flags.\n\
-Flags allowed are \"stop\", \"print\", \"pass\",\n\
- \"nostop\", \"noprint\" or \"nopass\".\n\
-Print means print a message if this signal happens.\n\
+Args are signal numbers and actions to apply to those signals.\n\
+Signal numbers may be numeric (ex. 11) or symbolic (ex. SIGSEGV).\n\
+Numeric ranges may be specified with the form LOW-HIGH (ex. 14-21).\n\
+The special arg \"all\" is recognized to mean all signals except those\n\
+used by the debugger, typically SIGTRAP and SIGINT.\n\
+Recognized actions include \"stop\", \"nostop\", \"print\", \"noprint\",\n\
+\"pass\", \"nopass\", \"ignore\", or \"noignore\".\n\
Stop means reenter debugger if this signal happens (implies print).\n\
+Print means print a message if this signal happens.\n\
Pass means let program see this signal; otherwise program doesn't know.\n\
+Ignore is a synonym for nopass and noignore is a synonym for pass.\n\
Pass and Stop may be combined.");
- for (i = 0; i < NSIG; i++)
+ stop_command = add_cmd ("stop", class_obscure, not_just_help_class_command,
+ "There is no `stop' command, but you can set a hook on `stop'.\n\
+This allows you to set a list of commands to be run each time execution\n\
+of the inferior program stops.", &cmdlist);
+
+ numsigs = signo_max () + 1;
+ signal_stop = (unsigned char *)
+ xmalloc (sizeof (signal_stop[0]) * numsigs);
+ signal_print = (unsigned char *)
+ xmalloc (sizeof (signal_print[0]) * numsigs);
+ signal_program = (unsigned char *)
+ xmalloc (sizeof (signal_program[0]) * numsigs);
+ for (i = 0; i < numsigs; i++)
{
signal_stop[i] = 1;
signal_print[i] = 1;