From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id DA1793858CD1 for ; Sat, 20 Apr 2024 21:33:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA1793858CD1 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 DA1793858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713648800; cv=none; b=SYxAHnljOE6aWdXzB37QI48GU+sKCB+7P0sGAsLXOmqmY+A1SkcWW28d0+9joMnGo5ECsiodXSc6end1eqyEFgpczkXUzLBP7HHpO2WaX7MxHijT3+3nw0R/PMED9ypsgOP/oJuZhxtVc29o3Pl7TgUHXcTlxhMac5r8Fn98LIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713648800; c=relaxed/simple; bh=7A7RJv4lF17bxCdvllQLMv6IQkLIx1G+gZj9b31LdT8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JSTw9BpObYn9A6h6VQDEdv2QaAvjx0ijyPnyX5JhHp3JP9VGkSQCGL9QvmuBVY5AInrDT3xwdLJr9Qdw1GkCa2uxhiqY+z/IXpfoTvlTdBSUmbkXPWy8BacA0/V6FUpcx5zJy4IBvOEm4NHquIAmDiREsoH5/2EJI+fR9LuRNGA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2a2d248a2e1so2973014a91.0 for ; Sat, 20 Apr 2024 14:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713648796; x=1714253596; 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=gHTCluC85oEL42VwmdNrpuRU7rK8ByusoVPxg9Mi/V8pkLuIJJQO88Dnq3Jcv4aua8 RukdGxD3161NYdWrPCgDHL6+RxdY3U0ZOkUIfdF/88VMQJ6wWUXHnpocqhj+CrwOYc0E RiLM6a0nHvEHYBtMyZ2RpGFD2HLt1AGyTTKiTxZZOcEoZu/A7m3qr04jYIfAVeSHGw9b dxlq/PQzJrP5/lovXFOj8OfZR1xFal+eoTYdy4/4wMSXa3zzq+7txJd5DQVgtsGjjDII /mwIjKBz23r4E4Zn2JN5cYk5cwtd+oDK4po+8OlIDtrsQpFqey0/zP9H10Op8o3eULt8 WrUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713648796; x=1714253596; 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=UUjaGpb/fliQKbRlIu8nCDAl9/iN02VtQXEvMJd6+Ze23aK5F9b87iL69W4AYSTyEP X50cFIm/Tk6gk86E3vuVhlWGq4MG9soQaqZZaSK3U5KvDFlLJOhjYgSTHYUZyEFUMeaH t/7d/lOo+1iCpXl+b/fbqMFDgeby2ehOj20VRhuCaKuA68ln4KrjNweTSg/xLGjwTV3+ hThys6H0olTpXK5Qmbn+wyUmdE2dSq0xX627QgeMt+DLVFdzvHAUH+KBTjjyreMEW2F2 +Q66ZEJ1YxMItBTbOBP0dTsw7fpk4iwOnA1iGqyjOuBfMNjNOXSULUdBU0fkyWxGGavt hr1w== X-Gm-Message-State: AOJu0YztdRtuZSXYPKOGIRtK4fpXvY7EndRAbnZoLcSVJkCefA5uccLq 3PRTjvR7NOsnOZ9XQ3Sdvk6LnDVz7o1bywH5ek0vqsMcTy/Hzv7WjBUVOQ0iVHRmTS89G2fMn6E d X-Google-Smtp-Source: AGHT+IGkhAifHGwIBO+vb656k3k+E7m2ErxLsPGGYbU/QeCHtS7HQGjVNyFE+HU0rXGTmRXvddq8gQ== X-Received: by 2002:a17:90a:3944:b0:2a4:b04b:d204 with SMTP id n4-20020a17090a394400b002a4b04bd204mr8649999pjf.7.1713648795801; Sat, 20 Apr 2024 14:33:15 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:3bb7:c4a7:c946:d2b6]) by smtp.gmail.com with ESMTPSA id z88-20020a17090a6d6100b002a2dbbbb36asm7365762pjj.37.2024.04.20.14.33.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 14:33:15 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdb/testsuite: Add libc_has_debug_info require helper Date: Sat, 20 Apr 2024 18:33:06 -0300 Message-ID: <20240420213307.976401-2-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240420213307.976401-1-thiago.bauermann@linaro.org> References: <20240420213307.976401-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.3 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. --- 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.