diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-01-19 11:47:24 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-01-19 11:47:24 -0500 |
commit | 6bd6f3b6569945700386847f624dc9e8b7f57450 (patch) | |
tree | 2b61af3adcec8d7760295c23a0d986892d58fe83 /gdb/procfs.c | |
parent | a3ab6cb01950e7d00519ddb3ead50eddff4fdcb8 (diff) | |
download | gdb-6bd6f3b6569945700386847f624dc9e8b7f57450.zip gdb-6bd6f3b6569945700386847f624dc9e8b7f57450.tar.gz gdb-6bd6f3b6569945700386847f624dc9e8b7f57450.tar.bz2 |
Remove args from target detach
I was looking into adding a parameter to target_detach, and was
wondering what the args parameter was. It seems like in the distant
past, it was possible to specify a signal number when detaching. That
signal was injected in the process before it was detached. There is an
example of code handling this in linux_nat_detach. With today's GDB, I
can't get this to work. Doing "detach 15" (15 == SIGTERM) doesn't work,
because detach is a prefix command and doesn't recognize the sub-command
15. Doing "detach inferiors 15" doesn't work because it expects a list
of inferior id to detach. Therefore, I don't think there's a way of
invoking detach_command with a non-NULL args. I also didn't find any
documentation related to this feature.
I assume that this feature stopped working when detach was made a prefix
command, which is in f73adfeb8bae36885e6ea248d12223ab0d5eb9cb (sorry,
there's no commit title) from 2006. Given that this feature was broken
for such a long time and we haven't heard anything (AFAIK, I did not
find any related bug), I think it's safe to remove it, as well as the
args parameter to target_detach. If someone wants to re-introduce it, I
would suggest rethinking the user interface, and in particular would
suggest using signal name instead of numbers.
I tried to fix all the impacted code, but I might have forgotten some
spots. It shouldn't be hard to fix if that's the case. I also couldn't
build-test everything I changed, especially the nto and solaris stuff.
gdb/ChangeLog:
* target.h (struct target_ops) <to_detach>: Remove args
parameter.
(target_detach): Likewise.
* target.c (dispose_inferior): Adjust.
(target_detach): Remove args parameter, adjust.
* aix-thread.c (aix_thread_detach): Adjust.
* corefile.c (core_file_command): Adjust.
* corelow.c (core_detach): Adjust.
* darwin-nat.c (darwin_detach): Adjust.
* gnu-nat.c (gnu_detach): Adjust.
* inf-ptrace.c (inf_ptrace_detach): Adjust.
* infcmd.c (detach_command): Adjust
* infrun.c (follow_fork_inferior): Adjust.
(handle_vfork_child_exec_or_exit): Adjust.
* linux-fork.c (linux_fork_detach): Remove args parameter.
* linux-fork.h (linux_fork_detach): Likewise.
* linux-nat.c (linux_nat_detach): Likewise, and adjust.
* linux-thread-db.c (thread_db_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* procfs.c (procfs_detach): Likewise.
(do_detach): Remove signo parameter.
* record.c (record_detach): Remove args parameter.
* record.h (record_detach): Likewise.
* remote-sim.c (gdbsim_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_detach): Likewise.
(extended_remote_detach): Likewise.
* sol-thread.c (sol_thread_detach): Likewise.
* target-delegates.c: Re-generate.
* top.c (struct qt_args) <args>: Remove field.
(kill_or_detach): Don't pass args.
(quit_force): Don't set args.
* windows-nat.c (windows_detach): Remove args parameter.
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r-- | gdb/procfs.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c index a939ded..491970a 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1829,7 +1829,7 @@ proc_iterate_over_threads (procinfo *pi, friends. */ static ptid_t do_attach (ptid_t ptid); -static void do_detach (int signo); +static void do_detach (); static void proc_trace_syscalls_1 (procinfo *pi, int syscallnum, int entry_or_exit, int mode, int from_tty); @@ -1924,14 +1924,10 @@ procfs_attach (struct target_ops *ops, const char *args, int from_tty) } static void -procfs_detach (struct target_ops *ops, const char *args, int from_tty) +procfs_detach (struct target_ops *ops, int from_tty) { - int sig = 0; int pid = ptid_get_pid (inferior_ptid); - if (args) - sig = atoi (args); - if (from_tty) { const char *exec_file; @@ -1945,7 +1941,7 @@ procfs_detach (struct target_ops *ops, const char *args, int from_tty) gdb_flush (gdb_stdout); } - do_detach (sig); + do_detach (); inferior_ptid = null_ptid; detach_inferior (pid); @@ -2023,16 +2019,13 @@ do_attach (ptid_t ptid) } static void -do_detach (int signo) +do_detach () { procinfo *pi; /* Find procinfo for the main process. */ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0); /* FIXME: threads */ - if (signo) - if (!proc_set_current_signal (pi, signo)) - proc_warn (pi, "do_detach, set_current_signal", __LINE__); if (!proc_set_traced_signals (pi, &pi->saved_sigset)) proc_warn (pi, "do_detach, set_traced_signal", __LINE__); @@ -2049,15 +2042,15 @@ do_detach (int signo) if (!proc_set_held_signals (pi, &pi->saved_sighold)) proc_warn (pi, "do_detach, set_held_signals", __LINE__); - if (signo || (proc_flags (pi) & (PR_STOPPED | PR_ISTOP))) - if (signo || !(pi->was_stopped) || - query (_("Was stopped when attached, make it runnable again? "))) + if (proc_flags (pi) & (PR_STOPPED | PR_ISTOP)) + if (!(pi->was_stopped) + || query (_("Was stopped when attached, make it runnable again? "))) { /* Clear any pending signal. */ if (!proc_clear_current_fault (pi)) proc_warn (pi, "do_detach, clear_current_fault", __LINE__); - if (signo == 0 && !proc_clear_current_signal (pi)) + if (!proc_clear_current_signal (pi)) proc_warn (pi, "do_detach, clear_current_signal", __LINE__); if (!proc_set_run_on_last_close (pi)) |