Message ID | 20200816053947.30110-1-maxim.cournoyer@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [bug#42882] system: Modify GDB skeleton to find debug files for any profile. | expand |
Context | Check | Description |
---|---|---|
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | success | View Laminar job |
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
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
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
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
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++.