From patchwork Sat Apr 20 21:33:06 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: 790528 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp1686346wrm; Sat, 20 Apr 2024 14:33:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXL6oGvvsyb9Infra+wkqnMM7NOKOTd1pKr3gBhhAjncm8EG4PpjIX6QPe1UWRcuJViO7MggsEy+iKr5yA7Av8G X-Google-Smtp-Source: AGHT+IEuiddOTOXEslcTuPRxdUYc9Q7prAngb+hKeaxwJ8RcpE51QTv2UBcL0SX6p1dT81GJPN3I X-Received: by 2002:ac8:5749:0:b0:439:80de:9521 with SMTP id 9-20020ac85749000000b0043980de9521mr2607022qtx.22.1713648828906; Sat, 20 Apr 2024 14:33:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713648828; cv=pass; d=google.com; s=arc-20160816; b=mqFOQxzwEfAOgZBud5xv3NibJCb4UEPF9KfLrVdxFazF1zsXtRuex1SkxeKZOlEi6B GTznt4F5H1x8OtnD8jESjaOk2QKtEXgW59qRLooNwuYYZX6pNgPm21snxougnfrQrXyL 3k3sqt06SLcaaY3onul87Az1mK+IxUwpb3D9TFfEaqOgGNHE9C7Me5CNUBi4tWCptTFi xN+Ctc6+aGhBMdkBRj/w7Qv1OtpIUMsH1vTTaRB/WShNQUWL3965+34gXLgOk0fpQyJh uaih6ab2vCrxC1MJ4u62n8945eymCtSoar+HTKCBbf3w3lJcXeE+7QkgvYdQE+OaECRS jpBw== 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=l2//MuXhk4EkuG2uL2QlCB8Yqh5JmQM3AyogZ4VzV8E0b6kh6rG4Hb07SYMJx6pQXA tmjQAcT9FnaV6CE0eKu3UCwb4QbtmifLdyzoUBKVG1IDNGoD6ha2z6+eXX6cIgSGruan Bu2S9EXJm5SzSqm670Je+/hgs1ig1VMeusyHw6HHJbmyS1s8mI/clQavpdcrow4EzvsU 86Pzw1QtrGl7IA45VBwUQ8UYcVrBHASqg8Tk/QABO/vupSuy88c3dXIjlAsrtd6WSdw4 8PbFDyolcxl6hFuLZoyprAUBXzaGP0/9SSzkpt+m/Rt7Kq9TLXDcQmhfGr3OjMZUmORW 58iA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gHTCluC8; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c2-20020ac85a82000000b004344c626782si6820447qtc.625.2024.04.20.14.33.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 14:33:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gHTCluC8; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 8F6DC3858294 for ; Sat, 20 Apr 2024 21:33:48 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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-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 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 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. From patchwork Sat Apr 20 21:33:07 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: 790529 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp1686384wrm; Sat, 20 Apr 2024 14:34:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEIUQUilEa5i3zhIeNyu7jC2xV+EpSIWB8X1vl5pw1Y03zhSCgcJSxTU5UUARS1M2c5n6MHCx4KbAbt0b4v4eU X-Google-Smtp-Source: AGHT+IE5Ht3MfkLhmVhGSx43t5SN37KVkHLxax2yPQo7kRylZaunaeiuqHDFcwXUX3YkdoS4yx45 X-Received: by 2002:ac8:58ca:0:b0:434:aebd:1b3f with SMTP id u10-20020ac858ca000000b00434aebd1b3fmr7234976qta.12.1713648840548; Sat, 20 Apr 2024 14:34:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713648840; cv=pass; d=google.com; s=arc-20160816; b=PshgBXtg9HcpHv0WFGAElYbyZi1LjoAM1Jn8bnwFyD6SEx6E/jLO2aiZA/b/c7Da3d LCtxlSKr+nb9OjUrSkCqNTaCNxPvad9Cy0PIOfJgVBkJaqw4IjEkrUhbuhx5OL4JFJVp LPmlMxcJrdF3Qdhibq8BAHjHCSMnuvekxWHqkM00A93r/+wbEpzW9G/0yEyUruDzWR07 H7r6Yc8A8x6EOu2R3Bj4qrGKuL50PRrfIPx/58G+wACkPv9BDYhG1RMxRsAYWf7fDf8N ++RFdrVfLHgtQbdIc1m3c9TzD1zcrNN4lwBb6EIEY4vhv7GLqcH3QZK3VcRV8r09bPU/ OEaQ== 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=WgnKNulno1lsWiYpepCakLlI7uQnEQJRWReMMwRdZL4=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=L3jQHk/8INKZV0UmmTW4PkE5fPuYLRC2nT0WQ2h4dHazkQd2hcBol7oAGWmCt9D6RH pyc0Gj/3uwTnmAzghYPMNriV57yn0kYilH0XBcbjK6DvIdenh/zEaGDgdDVMLKE5aMfx R+n+C1hOQLCqRLpsfvdhS1X7Ql3YHjMCrnN8qjPefQUGFg8igrl/4Fs0LGBsm6L9YzO6 mSWJxVrrsQ7ZxgBog00VIDwL9PxXm2VPTktjlWbBQ90A0Ci+tM7nc63PKsyKhJSp8Yhk tByU5RbUDrKX6mMZa0I0fa9FyDjRTWYN26xpErPPoxsSnxZkro+wPs5GKszwH0pVHDjr nHAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nf+RECUQ; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t8-20020a05622a180800b0043652487f9bsi7280000qtc.748.2024.04.20.14.34.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 14:34:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nf+RECUQ; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 232F2385840F for ; Sat, 20 Apr 2024 21:34:00 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by sourceware.org (Postfix) with ESMTPS id 97E823858D3C for ; Sat, 20 Apr 2024 21:33:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97E823858D3C 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 97E823858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::2e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713648802; cv=none; b=XbnZ0qgqgvR0fekNtv2CpInf9lteilm5/IFrotEi4RKoZiNWjTTlPHAgX7amU09DJ8wXp70p/pzerLUTNh1beKUriBsvjwizN5Bub60nLVNelX75sLQdyJWapbbjMnsN7cCuZ1JYwac8PURJpLb9/yaIcSBSJ9M/MDRY3KjlS+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713648802; c=relaxed/simple; bh=MYxmDfbpFaUpg/dVJ41KoG+7D0hfEmu1lzPIlbhP3y8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BPdEX+TOwgbQ7uU2c0jlnJvkbo3xY9/LG426MPsha7O8ErmGRAg4rv1H+KeMNp+Jlx38VHQaWWFx+qkvlAAHLGendV7KVAVoPk2YaZ5SYB9Mt0266IIkr/0sDlveiilyYOzY9wBF//agwn9o+uRmvGYoe3bE9ecjvmLG3DKI6H0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-23489b56559so1755559fac.1 for ; Sat, 20 Apr 2024 14:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713648799; x=1714253599; 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=WgnKNulno1lsWiYpepCakLlI7uQnEQJRWReMMwRdZL4=; b=nf+RECUQkrhXorlM+OZwgJRfA2xQdk01V8t+miGLojkWnyWm45J59utqqe0n97EFaY 0fIwAGH89Nrs9nUK4M62z4mTA+2hJnpyiJHReWFwk8vC+hsGLsPNBs+bwSzKK7Il36gR XpCkZJR36algvQkuAqh28Pv/osOEL/aFyCvoYdwwP7MPQr1yToF30Hy+ichcOUbe7/9o lMsUc7L44X17yKQlFyYp9fS8DiUnVLTbXMpaVaw5JNbhBnQ6jWihvMtxFUjEXN/XW0cr wzuaLypLfQj3SEeBXc9nxzqpw5fU9brOcf7czlzxYGF978VJ1XlrGHyT+vdcdHoWP07c CYXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713648799; x=1714253599; 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=WgnKNulno1lsWiYpepCakLlI7uQnEQJRWReMMwRdZL4=; b=ut/7nJyc59vaKk0LkQ1Em1fU7lVQA5VSQwMNB1DCU4PP8R3sG7oJ9y/acyhh//6Eyl MUwaxoZcgtj29Jn7/O2lPqAUnSwcX8Mugip0nKBaxOh9OGN3vpAeUvPh6aa6+50uh6s/ kEK29+MMVHOYglWAFfrA9//k8Xv8K4IT3W26YSLL8F9/2ZW+VetLKv2qBr2j/aSW42Ov R7KOvLFs70KJwkUXzuJoMl1DlOHq9IhD0prJ0x7JcV26YxulAdCvzbV8l3sNOfdvhxFF NIxg894Ue9ytZCmZUEGB6LIx+AQl3a2qo+Pvzwu6SIzdt8vGs4uSCPE5PzZ2Z2lF6ypu w/JQ== X-Gm-Message-State: AOJu0YxY4qKcnB9HPOWSH6AibuxJFseNtbD/8k9LK831XtAXWlzJ3l9k x4cb0992EgQIsBwZy3EzvZ5+Ms15O+OJKBZXJDwh27VCqQllyTMQF/afCclBV5c5vtv4u9rtZIO m X-Received: by 2002:a05:6870:f113:b0:234:581d:28e0 with SMTP id k19-20020a056870f11300b00234581d28e0mr7362574oac.10.1713648799367; Sat, 20 Apr 2024 14:33:19 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:3bb7:c4a7:c946:d2b6]) by smtp.gmail.com with ESMTPSA id a38-20020a631a26000000b005e4fa511505sm5027825pga.69.2024.04.20.14.33.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 14:33:18 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp Date: Sat, 20 Apr 2024 18:33:07 -0300 Message-ID: <20240420213307.976401-3-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 X-Spam-Status: No, score=-11.2 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 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 Test behaviour of watchpoints triggered by libc's memset/memcpy/memmove. These functions are frequently optimized with specialized instructions that favor larger memory access operations, so make sure GDB behaves correctly in their presence. There's a separate watched variable for each function so that the testcase can test whether GDB correctly identified the watchpoint that triggered. Also, the watchpoint is 31 bytes away from the beginning of the buffer being modified, so that large memory accesses (if present) as well as watching an unaligned memory address are exercised. PR testsuite/31484 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31484 --- gdb/testsuite/gdb.base/memops-watchpoint.c | 40 ++++++++++ gdb/testsuite/gdb.base/memops-watchpoint.exp | 83 ++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.c create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.exp NB: Please let me know if you think there are more interesting tests regarding watchpoint and memory accesses that can be done. I tried to make it cover the interesting scenarios but the testcase is small, so maybe I'm not very creative. diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.c b/gdb/testsuite/gdb.base/memops-watchpoint.c new file mode 100644 index 000000000000..13e923faa1e9 --- /dev/null +++ b/gdb/testsuite/gdb.base/memops-watchpoint.c @@ -0,0 +1,40 @@ +/* This test program is part of GDB, the GNU debugger. + + Copyright 2024 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 . */ + +#include +#include + +int +main (void) +{ + char s[40] = "This is a relatively long string..."; + char a[40] = "String to be overwritten with zeroes"; + char b[40] = "Another string to be memcopied..."; + char c[40] = "Another string to be memmoved..."; + + /* Break here. */ + memset (a, 0, sizeof (a)); + + memcpy (b, s, sizeof (b)); + + memmove (c, s, sizeof (c)); + + printf ("b = '%s'\n", b); + printf ("c = '%s'\n", c); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.exp b/gdb/testsuite/gdb.base/memops-watchpoint.exp new file mode 100644 index 000000000000..6fc84eb469c4 --- /dev/null +++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp @@ -0,0 +1,83 @@ +# Copyright 2024 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 . + +# Test a binary that uses standard libc memory operation functions. They are +# frequently optimized with specialized instructions, so make sure GDB behaves +# correctly in their presence. + +# It's not possible to check in which libc function the watchpoint triggers +# without its debug info. +require libc_has_debug_info + +standard_testfile + +set options "-fno-builtin-memset -fno-builtin-memcpy -fno-builtin-memmove" +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ + [list debug additional_flags=$options]] } { + return -1 +} + +set linespec ${srcfile}:[gdb_get_line_number "Break here"] + +if ![runto ${linespec}] { + return +} + +gdb_test "watch -location a\[31\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location a\\\[31\\\]" \ + "set watch on a" +gdb_test "watch -location b\[31\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location b\\\[31\\\]" \ + "set watchpoint on b" +gdb_test "watch -location c\[31\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location c\\\[31\\\]" \ + "set watchpoint on c" + +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "(Hardware w|W)atchpoint ${decimal}: -location a\\\[31\\\]" \ + "" \ + "Old value = 101 'e'" \ + "New value = 0 '\\\\000'" \ + ".*memset.* \\(\\) at .*:$decimal" \ + ".*"] \ + "continue until memset watchpoint hits" + +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "(Hardware w|W)atchpoint ${decimal}: -location b\\\[31\\\]" \ + "" \ + "Old value = 46 '\\.'" \ + "New value = 103 'g'" \ + ".*memcpy.* \\(\\) at .*:$decimal" \ + ".*"] \ + "continue until memcpy watchpoint hits" + +# Note: Some architectures use memcpy for memmove. +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "(Hardware w|W)atchpoint ${decimal}: -location c\\\[31\\\]" \ + "" \ + "Old value = 46 '\\.'" \ + "New value = 103 'g'" \ + ".*(memmove|memcpy).* \\(\\) at .*:$decimal" \ + ".*"] \ + "continue until memmove watchpoint hits"