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: 790692 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp2079593wrm; Sun, 21 Apr 2024 15:27:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/LEc2lS5z+48+hPGavwXw3JF7YtGTAO6T1ZHVk5rZB7E1Yx+UQMPlmcOMURWCFYHbMKUYYwNOg6G8eRRzhKS8 X-Google-Smtp-Source: AGHT+IGHdO8O6jHZn70KD5y9OWt2rLrR4HCj2Isr1rp8P3tx3d4sTz+6veJmXIaj9vpDLr1eVxMP X-Received: by 2002:a05:620a:3bc9:b0:78d:4bd1:5fca with SMTP id yf9-20020a05620a3bc900b0078d4bd15fcamr9216916qkn.41.1713738449001; Sun, 21 Apr 2024 15:27:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713738448; cv=pass; d=google.com; s=arc-20160816; b=AOy0rMVo2GCXUaCuo6JWAB2q6AoVq4A6fgHywLPQ9vGacctlDLLz6+b34SiaEJFbLx ERB0O9klnObGtyQo1AB3Guw2XZg2G6RLRveg55sLIkJ6V5PNyB+qmCt/vQZt59wGV07k c+biY8gSn+FDkYDkSUAs/VjhHftBJQ+cnR/I8CM+ytoHnAwiwqAzQTvkklzgY2Z2Fgua hwRQYAwPn5JPDSxkq9IrxpuGDRSuqNHJxBYp9q2IBX4JS7mBUgAk0D5mo+cy2NU9mbUV 0FBTWpDkd+MbsuA7nsmypvt04bTF7VWpbsg5spDuAIILQw3pmAoduHKpPBx9Yxjp9+p4 I2SA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=0KsfFZnnPjoqorOuN/BtZ5SUnq77YmgxhkNPxWURhGs=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=NLt8+5wG7ygB22thZEXL82dWM2+HqD54ocuFMxRNx4PRiaVjrs+DiewMC204jDQDrE 8BVUGsC9j3oSqYf8lU1qOM0PSXZjAiF9e9mbwH4QE6FR9EU6lKZF5Kh5rHz5obiC4Jdy LoHxXkExFrCP/kqdWfLxp+crAX3dNm/hFMtKI6ddsDlMFnvTFnqQjQygCe2jyCSqjxTd keVDLzA1e7f+jd5ro2wAgjFloIwAc6PnmVnoNufb6T8FXCbFb765V0DLMuGgLKIlh9uE oXxXOZJpBm7+cUp7m5AgaHhU6l8LFpuSr23wYdOuk56dx3IwSXSZWShrGVEUWKjlKxV0 LgPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PbUPZ8f9; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z12-20020ae9f44c000000b0078f0ec9420bsi5423837qkl.565.2024.04.21.15.27.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 15:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PbUPZ8f9; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A06D0384AB42 for ; Sun, 21 Apr 2024 22:27:28 +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-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+patch=linaro.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.