From patchwork Wed Dec 7 10:35:54 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: 61653 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 AC2C2383F23F for ; Wed, 7 Dec 2022 10:36:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC2C2383F23F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670409378; bh=LJaGcBxX0sGP3xDrjTdNdOm2tsYXLfaPaIOb3eA+t+k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WmqEQJ8J3noLrUXfnoAkD3d9JmHVpgLZNmx+eeEWS5AeMpuUDlV9MBSIOS1ZwjuNb wIP+vur+cUERpCDFweeYdIQcMsx6EDmFEonwPnFuRVIFvRKmJp4+RB6rY380hEuy7v Y0JYLuoWZqfwRSZ9iwp/ZsqhIcdbYAHet/xIQ+fk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B1337385517B for ; Wed, 7 Dec 2022 10:35:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B1337385517B Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 D6B9021C25 for ; Wed, 7 Dec 2022 10:35:54 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id BF32F134CD for ; Wed, 7 Dec 2022 10:35:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id wBRwLYpskGPsEAAAGKfGzw (envelope-from ) for ; Wed, 07 Dec 2022 10:35:54 +0000 To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Add KFAILs in gdb.base/longjmp.exp Date: Wed, 7 Dec 2022 11:35:54 +0100 Message-Id: <20221207103554.23121-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 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 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: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Add KFAILs in test-case gdb.base/longjmp.exp for PR gdb/26967, covering various ways that gdb is unable to recover the longjmp target if the libc probe is not supported. Tested on x86_64-linux. --- gdb/testsuite/gdb.base/longjmp.exp | 82 ++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) base-commit: 3198c863f62ab2253a3405e677489b90c403cf1c diff --git a/gdb/testsuite/gdb.base/longjmp.exp b/gdb/testsuite/gdb.base/longjmp.exp index 10e440bfca8..0f78304a14a 100644 --- a/gdb/testsuite/gdb.base/longjmp.exp +++ b/gdb/testsuite/gdb.base/longjmp.exp @@ -31,6 +31,43 @@ if {![runto_main]} { return 0 } +# With a libc with probes, all tests should pass. +# +# Without probes, we can still set a break on longjmp, but getting the longjmp +# target may not work, in the following cases: +# - gdbarch_get_longjmp_target_p (gdbarch) == 0: not implemented. +# - gdbarch_get_longjmp_target (gdbarch) == 0: for instance on amd64 if +# tdep->jb_pc_offset == -1. +# - gdbarch_get_longjmp_target (gdbarch) != 0: if we have a glibc with +# pointer mangling ( https://sourceware.org/glibc/wiki/PointerEncryption ) +# then we retrieve a mangled longjmp target that needs to be demangled. +# For instance on amd64 with target board unix/-m32. +# +# Pointer demangling is currently not implemented for any target. +# For the amd64 case, this would require copying for instance this: +# 48 c1 ca 11 ror $0x11,%rdx +# 64 48 33 14 25 30 00 xor %fs:0x30,%rdx +# into a scratch space, save the register set, set %rdx to the mangled +# longjmp target, displaced-step through the two insn and read the +# demangled longjmp target from %rdx, and restore the register set. +# +# The failure mode in the first two cases is that the next degrades into a +# continue. The failure mode in the latter case is a failure to set a +# breakpoint (matched by re_cannot_insert_bp) and a stop in longjmp. +# +# We detect the different failure modes and kfail these. + +set have_longjmp_probe 0 +gdb_test_multiple "info probes stap libc ^longjmp$" "" { + -re -wrap "No probes matched\\." { + pass $gdb_test_name + } + -re -wrap "\r\nstap\[ \t\]+libc\[ \t\]+longjmp\[ \t\]+.*" { + pass $gdb_test_name + set have_longjmp_probe 1 + } +} + set bp_miss_step_1 [gdb_get_line_number "miss_step_1"] set bp_miss_step_2 [gdb_get_line_number "miss_step_2"] @@ -38,6 +75,12 @@ set bp_start_test_1 [gdb_get_line_number "patt1"] set bp_start_test_2 [gdb_get_line_number "patt2"] set bp_start_test_3 [gdb_get_line_number "patt3"] +set re_cannot_insert_bp \ + [multi_line \ + "Warning:" \ + "Cannot insert breakpoint $decimal\\." \ + "Cannot access memory at address $hex"] + # # Pattern 1 - simple longjmp. # @@ -69,7 +112,18 @@ with_test_prefix "pattern 1" { gdb_test "next" "miss_step_1.*" "next into safety net" } -re "miss_step_1.*$gdb_prompt $" { - fail $msg + if { $have_longjmp_probe } { + fail $gdb_test_name + } else { + kfail $gdb_test_name "gdb/26967" + } + } + -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" { + if { $have_longjmp_probe } { + fail $gdb_test_name + } else { + kfail $gdb_test_name "gdb/26967" + } } } } @@ -105,7 +159,18 @@ with_test_prefix "pattern 2" { gdb_test "next" "miss_step_2.*" "next into safety net" } -re "miss_step_2.*$gdb_prompt $" { - fail $msg + if { $have_longjmp_probe } { + fail $gdb_test_name + } else { + kfail $gdb_test_name "gdb/26967" + } + } + -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" { + if { $have_longjmp_probe } { + fail $gdb_test_name + } else { + kfail $gdb_test_name "gdb/26967" + } } } } @@ -125,5 +190,16 @@ with_test_prefix "pattern 3" { gdb_test "continue" "patt3.*" "continue to breakpoint at pattern start" } - gdb_test "next" "longjmp caught.*" "next over pattern" + gdb_test_multiple "next" "next over pattern" { + -re -wrap "longjmp caught.*" { + pass $gdb_test_name + } + -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" { + if { $have_longjmp_probe } { + fail $gdb_test_name + } else { + kfail $gdb_test_name "gdb/26967" + } + } + } }