[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for
From: |
Maxim Cournoyer |
Subject: |
[bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile. |
Date: |
Sun, 16 Aug 2020 01:39:47 -0400 |
Instead of hard coding the debug directory to that of the user profile, use
Guile scripting to derive the debug file directories from the LIBRARY_PATH
environment variable.
* gnu/system/shadow.scm (default-skeletons)[gdbinit]: Derive the value of
DEBUG-FILE-DIRECTORY via the environment variable LIBRARY_PATH, so that debug
files from any profile can be found.
* doc/guix.texi (Installing Debugging Files): Document it.
---
doc/guix.texi | 17 +++++++++++++++++
gnu/system/shadow.scm | 11 ++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 587c004bee..53b85418fb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -30145,6 +30145,23 @@ GDB}):
From there on, GDB will pick up debugging information from the
@file{.debug} files under @file{~/.guix-profile/lib/debug}.
+Below is an alternative GDB script that can be useful when working with
+other profiles. It takes advantage of the Guile integration available
+in GDB.
+
+@example
+guile
+(begin
+ (use-modules (gdb)
+ (srfi srfi-26))
+ (let* ((library-paths (string-split (getenv "LIBRARY_PATH") #\:))
+ (debug-paths (map (cut string-append <> "/debug")
+ library-paths)))
+ (execute (format #f "set debug-file-directory ~a"
+ (string-join debug-paths ":")))))
+end
+@example
+
In addition, you will most likely want GDB to be able to show the source
code being debugged. To do that, you will have to unpack the source
code of the package of interest (obtained with @code{guix build
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index a69339bc07..d31cd37077 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -162,7 +162,16 @@ XTerm*utf8: always
XTerm*metaSendsEscape: true\n"))
(gdbinit (plain-file "gdbinit" "\
# Tell GDB where to look for separate debugging files.
-set debug-file-directory ~/.guix-profile/lib/debug
+guile
+(begin
+ (use-modules (gdb)
+ (srfi srfi-26))
+ (let* ((library-paths (string-split (getenv \"LIBRARY_PATH\") #\\:))
+ (debug-paths (map (cut string-append <> \"/debug\")
+ library-paths)))
+ (execute (format #f \"set debug-file-directory ~a\"
+ (string-join debug-paths \":\")))))
+end
# Authorize extensions found in the store, such as the
# pretty-printers of libstdc++.
--
2.27.0