This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2 1/2] gdbserver: Set Linux ptrace options ASAP
- From: Josh Stone <jistone at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: philippe dot waroquiers at skynet dot be, sergiodj at redhat dot com, palves at redhat dot com, eliz at gnu dot org, xdje42 at gmail dot com, Josh Stone <jistone at redhat dot com>
- Date: Wed, 25 Nov 2015 18:53:44 -0800
- Subject: [PATCH v2 1/2] gdbserver: Set Linux ptrace options ASAP
- Authentication-results: sourceware.org; auth=none
- References: <1446169946-28117-1-git-send-email-jistone at redhat dot com>
The ptrace options should be set as soon as we know a thread is stopped,
so no events can be missed. There's an arch-setup early return that was
effectively delaying this update before, and I found for instance that
the first syscall event wouldn't be properly reported with TRACESYSGOOD.
It's now more similar to the way that gdb/linux-nat.c handles it.
gdb/gdbserver/ChangeLog:
2015-11-25 Josh Stone <jistone@redhat.com>
* linux-low.c (linux_low_filter_event): Set ptrace options as soon as
each thread is stopped, even before arch-specific setup.
---
gdb/gdbserver/linux-low.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index e3a56a7c1690..9f577aefee1b 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -2249,6 +2249,16 @@ linux_low_filter_event (int lwpid, int wstat)
gdb_assert (WIFSTOPPED (wstat));
+ /* Set ptrace flags ASAP, so no events can be missed. */
+ if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags)
+ {
+ struct process_info *proc = find_process_pid (pid_of (thread));
+ int options = linux_low_ptrace_options (proc->attached);
+
+ linux_enable_event_reporting (lwpid, options);
+ child->must_set_ptrace_flags = 0;
+ }
+
if (WIFSTOPPED (wstat))
{
struct process_info *proc;
@@ -2276,15 +2286,6 @@ linux_low_filter_event (int lwpid, int wstat)
}
}
- if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags)
- {
- struct process_info *proc = find_process_pid (pid_of (thread));
- int options = linux_low_ptrace_options (proc->attached);
-
- linux_enable_event_reporting (lwpid, options);
- child->must_set_ptrace_flags = 0;
- }
-
/* Be careful to not overwrite stop_pc until
check_stopped_by_breakpoint is called. */
if (WIFSTOPPED (wstat) && WSTOPSIG (wstat) == SIGTRAP
--
2.5.0