From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30093 invoked by alias); 9 Jun 2014 13:58:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30083 invoked by uid 89); 9 Jun 2014 13:58:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jun 2014 13:58:08 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s59Dw5uL032175 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Jun 2014 09:58:05 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s59Dw40c029936; Mon, 9 Jun 2014 09:58:04 -0400 Message-ID: <5395BD6C.8060901@redhat.com> Date: Mon, 09 Jun 2014 13:58:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Hui Zhu , gdb-patches ml Subject: [pushed] Fix a bunch of fork related regressions. (was: Re: [PATCH] Fix gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout) with Linux 2.6.32 and older version) References: <533D17E2.9070402@mentor.com> <538636AF.9040208@redhat.com> <539020AB.8050105@mentor.com> <53902DAA.4090602@redhat.com> <5394460F.7060201@mentor.com> In-Reply-To: <5394460F.7060201@mentor.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-06/txt/msg00372.txt.bz2 On 06/08/2014 12:16 PM, Hui Zhu wrote: > Thanks for your help. Committed as > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c077881afaedb9b74063bee992b3e472b4b6e9ca This caused a bunch of failures and time outs. Hui, that patch clearly wasn't tested... ;-) I've pushed the patch below to fix this. 8<-------------- [PATCH] Fix a bunch of fork related regressions. I'm seeing a ton of new FAILs in fork-related tests. Like, these and many more: +FAIL: gdb.base/disp-step-syscall.exp: vfork: continue to vfork (2nd time) (timeout) +FAIL: gdb.base/disp-step-syscall.exp: vfork: display/i $pc (timeout) ... -PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step +FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step (timeout) -PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp +FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp (timeout) ... FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: breakpoint (A) after the first fork (timeout) FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint A after the first fork (timeout) FAIL: gdb.base/fileio.exp: System(3) call (timeout) FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint B after the first fork (timeout) -PASS: gdb.base/multi-forks.exp: run to exit 2 +FAIL: gdb.base/multi-forks.exp: run to exit 2 (timeout) ... PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (hw) -PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw) +FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw) (timeout) PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (sw) -PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) +FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout) Three issues with https://sourceware.org/ml/gdb-patches/2014-06/msg00348.html (c077881a). - The inner 'status' local is shadowing the outer 'status' local, thus PTRACE_DETACH is never seeing the status it intends to pass on the inferior. - With that fixed, we then try to pass down the SIGTRAP that results from the step to the inferior. Need to filter out signals that are in nopass state. - For software single-step archs, the current code is equivalent to: int status = 0; if (WIFSTOPPED (status)) ptrace (PTRACE_DETACH, child_pid, 0, WSTOPSIG (status)); ... and status == 0 is WIFEXITED, not WIFSTOPPED, so we're never detaching. gdb/ 2014-06-09 Pedro Alves * linux-nat.c (linux_child_follow_fork): Initialize status with W_STOPCODE (0) instead of 0. Remove shodowing 'status' local from inner block. Only pass the signal to PTRACE_DETACH if in pass state. --- gdb/testsuite/ChangeLog | 7 +++++++ gdb/linux-nat.c | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2b5cca3..6c78bdd 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-06-09 Pedro Alves + + * linux-nat.c (linux_child_follow_fork): Initialize status with + W_STOPCODE (0) instead of 0. Remove shodowing 'status' local from + inner block. Only pass the signal to PTRACE_DETACH if in pass + state. + 2014-06-09 Gary Benson * gdb.base/sigall.c [Functions to send signals]: Reorder to diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 3b117b5..c9677ca 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -414,7 +414,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ if (detach_fork) { struct cleanup *old_chain; - int status = 0; + int status = W_STOPCODE (0); /* Before detaching from the child, remove all breakpoints from it. If we forked, then this has already been taken @@ -460,8 +460,6 @@ holding the child stopped. Try \"set detach-on-fork\" or \ 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")); @@ -470,7 +468,15 @@ holding the child stopped. Try \"set detach-on-fork\" or \ } if (WIFSTOPPED (status)) - ptrace (PTRACE_DETACH, child_pid, 0, WSTOPSIG (status)); + { + int signo; + + signo = WSTOPSIG (status); + if (signo != 0 + && !signal_pass_state (gdb_signal_from_host (signo))) + signo = 0; + ptrace (PTRACE_DETACH, child_pid, 0, signo); + } do_cleanups (old_chain); } -- 1.9.0