unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile.
@ 2020-08-16  5:39 Maxim Cournoyer
  2020-08-16  8:21 ` Mathieu Othacehe
  2020-08-16 13:44 ` [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
  0 siblings, 2 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2020-08-16  5:39 UTC (permalink / raw)
  To: 42882; +Cc: Maxim Cournoyer

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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile.
  2020-08-16  5:39 [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
@ 2020-08-16  8:21 ` Mathieu Othacehe
  2020-08-16 19:18   ` [bug#42882] Maxim Cournoyer
  2020-08-16 13:44 ` [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
  1 sibling, 1 reply; 7+ messages in thread
From: Mathieu Othacehe @ 2020-08-16  8:21 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: 42882


Hello Maxim,

> +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.

You could say the "optional Guile integration", because it is (sadly)
disabled on Ubuntu's gdb build for instance.

> +
> +@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

And maybe precise that this very snippet will be installed by default as
.gdbinit on Guix System?

Otherwise it looks fine to me.

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile.
  2020-08-16  5:39 [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
  2020-08-16  8:21 ` Mathieu Othacehe
@ 2020-08-16 13:44 ` Maxim Cournoyer
  1 sibling, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2020-08-16 13:44 UTC (permalink / raw)
  To: 42882; +Cc: Maxim Cournoyer

Instead of hard coding the debug directory to that of the user profile, use
Guile scripting in combination with a new search path specification on GDB to
specify the debug file directories.

* gnu/packages/gdb.scm (gdb-9.1): Add a search path specification for the
GDB_DEBUG_FILE_DIRECTORY environment variable.
* gnu/system/shadow.scm (default-skeletons)[gdbinit]: Derive the value of
DEBUG-FILE-DIRECTORY via the GDB_DEBUG_FILE_DIRECTORY environment variable.
* doc/guix.texi (Installing Debugging Files): Document it.
---
 doc/guix.texi         | 12 ++++++++++++
 gnu/packages/gdb.scm  |  7 +++++++
 gnu/system/shadow.scm |  8 +++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 587c004bee..2118c6ae16 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -30145,6 +30145,18 @@ 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
+(use-modules (gdb))
+(execute (string-append "set debug-file-directory "
+                        (getenv "GDB_DEBUG_FILE_DIRECTORY")))
+end
+@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/packages/gdb.scm b/gnu/packages/gdb.scm
index 830121751f..11e0bb3e76 100644
--- a/gnu/packages/gdb.scm
+++ b/gnu/packages/gdb.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -117,6 +118,12 @@
         ("dejagnu" ,dejagnu)
         ("pkg-config" ,pkg-config)
         ,@(if (hurd-target?) `(("mig" ,mig)) '())))
+    ;; TODO: Add support for the GDB_DEBUG_FILE_DIRECTORY environment variable
+    ;; in GDB itself instead of relying on some glue code in the Guix-provided
+    ;; .gdbinit file.
+    (native-search-paths (list (search-path-specification
+                                (variable "GDB_DEBUG_FILE_DIRECTORY")
+                                (files '("lib/debug")))))
     (home-page "https://www.gnu.org/software/gdb/")
     (synopsis "The GNU debugger")
     (description
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index a69339bc07..8c76bc2b11 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -162,7 +163,12 @@ 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
+(use-modules (gdb))
+(execute (string-append \"set debug-file-directory \"
+                        (or (getenv \"GDB_DEBUG_FILE_DIRECTORY\")
+                            \"~/.guix-profile/lib/debug\")))
+end
 
 # Authorize extensions found in the store, such as the
 # pretty-printers of libstdc++.
-- 
2.27.0





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#42882]
  2020-08-16  8:21 ` Mathieu Othacehe
@ 2020-08-16 19:18   ` Maxim Cournoyer
  2020-08-16 19:18     ` [bug#42882] [PATCH v3] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
  2020-08-24  8:48     ` [bug#42882] Mathieu Othacehe
  0 siblings, 2 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2020-08-16 19:18 UTC (permalink / raw)
  To: 42882; +Cc: othacehe


Hello Mathieu,

Thanks for the review!  I've taken into account your suggestions and improved
the mechanism a bit, so that we can now simply use the
GDB_DEBUG_FILE_DIRECTORY environment variable (which is set up by a new search
path specification defined on the gdb package). I think this is better as
otherwise you'd need to ensure the gcc-toolchain is installed in the profile
you want GDB to find the debug files (because GCC is responsible for setting
the LIBRARY_PATH environment variable).

I hope it makes sense :-).

This will need to go to core-updates as gdb is has about 1500 dependents.

Thanks!

Maxim





^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#42882] [PATCH v3] system: Modify GDB skeleton to find debug files for any profile.
  2020-08-16 19:18   ` [bug#42882] Maxim Cournoyer
@ 2020-08-16 19:18     ` Maxim Cournoyer
  2020-08-24  8:48     ` [bug#42882] Mathieu Othacehe
  1 sibling, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2020-08-16 19:18 UTC (permalink / raw)
  To: 42882; +Cc: othacehe, Maxim Cournoyer

Instead of hard coding the debug directory to that of the user profile, use
Guile scripting in combination with a new search path specification on GDB to
specify the debug file directories.

* gnu/packages/gdb.scm (gdb-9.1): Add a search path specification for the
GDB_DEBUG_FILE_DIRECTORY environment variable.
* gnu/system/shadow.scm (default-skeletons)[gdbinit]: Derive the value of
DEBUG-FILE-DIRECTORY via the GDB_DEBUG_FILE_DIRECTORY environment variable.
* doc/guix.texi (Installing Debugging Files): Document it.
---
 doc/guix.texi         | 14 ++++++++++++++
 gnu/packages/gdb.scm  |  7 +++++++
 gnu/system/shadow.scm |  8 +++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 587c004bee..a066cddfe5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -30145,6 +30145,20 @@ 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 which is useful when working with
+other profiles.  It takes advantage of the optional Guile integration in
+GDB.  This snippet is included by default on Guix System in the
+@file{~/.gdbinit} file.
+
+@example
+guile
+(use-modules (gdb))
+(execute (string-append "set debug-file-directory "
+                        (or (getenv "GDB_DEBUG_FILE_DIRECTORY")
+                            "~/.guix-profile/lib/debug")))
+end
+@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/packages/gdb.scm b/gnu/packages/gdb.scm
index 830121751f..11e0bb3e76 100644
--- a/gnu/packages/gdb.scm
+++ b/gnu/packages/gdb.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -117,6 +118,12 @@
         ("dejagnu" ,dejagnu)
         ("pkg-config" ,pkg-config)
         ,@(if (hurd-target?) `(("mig" ,mig)) '())))
+    ;; TODO: Add support for the GDB_DEBUG_FILE_DIRECTORY environment variable
+    ;; in GDB itself instead of relying on some glue code in the Guix-provided
+    ;; .gdbinit file.
+    (native-search-paths (list (search-path-specification
+                                (variable "GDB_DEBUG_FILE_DIRECTORY")
+                                (files '("lib/debug")))))
     (home-page "https://www.gnu.org/software/gdb/")
     (synopsis "The GNU debugger")
     (description
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index a69339bc07..8c76bc2b11 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -162,7 +163,12 @@ 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
+(use-modules (gdb))
+(execute (string-append \"set debug-file-directory \"
+                        (or (getenv \"GDB_DEBUG_FILE_DIRECTORY\")
+                            \"~/.guix-profile/lib/debug\")))
+end
 
 # Authorize extensions found in the store, such as the
 # pretty-printers of libstdc++.
-- 
2.27.0





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#42882]
  2020-08-16 19:18   ` [bug#42882] Maxim Cournoyer
  2020-08-16 19:18     ` [bug#42882] [PATCH v3] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
@ 2020-08-24  8:48     ` Mathieu Othacehe
  2020-08-24 13:58       ` bug#42882: Maxim Cournoyer
  1 sibling, 1 reply; 7+ messages in thread
From: Mathieu Othacehe @ 2020-08-24  8:48 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: 42882


Hey Maxim,

> Thanks for the review!  I've taken into account your suggestions and improved
> the mechanism a bit, so that we can now simply use the
> GDB_DEBUG_FILE_DIRECTORY environment variable (which is set up by a new search
> path specification defined on the gdb package). I think this is better as
> otherwise you'd need to ensure the gcc-toolchain is installed in the profile
> you want GDB to find the debug files (because GCC is responsible for setting
> the LIBRARY_PATH environment variable).
>
> I hope it makes sense :-).

I think it makes! Your last revision seems fine to me.

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42882:
  2020-08-24  8:48     ` [bug#42882] Mathieu Othacehe
@ 2020-08-24 13:58       ` Maxim Cournoyer
  0 siblings, 0 replies; 7+ messages in thread
From: Maxim Cournoyer @ 2020-08-24 13:58 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 42882-done

Mathieu Othacehe <othacehe@gnu.org> writes:

> Hey Maxim,
>
>> Thanks for the review!  I've taken into account your suggestions and improved
>> the mechanism a bit, so that we can now simply use the
>> GDB_DEBUG_FILE_DIRECTORY environment variable (which is set up by a new search
>> path specification defined on the gdb package). I think this is better as
>> otherwise you'd need to ensure the gcc-toolchain is installed in the profile
>> you want GDB to find the debug files (because GCC is responsible for setting
>> the LIBRARY_PATH environment variable).
>>
>> I hope it makes sense :-).
>
> I think it makes! Your last revision seems fine to me.
>
> Thanks,
>
> Mathieu

Thanks for taking a look!  I've now pushed this change into the
core-updates branch as commit 720a4adc91.

Thank you,

Maxim




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-24 13:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16  5:39 [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
2020-08-16  8:21 ` Mathieu Othacehe
2020-08-16 19:18   ` [bug#42882] Maxim Cournoyer
2020-08-16 19:18     ` [bug#42882] [PATCH v3] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer
2020-08-24  8:48     ` [bug#42882] Mathieu Othacehe
2020-08-24 13:58       ` bug#42882: Maxim Cournoyer
2020-08-16 13:44 ` [bug#42882] [PATCH] system: Modify GDB skeleton to find debug files for any profile Maxim Cournoyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).