summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-04-26 03:39:13 +0200
committerLudovic Courtès <ludo@gnu.org>2022-05-09 12:26:45 +0200
commit4d1a88312cbebb10d47905d6d023953ac85bcd04 (patch)
tree6259f5b549049c4d4c6f27c9772b6cd948a81ae9
parentfcf0949c7dd40e9422ec74163d8e0d57200b183e (diff)
downloadguix-patches-4d1a88312cbebb10d47905d6d023953ac85bcd04.tar
guix-patches-4d1a88312cbebb10d47905d6d023953ac85bcd04.tar.gz
gnu: valgrind: Allow ld.so symbols to be found.
Fixes <https://issues.guix.gnu.org/54728>. * gnu/packages/valgrind.scm (valgrind/interactive)[native-inputs]: Add libc:debug [arguments]: Add patch-default-debuginfo-path phase [source]: Add patch. (valgrind-3.18)[source]: Inherit from (package-source valgrind/interactive) and remove 'patches' field. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--gnu/local.mk3
-rw-r--r--gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch100
-rw-r--r--gnu/packages/valgrind.scm59
3 files changed, 157 insertions, 5 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 7d61def3ff..3b7db46b26 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1921,7 +1921,8 @@ dist_patch_DATA = \
%D%/packages/patches/util-linux-tests.patch \
%D%/packages/patches/util-linux-CVE-2021-3995.patch \
%D%/packages/patches/util-linux-CVE-2021-3996.patch \
- %D%/packages/patches/valgrind-enable-arm.patch \
+ %D%/packages/patches/valgrind-enable-arm.patch \
+ %D%/packages/patches/valgrind-fix-default-debuginfo-path.patch \
%D%/packages/patches/vboot-utils-fix-format-load-address.patch \
%D%/packages/patches/vboot-utils-fix-tests-show-contents.patch \
%D%/packages/patches/vboot-utils-skip-test-workbuf.patch \
diff --git a/gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch b/gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch
new file mode 100644
index 0000000000..f78dec02dc
--- /dev/null
+++ b/gnu/packages/patches/valgrind-fix-default-debuginfo-path.patch
@@ -0,0 +1,100 @@
+From a7f17b57a94e9cde6d7fa96ac86be5c4fc4f9211 Mon Sep 17 00:00:00 2001
+From: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+Date: Sun, 24 Apr 2022 22:20:50 +0200
+Subject: [PATCH] valgrind: fix default debuginfo path
+
+Description: Workaround for missing symbol in Guix's ld.so. The
+ correct fix (not stripping all the ld.so symbols) will be done in the
+ next Guix release as it requires to recompile a lot of packages.
+
+Forwarded: not-needed
+Bug-Guix: https://issues.guix.gnu.org/54728
+Author: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+---
+ coregrind/m_debuginfo/readelf.c | 11 ++++++-----
+ docs/xml/manual-core-adv.xml | 4 ++--
+ docs/xml/manual-core.xml | 2 +-
+ 3 files changed, 9 insertions(+), 8 deletions(-)
+
+diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
+index c586e3f33..947fcc500 100644
+--- a/coregrind/m_debuginfo/readelf.c
++++ b/coregrind/m_debuginfo/readelf.c
+@@ -1509,9 +1509,9 @@ DiImage* find_debug_file( struct _DebugInfo* di,
+
+ if (buildid != NULL) {
+ debugpath = ML_(dinfo_zalloc)("di.fdf.1",
+- VG_(strlen)(buildid) + 33);
++ VG_(strlen)(buildid) + DEBUGPATH_EXTRA_BYTES_1);
+
+- VG_(sprintf)(debugpath, "/usr/lib/debug/.build-id/%c%c/%s.debug",
++ VG_(sprintf)(debugpath, "DEFAULT_DEBUGINFO_PATH/.build-id/%c%c/%s.debug",
+ buildid[0], buildid[1], buildid + 2);
+
+ dimg = open_debug_file(debugpath, buildid, 0, rel_ok, NULL);
+@@ -1536,7 +1536,8 @@ DiImage* find_debug_file( struct _DebugInfo* di,
+
+ debugpath = ML_(dinfo_zalloc)(
+ "di.fdf.3",
+- VG_(strlen)(objdir) + VG_(strlen)(debugname) + 64
++ VG_(strlen)(objdir) + VG_(strlen)(debugname)
++ + VG_(strlen)("DEFAULT_DEBUGINFO_PATH/") + 1
+ + (extrapath ? VG_(strlen)(extrapath) : 0)
+ + (serverpath ? VG_(strlen)(serverpath) : 0));
+
+@@ -1561,7 +1562,7 @@ DiImage* find_debug_file( struct _DebugInfo* di,
+
+ TRY_OBJDIR_USRMERGE_OBJDIR("%s/%s");
+ TRY_OBJDIR_USRMERGE_OBJDIR("%s/.debug/%s");
+- TRY_OBJDIR_USRMERGE_OBJDIR("/usr/lib/debug%s/%s");
++ TRY_OBJDIR_USRMERGE_OBJDIR("DEFAULT_DEBUGINFO_PATH%s/%s");
+
+ if (extrapath) {
+ TRY_OBJDIR("%s%s/%s", extrapath, objdir, debugname);
+@@ -1631,7 +1632,7 @@ DiImage* find_debug_file_ad_hoc( const DebugInfo* di,
+
+ debugpath = ML_(dinfo_zalloc)(
+ "di.fdfah.3",
+- VG_(strlen)(objdir) + 64
++ VG_(strlen)(objdir) + DEBUGPATH_EXTRA_BYTES_2
+ + (extrapath ? VG_(strlen)(extrapath) : 0)
+ + (serverpath ? VG_(strlen)(serverpath) : 0));
+
+diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml
+index 1fa801edc..a7c01d5e6 100644
+--- a/docs/xml/manual-core-adv.xml
++++ b/docs/xml/manual-core-adv.xml
+@@ -447,7 +447,7 @@ Valgrind embedded gdbserver:</para>
+ Remote debugging using | vgdb
+ relaying data between gdb and process 2418
+ Reading symbols from /lib/ld-linux.so.2...done.
+-Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so.debug...done.
++Reading symbols from DEFAULT_DEBUGINFO_PATH/lib/ld-2.11.2.so.debug...done.
+ Loaded symbols for /lib/ld-linux.so.2
+ [Switching to Thread 2418]
+ 0x001f2850 in _start () from /lib/ld-linux.so.2
+@@ -475,7 +475,7 @@ Remote communication error: Resource temporarily unavailable.
+ Remote debugging using | vgdb --pid=2479
+ relaying data between gdb and process 2479
+ Reading symbols from /lib/ld-linux.so.2...done.
+-Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so.debug...done.
++Reading symbols from DEFAULT_DEBUGINFO_PATH/lib/ld-2.11.2.so.debug...done.
+ Loaded symbols for /lib/ld-linux.so.2
+ [Switching to Thread 2479]
+ 0x001f2850 in _start () from /lib/ld-linux.so.2
+diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml
+index dc33e1269..f6eb60086 100644
+--- a/docs/xml/manual-core.xml
++++ b/docs/xml/manual-core.xml
+@@ -1409,7 +1409,7 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para>
+ <listitem>
+ <para>By default Valgrind searches in several well-known paths
+ for debug objects, such
+- as <computeroutput>/usr/lib/debug/</computeroutput>.</para>
++ as <computeroutput>DEFAULT_DEBUGINFO_PATH/</computeroutput>.</para>
+
+ <para>However, there may be scenarios where you may wish to put
+ debug objects at an arbitrary location, such as external storage
+--
+2.35.1
+
diff --git a/gnu/packages/valgrind.scm b/gnu/packages/valgrind.scm
index 6648f17dfa..2a6e63a410 100644
--- a/gnu/packages/valgrind.scm
+++ b/gnu/packages/valgrind.scm
@@ -25,9 +25,12 @@
(define-module (gnu packages valgrind)
#:use-module (guix build-system gnu)
#:use-module (guix download)
+ #:use-module (guix gexp)
#:use-module (guix licenses)
#:use-module (guix packages)
+ #:use-module (guix utils)
#:use-module (gnu packages)
+ #:use-module (gnu packages base)
#:use-module (gnu packages gdb)
#:use-module (gnu packages perl))
@@ -93,9 +96,58 @@ also use Valgrind to build new tools.")
(define-public valgrind/interactive
(package/inherit
valgrind
+ (version "3.17.0")
+ (source (origin
+ (method url-fetch)
+ (uri (list (string-append "https://sourceware.org/pub/valgrind"
+ "/valgrind-" version ".tar.bz2")
+ (string-append "ftp://sourceware.org/pub/valgrind"
+ "/valgrind-" version ".tar.bz2")))
+ (sha256
+ (base32
+ "18l5jbk301j3462gipqn9bkfx44mdmwn0pwr73r40gl1irkfqfmd"))
+ (patches (search-patches
+ "valgrind-enable-arm.patch"
+ "valgrind-fix-default-debuginfo-path.patch"))))
(inputs
;; GDB is needed to provide a sane default for `--db-command'.
- `(("gdb" ,gdb)))
+ `(("gdb" ,gdb)
+ ("glibc:debug" ,(canonical-package glibc) "debug")))
+ (arguments
+ (substitute-keyword-arguments (package-arguments valgrind)
+ ((#:phases phases #~%standard-phases)
+ #~(modify-phases #$phases
+ (add-before 'configure 'patch-default-debuginfo-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; This helps Valgrind find the debug symbols of ld.so.
+ ;; Without it, Valgrind does not work in a Guix shell
+ ;; container and cannot be used as-is during packages tests
+ ;; phases.
+ ;; TODO: Remove on the next rebuild cycle, when libc is not
+ ;; longer fully stripped.
+ (define libc-debug
+ (string-append (assoc-ref inputs "glibc:debug")
+ "/lib/debug"))
+
+ (substitute* '("coregrind/m_debuginfo/readelf.c"
+ "docs/xml/manual-core-adv.xml"
+ "docs/xml/manual-core.xml")
+ (("DEFAULT_DEBUGINFO_PATH")
+ libc-debug))
+ ;; We also need to account for the bigger path in
+ ;; the malloc-ed variables.
+ (substitute* '("coregrind/m_debuginfo/readelf.c")
+ (("DEBUGPATH_EXTRA_BYTES_1")
+ (number->string
+ (+ (string-length libc-debug)
+ (string-length "/.build-id//.debug")
+ 1))))
+ (substitute* '("coregrind/m_debuginfo/readelf.c")
+ (("DEBUGPATH_EXTRA_BYTES_2")
+ (number->string
+ (+ (string-length libc-debug)
+ (string-length "/usr/lib/debug")
+ 1))))))))))
(properties '())))
(define-public valgrind-3.18
@@ -103,12 +155,11 @@ also use Valgrind to build new tools.")
(inherit valgrind/interactive)
(version "3.18.1")
(source (origin
- (method url-fetch)
+ (inherit (package-source valgrind/interactive))
(uri (list (string-append "https://sourceware.org/pub/valgrind"
"/valgrind-" version ".tar.bz2")
(string-append "ftp://sourceware.org/pub/valgrind"
"/valgrind-" version ".tar.bz2")))
(sha256
(base32
- "1xgph509i6adv9w2glviw3xrmlz0dssg8992hbvxsbkp7ahrm180"))
- (patches (search-patches "valgrind-enable-arm.patch"))))))
+ "1xgph509i6adv9w2glviw3xrmlz0dssg8992hbvxsbkp7ahrm180"))))))