From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83692 invoked by alias); 26 Feb 2016 15:50:19 -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 83588 invoked by uid 89); 26 Feb 2016 15:50:18 -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-pa0-f65.google.com Received: from mail-pa0-f65.google.com (HELO mail-pa0-f65.google.com) (209.85.220.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 26 Feb 2016 15:50:16 +0000 Received: by mail-pa0-f65.google.com with SMTP id yy13so4651787pab.1 for ; Fri, 26 Feb 2016 07:50:16 -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:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=4dzk4zWsba61R/jiNlpOpMxWU9V/Dy53c27w2eFPRNY=; b=hE5M+TOE00WRv1lFm02CzN0Kg9GMbabd4jMGBX9XGfz6uwDItdHxqGgCJrqedvmbE7 BPU5a28NFzvKP4jGjT2FEx1QNRZKls1fi6LPDPnaXHpzP65oIpXyNiaBU9BFg/j5eAYV XPsKl9yvqBtRDLudBPXwchFyGqx7gUaLRLP/oSLh6w+hU9HCEjd36hBOeOSENO7PGl6c cTVcFrkXDrkvYv8FSbf553axFBUJ5l9kKtVulQv7/7GUhBmRSqPTkLK/lJ+hvx725uhh coYZsgszp3xUblTjkjFJ5fk4H+iQlcWhxRZYZNFVJ2jWoTi+g6IqCt8gcqprd5YMQWO0 VtxA== X-Gm-Message-State: AD7BkJIU4DfUavzo3QCjoGvTJhxQdI8h6nK/oXZV60LqfkNky0xiTONj21vnj3JU30u3aA== X-Received: by 10.66.244.15 with SMTP id xc15mr2952720pac.97.1456501814565; Fri, 26 Feb 2016 07:50:14 -0800 (PST) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id if4sm7113007pad.29.2016.02.26.07.50.11 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 26 Feb 2016 07:50:13 -0800 (PST) From: Yao Qi To: Luis Machado Cc: Yao Qi , Subject: Re: [PATCH 4/7] Step over fork/vfork syscall insn in gdbserver References: <1455892594-2294-1-git-send-email-yao.qi@linaro.org> <1456495426-7520-1-git-send-email-yao.qi@linaro.org> <1456495426-7520-5-git-send-email-yao.qi@linaro.org> <56D068E2.3070209@codesourcery.com> Date: Fri, 26 Feb 2016 15:50:00 -0000 In-Reply-To: <56D068E2.3070209@codesourcery.com> (Luis Machado's message of "Fri, 26 Feb 2016 12:01:54 -0300") Message-ID: <864mcvbheb.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00866.txt.bz2 Luis Machado writes: >> + # Delete breakpoint syscall insns to avoid interference to other sysca= lls. >> + delete_breakpoints > > "... interference with ..." Oops, I thought I fixed that to address your comment to v1. Sorry about th= at. --=20 Yao (=E9=BD=90=E5=B0=A7) =46rom 6fb354c27d4469e1b7b4ef3b94f74763cf6dd1e1 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Thu, 18 Feb 2016 12:39:57 +0000 Subject: [PATCH] Step over fork/vfork syscall insn in gdbserver 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: bre= ak on syscall insns continue^M Continuing.^M Remote connection closed^M (gdb) FAIL: gdb.base/disp-step-syscall.exp: fork: break cond on target: con= tinue 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=3D-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 =3D=3D 0 (gdb) c gdb/testsuite: 2016-02-26 Yao Qi * gdb.base/disp-step-syscall.exp (break_cond_on_syscall): New. If target supports condition evaluation on target, invoke break_cond_on_syscall for fork and vfork. diff --git a/gdb/testsuite/gdb.base/disp-step-syscall.exp b/gdb/testsuite/g= db.base/disp-step-syscall.exp index 3cf436d..0aac649 100644 --- a/gdb/testsuite/gdb.base/disp-step-syscall.exp +++ b/gdb/testsuite/gdb.base/disp-step-syscall.exp @@ -168,5 +168,62 @@ proc disp_step_cross_syscall { syscall } { } } =20 +# Set a breakpoint with a condition that evals false on syscall +# instruction. In fact, it tests GDBserver steps over syscall +# instruction. + +proc break_cond_on_syscall { syscall } { + with_test_prefix "break cond on target : $syscall" { + set testfile "disp-step-$syscall" + + set ret [setup $syscall] + + set syscall_insn_addr [lindex $ret 0] + set syscall_insn_next_addr [lindex $ret 1] + if { $syscall_insn_addr =3D=3D -1 } { + return -1 + } + + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|= )$syscall \\(\\).*" \ + "continue to $syscall" + # Delete breakpoint syscall insns to avoid interference with other syscal= ls. + delete_breakpoints + + + # Create a breakpoint with a condition that evals false. + gdb_test "break \*$syscall_insn_addr if main =3D=3D 0" \ + "Breakpoint \[0-9\]* at .*" + + gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at= .*" \ + "continue to marker ($syscall)" + } +} + disp_step_cross_syscall "fork" disp_step_cross_syscall "vfork" + +set testfile "disp-step-fork" +clean_restart $testfile +if { ![runto main] } then { + fail "run to main" + return -1 +} + +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 } { + break_cond_on_syscall "fork" + break_cond_on_syscall "vfork" +}