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]

Re: [RFA/commit 1/3] Do not call detach_breakpoints in inf_ttrace_follow_fork.


Hi Pedro,

Thanks for the review!

> Only in the fork case, and only from the child.  vfork is more
> complicated.  See linux-nat.c:linux_child_follow_fork:

Ooops! I did go a little too fast...

Would the attached patch be more correct?

Thank you,
-- 
Joel
>From c0dce68cb188083b11c8dfd1558f8a6058942f97 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Thu, 21 Jun 2012 14:58:16 -0400
Subject: [PATCH 1/3] inf_ttrace_follow_fork: detach_breakpoints called twice for child.

When debugging a program that forks with follow-fork set to follow
the parent, we end up calling detach_breakpoints for the child twice.
On ia64-hpux, this leads to a warning when trying to remove the
breakpoints the second time around, because the ia64 code detects
that the address does not point to a breakpoint instruction.

gdb/ChangeLog:

        * inf-ttrace.c (inf_ttrace_follow_fork): When following the
        parent, only call detach_breakpoints if tts.tts_event ==
        TTEVT_VFORK.
---
 gdb/inf-ttrace.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index 2c620d5..ddcbd42 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -467,7 +467,11 @@ inf_ttrace_follow_fork (struct target_ops *ops, int follow_child)
   else
     {
       inferior_ptid = ptid_build (pid, lwpid, 0);
-      detach_breakpoints (fpid);
+      /* Detach any remaining breakpoints in the child.  In the case
+	 of fork events, we do not need to do this, because breakpoints
+	 should have already been removed earlier.  */
+      if (tts.tts_event == TTEVT_VFORK)
+	detach_breakpoints (fpid);
 
       target_terminal_ours ();
       fprintf_unfiltered (gdb_stdlog,
-- 
1.7.0.4


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