From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108542 invoked by alias); 19 Feb 2016 14:36:55 -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 108288 invoked by uid 89); 19 Feb 2016 14:36:54 -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=1536, sk:0x00007, Hx-languages-length:3967, 257 X-HELO: mail-pf0-f175.google.com Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 19 Feb 2016 14:36:48 +0000 Received: by mail-pf0-f175.google.com with SMTP id c10so53731128pfc.2 for ; Fri, 19 Feb 2016 06:36:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=lL/oj9F7SvvhSz+lzBV0cdKWggH3aZl34Van56F3XUg=; b=IPVoaGRLJKZmT6iAvGuEyk+hygrYtkt1zmNaZIQct+PYhGz/fpOJBBMIXv0bO/QgaQ aNNVV8o0Xl3Dy4MYUPbveHIlC81WiI4+t7atLT6qzWp1db0+dOS4jU886Lwl46FruH0h /c5kEr02meMjFnCbWKgVclX+5v1mHjk5mDqlwx6CGd6SGNXDDB5GlgdV4V/+fA6M1iMA adSl1iDkA0BLHklXRhtGRUW0MBm0o5Vvw/6wIe6vCHB6M8B5qiptjMqtQXngFbhSXD1s 4r9aW4BOcIKQn8oEdBCGCC6DtOw3XzyLfITNEy8cdzkzagwZ+jotE9rViaqjUns+Kykj TDRw== X-Gm-Message-State: AG10YOTcjZFXvU3R1MYB5mau//JQY7PTZxxaEfgfMGJSYTm+0dWPru44i9pycYwQqzl3IA== X-Received: by 10.98.64.202 with SMTP id f71mr18470931pfd.113.1455892606477; Fri, 19 Feb 2016 06:36:46 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id kq3sm18452546pab.24.2016.02.19.06.36.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Feb 2016 06:36:45 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 5/8] Step over fork/vfork syscall insn in gdbserver Date: Fri, 19 Feb 2016 14:36:00 -0000 Message-Id: <1455892594-2294-6-git-send-email-yao.qi@linaro.org> In-Reply-To: <1455892594-2294-1-git-send-email-yao.qi@linaro.org> References: <1455892594-2294-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00594.txt.bz2 We can also extend disp-step-syscall.exp to test GDBserver step over breakpoint on syscall instruction. That is, we set a breakpoint with a false condition on syscall instruction, so that GDBserver will step over it. This test triggers a GDBserver internal error, which can be fixed by this series. (gdb) PASS: gdb.base/disp-step-syscall.exp: fork: break cond on target: break on syscall insns continue^M Continuing.^M Remote connection closed^M (gdb) FAIL: gdb.base/disp-step-syscall.exp: fork: break cond on target: continue to fork again In GDBserver, there is an internal error, /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:1922: A problem internal to GDBserver has been detected. unsuspend LWP 25554, suspended=-1 the simplified reproducer is like, $ ./gdb ./testsuite/outputs/gdb.base/disp-step-syscall/disp-step-fork (gdb) b main (gdb) c (gdb) disassemble fork // in order to find the address of insn 'syscall' .... 0x00007ffff7ad6023 <+179>: syscall (gdb) b *0x00007ffff7ad6023 if main == 0 (gdb) c gdb/testsuite: 2016-02-19 Yao Qi * gdb.base/disp-step-fork.c (main): Increase loop boundary. * gdb.base/disp-step-vfork.c (main): Likewise. * gdb.base/disp-step-syscall.exp (disp_step_cross_syscall): Test breakpoint condition evaluated on the target side. --- gdb/testsuite/gdb.base/disp-step-fork.c | 2 +- gdb/testsuite/gdb.base/disp-step-syscall.exp | 38 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/disp-step-vfork.c | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/disp-step-fork.c b/gdb/testsuite/gdb.base/disp-step-fork.c index d8d602f..6d477ea 100644 --- a/gdb/testsuite/gdb.base/disp-step-fork.c +++ b/gdb/testsuite/gdb.base/disp-step-fork.c @@ -26,7 +26,7 @@ main (void) { int i, pid; - for (i = 0; i < 4; i++) + for (i = 0; i < 6; i++) { pid = fork (); if (pid == 0) /* child */ diff --git a/gdb/testsuite/gdb.base/disp-step-syscall.exp b/gdb/testsuite/gdb.base/disp-step-syscall.exp index 9e43fbb..53ac1e1 100644 --- a/gdb/testsuite/gdb.base/disp-step-syscall.exp +++ b/gdb/testsuite/gdb.base/disp-step-syscall.exp @@ -153,6 +153,44 @@ proc disp_step_cross_syscall { syscall } { } } + with_test_prefix "break cond on target" { + set cond_bp_target 1 + + set test "set breakpoint condition-evaluation target" + gdb_test_multiple $test $test { + -re "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n$gdb_prompt $" { + # Target doesn't support breakpoint condition + # evaluation on its side. + set cond_bp_target 0 + } + -re "^$test\r\n$gdb_prompt $" { + } + } + + if { $cond_bp_target } { + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ + "continue to $syscall" + + # Create a breakpoint with the condition which is false. + set syscall_insn_bp 0 + gdb_test_multiple "break \*$syscall_insn_addr if main == 0" \ + "break on syscall insns" { + -re "Breakpoint (\[0-9\]*) at .*$gdb_prompt $" { + set syscall_insn_bp $expect_out(1,string) + pass "break on syscall insns" + } + } + + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ + "continue to $syscall again" + + # Delete breakpoint syscall insns to avoid interference to + # other syscalls. + gdb_test_no_output "delete $syscall_insn_bp" \ + "delete break $syscall insn" + } + } + gdb_test_no_output "delete $syscall_bp" "delete break $syscall" gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ diff --git a/gdb/testsuite/gdb.base/disp-step-vfork.c b/gdb/testsuite/gdb.base/disp-step-vfork.c index 17bef55..35665ab 100644 --- a/gdb/testsuite/gdb.base/disp-step-vfork.c +++ b/gdb/testsuite/gdb.base/disp-step-vfork.c @@ -25,7 +25,7 @@ main (void) { int i, pid; - for (i = 0; i < 4; i++) + for (i = 0; i < 6; i++) { pid = vfork (); if (pid == -1) -- 1.9.1