diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-01-19 11:48:11 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-01-19 11:48:11 -0500 |
commit | bc09b0c14fb713a9aec25e09b78499f3bc2441b5 (patch) | |
tree | 1be85b1497ab8383a20262964e0c9610988c42b5 /gdb/inferior.c | |
parent | 6e1e1966bac965c5a26b5e5cae69cb0ed21be4cc (diff) | |
download | gdb-bc09b0c14fb713a9aec25e09b78499f3bc2441b5.zip gdb-bc09b0c14fb713a9aec25e09b78499f3bc2441b5.tar.gz gdb-bc09b0c14fb713a9aec25e09b78499f3bc2441b5.tar.bz2 |
Make linux_nat_detach/thread_db_detach use the inferior parameter
This patch makes these two functions actually use the inferior parameter
added by the previous patch, instead of reading inferior_ptid. I chose
these two, because they are the one actually used when I detach on my
GNU/Linux system, so they were easy to test.
I took the opportunity to pass the inferior being detached to
inf_ptrace_detach_success, so it could use it too. From there, it made
sense to add an overload of detach_inferior that takes the inferior
directly rather than the pid, to avoid having to pass inf->pid only for
the callee to look up the inferior structure by pid.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_detach): Adjust call to
inf_ptrace_detach_success.
(inf_ptrace_detach_success): Add inferior parameter, use it
instead of inferior_ptid, pass it to detach_inferior.
* inf-ptrace.h (inf_ptrace_detach_success): Add inferior
parameter.
* inferior.c (detach_inferior): Add overload that takes an
inferior object.
* inferior.h (detach_inferior): Likewise.
* linux-nat.c (linux_nat_detach): Use the inf parameter, don't
use inferior_ptid, adjust call to inf_ptrace_detach_success.
* linux-thread-db.c (thread_db_detach): Use inf parameter.
Diffstat (limited to 'gdb/inferior.c')
-rw-r--r-- | gdb/inferior.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gdb/inferior.c b/gdb/inferior.c index 0b8f340..38b7369 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -253,10 +253,13 @@ exit_inferior_num_silent (int num) exit_inferior_1 (inf, 1); } +/* See inferior.h. */ + void -detach_inferior (int pid) +detach_inferior (inferior *inf) { - struct inferior *inf = find_inferior_pid (pid); + /* Save the pid, since exit_inferior_1 will reset it. */ + int pid = inf->pid; exit_inferior_1 (inf, 0); @@ -264,6 +267,14 @@ detach_inferior (int pid) printf_unfiltered (_("[Inferior %d detached]\n"), pid); } +/* See inferior.h. */ + +void +detach_inferior (int pid) +{ + detach_inferior (find_inferior_pid (pid)); +} + void inferior_appeared (struct inferior *inf, int pid) { |