summaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-04-21 14:20:36 +0100
committerPedro Alves <pedro@palves.net>2022-04-29 12:33:27 +0100
commitd51926f06a7f4854bebdd71dcb0a78dbaa2f4168 (patch)
treeaeeb243c5da413dc2dc2b3c8d539e7f65471312b /gdb/linux-nat.c
parent8a2ef851861706a113a080a1ff3d91c81449704d (diff)
downloadbinutils-gdb-d51926f06a7f4854bebdd71dcb0a78dbaa2f4168.tar.gz
Slightly tweak and clarify target_resume's interface
The current target_resume interface is a bit odd & non-intuitive. I've found myself explaining it a couple times the recent past, while reviewing patches that assumed STEP/SIGNAL always applied to the passed in PTID. It goes like this today: - if the passed in PTID is a thread, then the step/signal request is for that thread. - otherwise, if PTID is a wildcard (all threads or all threads of process), the step/signal request is for inferior_ptid, and PTID indicates which set of threads run free. Because GDB always switches the current thread to "leader" thread being resumed/stepped/signalled, we can simplify this a bit to: - step/signal are always for inferior_ptid. - PTID indicates the set of threads that run free. Still not ideal, but it's a minimal change and at least there are no special cases this way. That's what this patch does. It renames the PTID parameter to SCOPE_PTID, adds some assertions to target_resume, and tweaks target_resume's description. In addition, it also renames PTID to SCOPE_PTID in the remote and linux-nat targets, and simplifies their implementation a little bit. Other targets could do the same, but they don't have to. Change-Id: I02a2ec2ab3a3e9b191de1e9a84f55c17cab7daaf
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index dff8d07d3f7..740cc0ddfc0 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1595,32 +1595,22 @@ resume_set_callback (struct lwp_info *lp)
}
void
-linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
+linux_nat_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo)
{
struct lwp_info *lp;
- int resume_many;
linux_nat_debug_printf ("Preparing to %s %s, %s, inferior_ptid %s",
step ? "step" : "resume",
- ptid.to_string ().c_str (),
+ scope_ptid.to_string ().c_str (),
(signo != GDB_SIGNAL_0
? strsignal (gdb_signal_to_host (signo)) : "0"),
inferior_ptid.to_string ().c_str ());
- /* A specific PTID means `step only this process id'. */
- resume_many = (minus_one_ptid == ptid
- || ptid.is_pid ());
-
/* Mark the lwps we're resuming as resumed and update their
last_resume_kind to resume_continue. */
- iterate_over_lwps (ptid, resume_set_callback);
+ iterate_over_lwps (scope_ptid, resume_set_callback);
- /* See if it's the current inferior that should be handled
- specially. */
- if (resume_many)
- lp = find_lwp_pid (inferior_ptid);
- else
- lp = find_lwp_pid (ptid);
+ lp = find_lwp_pid (inferior_ptid);
gdb_assert (lp != NULL);
/* Remember if we're stepping. */
@@ -1669,11 +1659,12 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
return;
}
- if (resume_many)
- iterate_over_lwps (ptid, [=] (struct lwp_info *info)
- {
- return linux_nat_resume_callback (info, lp);
- });
+ /* No use iterating unless we're resuming other threads. */
+ if (scope_ptid != lp->ptid)
+ iterate_over_lwps (scope_ptid, [=] (struct lwp_info *info)
+ {
+ return linux_nat_resume_callback (info, lp);
+ });
linux_nat_debug_printf ("%s %s, %s (resume event thread)",
step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",