From eb822aa6d0f2cdc1a3125da084b96c5bbe32cb86 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Tue, 18 Nov 2014 09:19:11 -0800 Subject: [PATCH] SYMTAB_OBJFILE: New macro. gdb/ChangeLog: * symtab.h (SYMTAB_OBJFILE): New macro. All uses of member symtab.objfile updated to use it. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 4 ++-- gdb/breakpoint.c | 9 +++++---- gdb/cli/cli-cmds.c | 4 ++-- gdb/guile/scm-block.c | 6 +++--- gdb/guile/scm-frame.c | 2 +- gdb/guile/scm-symtab.c | 8 ++++---- gdb/mi/mi-symbol-cmds.c | 2 +- gdb/objfiles.c | 2 +- gdb/python/py-block.c | 6 +++--- gdb/python/py-frame.c | 2 +- gdb/python/py-symtab.c | 19 ++++++++++--------- gdb/source.c | 9 +++++---- gdb/symfile.c | 2 +- gdb/symmisc.c | 2 +- gdb/symtab.c | 2 +- gdb/symtab.h | 5 +++-- gdb/tui/tui-source.c | 2 +- gdb/tui/tui-winsource.c | 4 ++-- 19 files changed, 52 insertions(+), 43 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fd5fd697d24..9d7a84690e1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-11-18 Doug Evans + + * symtab.h (SYMTAB_OBJFILE): New macro. All uses of member + symtab.objfile updated to use it. + 2014-11-18 Doug Evans * buildsym.c (watch_main_source_file_lossage): Fix memory leak. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 4320eec27ac..344db2daa2f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11524,8 +11524,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 (sal.symtab->objfile != NULL - && re_exec (objfile_name (sal.symtab->objfile))) + if (SYMTAB_OBJFILE (sal.symtab) != NULL + && re_exec (objfile_name (SYMTAB_OBJFILE (sal.symtab)))) return 1; } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3ebe9c978ad..1c0a417bd1a 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7314,7 +7314,7 @@ get_sal_arch (struct symtab_and_line sal) if (sal.section) return get_objfile_arch (sal.section->objfile); if (sal.symtab) - return get_objfile_arch (sal.symtab->objfile); + return get_objfile_arch (SYMTAB_OBJFILE (sal.symtab)); return NULL; } @@ -10210,8 +10210,9 @@ resolve_sal_pc (struct symtab_and_line *sal) sym = block_linkage_function (b); if (sym != NULL) { - fixup_symbol_section (sym, sal->symtab->objfile); - sal->section = SYMBOL_OBJ_SECTION (sal->symtab->objfile, sym); + fixup_symbol_section (sym, SYMTAB_OBJFILE (sal->symtab)); + sal->section = SYMBOL_OBJ_SECTION (SYMTAB_OBJFILE (sal->symtab), + sym); } else { @@ -16050,7 +16051,7 @@ breakpoint_free_objfile (struct objfile *objfile) struct bp_location **locp, *loc; ALL_BP_LOCATIONS (loc, locp) - if (loc->symtab != NULL && loc->symtab->objfile == objfile) + if (loc->symtab != NULL && SYMTAB_OBJFILE (loc->symtab) == objfile) loc->symtab = NULL; } diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index a9f90b21757..0c3cfa7c6b8 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -818,7 +818,7 @@ edit_command (char *arg, int from_tty) error (_("No source file for address %s."), paddress (get_current_arch (), sal.pc)); - gdbarch = get_objfile_arch (sal.symtab->objfile); + gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab)); sym = find_pc_function (sal.pc); if (sym) printf_filtered ("%s is in %s (%s:%d).\n", @@ -1003,7 +1003,7 @@ list_command (char *arg, int from_tty) error (_("No source file for address %s."), paddress (get_current_arch (), sal.pc)); - gdbarch = get_objfile_arch (sal.symtab->objfile); + gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab)); sym = find_pc_function (sal.pc); if (sym) printf_filtered ("%s is in %s (%s:%d).\n", diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c index 67864f87c6d..bbde77e30b5 100644 --- a/gdb/guile/scm-block.c +++ b/gdb/guile/scm-block.c @@ -686,19 +686,19 @@ gdbscm_lookup_block (SCM pc_scm) section = find_pc_mapped_section (pc); symtab = find_pc_sect_symtab (pc, section); - if (symtab != NULL && symtab->objfile != NULL) + if (symtab != NULL && SYMTAB_OBJFILE (symtab) != NULL) block = block_for_pc (pc); } GDBSCM_HANDLE_GDB_EXCEPTION (except); - if (symtab == NULL || symtab->objfile == NULL) + if (symtab == NULL || SYMTAB_OBJFILE (symtab) == NULL) { gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, pc_scm, _("cannot locate object file for block")); } if (block != NULL) - return bkscm_scm_from_block (block, symtab->objfile); + return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab)); return SCM_BOOL_F; } diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index c335385e830..b2d662e030b 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -612,7 +612,7 @@ gdbscm_frame_block (SCM self) SCM block_scm; st = SYMBOL_SYMTAB (BLOCK_FUNCTION (fn_block)); - return bkscm_scm_from_block (block, st->objfile); + return bkscm_scm_from_block (block, SYMTAB_OBJFILE (st)); } return SCM_BOOL_F; diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c index dbf9f7dc014..3567ad82ce4 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; + struct objfile *objfile = SYMTAB_OBJFILE (symtab); htab_t htab = 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); + return ofscm_scm_from_objfile (SYMTAB_OBJFILE (symtab)); } /* (symtab-global-block ) -> @@ -366,7 +366,7 @@ gdbscm_symtab_global_block (SCM self) blockvector = BLOCKVECTOR (symtab); block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); - return bkscm_scm_from_block (block, symtab->objfile); + return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab)); } /* (symtab-static-block ) -> @@ -384,7 +384,7 @@ gdbscm_symtab_static_block (SCM self) blockvector = BLOCKVECTOR (symtab); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); - return bkscm_scm_from_block (block, symtab->objfile); + return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab)); } /* Administrivia for sal (symtab-and-line) smobs. */ diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index df008f734f2..e1ef0c22423 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -49,7 +49,7 @@ mi_cmd_symbol_list_lines (char *command, char **argv, int argc) already sorted by increasing values in the symbol table, so no need to perform any other sorting. */ - gdbarch = get_objfile_arch (s->objfile); + gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines"); if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 38a365ca678..e8c1b972ebb 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -641,7 +641,7 @@ free_objfile (struct objfile *objfile) { struct symtab_and_line cursal = get_current_source_symtab_and_line (); - if (cursal.symtab && cursal.symtab->objfile == objfile) + if (cursal.symtab && SYMTAB_OBJFILE (cursal.symtab) == objfile) clear_current_source_symtab_and_line (); } diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index 3fa4530487b..7dee7824d39 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -384,12 +384,12 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args) section = find_pc_mapped_section (pc); symtab = find_pc_sect_symtab (pc, section); - if (symtab != NULL && symtab->objfile != NULL) + if (symtab != NULL && SYMTAB_OBJFILE (symtab) != NULL) block = block_for_pc (pc); } GDB_PY_HANDLE_EXCEPTION (except); - if (!symtab || symtab->objfile == NULL) + if (!symtab || SYMTAB_OBJFILE (symtab) == NULL) { PyErr_SetString (PyExc_RuntimeError, _("Cannot locate object file for block.")); @@ -397,7 +397,7 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args) } if (block) - return block_to_block_object (block, symtab->objfile); + return block_to_block_object (block, SYMTAB_OBJFILE (symtab)); Py_RETURN_NONE; } diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index bec84ed5a00..62176df2c1d 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -303,7 +303,7 @@ frapy_block (PyObject *self, PyObject *args) struct symtab *symt; symt = SYMBOL_SYMTAB (BLOCK_FUNCTION (fn_block)); - return block_to_block_object (block, symt->objfile); + return block_to_block_object (block, SYMTAB_OBJFILE (symt)); } Py_RETURN_NONE; diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 1065ba348a8..e4e3ec1f411 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -121,7 +121,7 @@ stpy_get_objfile (PyObject *self, void *closure) STPY_REQUIRE_VALID (self, symtab); - result = objfile_to_objfile_object (symtab->objfile); + result = objfile_to_objfile_object (SYMTAB_OBJFILE (symtab)); Py_XINCREF (result); return result; } @@ -186,7 +186,7 @@ stpy_global_block (PyObject *self, PyObject *args) blockvector = BLOCKVECTOR (symtab); block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); - return block_to_block_object (block, symtab->objfile); + return block_to_block_object (block, SYMTAB_OBJFILE (symtab)); } /* Return the STATIC_BLOCK of the underlying symtab. */ @@ -202,7 +202,7 @@ stpy_static_block (PyObject *self, PyObject *args) blockvector = BLOCKVECTOR (symtab); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); - return block_to_block_object (block, symtab->objfile); + return block_to_block_object (block, SYMTAB_OBJFILE (symtab)); } /* Implementation of gdb.Symtab.linetable (self) -> gdb.Linetable. @@ -252,7 +252,7 @@ stpy_dealloc (PyObject *obj) symtab->prev->next = symtab->next; else if (symtab->symtab) { - set_objfile_data (symtab->symtab->objfile, + set_objfile_data (SYMTAB_OBJFILE (symtab->symtab), stpy_objfile_data_key, symtab->next); } if (symtab->next) @@ -333,7 +333,7 @@ salpy_dealloc (PyObject *self) if (self_sal->prev) self_sal->prev->next = self_sal->next; else if (self_sal->symtab != (symtab_object * ) Py_None) - set_objfile_data (self_sal->symtab->symtab->objfile, + set_objfile_data (SYMTAB_OBJFILE (self_sal->symtab->symtab), salpy_objfile_data_key, self_sal->next); if (self_sal->next) @@ -377,12 +377,12 @@ set_sal (sal_object *sal_obj, struct symtab_and_line sal) objfile cleanup observer linked list. */ if (sal_obj->symtab != (symtab_object *)Py_None) { - sal_obj->next = objfile_data (sal_obj->symtab->symtab->objfile, + sal_obj->next = objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab), salpy_objfile_data_key); if (sal_obj->next) sal_obj->next->prev = sal_obj; - set_objfile_data (sal_obj->symtab->symtab->objfile, + set_objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab), salpy_objfile_data_key, sal_obj); } else @@ -403,10 +403,11 @@ set_symtab (symtab_object *obj, struct symtab *symtab) obj->prev = NULL; if (symtab) { - obj->next = objfile_data (symtab->objfile, stpy_objfile_data_key); + obj->next = objfile_data (SYMTAB_OBJFILE (symtab), + stpy_objfile_data_key); if (obj->next) obj->next->prev = obj; - set_objfile_data (symtab->objfile, stpy_objfile_data_key, obj); + set_objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key, obj); } else obj->next = NULL; diff --git a/gdb/source.c b/gdb/source.c index 1bb19c9d5fc..894531adb14 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1189,8 +1189,8 @@ find_source_lines (struct symtab *s, int desc) if (fstat (desc, &st) < 0) perror_with_name (symtab_to_filename_for_display (s)); - if (s->objfile && s->objfile->obfd) - mtime = s->objfile->mtime; + if (SYMTAB_OBJFILE (s) != NULL && SYMTAB_OBJFILE (s)->obfd != NULL) + mtime = SYMTAB_OBJFILE (s)->mtime; else if (exec_bfd) mtime = exec_bfd_mtime; @@ -1294,7 +1294,7 @@ identify_source_line (struct symtab *s, int line, int mid_statement, /* Don't index off the end of the line_charpos array. */ return 0; annotate_source (s->fullname, line, s->line_charpos[line - 1], - mid_statement, get_objfile_arch (s->objfile), pc); + mid_statement, get_objfile_arch (SYMTAB_OBJFILE (s)), pc); current_source_line = line; current_source_symtab = s; @@ -1538,7 +1538,8 @@ line_info (char *arg, int from_tty) else if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc)) { - struct gdbarch *gdbarch = get_objfile_arch (sal.symtab->objfile); + struct gdbarch *gdbarch + = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab)); if (start_pc == end_pc) { diff --git a/gdb/symfile.c b/gdb/symfile.c index b16abe46fa4..01ff6aef379 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2947,7 +2947,7 @@ allocate_symtab (const char *filename, struct objfile *objfile) /* Hook it to the objfile it comes from. */ - symtab->objfile = objfile; + SYMTAB_OBJFILE (symtab) = objfile; symtab->next = objfile->symtabs; objfile->symtabs = symtab; diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 885fe12f5c8..623bcb32331 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -182,7 +182,7 @@ dump_objfile (struct objfile *objfile) printf_filtered ("%s at ", symtab_to_filename_for_display (symtab)); gdb_print_host_address (symtab, gdb_stdout); printf_filtered (", "); - if (symtab->objfile != objfile) + if (SYMTAB_OBJFILE (symtab) != objfile) { printf_filtered ("NOT ON CHAIN! "); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 1962e02b948..5b00b1b3b4c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2317,7 +2317,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) } bv = BLOCKVECTOR (s); - objfile = s->objfile; + objfile = SYMTAB_OBJFILE (s); /* Look at all the symtabs that share this blockvector. They all have the same apriori range, that we found was right; diff --git a/gdb/symtab.h b/gdb/symtab.h index 257d3be2176..fdedd59b4cb 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -774,7 +774,7 @@ extern const struct symbol_impl *symbol_impls; #define SYMBOL_BLOCK_OPS(symbol) (SYMBOL_IMPL (symbol).ops_block) #define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register) #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value -#define SYMBOL_OBJFILE(symbol) (SYMBOL_SYMTAB (symbol)->objfile) +#define SYMBOL_OBJFILE(symbol) SYMTAB_OBJFILE (SYMBOL_SYMTAB (symbol)) extern int register_symbol_computed_impl (enum address_class, const struct symbol_computed_ops *); @@ -982,7 +982,8 @@ struct symtab #define BLOCKVECTOR(symtab) (symtab)->blockvector #define LINETABLE(symtab) (symtab)->linetable -#define SYMTAB_PSPACE(symtab) (symtab)->objfile->pspace +#define SYMTAB_OBJFILE(symtab) ((symtab)->objfile) +#define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace) /* Call this to set the "primary" field in struct symtab. */ extern void set_symtab_primary (struct symtab *, int primary); diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 9842bb37e3a..5cdd2e4553d 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -111,7 +111,7 @@ tui_set_source_content (struct symtab *s, stream = fdopen (desc, FOPEN_RT); clearerr (stream); cur_line = 0; - src->gdbarch = get_objfile_arch (s->objfile); + src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); src->start_line_or_addr.loa = LOA_LINE; cur_line_no = src->start_line_or_addr.u.line_no = line_no; if (offset > 0) diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 48a95e4edcb..9768c6d18dd 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -115,7 +115,7 @@ tui_update_source_window_as_is (struct tui_win_info *win_info, sal.line = line_or_addr.u.line_no + (win_info->generic.content_size - 2); sal.symtab = s; - sal.pspace = s->objfile->pspace; + sal.pspace = SYMTAB_PSPACE (s); set_current_source_symtab_and_line (&sal); /* If the focus was in the asm win, put it in the src win if we don't have a split layout. */ @@ -183,7 +183,7 @@ tui_update_source_windows_with_line (struct symtab *s, int line) if (!s) return; - gdbarch = get_objfile_arch (s->objfile); + gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); switch (tui_current_layout ()) { -- 2.30.2