From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id bW4yN+/RqGg74QkAWB0awg (envelope-from ) for ; Fri, 22 Aug 2025 16:24:15 -0400 Received: by simark.ca (Postfix, from userid 112) id CD5DE1E023; Fri, 22 Aug 2025 16:24:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1B3191E023 for ; Fri, 22 Aug 2025 16:24:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8E4DC3851A9C for ; Fri, 22 Aug 2025 20:24:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E4DC3851A9C Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by sourceware.org (Postfix) with ESMTPS id 915703858D29 for ; Fri, 22 Aug 2025 20:23:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 915703858D29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 915703858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755894218; cv=none; b=CjzXLpn2Gh8H8ncWYgXVhwNKJrsyVp0nsgG9U6cZMg5OtcRRl1iD/DdgSs2D6BkvDMKwCy7yYIovONRuj8K2oO1kbr27GWwrFBXetSkDyKgEhdRozlxNZeiETfqD99dk+Yek+7zh4uzW2QgFtD4V6LomIIg4j9i0u/f6YOgkkRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755894218; c=relaxed/simple; bh=QFEWE95ZYUvHFt6YCTGyvy2FXhtsbfUF31rjWWfvv/E=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=RPVAdw9m2BnVfJ7If1rzLrKCmEHsbWrh8NtmzntAXg7kSGl3mPGAVEH/yZYTKC1/FJjcl79K6aZCml/Ee4OwYyhBuBlsMYpRPMoVLzWcWOL3Q1eMByXmBgUDgEPLLYBwGO/CZX0Z/0FtzB0MNtnu+bjGKKoplac4id95tXiyyKM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 915703858D29 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3c607029266so683871f8f.3 for ; Fri, 22 Aug 2025 13:23:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755894217; x=1756499017; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ICX6F6wUYh1kg9ZuKMKOdxfLc4VWFM8Ggi0s3h8bfyE=; b=Xmk7HD7sI+4+ZdxkpEL6Q8Nz9q/1opiV/tqzB88NnQ8kuh3vkbbAhSwBJhEE7bvssI vmwxc6gRSxx+Ir5WxLv778z0TpEYj+yQcwAhKdi3oC0nmnX6/sMDjtd1CVXJuTnXj9Mq nfGjnUl1+HRJ6qGBEFHscqxNkl4K+ym8nnFO69IdcgEPRqMLQsSDuyi5uEw+d4DQRQr6 b8swYHKNI0cCjESRge6uY2ZgV85Y1+7zeClfU8DQE7G2nkHbxQ1FYP1/6OoMxpaF55+e Dpj07+jRp1itg2YQW8GmRdsu1SobL6YzE8DRbu9PAavDr2wF8t96ZE7SDFA8B5us8nx/ lTag== X-Gm-Message-State: AOJu0YyP2hp3xV6EYEWXJwLoAm7i39b1MywyhXnuU6CH5MyEbao3U7dI bfIlP+mgcV3I8Lr/9Yigq4TNEsmEIGqNBD6ogaacOWW9tRkzdjaWDZYkLPEvNQHG X-Gm-Gg: ASbGncscic9QJviSUuXgY0Nz4CHq1PloPQRs4GAMkk5+khBNq24obJJMOjH7G7zWOpD TAjjpBAH2i8V2ZshgkTybWl2Y2X8zlQnppHQNDXd2cNVQKzNA7S5Txr6nbjA7HTkEXLSzUSqPL0 R3i90VhE8dkC86jWWP5VMuH9Qgw24Sj7DbjIk4I/DU+5ATHQc60oJLb+rwmI7TJTfwUda4pMtB+ nd1IgSq5AiGPr9KfGf8TaaNcPZQpew2oyimcFET4rvyR7vsmUKp3WZbgasOLQxlZ9l3SVWU8Ini TV4GMtgNN/QucwMu72bAr3kohbp1UeZT9eC7Lmz4IFQNLMbGzUoV0UeSXoYcOLjrE28tGvBwMWL bCNH/J8V5G3/HT87sPQHA X-Google-Smtp-Source: AGHT+IGbuBP5BpwdKDD4/GL04Zggbbj80KJLsC38vj91TMJ5glVa2tN0dYkZkxTBUQBniwPzFY/4aA== X-Received: by 2002:a05:6000:24c7:b0:3b9:6e:5242 with SMTP id ffacd0b85a97d-3c5db8aa9aemr2315727f8f.4.1755894216880; Fri, 22 Aug 2025 13:23:36 -0700 (PDT) Received: from localhost ([2001:8a0:faf3:7600:ecf:b103:3f7d:622c]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-45b57444b2fsm11956855e9.5.2025.08.22.13.23.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Aug 2025 13:23:36 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Fix gdb.base/gcorebg.exp and --program-prefix Date: Fri, 22 Aug 2025 21:23:34 +0100 Message-ID: <20250822202335.874093-1-pedro@palves.net> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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~public-inbox=simark.ca@sourceware.org When GDB is configured with --program-prefix, we see: Running /home/pedro/gdb/src/gdb/testsuite/gdb.base/gcorebg.exp ... FAIL: gdb.base/gcorebg.exp: detached=detached: Spawned gcore finished FAIL: gdb.base/gcorebg.exp: detached=detached: Core file generated by gcore FAIL: gdb.base/gcorebg.exp: detached=standard: Spawned gcore finished FAIL: gdb.base/gcorebg.exp: detached=standard: Core file generated by gcore The problem is here (with --program-prefix=prefix-), from gdb.log: gcore: GDB binary (/home/pedro/gdb/build-program-prefix/gdb/testsuite/../../gdb/prefix-gdb) not found FAIL: gdb.base/gcorebg.exp: detached=detached: Spawned gcore finished That is gcore (the script, not the GDB command) trying to run the installed GDB: if [ ! -f "$binary_path/@GDB_TRANSFORM_NAME@" ]; then echo "gcore: GDB binary (${binary_path}/@GDB_TRANSFORM_NAME@) not found" exit 1 fi ... "$binary_path/@GDB_TRANSFORM_NAME@" 100755 gdb/gcore-1.in diff --git a/gdb/NEWS b/gdb/NEWS index db0e74a2623..f8e817299c9 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -35,6 +35,9 @@ a -h or --help option, which prints each options and a brief description. +* The gcore script now has a -g option that lets you specify the GDB + binary invoked by gcore. + * On systems that support linker namespaces, the output of the command "info sharedlibraries" may add one more column, NS, which identifies the namespace into which the library was loaded, if more than one namespace diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 7718a9c4d83..418a9e33c18 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -51530,6 +51530,12 @@ composed as @file{@var{prefix}.@var{pid}}, where @var{pid} is the process ID of the running program being analyzed by @command{gcore}. If not specified, @var{prefix} defaults to @var{core}. +@item -g @var{gdb} +Use @var{gdb} as the executable binary to invoke @value{GDBN} for +running the gcore command. This argument is optional, and defaults to +invoking the @value{GDBN} binary that is installed alongside +@command{gcore}. + @item -d @var{directory} Use @var{directory} as the data directory when invoking @value{GDBN} for running the gcore command. This argument is optional. diff --git a/gdb/gcore-1.in b/gdb/gcore-1.in old mode 100644 new mode 100755 index 2f6eb02557a..d733682704d --- a/gdb/gcore-1.in +++ b/gdb/gcore-1.in @@ -32,12 +32,15 @@ dump_all_cmds=() data_directory_opt=() +# The GDB binary to run. +gdb_binary= + function print_usage() { prefix="Usage: $0" padding=$(printf '%*s' ${#prefix}) echo "$prefix [-h|--help] [-v|--version]" - echo "$padding [-a] [-o prefix] [-d data-directory]" + echo "$padding [-a] [-o prefix] [-g gdb] [-d data-directory]" echo "$padding pid1 [pid2...pidN]" } @@ -55,6 +58,8 @@ function print_help() { echo " -a Dump all memory mappings." echo " -o prefix Use 'prefix.pid' as the core file name." echo " The default prefix is 'core'." + echo " -g gdb The GDB binary to run." + echo " Defaults to GDB installed alongside gcore." echo " -d dir Pass '--data-directory dir' as an argument" echo " to GDB." } @@ -63,7 +68,7 @@ function print_version() { echo "GNU gcore (${PKGVERSION}) ${VERSION}" } -while getopts vhao:d:-: OPT; do +while getopts vhao:g:d:-: OPT; do if [ "$OPT" = "-" ]; then OPT="${OPTARG%%=*}" OPTARG="${OPTARG#'$OPT'}" @@ -82,6 +87,9 @@ while getopts vhao:d:-: OPT; do o) prefix=$OPTARG ;; + g) + gdb_binary="$OPTARG" + ;; d) data_directory_opt=("--data-directory" "$OPTARG") ;; @@ -144,10 +152,16 @@ if test "x$binary_path" = x. ; then fi fi +if [ -z "$gdb_binary" ]; then + gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@" +fi + +gdb_binary_basename=`basename "$gdb_binary"` + # Check if the GDB binary is in the expected path. If not, just # quit with a message. -if [ ! -f "$binary_path/@GDB_TRANSFORM_NAME@" ]; then - echo "gcore: GDB binary (${binary_path}/@GDB_TRANSFORM_NAME@) not found" +if [ ! -f "$gdb_binary" ]; then + echo "gcore: GDB binary ($gdb_binary) not found" exit 1 fi @@ -159,7 +173,7 @@ for pid in "$@" do # `