From deeafabb678e59d8585be6d765c7fbd0e7060b6c Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 19 Jan 2019 21:33:50 -0700 Subject: [PATCH] Remove MULTI_OBJFILE_P This removes the MULTI_OBJFILE_P macro in favor of a method on the program space. gdb/ChangeLog 2019-12-12 Tom Tromey * progspace.c (program_space::multi_objfile_p): New method. * printcmd.c (info_symbol_command): Update. * maint.c (maintenance_translate_address): Update. * objfiles.h (MULTI_OBJFILE_P): Remove. * progspace.h (struct program_space) : New method. Change-Id: I2779e26ea8909078d63fea8f13bce94cab73948c --- gdb/ChangeLog | 9 +++++++++ gdb/maint.c | 2 +- gdb/objfiles.h | 4 ---- gdb/printcmd.c | 2 +- gdb/progspace.c | 8 ++++++++ gdb/progspace.h | 5 +++++ 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c6345c0d63f..26f764e174b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2019-12-12 Tom Tromey + + * progspace.c (program_space::multi_objfile_p): New method. + * printcmd.c (info_symbol_command): Update. + * maint.c (maintenance_translate_address): Update. + * objfiles.h (MULTI_OBJFILE_P): Remove. + * progspace.h (struct program_space) : New + method. + 2019-12-12 Tom Tromey * progspace.h (struct program_space) : Declare. diff --git a/gdb/maint.c b/gdb/maint.c index dbc949a61c0..f71cb80cec6 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -589,7 +589,7 @@ maintenance_translate_address (const char *arg, int from_tty) gdb_assert (sect->objfile && objfile_name (sect->objfile)); obj_name = objfile_name (sect->objfile); - if (MULTI_OBJFILE_P ()) + if (current_program_space->multi_objfile_p ()) printf_filtered (_("%s + %s in section %s of %s\n"), symbol_name, symbol_offset, section_name, obj_name); diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 49b4627d67c..0656cfe4a12 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -773,10 +773,6 @@ extern void default_iterate_over_objfiles_in_search_order uninitialized section index. */ #define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss -/* Answer whether there is more than one object file loaded. */ - -#define MULTI_OBJFILE_P() (object_files && object_files->next) - /* Reset the per-BFD storage area on OBJ. */ void set_objfile_per_bfd (struct objfile *obj); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 480e7f22390..77cdd77a161 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1367,7 +1367,7 @@ info_symbol_command (const char *arg, int from_tty) gdb_assert (osect->objfile && objfile_name (osect->objfile)); obj_name = objfile_name (osect->objfile); - if (MULTI_OBJFILE_P ()) + if (current_program_space->multi_objfile_p ()) if (pc_in_unmapped_range (addr, osect)) if (section_is_overlay (osect)) printf_filtered (_("%s in load address range of " diff --git a/gdb/progspace.c b/gdb/progspace.c index e6c4f55c4e8..a39b34c9233 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -200,6 +200,14 @@ program_space::remove_objfile (struct objfile *objfile) _("remove_objfile: objfile already unlinked")); } +/* See progspace.h. */ + +bool +program_space::multi_objfile_p () const +{ + return objfiles_head != nullptr && objfiles_head->next != nullptr; +} + /* Copies program space SRC to DEST. Copies the main executable file, and the main symbol file. Returns DEST. */ diff --git a/gdb/progspace.h b/gdb/progspace.h index e1fcc3c68d2..86bc22acc22 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -173,6 +173,11 @@ struct program_space /* Remove OBJFILE from the list of objfiles. */ void remove_objfile (struct objfile *objfile); + /* Return true if there is more than one object file loaded; false + otherwise. */ + bool multi_objfile_p () const; + + /* Pointer to next in linked list. */ struct program_space *next = NULL; -- 2.30.2