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. From patchwork Sun Apr 21 22:26:57 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: 790694 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp2079639wrm; Sun, 21 Apr 2024 15:27:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU0iyz5ugWxkumlZ65h3eXxjPDNRw/uKqvT1xrMlxGSMsp4AOr7CnM5V6GtHv61XOZFWa4L+WSpPxlAd9JCKWLn X-Google-Smtp-Source: AGHT+IHi8IvQtQSGq/ph1gTdPDy23ghtA7rbmvXy4IPYmewDf1bNPfNXBeK+EX93tMwOJ+h9CNxs X-Received: by 2002:a05:6214:1414:b0:69b:188a:f31e with SMTP id pr20-20020a056214141400b0069b188af31emr9335238qvb.38.1713738462726; Sun, 21 Apr 2024 15:27:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713738462; cv=pass; d=google.com; s=arc-20160816; b=e2Xw4N29mj+m+ePqLtqCNTers8qMNiN8jXz/QyliuE72G5Bo5DRi+9xL/G0wulwTUF p/O7bVEd34j6Yg75y/PdEXJPmJjtn8DyJntcIPSdRKfufWlLt13jmbtM+8ZX98gXkQOb zPM/Xcb9Hj+1/pzDhkyPpCpGJrw9OiLiMQ8l7ZOmgiER0FmMDdsT2E8veXXHI3FtmJr2 5oazHKryHyqHvuR+G7kx5ygsXRhRy+vDmNka3R9VF6oRFR/yrbcWVbXNPlSgDLiuQwyP kv0mhYlXXo5JsZdf5wqDyu7QFd0PHqPUo6iO1WxmM6QOFjhiTlrHlll9S9n3dzozRbcx zdgg== 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=/ukqTm7EusgO/4PrZreRAKZ7V5bilS9/CkQd/KbnJ7w=; fh=72kqq0iQhigvR9Vv/oqX5ebs3Yyyw7XhzWxOOEPdupI=; b=NfttVTo7edq8NcbmakE2M+/TKTPdXH2otkZlntACez7rYyASiX3/h2eutBP9kg+8Ra UTVcrdTJ1UJShkLJBfqcvp2FD2M5e459tV3YgqCexkFL0e9UAj2QxVVo8T6BxsE7Jugd ZzcixfMNoyv0wv7/hd7zOxQadTd7OArlX6tv4OIkXQfEeOIYMxWfK477Irt3wudQibSz ts1xhZQMFWuEJctlZ/BKeUhlI34SxJ1VqSOZVxt8+dRbgLCPVy4YZVGXHDY/9zY0a7tH 2vDn9biktxjrVa+TM3H8QHaNWd0r6+hLNzfE4GNNX9BtEtksurq+DG4XSgvIbPeAixRc Daaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vTMhQNrA; 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 ed14-20020ad44eae000000b006a081cb5adcsi566927qvb.334.2024.04.21.15.27.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 15:27:42 -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=vTMhQNrA; 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 41BA73858D37 for ; Sun, 21 Apr 2024 22:27:42 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id C5C973858D39 for ; Sun, 21 Apr 2024 22:27:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5C973858D39 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 C5C973858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713738432; cv=none; b=p30tv7f6+nAe7GWjFxiDM/JHbtsUsFwO86TmvpH9yxta+ARphKYsv1HVuRxz46wZWCRMZ7pDox7iNf6+z4sy8SmN8AUO2ZNxJTVqT0EKjh2Hv7+UPQVl6c26rF3jl3h0Sx+QmBnqAr+MzNRSkn/OWy2zcolx6NPnsIe1pKMnxQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713738432; c=relaxed/simple; bh=es1Nk4sKaz0Do04kHIwwX55l694pYc49tXV59xPvJ/0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tBBIYi6Whfkhr4aAsk1mgtoiQWtgPg++tRVvYsDoLjQOcK5T65EM0Ql+hPchgWPBTfv9oiLQc1t3Ftf1kM4zHLSAsvf9/Z290hEgBp+A5Acg/n7mEt6G8cNej0X4w4Y6iQFfU4Jc0j1hpt7PHCIkjM2WtuWxdYAxldF7Ye9JkBU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-5f415fd71f8so2794004a12.3 for ; Sun, 21 Apr 2024 15:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713738429; x=1714343229; 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=/ukqTm7EusgO/4PrZreRAKZ7V5bilS9/CkQd/KbnJ7w=; b=vTMhQNrAwxqJLlfIu/3vphKE6tYmK+GLf2aiV4eE8fXNvPSKA16KjKWh4JjZ5g/UMC m9ukYOu2rNqmsa0h6OjmSmOEb9G/Qu0lSlL7XperCHa8Cs3cAIcIQJmYTRg/HrqDgFIA Xsi7hk6CJ13L0CfwLOUfM/E5VcL2vlW522YQ0GEBQDaa2RVivaB5td3/W7MVQagRP07T 5z7Nxnc6bL5Hd5UiQ4O6qIxWHn4A1JTXG/5jQiMJnRebeIv8PohIKr37Vu5Futk5ltiH BTr4mqJ1ufo1wGOrq8s3DkP0UtSo4H71QT7e2/QQeEpLiudhxRKRXdXByeVrq6DQmUV8 pk/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713738429; x=1714343229; 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=/ukqTm7EusgO/4PrZreRAKZ7V5bilS9/CkQd/KbnJ7w=; b=Ss71wvPXVXGizv52BNCTc821COE329uH/G38p5bT5GrtgjvkiD/4erz7ZHmHZApplX Df5Auxatix57+qT8JeZXwMACIrAEL3QB2B1B857HTPE7Qgd64NLXgDTBSDuyGhBL5Jbs FyPqwfi0bpXuU3unLUU9zvGadJ7DJFL682tyfyPEod5ivTEyE+TYh4mUwjlRS+qp2cVI 8h0C36cghYz0OBpS4ur7rCkHumUeCFrx7ExNN7/Pi0GsrI4Zt0k1gPIin6YIbgsXihsk kGvlduurRdRuWE29s/EhCDumYE1Xru+gHvAvBBJdsNxGAE3Y08zCMmxbWbvs/KuJ56oL CweQ== X-Gm-Message-State: AOJu0YxGrxDR3UJ06fsuUdIINPSEpIqG+0/W38cIsWigQkyGVYNMJ/l+ Z6qv6+6T9Lr7hQc/Sq/nsNvSuDtzF0KT9YdGO7Y2RDHYVmGlQDMn/C+jUIXrwBDO301UFYd5EoY e X-Received: by 2002:a17:902:f68b:b0:1e5:9da5:a799 with SMTP id l11-20020a170902f68b00b001e59da5a799mr9811180plg.6.1713738428641; Sun, 21 Apr 2024 15:27:08 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:3224:7231:e42f:1da5]) by smtp.gmail.com with ESMTPSA id u7-20020a17090341c700b001dcfaf4db22sm6773051ple.2.2024.04.21.15.27.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 15:27:08 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Subject: [PATCH v2 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp Date: Sun, 21 Apr 2024 19:26:57 -0300 Message-ID: <20240421222657.1052635-3-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=-11.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 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 28 bytes away from the beginning of the buffer being modified, so that large memory accesses (if present) are exercised. PR testsuite/31484 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31484 --- gdb/testsuite/gdb.base/memops-watchpoint.c | 45 ++++++++++ gdb/testsuite/gdb.base/memops-watchpoint.exp | 86 ++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.c create mode 100644 gdb/testsuite/gdb.base/memops-watchpoint.exp NB: As with v1, 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. Changes in v2: - Ensure watchpoints are aligned to 4 bytes. - Add kfail for arm-linux. diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.c b/gdb/testsuite/gdb.base/memops-watchpoint.c new file mode 100644 index 000000000000..0255cfb43404 --- /dev/null +++ b/gdb/testsuite/gdb.base/memops-watchpoint.c @@ -0,0 +1,45 @@ +/* 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) +{ + /* Some targets need 4-byte alignment for hardware watchpoints. */ + char s[40] __attribute__ ((aligned (4))) + = "This is a relatively long string..."; + char a[40] __attribute__ ((aligned (4))) + = "String to be overwritten with zeroes"; + char b[40] __attribute__ ((aligned (4))) + = "Another string to be memcopied..."; + char c[40] __attribute__ ((aligned (4))) + = "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..0edc646e67aa --- /dev/null +++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp @@ -0,0 +1,86 @@ +# 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\[28\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \ + "set watch on a" +gdb_test "watch -location b\[28\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \ + "set watchpoint on b" +gdb_test "watch -location c\[28\]" \ + "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \ + "set watchpoint on c" + +setup_kfail breakpoints/31665 arm*-*-linux* +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \ + "" \ + "Old value = 104 'h'" \ + "New value = 0 '\\\\000'" \ + ".*memset.* \\(\\) at .*:$decimal" \ + ".*"] \ + "continue until memset watchpoint hits" + +setup_kfail breakpoints/31665 arm*-*-linux* +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \ + "" \ + "Old value = 101 'e'" \ + "New value = 114 'r'" \ + ".*memcpy.* \\(\\) at .*:$decimal" \ + ".*"] \ + "continue until memcpy watchpoint hits" + +# Note: Some architectures use memcpy for memmove. +setup_kfail breakpoints/31665 arm*-*-linux* +gdb_test "continue" \ + [multi_line \ + "Continuing\\." \ + "" \ + "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \ + "" \ + "Old value = 100 'd'" \ + "New value = 114 'r'" \ + ".*(memmove|memcpy).* \\(\\) at .*:$decimal" \ + ".*"] \ + "continue until memmove watchpoint hits"