From patchwork Fri Dec 23 08:14:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 62347 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA435385B500 for ; Fri, 23 Dec 2022 08:15:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA435385B500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671783301; bh=4EUkfZ7ByXi5u/FqHy/9xyd2bOkhSJqLce1pjfJL1h0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=NDSYRvlfgmLoG421w1uy8JcBjrpHu2SqFYmOCEseHtGakWbHSFhzYdko+iWKyn8rs zY+Dg26TA0rsT2yeOBWWcy/K/TTriknwlrv0fiRBrK7x8BtHpl73VtAl3fe0Tm+Jp3 KtzLsHIq2X9mJ3qNQybvAFRd6ZVT4Oh6L3hCPpIw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 17FCA38582A3 for ; Fri, 23 Dec 2022 08:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17FCA38582A3 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9229F38D77 for ; Fri, 23 Dec 2022 08:14:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8B664138E4 for ; Fri, 23 Dec 2022 08:14:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UpzaIWljpWMhUgAAMHmgww (envelope-from ) for ; Fri, 23 Dec 2022 08:14:33 +0000 MIME-Version: 1.0 Date: Fri, 23 Dec 2022 08:14:33 +0000 To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Fix gdb.cp/step-and-next-inline.exp with -fcf-protection User-Agent: Roundcube Webmail Message-ID: <2feda36aa35dd25ac27cba5b7ae86f2c@suse.de> X-Sender: tdevries@suse.de X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Disposition: attachment; filename=0001-gdb-testsuite-Fix-gdb.cp-step-and-next-inline.exp-wi.patch; size=2917 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: , X-Patchwork-Original-From: tdevries via Gdb-patches From: Tom de Vries Reply-To: tdevries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From cca0c8600e15879b9fa7bd7d3e4f18e1ab008759 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 20 Dec 2022 15:23:16 +0100 Subject: [PATCH] [gdb/testsuite] Fix gdb.cp/step-and-next-inline.exp with -fcf-protection On Ubuntu 22.04.1 x86_64, I run into: ... (gdb) PASS: gdb.cp/step-and-next-inline.exp: no_header: not in inline 1 next^M 51 if (t != NULL^M (gdb) FAIL: gdb.cp/step-and-next-inline.exp: no_header: next step 1 ... This is due to -fcf-protection, which adds the endbr64 at the start of get_alias_set: ... 0000000000001180 <_Z13get_alias_setP4tree>: 1180: f3 0f 1e fa endbr64 1184: 48 85 ff test %rdi,%rdi ... so the extra insn gets an is-stmt line number entry: ... INDEX LINE ADDRESS IS-STMT PROLOGUE-END ... 11 50 0x0000000000001180 Y 12 50 0x0000000000001180 13 51 0x0000000000001184 Y 14 54 0x0000000000001184 ... and when stepping into get_alias_set we step to line 50: ... (gdb) PASS: gdb.cp/step-and-next-inline.exp: no_header: in main step^M get_alias_set (t=t@entry=0x555555558018 ) at step-and-next-inline.cc:50^M 50 {^M ... In contrast, with -fcf-protection=none, we get: ... 0000000000001170 <_Z13get_alias_setP4tree>: 1170: 48 85 ff test %rdi,%rdi ... and: ... INDEX LINE ADDRESS IS-STMT PROLOGUE-END ... 11 50 0x0000000000001170 Y 12 51 0x0000000000001170 Y 13 54 0x0000000000001170 ... so when stepping into get_alias_set we step to line 51: ... (gdb) PASS: gdb.cp/step-and-next-inline.exp: no_header: in main step^M get_alias_set (t=t@entry=0x555555558018 ) at step-and-next-inline.cc:51^M 51 if (t != NULL^M ... Fix this by rewriting the gdb_test issuing the step command to check which line the step lands on, and issuing an extra next if needed. Tested on x86_64-linux, both with and without -fcf-protection=none. PR testsuite/29920 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29920 --- gdb/testsuite/gdb.cp/step-and-next-inline.exp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline.exp b/gdb/testsuite/gdb.cp/step-and-next-inline.exp index 8b2ad2766bc..36fac239e2f 100644 --- a/gdb/testsuite/gdb.cp/step-and-next-inline.exp +++ b/gdb/testsuite/gdb.cp/step-and-next-inline.exp @@ -60,7 +60,16 @@ proc do_test { use_header } { } gdb_test "bt" "\\s*\\#0\\s+main.*" "in main" - gdb_test "step" ".*" "step into get_alias_set" + set line1 {\t\{} + set line2 {\t if \(t != NULL} + gdb_test_multiple "step" "step into get_alias_set" { + -re -wrap $line1 { + gdb_test "next" $line2 $gdb_test_name + } + -re -wrap $line2 { + pass $gdb_test_name + } + } gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \ "not in inline 1" -- 2.34.1