From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cmvdEPKz/V/PQwAAWB0awg (envelope-from ) for ; Tue, 12 Jan 2021 09:36:34 -0500 Received: by simark.ca (Postfix, from userid 112) id 374721EF7E; Tue, 12 Jan 2021 09:36:34 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D01141E940 for ; Tue, 12 Jan 2021 09:36:33 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1AD50386F033; Tue, 12 Jan 2021 14:36:33 +0000 (GMT) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 47F94386F01F for ; Tue, 12 Jan 2021 14:36:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 47F94386F01F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6C3D4AC24 for ; Tue, 12 Jan 2021 14:36:29 +0000 (UTC) Date: Tue, 12 Jan 2021 15:36:27 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Fix gdb.base/step-over-syscall.exp with -m32 Message-ID: <20210112143626.GA23956@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, When executing test-case gdb.base/step-over-syscall.exp with target board unix/-m32, we run into: ... (gdb) x/2i $pc^M => 0xf7fd5155 <__kernel_vsyscall+5>: sysenter ^M 0xf7fd5157 <__kernel_vsyscall+7>: int $0x80^M (gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: \ pc before/after syscall instruction stepi^M [Detaching after fork from child process 23593]^M 0xf7fd5159 in __kernel_vsyscall ()^M 1: x/i $pc^M => 0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp^M (gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: stepi fork insn print /x $pc^M $2 = 0xf7fd5159^M (gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: pc after stepi FAIL: gdb.base/step-over-syscall.exp: fork: displaced=off: \ pc after stepi matches insn addr after syscall ... The test tries to verify that after doing a stepi at a syscall insn, the $pc is matching the insn after the syscall insn. However, in the case that the syscall insn is "sysenter", the stepi will land further away, so in this case: ... 0xf7fd5155 <__kernel_vsyscall+5>: sysenter ^M 0xf7fd5157 <__kernel_vsyscall+7>: int $0x80^M 0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp^M ... the stepi will land at 0xf7fd5159 instead of 0xf7fd5157. Fix this by detecting the sysenter/int sequence and adjusting the expected pc. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Fix gdb.base/step-over-syscall.exp with -m32 gdb/testsuite/ChangeLog: 2021-01-12 Tom de Vries * gdb.base/step-over-syscall.exp: Detect and handle sysenter/int sequence. --- gdb/testsuite/gdb.base/step-over-syscall.exp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp index e6f58aecd3d..ecfb7be481d 100644 --- a/gdb/testsuite/gdb.base/step-over-syscall.exp +++ b/gdb/testsuite/gdb.base/step-over-syscall.exp @@ -155,11 +155,34 @@ proc setup { syscall } { gdb_test_multiple "x/2i \$pc" "pc before/after syscall instruction" { -re "x/2i .*=> ($hex) .*:.*$syscall_insn.* ($hex) .*:.*$gdb_prompt $" { set syscall_insn_addr $expect_out(1,string) + set actual_syscall_insn $expect_out(2,string) set next_insn_addr $expect_out(3,string) pass $gdb_test_name } } + # If we encounter a sequence: + # 0xf7fd5155 <__kernel_vsyscall+5>: sysenter + # 0xf7fd5157 <__kernel_vsyscall+7>: int $0x80 + # 0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp + # then a stepi at sysenter will step over the int insn, so make sure + # next_insn_addr points after the int insn. + if { $actual_syscall_insn == "sysenter" } { + set test "pc after sysenter instruction" + set re_int_insn "\[ \t\]*int\[ \t\]\[^\r\n\]*" + set re [multi_line \ + "x/2i $hex" \ + "\[^\r\n\]* $hex \[^\r\n\]*:$re_int_insn" \ + "\[^\r\n\]* ($hex) \[^\r\n\]*:\[^\r\n\]*"] + gdb_test_multiple "x/2i $next_insn_addr" $test { + -re -wrap $re { + set next_insn_addr $expect_out(1,string) + } + -re -wrap "" { + } + } + } + if {[gdb_test "stepi" "x/i .*=>.*" "stepi $syscall insn"] != 0} { return { -1, -1 } }