From 39f8cca8df4f6ce93b8a8d13bdd67027e4629039 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 Resolves: #2208574 Disable valgrind-monitor python scripts --- valgrind-3.21.0-Add-with-gdbscripts-dir.patch | 152 ++++++++++++++++++ valgrind.spec | 14 +- 2 files changed, 164 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..c241dc3 --- /dev/null +++ b/valgrind-3.21.0-Add-with-gdbscripts-dir.patch @@ -0,0 +1,152 @@ +From e3602b3eec0696b183722ea21da14588cf205c74 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). A user can also configure --without-gdbscripts-dir to +disable adding a .debug_gdb_scripts section to the vgpreload library +and installing the valgrind-monitor python scripts completely. + +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. + +https://bugs.kde.org/show_bug.cgi?id=469768 +--- + NEWS | 8 ++++++++ + configure.ac | 17 +++++++++++++++++ + coregrind/Makefile.am | 20 +++++++++++++++----- + coregrind/vg_preloaded.c | 4 +++- + coregrind/vgdb.c | 9 +++++++-- + 5 files changed, 50 insertions(+), 8 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 15fbf5ea2..0cf84a1c0 100755 +--- a/configure.ac ++++ b/configure.ac +@@ -1198,6 +1198,23 @@ 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]) ++if test "x$gdbscriptsdir" != "xno"; then ++ AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir]) ++ AM_CONDITIONAL(GDBSCRIPTS, true) ++else ++ AC_SUBST(VG_GDBSCRIPTS_DIR, []) ++ AM_CONDITIONAL(GDBSCRIPTS, false) ++fi ++ + #---------------------------------------------------------------------------- + # Libc and suppressions + #---------------------------------------------------------------------------- +diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am +index 553211782..8a7f753a6 100644 +--- a/coregrind/Makefile.am ++++ b/coregrind/Makefile.am +@@ -101,7 +101,7 @@ + vgdb_SOURCES += vgdb-invoker-freebsd.c + endif + +-vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) ++vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) $(GDB_SCRIPTS_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 +@@ -624,9 +624,15 @@ if VGCONF_OS_IS_DARWIN + noinst_DSYMS = $(noinst_PROGRAMS) + endif + ++if GDBSCRIPTS ++ GDB_SCRIPTS_DIR=-DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\"" ++else ++ GDB_SCRIPTS_DIR= ++endif ++ + 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@) $(GDB_SCRIPTS_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 +640,7 @@ vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS = \ + 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@) $(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 +772,12 @@ GDBSERVER_XML_FILES = \ + # 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 ++ ++if GDBSCRIPTS ++gdbscriptsdir = @VG_GDBSCRIPTS_DIR@ ++gdbscripts_DATA = m_gdbserver/valgrind-monitor.py ++gdbscripts_DATA += m_gdbserver/valgrind-monitor-def.py ++endif + + # 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..86f6ac5a2 100644 +--- a/coregrind/vg_preloaded.c ++++ b/coregrind/vg_preloaded.c +@@ -61,7 +61,9 @@ + .popsection \n\ + "); + +-DEFINE_GDB_PY_SCRIPT(VG_LIBDIR "/valgrind-monitor.py") ++#ifdef VG_GDBSCRIPTS_DIR ++DEFINE_GDB_PY_SCRIPT(VG_GDBSCRIPTS_DIR "/valgrind-monitor.py") ++#endif + #endif + + #if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) +diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c +index 8ec424077..56a969de7 100644 +--- a/coregrind/vgdb.c ++++ b/coregrind/vgdb.c +@@ -1982,10 +1982,15 @@ void usage(void) + " -d arg tells to show debug info. Multiple -d args for more debug info\n" + "\n" + " -h --help shows this message\n" ++#ifdef VG_GDBSCRIPTS_DIR + " The GDB python code defining GDB front end valgrind commands is:\n %s\n" ++#endif + " To get help from the Valgrind gdbserver, use vgdb help\n" +-"\n", vgdb_prefix_default(), VG_LIBDIR "/valgrind-monitor.py" +- ); ++"\n", vgdb_prefix_default() ++#ifdef VG_GDBSCRIPTS_DIR ++ , VG_GDBSCRIPTS_DIR "/valgrind-monitor.py" ++#endif ++ ); + invoker_restrictions_msg(); + } + +-- +2.31.1 + diff --git a/valgrind.spec b/valgrind.spec index d985f13..ab43514 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/ @@ -88,6 +88,10 @@ 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: valgrind-3.21.0-Add-with-gdbscripts-dir.patch + BuildRequires: make BuildRequires: glibc-devel @@ -230,6 +234,8 @@ Valgrind User Manual for details. %patch5 -p1 +%patch6 -p1 + %build # Some patches (might) touch Makefile.am or configure.ac files. @@ -294,7 +300,8 @@ export LDFLAGS %configure \ --with-mpicc=%{mpiccpath} \ %{only_arch} \ - GDB=%{_bindir}/gdb + GDB=%{_bindir}/gdb \ + --without-gdbscripts-dir make %{?_smp_mflags} @@ -454,6 +461,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 - Upgrade to upstream 3.21.0 - Remove upstreamed patches