[binutils-gdb] gdb: wrap mdebug debuginfo reading in ifdefs
Guinevere Larsen
guinevere@sourceware.org
Tue Jun 3 16:36:58 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5cbfbe4263a5347501bbe14b53b30cf7c09a9f62
commit 5cbfbe4263a5347501bbe14b53b30cf7c09a9f62
Author: Guinevere Larsen <guinevere@redhat.com>
Date: Fri Jan 3 14:59:16 2025 -0300
gdb: wrap mdebug debuginfo reading in ifdefs
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>
Diff:
---
gdb/Makefile.in | 1 -
gdb/NEWS | 4 ++++
gdb/README | 3 +++
gdb/config.in | 3 +++
gdb/configure | 33 +++++++++++++++++++++++++++++++--
gdb/configure.ac | 14 ++++++++++++++
gdb/mdebugread.c | 2 +-
gdb/mdebugread.h | 25 +++++++++++++++++++++----
8 files changed, 77 insertions(+), 8 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index f30c38d1b47..a3760c6b3fd 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -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 \
diff --git a/gdb/NEWS b/gdb/NEWS
index 24d00892564..5efe45605ab 100644
--- 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
diff --git a/gdb/README b/gdb/README
index 3c42936b679..ae331a4e816 100644
--- a/gdb/README
+++ b/gdb/README
@@ -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.
diff --git a/gdb/config.in b/gdb/config.in
index 426947e6b2d..db55ad69cd2 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -639,6 +639,9 @@
*/
#undef LT_OBJDIR
+/* defined if mdebug format was requested. */
+#undef MDEBUG_FORMAT_AVAILABLE
+
/* Name of this package. */
#undef PACKAGE
diff --git a/gdb/configure b/gdb/configure
index b34f66679e8..01db0d0f1e2 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -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
@@ -24875,6 +24879,31 @@ fi
+# 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
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 9529e850154..e8ce4212ab9 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -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
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 51e224fa135..51e1907c683 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -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,
diff --git a/gdb/mdebugread.h b/gdb/mdebugread.h
index a4a5aa99b62..f7e9f9806f7 100644
--- a/gdb/mdebugread.h
+++ b/gdb/mdebugread.h
@@ -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 */
More information about the Gdb-cvs
mailing list