]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add --with-gdbscripts-dir=PATH configure option
authorMark Wielaard <mark@klomp.org>
Sun, 14 May 2023 21:34:05 +0000 (23:34 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 19 May 2023 13:51:38 +0000 (15:51 +0200)
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
configure.ac
coregrind/Makefile.am
coregrind/vg_preloaded.c
coregrind/vgdb.c

diff --git a/NEWS b/NEWS
index 87bfae5960b24dbf286bac77cfa4e2c029b7e49d..ea9fc7c868337a42d33ecc3a0014221c80134b54 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,13 @@ AMD64/macOS 10.13 and nanoMIPS/Linux.
 
 * ==================== CORE CHANGES ===================
 
+* A new configure option --with-gdbscripts-dir lets you install
+  the gdb valgrind python monitor scripts in a specific location.
+  For example an distro could use it to install the scripts in a
+  safe load location --with-gdbscripts-dir=%{_datadir}/gdb/auto-load
+  It is also possible to configure --without-gdb-scripts-dir so no
+  .debug_gdb_scripts section is added to the vgpreload library and
+  no valgrind-monitor python scripts are installed at all.
 
 * ================== PLATFORM CHANGES =================
 
@@ -29,6 +36,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 460192  Add epoll_pwait2
 469049  link failure on ppc64 (big endian) valgrind 3.20
 469146  massif --ignore-fn does not ignore inlined functions
+469768  Make it possible to install gdb scripts in a different location
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 15fbf5ea206d69a7e10c9858ebd00fda5bc2e945..0cf84a1c00be295042f8f1f0d26b703170fe8aa7 100755 (executable)
@@ -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
 #----------------------------------------------------------------------------
index 553211782fcf277dc4f5ca7b095108d01a3b77b4..8a7f753a6e0dabb594464148fc617695b54f35b5 100644 (file)
@@ -101,7 +101,7 @@ if VGCONF_OS_IS_FREEBSD
 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)
 vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI)
 vgdb_LDFLAGS   = $(AM_CFLAGS_PRI) @LIB_UBSAN@
@@ -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)
index d6e05898c9026a518626cfdd7ea17741414bf28c..86f6ac5a26e498e2a216785a0f22e4c045c4414f 100644 (file)
@@ -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)
index 8ec42407704b1c0fe59de4ebdec7add8d0ec0e54..56a969de7881585eabc18ee6027b81284e7ab7bc 100644 (file)
@@ -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();
 }