From 7c6f24f04bbf75f029c35e2be2d72046c29a406e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= Date: Tue, 16 May 2023 12:54:04 +0200 Subject: [PATCH] 3.21.0-3 - Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch --- valgrind-3.21.0-Add-with-gdbscripts-dir.patch | 123 ++++++++++++++++++ valgrind.spec | 19 ++- 2 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 valgrind-3.21.0-Add-with-gdbscripts-dir.patch diff --git a/valgrind-3.21.0-Add-with-gdbscripts-dir.patch b/valgrind-3.21.0-Add-with-gdbscripts-dir.patch new file mode 100644 index 0000000..5f8b4f9 --- /dev/null +++ b/valgrind-3.21.0-Add-with-gdbscripts-dir.patch @@ -0,0 +1,123 @@ +From e97f7a6cf2315908fb0a9b900f1de87a155c9df1 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sun, 14 May 2023 23:34:05 +0200 +Subject: [PATCH] Add --with-gdbscripts-dir=PATH configure option + +Currently the gdb valgrind scripts are installed under VG_LIBDIR +which is normally pkglibexecdir which is likely not in the default +gdb safe-path (a list of directories from which it is safe to +auto-load files). So users will have to add the directory to their +.gdbinit file. + +This patch adds a --with-gdbscripts-dir=PATH configure option that +sets VG_GDBSCRIPTS_DIR to the given PATH (${libexecdir}/valgrind if +not given). + +Use VG_GDBSCRIPTS_DIR as gdbscriptsdir to install the valgrind-monitor +python files and pass it with CPPFLAGS when building vg_preloaded.c +and vgdb.c to use instead of VG_LIBDIR. +--- + configure.ac | 11 +++++++++++ + coregrind/Makefile.am | 15 ++++++++++----- + coregrind/vg_preloaded.c | 2 +- + coregrind/vgdb.c | 2 +- + 4 files changed, 23 insertions(+), 7 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 15fbf5ea2..223ab4529 100755 +--- a/configure.ac ++++ b/configure.ac +@@ -1198,6 +1198,17 @@ AC_MSG_RESULT([$xcodedir]) + AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory]) + AC_SUBST(XCODE_DIR, [$xcodedir])]) + ++#---------------------------------------------------------------------------- ++# Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir) ++#---------------------------------------------------------------------------- ++AC_MSG_CHECKING([where gdb scripts are installed]) ++AC_ARG_WITH(gdbscripts-dir, ++ [ --with-gdbscripts-dir=PATH Specify path to install gdb scripts], ++ [gdbscriptsdir=${withval}], ++ [gdbscriptsdir=${libexecdir}/valgrind]) ++AC_MSG_RESULT([$gdbscriptsdir]) ++AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir]) ++ + #---------------------------------------------------------------------------- + # Libc and suppressions + #---------------------------------------------------------------------------- +diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am +index 553211782..64d593b08 100644 +--- a/coregrind/Makefile.am ++++ b/coregrind/Makefile.am +@@ -101,7 +101,8 @@ + vgdb_SOURCES += vgdb-invoker-freebsd.c + endif + +-vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) ++vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) \ ++ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" + vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) -fstack-protector-strong + vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI) + vgdb_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ -Wl,-z,now +@@ -626,7 +627,8 @@ + + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = \ +- $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) ++ $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) \ ++ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CFLAGS = \ + $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_PRI_CAPS@) + vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS = \ +@@ -634,7 +636,8 @@ + if VGCONF_HAVE_PLATFORM_SEC + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CPPFLAGS = \ +- $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) ++ $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) \ ++ -DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CFLAGS = \ + $(AM_CFLAGS_PSO_@VGCONF_PLATFORM_SEC_CAPS@) + vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_LDFLAGS = \ +@@ -766,8 +769,10 @@ + # so as to make sure these get copied into the install tree + vglibdir = $(pkglibexecdir) + vglib_DATA = $(GDBSERVER_XML_FILES) +-vglib_DATA += m_gdbserver/valgrind-monitor.py +-vglib_DATA += m_gdbserver/valgrind-monitor-def.py ++ ++gdbscriptsdir = @VG_GDBSCRIPTS_DIR@ ++gdbscripts_DATA = m_gdbserver/valgrind-monitor.py ++gdbscripts_DATA += m_gdbserver/valgrind-monitor-def.py + + # so as to make sure these get copied into the tarball + EXTRA_DIST += $(GDBSERVER_XML_FILES) +diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c +index d6e05898c..bff76b81b 100644 +--- a/coregrind/vg_preloaded.c ++++ b/coregrind/vg_preloaded.c +@@ -61,7 +61,7 @@ + .popsection \n\ + "); + +-DEFINE_GDB_PY_SCRIPT(VG_LIBDIR "/valgrind-monitor.py") ++DEFINE_GDB_PY_SCRIPT(VG_GDBSCRIPTS_DIR "/valgrind-monitor.py") + #endif + + #if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) +diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c +index 8ec424077..a449b86e0 100644 +--- a/coregrind/vgdb.c ++++ b/coregrind/vgdb.c +@@ -1984,7 +1984,7 @@ void usage(void) + " -h --help shows this message\n" + " The GDB python code defining GDB front end valgrind commands is:\n %s\n" + " To get help from the Valgrind gdbserver, use vgdb help\n" +-"\n", vgdb_prefix_default(), VG_LIBDIR "/valgrind-monitor.py" ++"\n", vgdb_prefix_default(), VG_GDBSCRIPTS_DIR "/valgrind-monitor.py" + ); + invoker_restrictions_msg(); + } +-- +2.40.0 + diff --git a/valgrind.spec b/valgrind.spec index 1b2a9ed..09b30ff 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 2%{?dist} +Release: 3%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -87,6 +87,13 @@ Patch4: valgrind-3.16.0-some-Wl-z-now.patch # by disabling overlap checking for memcpy Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch +# Add --with-gdbscripts-dir=PATH configure option +# https://bugs.kde.org/show_bug.cgi?id=469768 + %patch6 -p1 + + +Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch + BuildRequires: make BuildRequires: glibc-devel @@ -226,6 +233,8 @@ Valgrind User Manual for details. %patch5 -p1 +%patch6 -p1 + %build # LTO triggers undefined symbols in valgrind. Valgrind has a --enable-lto # configure time option, but that doesn't seem to help. @@ -294,7 +303,8 @@ export LDFLAGS %configure \ --with-mpicc=%{mpiccpath} \ %{only_arch} \ - GDB=%{_bindir}/gdb + GDB=%{_bindir}/gdb \ + --with-gdbscripts-dir=%{_datadir}/gdb/auto-load %make_build @@ -412,6 +422,8 @@ echo ===============END TESTING=============== # Was disabled in %%install to prevent debuginfo stripping. %attr(0755,root,root) %{_libexecdir}/valgrind/vgpreload*-%{valarch}-*so %{_mandir}/man1/* +%{_datadir}/gdb/auto-load/valgrind-monitor.py +%{_datadir}/gdb/auto-load/valgrind-monitor-def.py %files devel %dir %{_includedir}/valgrind @@ -454,6 +466,9 @@ fi %endif %changelog +* Tue May 16 2023 Alexandra Hájková - 3.21.0-3 +- Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch + * Fri May 5 2023 Mark Wielaard - 3.21.0-2 - Add valgrind-3.21.0-no-memcpy-replace-check.patch