From patchwork Sun Apr 21 22:26:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 88822 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 B56F4385841E for ; Sun, 21 Apr 2024 22:27:34 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 55F5D3858D28 for ; Sun, 21 Apr 2024 22:27:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55F5D3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 55F5D3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1034 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713738428; cv=none; b=YCKPxmFGTEEY5/Pp5Rj55nEj1X8F1xmVBRjgyDCwa3gMhKynU0Idj517selzNdFyBo2OOu8wbr+Vjq/dIHabXWvDtvnQPJerE9Zr0C1JPBAqhs74PJiFGyG/I4QdJtw4QHJciutSs3g4Z21LKPtLhVigPjeLfQ48Xx1PJFPocdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713738428; c=relaxed/simple; bh=7A7RJv4lF17bxCdvllQLMv6IQkLIx1G+gZj9b31LdT8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hiYkrUaeSHtlYVD7JTm6oaSddehMklXc9Go75GV5afcEZ4ppIaXaDfrHrShi2jM9QMna6JZIs1l110dVNQis/JZQLWREUqitnar9z90dsnl5g69ZHFSrzzVehIeM92V5IECB4E8IMpqfofuuYnCrk5FTimMG+s2PTOhk7MpRnsU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2a614b0391dso2897797a91.1 for ; Sun, 21 Apr 2024 15:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713738425; x=1714343225; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0KsfFZnnPjoqorOuN/BtZ5SUnq77YmgxhkNPxWURhGs=; b=PbUPZ8f9Bs75elfONBP1Js+K4y0c+rG1neVq8LFZ+xKZIdmgyVAGnq4CiXMp3zYk1m zMSTTsGk0IHOtkmdIdJJK7ZpfVq7OFgvLG0/kfTCvIz0/MOt7ZsqRpUKGteOF3Tprktm CGJHT3L2bWYtXx+yBFrceKZSOOEhm+56JCcNkDKmOnKxId/BNhSmPLFBV+iRCJr6lOGz SdxWieBh7frwbjaitK/eQPFtR8StLIwBy2eoTqHuKSN1EJCvx1Ruq//1PF/cDCc7Mn6+ Z45TseEwE/1mOY98eZOL2vnGsUOkjzUrnpDKXuB8QG3cy8D35wfqEWBRfR+A0tT+tON0 NJmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713738425; x=1714343225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0KsfFZnnPjoqorOuN/BtZ5SUnq77YmgxhkNPxWURhGs=; b=LgWSZdWC1j+2ZLfhhb5mER6ypEEpPyHdIqYYYqtFd6Z1b6obNLRtvh9bk4kyR/7HSE fbSlrKwI6efodV2RODmzc6UzZUgDo5wAXh+zncLEE3Sn9jlb9Mv5Yh99xGBHZyaaSMSX ytdah8aycnvsMsH60RuFueHQqvlUDe3YX0A9EmHKB6cZU1sMvLd/b8U0WyBxwgLIRjb6 vyJxH7lm0MhKZpfUyODm7rKWo7CV9zYkHWQL55qtlPRfw+ElXSCnJhbY7bIVAQBlrhWV ycMwqLRyIpH1oIhoZQUJBAUg395aWcjKo2JGYp1Qhrwr0Ai7D/CnAUgCW5lwpSxhjXXi j7qw== X-Gm-Message-State: AOJu0YxloVrAASNa83O2vBvSzYQGTiRV5LNGNz1FWfoaxNO2Whf7rTXe TQmkFAiT5YfzrkiIksTg8OIRp0DAv9K9Q3ltcNz4uSFVDV/8+9oDGS6giOhyaMQbvGD+NSeDrPY I X-Google-Smtp-Source: AGHT+IFz0cNWlhma5Jd16hofPBbNcuFLef2Wlmi4xc6gN+xfzc19r8jGfDxp3M2zL0Y/jMvSGYebmg== X-Received: by 2002:a17:90a:bb90:b0:2ad:4321:5bd3 with SMTP id v16-20020a17090abb9000b002ad43215bd3mr2441273pjr.15.1713738425303; Sun, 21 Apr 2024 15:27:05 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:3224:7231:e42f:1da5]) by smtp.gmail.com with ESMTPSA id cf6-20020a17090aebc600b0029c7963a33fsm8074245pjb.10.2024.04.21.15.27.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 15:27:04 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH v2 1/2] gdb/testsuite: Add libc_has_debug_info require helper Date: Sun, 21 Apr 2024 19:26:56 -0300 Message-ID: <20240421222657.1052635-2-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240421222657.1052635-1-thiago.bauermann@linaro.org> References: <20240421222657.1052635-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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 Factor the test for libc debug info out of gdb.base/relativedebug.exp to a new procedure. Also, change the "info sharedlibrary" test to explicitly detect when libc has debug info. --- gdb/testsuite/gdb.base/relativedebug.exp | 13 +----- gdb/testsuite/lib/gdb.exp | 54 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/gdb.base/relativedebug.exp b/gdb/testsuite/gdb.base/relativedebug.exp index bf8d76887122..f882a5cf1676 100644 --- a/gdb/testsuite/gdb.base/relativedebug.exp +++ b/gdb/testsuite/gdb.base/relativedebug.exp @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -require {!target_info exists gdb,nosignals} +require {!target_info exists gdb,nosignals} libc_has_debug_info standard_testfile .c @@ -28,17 +28,6 @@ clean_restart ${binfile} runto_main -set test "info sharedlibrary" -gdb_test_multiple $test $test { - -re ".*\(\\*\)\[^\r\n\]*/libc\.so.*$gdb_prompt $" { - # Skip the test below if libc doesn't have debug info. - unsupported "libc doesn't have debug info" - return -1 - } - -re ".*$gdb_prompt $" { - } -} - # pause () -> SIGALRM -> handler () -> abort () gdb_test "continue" "Program received signal SIGABRT.*" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index ddee928d5104..9af73bef8f09 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3699,6 +3699,60 @@ proc support_displaced_stepping {} { return 0 } +# Return 1 if GDB can find the libc debug info, or 0 and a reason string if it +# can't. This procedure is meant to be called by the require procedure. +gdb_caching_proc libc_has_debug_info {} { + global srcdir subdir gdb_prompt inferior_exited_re + + set me "libc_has_debug_info" + + # Compile a test program. + set src { + int main (void) { + printf ("Hello, world!\n"); + return 0; + } + } + if {![gdb_simple_compile $me $src executable {debug}]} { + return [list 0 "failed to compile test program"] + } + + # No error message, compilation succeeded so now run it via gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load "$obj" + runto_main + set test "info sharedlibrary libc.so" + gdb_test_multiple $test $test { + -re ".*\(\\*\)\[^\r\n\]*/libc\.so.*$gdb_prompt $" { + # Matched the "(*)" in the "Syms Read" columns which means: + # "(*): Shared library is missing debugging information." + verbose -log "$me: libc doesn't have debug info" + set libc_has_debug_info 0 + set message "libc doesn't have debug info" + } + -re ".*Yes\[ \t\]+\[^\r\n\]*/libc\.so.*$gdb_prompt $" { + verbose -log "$me: libc has debug info" + set libc_has_debug_info 1 + } + default { + set libc_has_debug_info 0 + set message "libc not found in the inferior" + } + } + gdb_exit + remote_file build delete $obj + + verbose "$me: returning $libc_has_debug_info" 2 + if { $libc_has_debug_info } { + return $libc_has_debug_info + } else { + return [list $libc_has_debug_info $message] + } +} + # Run a test on the target to see if it supports vmx hardware. Return 1 if so, # 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.