From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29941 invoked by alias); 27 Jan 2020 20:32:11 -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 29879 invoked by uid 89); 27 Jan 2020 20:32:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HTo:D*ca X-HELO: mail-qt1-f196.google.com Received: from mail-qt1-f196.google.com (HELO mail-qt1-f196.google.com) (209.85.160.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Jan 2020 20:32:08 +0000 Received: by mail-qt1-f196.google.com with SMTP id w8so8455820qts.11 for ; Mon, 27 Jan 2020 12:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PAthoTkHyQZfSr4GNl/cmLNysVR6pcjIjrH4NJFYEes=; b=H4OHjoiggRp5dD8+ow2K6R06JomIrvSdmph8WARlfBzsiRivLi7vstatK11ECzkzgx Lx8NtYVc09wsIu47VYeVv28CDJAoiPJ3m+pWsIU29+yiLtxBLCZJK6nnVJjKFxH3/TdH Rdb8b3hRkATj1yQD+LU/GCKMrYi6PV84WYGt84YAg2taaN508EivWhy71pADzzW0Lc1J oxwsmkUEu6vrpGK/5ncob5OXfAQx3uJ5GEC13agCH2puc/PJmRcAzT2IdqYSJ9fGz1rY 2CoabU9ntoFa2sw/wmkJUyINx3UTwA4yVyUmYci7qg8NU+lTZac6qxfRvPoNB9Jv9KTx OPig== Return-Path: Received: from [192.168.0.185] ([191.34.221.247]) by smtp.gmail.com with ESMTPSA id t23sm1922214qtp.82.2020.01.27.12.32.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Jan 2020 12:32:06 -0800 (PST) Subject: Re: [PATCH v3] Harden gdb.base/step-over-syscall.exp To: Simon Marchi , gdb-patches@sourceware.org Cc: Alan.Hayward@arm.com References: <20200115203645.26360-1-luis.machado@linaro.org> <20200127181336.13893-1-luis.machado@linaro.org> <491a48b7-e3ad-9372-5d45-1d645f94fd19@simark.ca> From: Luis Machado Message-ID: Date: Mon, 27 Jan 2020 21:25: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: <491a48b7-e3ad-9372-5d45-1d645f94fd19@simark.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2020-01/txt/msg00887.txt.bz2 On 1/27/20 3:48 PM, Simon Marchi wrote: > 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 > Thanks for the review and suggestions. Pushed now.