From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id B87193858D38 for ; Mon, 22 Apr 2024 23:07:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B87193858D38 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 B87193858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713827229; cv=none; b=bgQYtfTo/iEdaoBqxY572h8qb4XGf35joe4B+gA//9hEucnJJmNrz5Lv+ApeFonMCuDq+aQBSSpjztwLhN+UtvDIGxtxqbIkeIDl9F0xvkZJDge39EVQsKGufxwlioVrkgJNrytuztR9xYonGrJ0+s5jv8RMAkNp0rripdWHfbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713827229; c=relaxed/simple; bh=A03BjH/kUFd+vwoQ4oYZY+4chL5U+3YWws8JzC+jmY8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=r7YdUfV4a14qG87LwtC7E//duksMXCeyPKn3iSPJQmg7rxyTUzaM6Cnls+cIfARZsJMcPiuebocsLUxL6kVrqJTaY0wFRzQIOElxN8KfPeBcK/v1fK0rNp8VTP5RfoKczW0TA8SqJzXbdBjHuwUq9BeBrkmjGRTE3cHZhMbGF8A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5d8b887bb0cso3808372a12.2 for ; Mon, 22 Apr 2024 16:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713827226; x=1714432026; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Waq7f27F5L6ywgsBNtXlKHPIZFYfTqbirajDo2U5lxc=; b=AOizKtGK4GYQszYXVGfqSsyvM451u2TsuvqAqCYnsnlz+G4gtZWUh6hALNnGDVvRac TVe+DVP17jEAc0P1TH9mZkvb5LN2TCHXxKSMW82vCyGrDTY1tEqpubMHyESQoMFl6cMU bVW5Qt7KbALZVT9QSehMfgv9XBG2RTqiSJqrQvYnuEIWCmdz16qKglTWBL/PVkeTUKyM +ne+KOjdqWVylxH5TTTPEtY63YHyEO7Tmkae+oDtnBQrRdOCuzJgmq/ddrZ1/BcrBtXG FrccmrHV1BJ/2O/6lC0DbWTit+GpsKMRDUeB1l0HZ+FY/jffPfQcwAnPHX/C/IsrM/XZ UZvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713827226; x=1714432026; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Waq7f27F5L6ywgsBNtXlKHPIZFYfTqbirajDo2U5lxc=; b=hoqpiaja3k15lsmdT/TJXJPTvka7lY70vpaKUobChCikg8PICpSHU+Eu149stMzy3r SSzYlhwWQr/XwYJeDfRxZKfkEbchApo+7i/0BCNE9J8CTflFcu7EZBu2BrdiyWVeAABv vqluDcQjZXL2JaqoJX687IxUomZUvwKgcRPrT4AlWorTeob758IhmrB0UBvIIVU6ZHgb okqKJSpjKpJR55lvef9Ctkb0fFjNgeovKfFp7ebQbIUrZMFqk7Y+sAJe0Vqb+ZPYoiwl auJ0vwtWqXBzcHTJVXt/DDw5JubY+nIncflghpd8zzTOKTkC868f3SfPnZIjdhRpyeTw NzQQ== X-Gm-Message-State: AOJu0Yzas9GFgeE1q4KCBTZBzo5RScj/qc3JdWVFJaAm7ECT4tKef8of CKsKHbVLrutHtDzRC/wFzH2m1VL1ZrBsH+nFFBi2k7R6HNSlMgCizIn0jI2L+ckSI1bfFLsbh5s s X-Google-Smtp-Source: AGHT+IF3dn17P087Vwl+PnMQY8CD9jYwRKkfpRSSd6jJJ78wJjT34JBI1JNBxEL2Wcrq+k8VMclWzw== X-Received: by 2002:a17:90a:5e46:b0:2ad:e74a:f4f4 with SMTP id u6-20020a17090a5e4600b002ade74af4f4mr4713125pji.6.1713827225755; Mon, 22 Apr 2024 16:07:05 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:25e4:a74b:cf9:5423]) by smtp.gmail.com with ESMTPSA id sv14-20020a17090b538e00b002ab3bffb765sm8226906pjb.32.2024.04.22.16.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 16:07:05 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Kevin Buettner , Luis Machado Subject: [PATCH v3 1/2] gdb/testsuite: Add libc_has_debug_info require helper Date: Mon, 22 Apr 2024 20:06:59 -0300 Message-ID: <20240422230700.1173173-2-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240422230700.1173173-1-thiago.bauermann@linaro.org> References: <20240422230700.1173173-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 List-Id: 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. --- As mentioned in the cover letter, the new testcase doesn't use this helper procedure anymore so this is an optional patch. I think it's a nice cleanup, though I didn't find any other testcase that need it so perhaps the new helper is not as useful as I imagine it to be. I'm fine with not committing this patch. Changes in v3: - Include in test program to avoid error when using clang (suggested by Kevin). gdb/testsuite/gdb.base/relativedebug.exp | 13 +----- gdb/testsuite/lib/gdb.exp | 56 ++++++++++++++++++++++++ 2 files changed, 57 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 cbd37fd30947..1e26937c0dcf 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3699,6 +3699,62 @@ 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 { + #include + + 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.