From 652099717dbb767c9d3eaed4c533486dd99d5e5b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 20 Nov 2021 21:54:11 -0500 Subject: [PATCH] gdb: remove SYMTAB_OBJFILE macro Remove the macro, replace with an equivalent method. Change-Id: I8f9ecd290ad28502e53c1ceca5006ba78bf042eb --- gdb/ada-lang.c | 4 ++-- gdb/annotate.c | 2 +- gdb/breakpoint.c | 8 ++++---- gdb/cli/cli-cmds.c | 4 ++-- gdb/guile/scm-symtab.c | 8 ++++---- gdb/linespec.c | 4 ++-- gdb/mi/mi-symbol-cmds.c | 2 +- gdb/objfiles.c | 2 +- gdb/python/py-symtab.c | 18 +++++++++--------- gdb/source-cache.c | 4 ++-- gdb/source.c | 2 +- gdb/symmisc.c | 4 ++-- gdb/symtab.c | 6 +++--- gdb/symtab.h | 12 +++++++++--- gdb/tui/tui-source.c | 2 +- gdb/tui/tui-winsource.c | 2 +- 16 files changed, 45 insertions(+), 39 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index f3b8442b550..e6bfb8e1467 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11388,8 +11388,8 @@ is_known_support_routine (struct frame_info *frame) re_comp (known_runtime_file_name_patterns[i]); if (re_exec (lbasename (sal.symtab->filename))) return 1; - if (SYMTAB_OBJFILE (sal.symtab) != NULL - && re_exec (objfile_name (SYMTAB_OBJFILE (sal.symtab)))) + if (sal.symtab->objfile () != NULL + && re_exec (objfile_name (sal.symtab->objfile ()))) return 1; } diff --git a/gdb/annotate.c b/gdb/annotate.c index 4ac1b63b66b..b84d8f0bf6a 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -448,7 +448,7 @@ annotate_source_line (struct symtab *s, int line, int mid_statement, return false; annotate_source (s->fullname, line, (int) (*offsets)[line - 1], - mid_statement, SYMTAB_OBJFILE (s)->arch (), + mid_statement, s->objfile ()->arch (), pc); /* Update the current symtab and line. */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 96a2b46dfc2..b1130acbab2 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7194,7 +7194,7 @@ get_sal_arch (struct symtab_and_line sal) if (sal.section) return sal.section->objfile->arch (); if (sal.symtab) - return SYMTAB_OBJFILE (sal.symtab)->arch (); + return sal.symtab->objfile ()->arch (); return NULL; } @@ -9236,8 +9236,8 @@ resolve_sal_pc (struct symtab_and_line *sal) sym = block_linkage_function (b); if (sym != NULL) { - fixup_symbol_section (sym, SYMTAB_OBJFILE (sal->symtab)); - sal->section = sym->obj_section (SYMTAB_OBJFILE (sal->symtab)); + fixup_symbol_section (sym, sal->symtab->objfile ()); + sal->section = sym->obj_section (sal->symtab->objfile ()); } else { @@ -14736,7 +14736,7 @@ void breakpoint_free_objfile (struct objfile *objfile) { for (bp_location *loc : all_bp_locations ()) - if (loc->symtab != NULL && SYMTAB_OBJFILE (loc->symtab) == objfile) + if (loc->symtab != NULL && loc->symtab->objfile () == objfile) loc->symtab = NULL; } diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 1d14b8e4527..9120bbf1d84 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1003,7 +1003,7 @@ edit_command (const char *arg, int from_tty) error (_("No source file for address %s."), paddress (get_current_arch (), sal.pc)); - gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); + gdbarch = sal.symtab->objfile ()->arch (); sym = find_pc_function (sal.pc); if (sym) printf_filtered ("%s is in %s (%s:%d).\n", @@ -1342,7 +1342,7 @@ list_command (const char *arg, int from_tty) error (_("No source file for address %s."), paddress (get_current_arch (), sal.pc)); - gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); + gdbarch = sal.symtab->objfile ()->arch (); sym = find_pc_function (sal.pc); if (sym) printf_filtered ("%s is in %s (%s:%d).\n", diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c index e2a90e58016..d1a5056aac8 100644 --- a/gdb/guile/scm-symtab.c +++ b/gdb/guile/scm-symtab.c @@ -109,7 +109,7 @@ stscm_eq_symtab_smob (const void *ap, const void *bp) static htab_t stscm_objfile_symtab_map (struct symtab *symtab) { - struct objfile *objfile = SYMTAB_OBJFILE (symtab); + struct objfile *objfile = symtab->objfile (); htab_t htab = (htab_t) objfile_data (objfile, stscm_objfile_data_key); if (htab == NULL) @@ -348,7 +348,7 @@ gdbscm_symtab_objfile (SCM self) = stscm_get_valid_symtab_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); const struct symtab *symtab = st_smob->symtab; - return ofscm_scm_from_objfile (SYMTAB_OBJFILE (symtab)); + return ofscm_scm_from_objfile (symtab->objfile ()); } /* (symtab-global-block ) -> @@ -366,7 +366,7 @@ gdbscm_symtab_global_block (SCM self) blockvector = symtab->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); - return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab)); + return bkscm_scm_from_block (block, symtab->objfile ()); } /* (symtab-static-block ) -> @@ -384,7 +384,7 @@ gdbscm_symtab_static_block (SCM self) blockvector = symtab->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); - return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab)); + return bkscm_scm_from_block (block, symtab->objfile ()); } /* Administrivia for sal (symtab-and-line) smobs. */ diff --git a/gdb/linespec.c b/gdb/linespec.c index 31e3b36d3aa..c4edc0d1c77 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -4323,10 +4323,10 @@ search_minsyms_for_name (struct collect_info *info, { set_current_program_space (SYMTAB_PSPACE (symtab)); iterate_over_minimal_symbols - (SYMTAB_OBJFILE (symtab), name, + (symtab->objfile (), name, [&] (struct minimal_symbol *msym) { - add_minsym (msym, SYMTAB_OBJFILE (symtab), symtab, + add_minsym (msym, symtab->objfile (), symtab, info->state->list_mode, &minsyms); return false; }); diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index 2078ab8e524..a8edce386d2 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -50,7 +50,7 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc) already sorted by increasing values in the symbol table, so no need to perform any other sorting. */ - gdbarch = SYMTAB_OBJFILE (s)->arch (); + gdbarch = s->objfile ()->arch (); ui_out_emit_list list_emitter (uiout, "lines"); if (s->linetable () != NULL && s->linetable ()->nitems > 0) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index d41dc73b02b..90163ca59b8 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -591,7 +591,7 @@ objfile::~objfile () { struct symtab_and_line cursal = get_current_source_symtab_and_line (); - if (cursal.symtab && SYMTAB_OBJFILE (cursal.symtab) == this) + if (cursal.symtab && cursal.symtab->objfile () == this) clear_current_source_symtab_and_line (); } diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 33657f1e6e4..cb28264a03f 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -119,7 +119,7 @@ stpy_get_objfile (PyObject *self, void *closure) STPY_REQUIRE_VALID (self, symtab); - return objfile_to_objfile_object (SYMTAB_OBJFILE (symtab)).release (); + return objfile_to_objfile_object (symtab->objfile ()).release (); } /* Getter function for symtab.producer. */ @@ -183,7 +183,7 @@ stpy_global_block (PyObject *self, PyObject *args) blockvector = symtab->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); - return block_to_block_object (block, SYMTAB_OBJFILE (symtab)); + return block_to_block_object (block, symtab->objfile ()); } /* Return the STATIC_BLOCK of the underlying symtab. */ @@ -199,7 +199,7 @@ stpy_static_block (PyObject *self, PyObject *args) blockvector = symtab->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); - return block_to_block_object (block, SYMTAB_OBJFILE (symtab)); + return block_to_block_object (block, symtab->objfile ()); } /* Implementation of gdb.Symtab.linetable (self) -> gdb.LineTable. @@ -247,7 +247,7 @@ stpy_dealloc (PyObject *obj) symtab->prev->next = symtab->next; else if (symtab->symtab) { - set_objfile_data (SYMTAB_OBJFILE (symtab->symtab), + set_objfile_data (symtab->symtab->objfile (), stpy_objfile_data_key, symtab->next); } if (symtab->next) @@ -330,7 +330,7 @@ salpy_dealloc (PyObject *self) self_sal->prev->next = self_sal->next; else if (self_sal->symtab != Py_None) set_objfile_data - (SYMTAB_OBJFILE (symtab_object_to_symtab (self_sal->symtab)), + (symtab_object_to_symtab (self_sal->symtab)->objfile (), salpy_objfile_data_key, self_sal->next); if (self_sal->next) @@ -378,12 +378,12 @@ set_sal (sal_object *sal_obj, struct symtab_and_line sal) symtab *symtab = symtab_object_to_symtab (sal_obj->symtab); sal_obj->next - = ((sal_object *) objfile_data (SYMTAB_OBJFILE (symtab), + = ((sal_object *) objfile_data (symtab->objfile (), salpy_objfile_data_key)); if (sal_obj->next) sal_obj->next->prev = sal_obj; - set_objfile_data (SYMTAB_OBJFILE (symtab), + set_objfile_data (symtab->objfile (), salpy_objfile_data_key, sal_obj); } else @@ -406,10 +406,10 @@ set_symtab (symtab_object *obj, struct symtab *symtab) { obj->next = ((symtab_object *) - objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key)); + objfile_data (symtab->objfile (), stpy_objfile_data_key)); if (obj->next) obj->next->prev = obj; - set_objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key, obj); + set_objfile_data (symtab->objfile (), stpy_objfile_data_key, obj); } else obj->next = NULL; diff --git a/gdb/source-cache.c b/gdb/source-cache.c index d2447ca5007..bfd47608fef 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -107,8 +107,8 @@ source_cache::get_plain_source_lines (struct symtab *s, perror_with_name (symtab_to_filename_for_display (s)); time_t mtime = 0; - if (SYMTAB_OBJFILE (s) != NULL && SYMTAB_OBJFILE (s)->obfd != NULL) - mtime = SYMTAB_OBJFILE (s)->mtime; + if (s->objfile () != NULL && s->objfile ()->obfd != NULL) + mtime = s->objfile ()->mtime; else if (current_program_space->exec_bfd ()) mtime = current_program_space->ebfd_mtime; diff --git a/gdb/source.c b/gdb/source.c index e99fff88525..d184990a6c0 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1559,7 +1559,7 @@ info_line_command (const char *arg, int from_tty) else if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc)) { - struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); + struct gdbarch *gdbarch = sal.symtab->objfile ()->arch (); if (start_pc == end_pc) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 3f5f840fbe7..62b584041de 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -131,7 +131,7 @@ dump_objfile (struct objfile *objfile) printf_filtered ("%s at %s", symtab_to_filename_for_display (symtab), host_address_to_string (symtab)); - if (SYMTAB_OBJFILE (symtab) != objfile) + if (symtab->objfile () != objfile) printf_filtered (", NOT ON CHAIN!"); printf_filtered ("\n"); } @@ -234,7 +234,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) static void dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) { - struct objfile *objfile = SYMTAB_OBJFILE (symtab); + struct objfile *objfile = symtab->objfile (); struct gdbarch *gdbarch = objfile->arch (); int i; struct mdict_iterator miter; diff --git a/gdb/symtab.c b/gdb/symtab.c index 65359374fef..671e22c5723 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3712,7 +3712,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_section *section, && (sal.symtab->compunit ()->locations_valid () || sal.symtab->language () == language_asm)) { - struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); + struct gdbarch *gdbarch = sal.symtab->objfile ()->arch (); sal.pc = func_addr; if (gdbarch_skip_entrypoint_p (gdbarch)) @@ -6527,7 +6527,7 @@ struct objfile * symbol_objfile (const struct symbol *symbol) { gdb_assert (SYMBOL_OBJFILE_OWNED (symbol)); - return SYMTAB_OBJFILE (symbol->owner.symtab); + return symbol->owner.symtab->objfile (); } /* See symtab.h. */ @@ -6537,7 +6537,7 @@ symbol_arch (const struct symbol *symbol) { if (!SYMBOL_OBJFILE_OWNED (symbol)) return symbol->owner.arch; - return SYMTAB_OBJFILE (symbol->owner.symtab)->arch (); + return symbol->owner.symtab->objfile ()->arch (); } /* See symtab.h. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 1935113336a..9cfbd71937a 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1405,6 +1405,8 @@ struct symtab const struct blockvector *blockvector () const; + struct objfile *objfile () const; + /* Unordered chain of all filetabs in the compunit, with the exception that the "main" source file is the first entry in the list. */ @@ -1437,9 +1439,7 @@ struct symtab using symtab_range = next_range; -#define SYMTAB_OBJFILE(symtab) \ - (symtab->compunit ()->objfile ()) -#define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace) +#define SYMTAB_PSPACE(symtab) ((symtab)->objfile ()->pspace) #define SYMTAB_DIRNAME(symtab) ((symtab)->compunit ()->dirname ()) /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well @@ -1689,6 +1689,12 @@ symtab::blockvector () const return this->compunit ()->blockvector (); } +inline struct objfile * +symtab::objfile () const +{ + return this->compunit ()->objfile (); +} + /* Return the language of CUST. */ extern enum language compunit_language (const struct compunit_symtab *cust); diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index bbdefbafb61..294ea1c7f13 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -70,7 +70,7 @@ tui_source_window::set_contents (struct gdbarch *arch, m_fullname = make_unique_xstrdup (symtab_to_fullname (s)); cur_line = 0; - m_gdbarch = SYMTAB_OBJFILE (s)->arch (); + m_gdbarch = s->objfile ()->arch (); m_start_line_or_addr.loa = LOA_LINE; cur_line_no = m_start_line_or_addr.u.line_no = line_no; diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 23c7ddae429..c8a1c1aa64b 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -199,7 +199,7 @@ tui_update_source_windows_with_line (struct symtab_and_line sal) if (sal.symtab != nullptr) { find_line_pc (sal.symtab, sal.line, &sal.pc); - gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch (); + gdbarch = sal.symtab->objfile ()->arch (); } for (struct tui_source_window_base *win_info : tui_source_windows ()) -- 2.30.2