This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 1/2] gdbserver: Set Linux ptrace options ASAP


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]