]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: wrap mdebug debuginfo reading in ifdefs
authorGuinevere Larsen <guinevere@redhat.com>
Fri, 3 Jan 2025 17:59:16 +0000 (14:59 -0300)
committerGuinevere Larsen <guinevere@redhat.com>
Tue, 3 Jun 2025 16:36:32 +0000 (13:36 -0300)
This commit aims to allow a user to enable or disable mdebug support at
compilation time. To do that, a new configure option is added, called
--enable-gdb-mdebug-support (and the accompanying --disable version). By
default, support is enabled, and if a user decides to disable support,
the file mdebugread.c won't be compiled in the final binary, and the
macro MDEBUG_FORMAT_AVAILABLE won't be defined.

That macro is used to control the definitions of mdebug reading, either
the actual definition in mdebugread.c, or a static inline version that
only emits the following warning:

> No mdebug support available.

Ideally, we'd like to guard the entirity of mdebugread in the macro, but
the alpha-mdebug-tdep file uses those directly, and I don't think we
should restrict alpha hosts to requiring that debug format compiled in,
nor do I understand the tdep file enough to be comfortable disentangling
the requirements.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/Makefile.in
gdb/NEWS
gdb/README
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/mdebugread.c
gdb/mdebugread.h

index f30c38d1b47aef636e1ee53399bae49ff2e18eb1..a3760c6b3fd92a09716ff2f4f9d5758782717a92 100644 (file)
@@ -1172,7 +1172,6 @@ COMMON_SFILES = \
        maint.c \
        maint-test-options.c \
        maint-test-settings.c \
-       mdebugread.c \
        mem-break.c \
        memattr.c \
        memory-map.c \
index 24d00892564686eccf872d89f510c3c0e4929704..5efe45605ab0cb5d7d1f76a06d462f9bb4bdca27 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -209,6 +209,10 @@ qXfer:threads:read
   subsystem to be disabled at configure time, in the form of
   --disable-gdb-compile.
 
+* A new configure option was added, allowing support for mdebug/ecoff
+  debug information to be disabled at configure time.  The flag to do
+  that is --disable-gdb-mdebug-support.
+
 *** Changes in GDB 16
 
 * Support for Nios II targets has been removed as this architecture
index 3c42936b67962f86222a11de7c6ddf7095be3f8b..ae331a4e816fd3b49f68ffa5a3d25246ec3468b7 100644 (file)
@@ -445,6 +445,9 @@ more obscure GDB `configure' options are not listed here.
 `--disable-gdb-compile'
     Build GDB without support for the 'compile' command.
 
+`--disable-gdb-mdebug-support'
+    Build GDB without support for reading mdebug debug information.
+
 `--with-curses'
      Use the curses library instead of the termcap library, for
      text-mode terminal operations.
index 426947e6b2d8fe1fa8e9f0205c1032e835427563..db55ad69cd22516b3f4953b14604ba60a274bbbd 100644 (file)
    */
 #undef LT_OBJDIR
 
+/* defined if mdebug format was requested. */
+#undef MDEBUG_FORMAT_AVAILABLE
+
 /* Name of this package. */
 #undef PACKAGE
 
index b34f66679e8e3c47a36358d5b7c636c15d5c2a1d..01db0d0f1e21ffb29ddd776a28a5e3c9fdcf573d 100755 (executable)
@@ -932,6 +932,7 @@ with_relocated_sources
 with_auto_load_dir
 with_auto_load_safe_path
 enable_targets
+enable_gdb_mdebug_support
 with_amd_dbgapi
 enable_tui
 enable_gdbtk
@@ -1643,6 +1644,9 @@ Optional Features:
   --disable-nls           do not use Native Language Support
   --enable-targets=TARGETS
                           alternative target configurations
+  --enable-gdb-mdebug-support
+                          Enable support for the mdebug debuginfo format
+                          (default 'yes')
   --enable-tui            enable full-screen terminal user interface (TUI)
   --enable-gdbtk          enable gdbtk graphical user interface (GUI)
   --enable-profiling      enable profiling of GDB
@@ -11499,7 +11503,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11502 "configure"
+#line 11506 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11605,7 +11609,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11608 "configure"
+#line 11612 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
 
 
 
