diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2011-04-27 13:29:15 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2011-04-27 13:29:15 +0000 |
commit | 2455069d930b37918b92281be109444d1e38dc6d (patch) | |
tree | 1dede0ae37934adb93839c5dbe7d705198704b2b /gdb/linux-nat.c | |
parent | 46c6471b0a591c6a53cf9bacdee6663cc63cd588 (diff) | |
download | gdb-2455069d930b37918b92281be109444d1e38dc6d.zip gdb-2455069d930b37918b92281be109444d1e38dc6d.tar.gz gdb-2455069d930b37918b92281be109444d1e38dc6d.tar.bz2 |
* target.h (struct target_ops): Remove to_notice_signals;
add to_pass_signals.
(target_notice_signals): Remove.
(target_pass_signals): Add prototype.
* target.c (update_current_target): Remove to_notice_signals;
mention to_pass_signals.
(target_pass_signals): New function.
(debug_to_notice_signals): Remove.
(setup_target_debug): Do not install debug_to_notice_signals.
* infrun.c (signal_pass): New global.
(resume): Call target_pass_signals.
(handle_inferior_event): Report all signals while stepping over
non-steppable watchpoint. Reset trap_expected to ensure breakpoints
are re-inserted when stepping over a signal handler.
(signal_cache_update): New function.
(signal_stop_update): Call it.
(signal_print_update): Likewise.
(signal_pass_update): Likewise.
(handle_command): Call signal_cache_update and target_pass_signals
instead of target_notice_signals.
(_initialize_infrun): Initialize signal_pass.
* linux-nat.c (pass_mask): New global.
(linux_nat_pass_signals): New function.
(linux_nat_create_inferior): Report all signals initially.
(linux_nat_attach): Likewise.
(linux_nat_resume): Use pass_mask to decide whether to directly
handle an inferior signal.
(linux_nat_wait_1): Likewise.
(linux_nat_add_target): Install to_pass_signals callback.
* nto-procfs.c (notice_signals): Remove.
(procfs_resume): Do not call notice_signals.
(procfs_notice_signals): Remove.
(procfs_pass_signals): New function.
(init_procfs_ops): Install to_pass_signals callback instead of
to_notice_signals callback.
(_initialize_procfs): Report all signals initially.
* procfs.c (procfs_notice_signals): Remove.
(procfs_pass_signals): New function.
(procfs_target): Install to_pass_signals callback instead of
to_notice_signals callback.
(register_gdb_signals): Remove.
(procfs_debug_inferior): Report all signals initially.
(procfs_init_inferior): Remove redundant register_gdb_signals call.
* remote.c (remote_pass_signals): Add numsigs and pass_signals
parameters; use them instead of calling signal_..._state routines.
(remote_notice_signals): Remove.
(remote_start_remote): Report all signals initially.
(remote_resume): Do not call remote_pass_signals.
(_initialize_remote): Install to_pass_signals callback instead of
to_notice_signals callback.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r-- | gdb/linux-nat.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 741d5f8..08f49e4 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1041,6 +1041,26 @@ restore_child_signals_mask (sigset_t *prev_mask) { sigprocmask (SIG_SETMASK, prev_mask, NULL); } + +/* Mask of signals to pass directly to the inferior. */ +static sigset_t pass_mask; + +/* Update signals to pass to the inferior. */ +static void +linux_nat_pass_signals (int numsigs, unsigned char *pass_signals) +{ + int signo; + + sigemptyset (&pass_mask); + + for (signo = 1; signo < NSIG; signo++) + { + int target_signo = target_signal_from_host (signo); + if (target_signo < numsigs && pass_signals[target_signo]) + sigaddset (&pass_mask, signo); + } +} + /* Prototypes for local functions. */ @@ -1506,6 +1526,9 @@ linux_nat_create_inferior (struct target_ops *ops, } #endif /* HAVE_PERSONALITY */ + /* Make sure we report all signals during startup. */ + linux_nat_pass_signals (0, NULL); + linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty); #ifdef HAVE_PERSONALITY @@ -1527,6 +1550,9 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty) int status; ptid_t ptid; + /* Make sure we report all signals during attach. */ + linux_nat_pass_signals (0, NULL); + linux_ops->to_attach (ops, args, from_tty); /* The ptrace base target adds the main thread with (pid,0,0) @@ -1885,19 +1911,9 @@ linux_nat_resume (struct target_ops *ops, if (lp->status && WIFSTOPPED (lp->status)) { - enum target_signal saved_signo; - struct inferior *inf; - - inf = find_inferior_pid (ptid_get_pid (lp->ptid)); - gdb_assert (inf); - saved_signo = target_signal_from_host (WSTOPSIG (lp->status)); - - /* Defer to common code if we're gaining control of the - inferior. */ - if (inf->control.stop_soon == NO_STOP_QUIETLY - && signal_stop_state (saved_signo) == 0 - && signal_print_state (saved_signo) == 0 - && signal_pass_state (saved_signo) == 1) + if (!lp->step + && WSTOPSIG (lp->status) + && sigismember (&pass_mask, WSTOPSIG (lp->status))) { if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, @@ -1907,7 +1923,7 @@ linux_nat_resume (struct target_ops *ops, /* FIXME: What should we do if we are supposed to continue this thread with a signal? */ gdb_assert (signo == TARGET_SIGNAL_0); - signo = saved_signo; + signo = target_signal_from_host (WSTOPSIG (lp->status)); lp->status = 0; } } @@ -3553,20 +3569,11 @@ retry: if (WIFSTOPPED (status)) { enum target_signal signo = target_signal_from_host (WSTOPSIG (status)); - struct inferior *inf; - - inf = find_inferior_pid (ptid_get_pid (lp->ptid)); - gdb_assert (inf); - /* Defer to common code if we get a signal while - single-stepping, since that may need special care, e.g. to - skip the signal handler, or, if we're gaining control of the - inferior. */ + /* When using hardware single-step, we need to report every signal. + Otherwise, signals in pass_mask may be short-circuited. */ if (!lp->step - && inf->control.stop_soon == NO_STOP_QUIETLY - && signal_stop_state (signo) == 0 - && signal_print_state (signo) == 0 - && signal_pass_state (signo) == 1) + && WSTOPSIG (status) && sigismember (&pass_mask, WSTOPSIG (status))) { /* FIMXE: kettenis/2001-06-06: Should we resume all threads here? It is not clear we should. GDB may not expect @@ -5675,6 +5682,7 @@ linux_nat_add_target (struct target_ops *t) t->to_detach = linux_nat_detach; t->to_resume = linux_nat_resume; t->to_wait = linux_nat_wait; + t->to_pass_signals = linux_nat_pass_signals; t->to_xfer_partial = linux_nat_xfer_partial; t->to_kill = linux_nat_kill; t->to_mourn_inferior = linux_nat_mourn_inferior; |