From patchwork Tue Jun 6 23:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 70683 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C54D33858032 for ; Tue, 6 Jun 2023 23:31:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C54D33858032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686094310; bh=C5Gy8hIrLjTI7G6b4AIwGjTibQtjOXx9sFJ+W0ay8ZE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=d/JcjMW+LwU1FQo81FkL1bipQF9sY4UynST9pyJDJ+C3vL62FzDyMIBw1iicHr9C4 0dbp8Azpzo2EioQ/Ssoz4eVb6v4Mx94vDoORj6nZax89pQVjjRTVT04tnKHp/8yEio uwBhcj5TX3nejWAsy/WPRdSGv0thVSwQ00wMbt1U= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 8E3EE3858D38 for ; Tue, 6 Jun 2023 23:31:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E3EE3858D38 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-977d6aa3758so515650466b.0 for ; Tue, 06 Jun 2023 16:31:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686094284; x=1688686284; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=C5Gy8hIrLjTI7G6b4AIwGjTibQtjOXx9sFJ+W0ay8ZE=; b=V8a73Y86hFiUdzFxrB/t7pyE5lwdmI9jmFNuANerXltVZOCGxHW5reiSpNr620N/TL 7aX6irxp8wAP5NDwJqYeANfRU7SJ9vLTZhum1tHhZ6VTWNYiC6fqRdVTaGPoDeDu68m2 dAErE8tQ2pwp+qkuzq1LgQOx9kTMkczrD2f8sfjikV3t42pPDVy2Mbo+MlP9a2d5GOuR //rAGq81i4KlmK0kBJcvI5dLpTAm9GQZ5lplVhV7nhuDUmOzqp6cpFeI0Ai2mteWRKTP isK0fzes5sdQImF05yJO8naZXS16HV3dhp9SqvKbxbl85SOj1zbITte7McYqkac8tL2E 5tMw== X-Gm-Message-State: AC+VfDzrLm83ljBynJdoV2AaXv6TIKjOPhPkI91yUO8pBOk19Io9LRPk JgyPSfBJ5G7ovpLqshWshO51kKd7M3JizZjPCs8= X-Google-Smtp-Source: ACHHUZ5Fvv+DHrcHp2kNdEWZxqlrLnoqnUuvSQopHV6BpLa6naFHIVnNvyUOb9hYnQNb/N882PZdMQ== X-Received: by 2002:a17:907:8a1a:b0:977:bf02:b158 with SMTP id sc26-20020a1709078a1a00b00977bf02b158mr3965509ejc.10.1686094284159; Tue, 06 Jun 2023 16:31:24 -0700 (PDT) Received: from localhost (p200300eaff33e0a4c62d799d7c36ec49.dip0.t-ipconnect.de. [2003:ea:ff33:e0a4:c62d:799d:7c36:ec49]) by smtp.gmail.com with ESMTPSA id o24-20020a1709062e9800b00977c863ee00sm4692245eji.130.2023.06.06.16.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 16:31:23 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Thiago Jung Bauermann Subject: [PATCH] gdb/configure.ac: Add option --with-additional-debug-dirs Date: Wed, 7 Jun 2023 01:31:18 +0200 Message-Id: <20230606233118.146167-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Thiago Jung Bauermann via Gdb-patches From: Thiago Jung Bauermann Reply-To: Thiago Jung Bauermann Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" If you want to install GDB in a custom prefix, have it look for debug info in that prefix but also in the distro's default location (typically, /usr/lib/debug) and run the GDB testsuite before doing "make install", you have a bit of a problem: Configuring GDB with '--prefix=$PREFIX' sets the GDB 'debug-file-directory' parameter to $PREFIX/lib/debug. Unfortunately this precludes GDB from looking for distro-installed debug info in /usr/lib/debug. For regular GDB use you could set debug-file-directory to $PREFIX:/usr/lib/debug in $PREFIX/etc/gdbinit so that GDB will look in both places, but if you want to run the testsuite then that doesn't help because in that case GDB runs with the '-nx' option. There's the configure option '--with-separate-debug-dir' to set the default value for 'debug-file-directory', but it accepts only one directory and not a list. I considered modifying it to accept a list, but it's not obvious how to do that because its value is also used by BFD, as well as processed for "relocatability". I thought it was simpler to add a new option to specify a list of additional directories that will be appended to the debug-file-directory setting. --- gdb/config.in | 3 +++ gdb/configure | 19 +++++++++++++++++-- gdb/configure.ac | 6 ++++++ gdb/main.c | 5 +++++ gdb/top.c | 6 ++++++ 5 files changed, 37 insertions(+), 2 deletions(-) base-commit: d3f340763bab7c74838ebb481fd7ff93acd9f00c diff --git a/gdb/config.in b/gdb/config.in index a7da88b92d77..ec70e17c2c11 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -3,6 +3,9 @@ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD +/* Additional directories to look for separate debug info. */ +#undef ADDITIONAL_DEBUG_DIRS + /* Directories from which to load auto-loaded scripts. */ #undef AUTO_LOAD_DIR diff --git a/gdb/configure b/gdb/configure index 5bb2a0795e59..9a61bbe857e9 100755 --- a/gdb/configure +++ b/gdb/configure @@ -906,6 +906,7 @@ enable_fast_install with_gnu_ld enable_libtool_lock with_separate_debug_dir +with_additional_debug_dirs with_gdb_datadir with_relocated_sources with_auto_load_dir @@ -1660,6 +1661,9 @@ Optional Packages: --with-separate-debug-dir=PATH look for global separate debug info in this path [LIBDIR/debug] + --with-additional-debug-dirs=PATHs + list of additional directories to search for + separate debug info --with-gdb-datadir=PATH look for global separate data files in this path [DATADIR/gdb] --with-relocated-sources=PATH @@ -11448,7 +11452,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11451 "configure" +#line 11455 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11554,7 +11558,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11557 "configure" +#line 11561 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17830,6 +17834,17 @@ _ACEOF + +# Check whether --with-additional-debug-dirs was given. +if test "${with_additional_debug_dirs+set}" = set; then : + withval=$with_additional_debug_dirs; +cat >>confdefs.h <<_ACEOF +#define ADDITIONAL_DEBUG_DIRS "${withval}" +_ACEOF + +fi + + # We can't pass paths as command line arguments. # Mingw32 tries to be clever and will convert the paths for us. # For example -DBINDIR="/usr/local/bin" passed on the command line may get diff --git a/gdb/configure.ac b/gdb/configure.ac index fb43cd10d6c8..715001384177 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -119,6 +119,12 @@ GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir, [look for global separate debug info in this path @<:@LIBDIR/debug@:>@], [${libdir}/debug]) +AC_ARG_WITH(additional-debug-dirs, +AS_HELP_STRING([--with-additional-debug-dirs=PATHs], + [list of additional directories to search for separate debug info]), +[AC_DEFINE_UNQUOTED(ADDITIONAL_DEBUG_DIRS, "${withval}", + Additional directories to look for separate debug info.)]) + # We can't pass paths as command line arguments. # Mingw32 tries to be clever and will convert the paths for us. # For example -DBINDIR="/usr/local/bin" passed on the command line may get diff --git a/gdb/main.c b/gdb/main.c index 47eec0e50730..788cc3199617 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -719,6 +719,11 @@ captured_main_1 (struct captured_main_args *context) debug_file_directory = relocate_gdb_directory (DEBUGDIR, DEBUGDIR_RELOCATABLE); +#ifdef ADDITIONAL_DEBUG_DIRS + debug_file_directory = debug_file_directory + DIRNAME_SEPARATOR + + ADDITIONAL_DEBUG_DIRS; +#endif + gdb_datadir = relocate_gdb_directory (GDB_DATADIR, GDB_DATADIR_RELOCATABLE); diff --git a/gdb/top.c b/gdb/top.c index 90ddc5f5ea73..3528243cc058 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1581,6 +1581,12 @@ This GDB was configured as follows:\n\ --with-separate-debug-dir=%s%s\n\ "), DEBUGDIR, DEBUGDIR_RELOCATABLE ? " (relocatable)" : ""); +#ifdef ADDITIONAL_DEBUG_DIRS + gdb_printf (stream, _ ("\ + --with-additional-debug-dirs=%s\n\ +"), ADDITIONAL_DEBUG_DIRS); +#endif + if (TARGET_SYSTEM_ROOT[0]) gdb_printf (stream, _("\ --with-sysroot=%s%s\n\