aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/common/linux-ptrace.c9
-rw-r--r--gdb/common/linux-ptrace.h1
-rw-r--r--gdb/linux-nat.c25
4 files changed, 43 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dc63863..79aded4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2014-06-08 Hui Zhu <hui@codesourcery.com>
+
+ * common/linux-ptrace.c (linux_disable_event_reporting): New
+ function.
+ * common/linux-ptrace.h (linux_disable_event_reporting): New
+ declaration.
+ * linux-nat.c (linux_child_follow_fork): Do a single step before
+ detach.
+
2014-06-07 Keith Seitz <keiths@redhat.com>
Revert:
diff --git a/gdb/common/linux-ptrace.c b/gdb/common/linux-ptrace.c
index efbd1ea..b140b08 100644
--- a/gdb/common/linux-ptrace.c
+++ b/gdb/common/linux-ptrace.c
@@ -476,6 +476,15 @@ linux_enable_event_reporting (pid_t pid)
(PTRACE_TYPE_ARG4) (uintptr_t) current_ptrace_options);
}
+/* Disable reporting of all currently supported ptrace events. */
+
+void
+linux_disable_event_reporting (pid_t pid)
+{
+ /* Set the options. */
+ ptrace (PTRACE_SETOPTIONS, pid, (PTRACE_TYPE_ARG3) 0, 0);
+}
+
/* Returns non-zero if PTRACE_OPTIONS is contained within
CURRENT_PTRACE_OPTIONS, therefore supported. Returns 0
otherwise. */
diff --git a/gdb/common/linux-ptrace.h b/gdb/common/linux-ptrace.h
index 881d9c9..cffb5ce 100644
--- a/gdb/common/linux-ptrace.h
+++ b/gdb/common/linux-ptrace.h
@@ -86,6 +86,7 @@ struct buffer;
extern void linux_ptrace_attach_fail_reason (pid_t pid, struct buffer *buffer);
extern void linux_ptrace_init_warnings (void);
extern void linux_enable_event_reporting (pid_t pid);
+extern void linux_disable_event_reporting (pid_t pid);
extern int linux_supports_tracefork (void);
extern int linux_supports_traceclone (void);
extern int linux_supports_tracevforkdone (void);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 6ca5c7e..3b117b5 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -414,6 +414,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \
if (detach_fork)
{
struct cleanup *old_chain;
+ int status = 0;
/* Before detaching from the child, remove all breakpoints
from it. If we forked, then this has already been taken
@@ -447,7 +448,29 @@ holding the child stopped. Try \"set detach-on-fork\" or \
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (child_lp);
- ptrace (PTRACE_DETACH, child_pid, 0, 0);
+
+ /* When debugging an inferior in an architecture that supports
+ hardware single stepping on a kernel without commit
+ 6580807da14c423f0d0a708108e6df6ebc8bc83d, the vfork child
+ process starts with the TIF_SINGLESTEP/X86_EFLAGS_TF bits
+ set if the parent process had them set.
+ To work around this, single step the child process
+ once before detaching to clear the flags. */
+
+ if (!gdbarch_software_single_step_p (target_thread_architecture
+ (child_lp->ptid)))
+ {
+ int status;
+
+ linux_disable_event_reporting (child_pid);
+ if (ptrace (PTRACE_SINGLESTEP, child_pid, 0, 0) < 0)
+ perror_with_name (_("Couldn't do single step"));
+ if (my_waitpid (child_pid, &status, 0) < 0)
+ perror_with_name (_("Couldn't wait vfork process"));
+ }
+
+ if (WIFSTOPPED (status))
+ ptrace (PTRACE_DETACH, child_pid, 0, WSTOPSIG (status));
do_cleanups (old_chain);
}