From patchwork Wed Mar 19 12:32:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= X-Patchwork-Id: 108398 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 08F35385841F for ; Wed, 19 Mar 2025 12:34:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08F35385841F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PYBYUY/A X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id F07143857C6D for ; Wed, 19 Mar 2025 12:33:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F07143857C6D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F07143857C6D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742387581; cv=none; b=gP5DNoxdwBzZU7O58emMhKkN3xW1+25Zb0oAWXcozq9jnva+Z612znGpEdsqUhh4624dVyCkjINhfdDtZjrdY2PiUl1nE3ELTBOCuYkN2rdwwW3f4tHtGRahsqJPk7HjfUjLVVUk4ZgHVE/tuBZ9kZyoIHinRni4W7DpVBGocWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742387581; c=relaxed/simple; bh=MvBIo2VNlfQp9HL3tewudMPI1Ea/Lz10vb4UxkZVG9A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=s1oKrYZMHzmLHxSuhZtFxuzlr2du4ltOzEIra6vl8A9scSzamBbSDrJiiQA9GoNzfHkFeVH+pPQP/HPPPb9RKMNHmvaQSNYYWR7F1Dpf+MrKrBPIkOwhyfSd5bfUnQbQ8rQOjHOLRiDmiBBCV0fojtGYVmy+rTxSh4w6/+TzyNs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F07143857C6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742387580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q59up6yDHPsB0CpE9GvdUKSJxJxhmWV1d2YMqkFXwb0=; b=PYBYUY/A40QtgmJx6QYXvf2MJ9oRe3pCxEKG/XDmoKX89B0g/cvlF30SwZ2ZGR88JnDCdW AapLQPwsUB5Ufa0k1xDq0COB2Q/K6bruSAJyLoXOYgaQp9nMy2VNEvsaBANimNhgK258m9 VFKKCM+/+rAP8dg4sKWWolpJAepaROA= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-YCE6Rr2nPY2w2ua3MsmLeA-1; Wed, 19 Mar 2025 08:32:59 -0400 X-MC-Unique: YCE6Rr2nPY2w2ua3MsmLeA-1 X-Mimecast-MFC-AGG-ID: YCE6Rr2nPY2w2ua3MsmLeA_1742387578 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 628BC180AB1C for ; Wed, 19 Mar 2025 12:32:58 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.22.12]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C5F01956094; Wed, 19 Mar 2025 12:32:56 +0000 (UTC) From: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= To: gdb-patches@sourceware.org Cc: ahajkova@redhat.com Subject: [PATCH] Add gdb.base/set-solib-absolute-prefix.exp Date: Wed, 19 Mar 2025 13:32:54 +0100 Message-ID: <20250319123254.351647-1-ahajkova@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: beiOKjD29xQavpWlGeLMFL9fRAPOfWSoB8RQ227ydgY_1742387578 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_W, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: Alexandra Hajkova This test tests GDB displays backtrace properly when sysroot is set to non-existing directory and GDB attempts to load the vDSO from the filesystem and cannot. This test was present in Fedora for a long time and was originally written by Jan Kratochvil for this fix 829a902da291e72ad17e8c44fa8d9ead3db41b1f. Co-Authored-By: Jan Kratochvil --- .../gdb.base/set-solib-absolute-prefix.c | 32 +++++++++++ .../gdb.base/set-solib-absolute-prefix.exp | 54 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 gdb/testsuite/gdb.base/set-solib-absolute-prefix.c create mode 100644 gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp diff --git a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c new file mode 100644 index 00000000000..685a22e0d77 --- /dev/null +++ b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2012-2025 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Global var used to generate filler code. */ +volatile int global_var = 0; + +int +main () +{ + global_var++; + global_var++; + + abort (); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp new file mode 100644 index 00000000000..21555ae29c4 --- /dev/null +++ b/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp @@ -0,0 +1,54 @@ +# Copyright 2012-2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Compile a 32-bit x86 executable and then stop within a system call. +# Change the sysroot to a non-existent directory, GDB should try (and +# fail) to reload the currently loaded shared libraries. However, GDB +# should retain the symbols for the vDSO library as that is not loaded +# from the file system. +# +# Check the backtrace to ensure that the __kernel_vsyscall symbol is +# still in the backtrace, this indicates GDB still has the vDSO +# symbols available. + +require {is_any_target "i?86-*-linux*" "x86_64-*-linux*"} +standard_testfile + +# The binary must be compiled as 32-bit so that the system call +# `__kernel_vsyscall' originates from vDSO. +set flags { debug } +if { ![is_ilp32_target] } { + lappend flags "additional_flags=-m32" +} + +if { [prepare_for_testing $testfile.exp $testfile $srcfile $flags] } { + return +} + +if { ![runto_main] } { + return +} + +set non_existing_directory "/BOGUS_DIRECT" +if { [file exists $non_existing_directory] } { + return +} + +gdb_test "continue" "Program received signal SIGABRT, Aborted.*" \ + "continue until abort" +gdb_test "set sysroot $non_existing_directory" \ + ".*warning: Unable to find dynamic linker breakpoint function.*" \ + "set sysroot" +gdb_test "bt" "__kernel_vsyscall.*" "backtrace with __kernel_vsyscall"