From patchwork Wed Oct 4 18:31:02 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: 77129 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 40AC43855587 for ; Wed, 4 Oct 2023 18:31:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40AC43855587 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696444290; bh=erzaFjsV+3JIrauJOeSPyHhx/ZW6w/sNQ8NP6Bf6dVM=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=q1zcBafwgep0cfoMqJj3Sf1c7MOIXpLyo27BKCMxke38QfuKlW2uQmYGGXWIQfqWP 7gxHt10NNnZ/jFhovnWuCXzrDHEU1nkqCdRam+k9Fgx2hJYATwGeKbOT7xsiiTADZR 5mVacSUdBiP1LzBq3kx/+cT2tZLpWsSCNRMU04Rg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 350763857C44 for ; Wed, 4 Oct 2023 18:31:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 350763857C44 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c5cd27b1acso437625ad.2 for ; Wed, 04 Oct 2023 11:31:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696444265; x=1697049065; 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=erzaFjsV+3JIrauJOeSPyHhx/ZW6w/sNQ8NP6Bf6dVM=; b=gLVkX79fD5fv46XKzIPRmQQ3lUQfjRtDaA/ScMsvUuNADzw+536UVj5VSWpwmm3zES 6mTwmhGCYtZ+FZ0btIuZq/bp4S0nNDeYb9BWrOlBhixbPehX3T9s2jLSGlkDlz40mNek SJgD6pOi6g83k1zaJK6Ls6yA3Yn523wIZvGCdMe1sUnhgMwtkuaMq0Xc3eLiksX2uErb 4SSh0pjJZCPB3WUjgwaugccUB9lXFZhuw0W90zGQzYregXJ4HTzKu8OEaqyAKvlA2Zbn 8oaYwl/3XBLOgpWIit+U2cNUZ5RaxINwknctGyJIXIU99XQpk1h16JZcDZBWQllThcpX rkjA== X-Gm-Message-State: AOJu0YyAQ+IHu/e1MO4GekJo+QN/l34QrHW9RfQJLRoz0OYM5ql7aGVd WJX01xGkz0MoYDg0D1DxMqOq9ASgq3csB6BVBxk= X-Google-Smtp-Source: AGHT+IEQj/b00Wc+DvVwugHbcoe3wVQ0jNWOSoUD288L3brvznjQ/kk0GiMmbEPO4fgf+oep3WgS6A== X-Received: by 2002:a17:902:ed54:b0:1c6:845:27c5 with SMTP id y20-20020a170902ed5400b001c6084527c5mr3369996plb.61.1696444265198; Wed, 04 Oct 2023 11:31:05 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:2dfa:6486:a698:5ba9]) by smtp.gmail.com with ESMTPSA id m6-20020a170902db8600b001c726147a46sm4065808pld.234.2023.10.04.11.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 11:31:04 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2] gdb/configure.ac: Add option --with-additional-debug-dirs Date: Wed, 4 Oct 2023 15:31:02 -0300 Message-ID: <20231004183102.61669-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 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 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: , 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. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 8 ++++++++ gdb/config.in | 3 +++ gdb/configure | 19 +++++++++++++++++-- gdb/configure.ac | 8 ++++++++ gdb/doc/gdb.texinfo | 6 ++++-- gdb/main.c | 5 +++++ gdb/top.c | 6 ++++++ 7 files changed, 51 insertions(+), 4 deletions(-) Changed since v1: Addressed Tom Tromey's review comments: - Added NEWS entry for the new configure option. - Documented the new configure option in the GDB manual. - Properly indented the body of AC_ARG_WITH. - Added parentheses around RHS side of the assignment in gdb/main.c. base-commit: 1181bcd0d2572aee2c0947040e56bc1f9af634e3 diff --git a/gdb/NEWS b/gdb/NEWS index 20f53a0d542d..9fe46b5b2e32 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -110,6 +110,14 @@ 'inferior' keyword with either the 'thread' or 'task' keywords when creating a breakpoint. +* Configure changes + +--additional-debug-dirs=PATHs + + Provide a colon-separated list of additional directories to search for + separate debug info. These directories are added to the default value of + the 'debug-file-directory' GDB parameter. + * New commands set debug breakpoint on|off diff --git a/gdb/config.in b/gdb/config.in index f67d3029d829..e17245156d8d 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 2d07e0cb596e..1cbc356cb967 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 + colon-separated 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 @@ -11479,7 +11483,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11482 "configure" +#line 11486 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11585,7 +11589,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11588 "configure" +#line 11592 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17886,6 +17890,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 97c6bf0ed5f9..0264199b9481 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -119,6 +119,14 @@ 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], + [colon-separated 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/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e1385cfb5192..168c4f7cc016 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22275,8 +22275,10 @@ file from @code{debuginfod} servers. @anchor{debug-file-directory} Global debugging info directories default to what is set by @value{GDBN} -configure option @option{--with-separate-debug-dir}. During @value{GDBN} run -you can also set the global debugging info directories, and view the list +configure option @option{--with-separate-debug-dir} and augmented by the +colon-separated list of directories provided via @value{GDBN} configure +option @option{--additional-debug-dirs}. During @value{GDBN} run you can +also set the global debugging info directories, and view the list @value{GDBN} is currently using. @table @code diff --git a/gdb/main.c b/gdb/main.c index 97e04f5b5d8e..99468e0853ed 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -723,6 +723,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 cbe14b010466..5028440b6711 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1587,6 +1587,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\