[RFC] gdb: wrap mdebug debuginfo reading in ifdefs
Checks
Commit Message
This commit aims to allow a user to enable or disable mdebug support at
compilation time. In order to do that, 2 new macros are defined:
elf_read_mdebug and mips_read_mdebug. If support was requested at
compile time, these macros are turned into simple function calls to
elfmdebug_build_psymtabs and mipsmdebug_build_psymtabs. If support was
disabled, the macros are turned into warnings that mdebug is not
supported.
The final implementation will also contain changes to the configure
script.
---
Hi Tromey!
This is my best solution for using preprocessor ifs to define functions,
and mdebug is a simple case to test out. I don't quite love the final result,
so if you have better ideas I'm all ears!
---
gdb/elfread.c | 2 +-
gdb/mdebugread.h | 22 ++++++++++++++++++++++
gdb/mipsread.c | 2 +-
3 files changed, 24 insertions(+), 2 deletions(-)
@@ -1333,7 +1333,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
information. */
swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
if (swap)
- elfmdebug_build_psymtabs (objfile, swap, ei.mdebugsect);
+ elf_read_mdebug (objfile, swap, ei.mdebugsect);
}
if (ei.stabsect)
{
@@ -54,4 +54,26 @@ extern void mipsmdebug_build_psymtabs (struct objfile *,
const struct ecoff_debug_swap *,
struct ecoff_debug_info *);
+#define MDEBUG_FORMAT_AVAILABLE 1
+
+#if MDEBUG_FORMAT_AVAILABLE
+# define elf_read_mdebug(objf, swap, asection) \
+ elfmdebug_build_psymtabs(objf, swap, asection)
+# define mips_read_mdebug(objf, swap, info) \
+ mipsmdebug_build_psymtabs(objf, swap, info)
+#else
+/* We need the second line here so that the compiler doesn't
+ complain about unused variables. */
+# define elf_read_mdebug(objf, swap, asection) \
+ do { \
+ warning ("No mdebug support available"); \
+ (void) objf; (void) swap; (void) asection; \
+ } while (0)
+# define mips_read_mdebug(objf, swap, info) \
+ do { \
+ warning ("No mdebug support available"); \
+ (void) objf; (void) swap; (void) info; \
+ } while (0)
+#endif /* MDEBUG_FORMAT_AVAILABLE */
+
#endif /* GDB_MDEBUGREAD_H */
@@ -69,7 +69,7 @@ mipscoff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
/* Now that the executable file is positioned at symbol table,
process it and define symbols accordingly. */
- mipsmdebug_build_psymtabs (objfile, &ecoff_backend (abfd)->debug_swap,
+ mips_read_mdebug (objfile, &ecoff_backend (abfd)->debug_swap,
&ecoff_data (abfd)->debug_info);
/* Add alpha coff dynamic symbols. */