aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-11-19 22:23:28 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2017-11-19 22:23:28 -0500
commit578290ecafb83e93f0ac695df586b65dac5e8c5d (patch)
tree2fcc9936f98ddf9c1c343859d89c04d90c985fe3 /gdb
parenteca55aec1d919b69e0d61c91367f8b4d25bc7c43 (diff)
downloadgdb-578290ecafb83e93f0ac695df586b65dac5e8c5d.zip
gdb-578290ecafb83e93f0ac695df586b65dac5e8c5d.tar.gz
gdb-578290ecafb83e93f0ac695df586b65dac5e8c5d.tar.bz2
Remove usage of find_inferior when calling kill_one_lwp_callback
Replace with for_each_thread. gdb/gdbserver/ChangeLog: * linux-low.c (kill_one_lwp_callback): Return void, take argument directly, don't filter on pid. (linux_kill): Use for_each_thread.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbserver/ChangeLog6
-rw-r--r--gdb/gdbserver/linux-low.c18
2 files changed, 14 insertions, 10 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 26fd062..d891b2d 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2017-11-19 Simon Marchi <simon.marchi@ericsson.com>
+ * linux-low.c (kill_one_lwp_callback): Return void, take
+ argument directly, don't filter on pid.
+ (linux_kill): Use for_each_thread.
+
+2017-11-19 Simon Marchi <simon.marchi@ericsson.com>
+
* linux-low.c (need_step_over_p): Return bool, remove dummy
argument.
(linux_resume, proceed_all_lwps): Use find_thread.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 33eb4f8..274263a 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1356,17 +1356,13 @@ kill_wait_lwp (struct lwp_info *lwp)
perror_with_name ("kill_wait_lwp");
}
-/* Callback for `find_inferior'. Kills an lwp of a given process,
+/* Callback for `for_each_thread'. Kills an lwp of a given process,
except the leader. */
-static int
-kill_one_lwp_callback (thread_info *thread, void *args)
+static void
+kill_one_lwp_callback (thread_info *thread, int pid)
{
struct lwp_info *lwp = get_thread_lwp (thread);
- int pid = * (int *) args;
-
- if (thread->id.pid () != pid)
- return 0;
/* We avoid killing the first thread here, because of a Linux kernel (at
least 2.6.0-test7 through 2.6.8-rc4) bug; if we kill the parent before
@@ -1378,11 +1374,10 @@ kill_one_lwp_callback (thread_info *thread, void *args)
if (debug_threads)
debug_printf ("lkop: is last of process %s\n",
target_pid_to_str (thread->id));
- return 0;
+ return;
}
kill_wait_lwp (lwp);
- return 0;
}
static int
@@ -1399,7 +1394,10 @@ linux_kill (int pid)
first, as PTRACE_KILL will not work otherwise. */
stop_all_lwps (0, NULL);
- find_inferior (&all_threads, kill_one_lwp_callback , &pid);
+ for_each_thread (pid, [&] (thread_info *thread)
+ {
+ kill_one_lwp_callback (thread, pid);
+ });
/* See the comment in linux_kill_one_lwp. We did not kill the first
thread in the list, so do so now. */