+# Check whether to support mdebug/ecoff debug information.
+# Check whether --enable-gdb-mdebug-support was given.
+if test "${enable_gdb_mdebug_support+set}" = set; then :
+  enableval=$enable_gdb_mdebug_support;
+          case $enableval in
+            yes | no)
+              ;;
+            *)
+              as_fn_error $? "bad value $enableval for --enable-gdb-mdebug-support" "$LINENO" 5
+              ;;
+          esac
+
+else
+  enable_gdb_mdebug_support=yes
+fi
+
+
+if test "x${enable_gdb_mdebug_support}" != "xno"; then
+    CONFIG_SRCS="$CONFIG_SRCS mdebugread.c"
+    CONFIG_OBS="$CONFIG_OBS mdebugread.o"
+
+$as_echo "#define MDEBUG_FORMAT_AVAILABLE 1" >>confdefs.h
+
+fi
+
 # See whether 64-bit bfd lib has been enabled.
 OLD_CPPFLAGS=$CPPFLAGS
 # Put the old CPPFLAGS last, in case the user's CPPFLAGS point somewhere
index 9529e850154f780b98c4966363246a25fe4fbda5..e8ce4212ab93403378fbe20130f4fa1aed6b2c85 100644 (file)
@@ -192,6 +192,20 @@ AS_HELP_STRING([--enable-targets=TARGETS], [alternative target configurations]),
 esac])
 
 
+# Check whether to support mdebug/ecoff debug information.
+AC_ARG_ENABLE(gdb-mdebug-support,
+AS_HELP_STRING([--enable-gdb-mdebug-support],
+              [Enable support for the mdebug debuginfo format (default 'yes')]),
+[GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdb-mdebug-support])],
+[enable_gdb_mdebug_support=yes])
+
+if test "x${enable_gdb_mdebug_support}" != "xno"; then
+    CONFIG_SRCS="$CONFIG_SRCS mdebugread.c"
+    CONFIG_OBS="$CONFIG_OBS mdebugread.o"
+    AC_DEFINE(MDEBUG_FORMAT_AVAILABLE, 1,
+             [defined if mdebug format was requested.])
+fi
+
 BFD_64_BIT
 
 # Provide defaults for some variables set by the per-host and per-target
index 51e224fa135d1db307b2507e49a5c0348c2491e9..51e1907c6830a23eecca77044cb4b78c2ae2d785 100644 (file)
@@ -329,7 +329,7 @@ fdr_name (FDR *f)
 /* Read in and parse the symtab of the file OBJFILE.  Symbols from
    different sections are relocated via the SECTION_OFFSETS.  */
 
-void
+static void
 mdebug_build_psymtabs (minimal_symbol_reader &reader,
                       struct objfile *objfile,
                       const struct ecoff_debug_swap *swap,
index a4a5aa99b62800c54a665f0ba80a0f17507a7eda..f7e9f9806f74bdd458d936ea1e06366ae1eded46 100644 (file)
@@ -37,10 +37,7 @@ struct mdebug_extra_func_info
 
 #define MDEBUG_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
 
-extern void mdebug_build_psymtabs (minimal_symbol_reader &,
-                                  struct objfile *,
-                                  const struct ecoff_debug_swap *,
-                                  struct ecoff_debug_info *);
+#if defined(MDEBUG_FORMAT_AVAILABLE)
 
 extern void elfmdebug_build_psymtabs (struct objfile *,
                                      const struct ecoff_debug_swap *,
@@ -54,4 +51,24 @@ extern void mipsmdebug_build_psymtabs (struct objfile *,
                                       const struct ecoff_debug_swap *,
                                       struct ecoff_debug_info *);
 
+#else /* MDEBUG_FORMAT_AVAILABLE */
+
+static inline void
+elfmdebug_build_psymtabs (struct objfile *,
+                         const struct ecoff_debug_swap *,
+                         asection *)
+{
+  warning (_("No mdebug support available"));
+}
+
+static inline void
+mipsmdebug_build_psymtabs (struct objfile *,
+                          const struct ecoff_debug_swap *,
+                          struct ecoff_debug_info *)
+{
+  warning (_("No mdebug support available"));
+}
+
+#endif /* MDEBUG_FORMAT_AVAILABLE */
+
 #endif /* GDB_MDEBUGREAD_H */