From patchwork Fri Jun 17 09:53:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 13155 Received: (qmail 65498 invoked by alias); 17 Jun 2016 09:53:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 65486 invoked by uid 89); 17 Jun 2016 09:53:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pf0-f195.google.com Received: from mail-pf0-f195.google.com (HELO mail-pf0-f195.google.com) (209.85.192.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 17 Jun 2016 09:53:26 +0000 Received: by mail-pf0-f195.google.com with SMTP id t190so5932788pfb.2 for ; Fri, 17 Jun 2016 02:53:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=4r8oULKFBfcE68bZZyALcExyowD7Ny0/ZY3LD/SD2jk=; b=kQI8KkKo+8RPx+frTO1U/RNc4/H+xVCCDlosOeoHaGfCOzGOYSC0AhFruR5S7WS6sN puKObzUFJ6nTsHX8p5YnsWeu/nWeebakZfsy8qaEbhH3fzEBRtV5miWDnf7B5f+MvMYi A7fEAVgX5RwS4Bp/aQJC1xzUx9gcEt5IPmlTOTRH7WGxY4w3L0DVzUW+qRIP8DhzGO2G oo8A9Z2VBrs9DQJdNTQf/KJABWCXpu9MurfJBjp/jBRyT47lYO9vv7QNIOYP5cJJOdEY 9dj+clL80HPqiUYDMUjOMl6wi7yErBNIbPkdbb1c4bcuS9BoBv7yIrJwyaxZV80N2kb9 q+9w== X-Gm-Message-State: ALyK8tIokHWx2jzcHVTMkwxJCGfhkYgWGPzvBc000Mc+096YnsdQa2uRiYyUHTdaHLfmng== X-Received: by 10.98.18.9 with SMTP id a9mr1559010pfj.14.1466157204708; Fri, 17 Jun 2016 02:53:24 -0700 (PDT) Received: from E107787-LIN (gcc113.osuosl.org. [140.211.9.71]) by smtp.gmail.com with ESMTPSA id k69sm66967428pfc.41.2016.06.17.02.53.22 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 17 Jun 2016 02:53:23 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 04/12] Delete reinsert breakpoints from forked child References: <1464859846-15619-1-git-send-email-yao.qi@linaro.org> <1464859846-15619-5-git-send-email-yao.qi@linaro.org> <86twgxt4hg.fsf@gmail.com> <86porkt3yy.fsf@gmail.com> Date: Fri, 17 Jun 2016 10:53:13 +0100 In-Reply-To: (Pedro Alves's message of "Tue, 14 Jun 2016 12:40:17 +0100") Message-ID: <861t3wta46.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves writes: > I'd suggest reversing the condition logic, making it match the > comment, like this: > > if { $syscall == "vfork" > && ${follow-fork} == "parent" > && ${detach-on-fork} == "off" } { > # Both vforked child process and parent process are > # under GDB's control, but GDB follows the parent > # process only, which can't be run until vforked child > # finishes. Skip the test in this scenario. > continue > } > > break_cond_on_syscall $syscall ${follow-fork} ${detach-on-fork} OK, revert the condition logic, and patch below is pushed in. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index fbdcd2b..69aad53 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2016-06-17 Yao Qi + * gdb.base/step-over-syscall.exp (break_cond_on_syscall): New + parameters follow_fork and detach_on_fork. Set follow-fork-mode + and detach-on-fork. Adjust tests. + (top level): Invoke break_cond_on_syscall with combinations of + syscall, follow-fork-mode and detach-on-fork. + +2016-06-17 Yao Qi + * gdb.base/step-over-exit.c: New. * gdb.base/step-over-exit.exp: New. diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp index 7e5a719..e1d5ba1 100644 --- a/gdb/testsuite/gdb.base/step-over-syscall.exp +++ b/gdb/testsuite/gdb.base/step-over-syscall.exp @@ -176,9 +176,11 @@ proc step_over_syscall { syscall } { # Set a breakpoint with a condition that evals false on syscall # instruction. In fact, it tests GDBserver steps over syscall -# instruction. +# instruction. SYSCALL is the syscall the program calls. +# FOLLOW_FORK is either "parent" or "child". DETACH_ON_FORK is +# "on" or "off". -proc break_cond_on_syscall { syscall } { +proc break_cond_on_syscall { syscall follow_fork detach_on_fork } { with_test_prefix "break cond on target : $syscall" { set testfile "step-over-$syscall" @@ -195,6 +197,8 @@ proc break_cond_on_syscall { syscall } { # Delete breakpoint syscall insns to avoid interference with other syscalls. delete_breakpoints + gdb_test "set follow-fork-mode $follow_fork" + gdb_test "set detach-on-fork $detach_on_fork" # Create a breakpoint with a condition that evals false. gdb_test "break \*$syscall_insn_addr if main == 0" \ @@ -212,9 +216,27 @@ proc break_cond_on_syscall { syscall } { gdb_test "break clone_fn if main == 0" } - gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" - gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ - "continue to marker ($syscall)" + if { $syscall == "clone" } { + # follow-fork and detach-on-fork only make sense to + # fork and vfork. + gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ + "continue to marker" + } else { + if { $follow_fork == "child" } { + gdb_test "continue" "exited normally.*" "continue to end of inf 2" + if { $detach_on_fork == "off" } { + gdb_test "inferior 1" + gdb_test "break marker" "Breakpoint.*at.*" + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ + "continue to marker" + } + } else { + gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ + "continue to marker" + } + } } } @@ -243,7 +265,22 @@ gdb_test_multiple $test $test { } if { $cond_bp_target } { - break_cond_on_syscall "fork" - break_cond_on_syscall "vfork" - break_cond_on_syscall "clone" + + foreach_with_prefix detach-on-fork {"on" "off"} { + foreach_with_prefix follow-fork {"parent" "child"} { + foreach syscall { "fork" "vfork" "clone" } { + + if { $syscall == "vfork" + && ${follow-fork} == "parent" + && ${detach-on-fork} == "off" } { + # Both vforked child process and parent process are + # under GDB's control, but GDB follows the parent + # process only, which can't be run until vforked child + # finishes. Skip the test in this scenario. + continue + } + break_cond_on_syscall $syscall ${follow-fork} ${detach-on-fork} + } + } + } }