This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[gdbserver/linux] centralize enabling clone event reporting
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 2 May 2010 01:52:31 +0100
- Subject: [gdbserver/linux] centralize enabling clone event reporting
I've applied this patch to centralize enabling clone event reporting.
Actually, this scratches an itch I had --- I often want to test how
gdbserver behaves on kernels that don't support clone event
reporting, where we still need the thread event breakpoint. I
usually just comment out the linux_test_for_tracefork call, but that
only ends up forcing the use of the thread event breakpoint, it
doesn't cause clone events to also be disabled by itself.
Well, it does now.
--
Pedro Alves
2010-05-01 Pedro Alves <pedro@codesourcery.com>
* linux-low.c (linux_enable_event_reporting): New.
(linux_wait_for_event_1, handle_extended_wait): Use it.
---
gdb/gdbserver/linux-low.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
Index: src/gdb/gdbserver/linux-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-low.c 2010-05-01 15:12:29.000000000 +0100
+++ src/gdb/gdbserver/linux-low.c 2010-05-01 16:18:16.000000000 +0100
@@ -150,6 +150,7 @@ static void unstop_all_lwps (struct lwp_
static int finish_step_over (struct lwp_info *lwp);
static CORE_ADDR get_stop_pc (struct lwp_info *lwp);
static int kill_lwp (unsigned long lwpid, int signo);
+static void linux_enable_event_reporting (int pid);
/* True if the low target can hardware single-step. Such targets
don't need a BREAKPOINT_REINSERT_ADDR callback. */
@@ -396,7 +397,7 @@ handle_extended_wait (struct lwp_info *e
warning ("wait returned unexpected status 0x%x", status);
}
- ptrace (PTRACE_SETOPTIONS, new_pid, 0, (PTRACE_ARG4_TYPE) PTRACE_O_TRACECLONE);
+ linux_enable_event_reporting (new_pid);
ptid = ptid_build (pid_of (event_child), new_pid, 0);
new_lwp = (struct lwp_info *) add_lwp (ptid);
@@ -1318,8 +1319,7 @@ linux_wait_for_event_1 (ptid_t ptid, int
if (event_child->must_set_ptrace_flags)
{
- ptrace (PTRACE_SETOPTIONS, lwpid_of (event_child),
- 0, (PTRACE_ARG4_TYPE) PTRACE_O_TRACECLONE);
+ linux_enable_event_reporting (lwpid_of (event_child));
event_child->must_set_ptrace_flags = 0;
}
@@ -3415,6 +3415,15 @@ linux_write_memory (CORE_ADDR memaddr, c
/* Non-zero if the kernel supports PTRACE_O_TRACEFORK. */
static int linux_supports_tracefork_flag;
+static void
+linux_enable_event_reporting (int pid)
+{
+ if (!linux_supports_tracefork_flag)
+ return;
+
+ ptrace (PTRACE_SETOPTIONS, pid, 0, (PTRACE_ARG4_TYPE) PTRACE_O_TRACECLONE);
+}
+
/* Helper functions for linux_test_for_tracefork, called via clone (). */
static int