From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23810 invoked by alias); 27 Jan 2020 18:48:57 -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 23650 invoked by uid 89); 27 Jan 2020 18:48:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=H*r:sk:server-, H*M:9372 X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Jan 2020 18:48:21 +0000 Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A33461E5F7; Mon, 27 Jan 2020 13:48:15 -0500 (EST) Subject: Re: [PATCH v3] Harden gdb.base/step-over-syscall.exp To: Luis Machado , gdb-patches@sourceware.org Cc: Alan.Hayward@arm.com References: <20200115203645.26360-1-luis.machado@linaro.org> <20200127181336.13893-1-luis.machado@linaro.org> From: Simon Marchi Message-ID: <491a48b7-e3ad-9372-5d45-1d645f94fd19@simark.ca> Date: Mon, 27 Jan 2020 19:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200127181336.13893-1-luis.machado@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-01/txt/msg00884.txt.bz2 On 2020-01-27 1:13 p.m., Luis Machado wrote: > @@ -75,39 +100,78 @@ proc setup { syscall } { > # Hit the breakpoint on $syscall for the second time. In this time, > # the address of syscall insn and next insn of syscall are recorded. > > - gdb_test "display/i \$pc" ".*" > + # Check if the first instruction we stopped at is the syscall one. > + set syscall_insn_addr -1 > + gdb_test_multiple "display/i \$pc" "fetch first stop pc" { > + -re "display/i .*: x/i .*=> ($hex) .*:.*$syscall_insn.*$gdb_prompt $" { > + set insn_addr $expect_out(1,string) > > - # Single step until we see a syscall insn or we reach the > - # upper bound of loop iterations. > - set msg "find syscall insn in $syscall" > - set steps 0 > - set max_steps 1000 > - gdb_test_multiple "stepi" $msg { > - -re ".*$syscall_insn.*$gdb_prompt $" { > - pass $msg > + # Is the syscall number the correct one? > + if {[syscall_number_matches $syscall]} { > + set syscall_insn_addr $insn_addr > + } > + pass $gdb_test_name > } > - -re "x/i .*=>.*\r\n$gdb_prompt $" { > - incr steps > - if {$steps == $max_steps} { > - fail $msg > - } else { > - send_gdb "stepi\n" > - exp_continue > + -re ".*$gdb_prompt $" { > + pass $gdb_test_name > + } > + } > + > + # If we are not at the syscall instruction yet, keep looking for it with > + # stepi commands. > + if {$syscall_insn_addr == -1} { > + # Single step until we see a syscall insn or we reach the > + # upper bound of loop iterations. > + set msg "find syscall insn in $syscall" This can be a literal in the gdB_test_multiple call, we don't need `msg` anymore. The patch LGTM with that fixed. Simon