From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id AF4BB3858405; Thu, 7 Apr 2022 17:08:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF4BB3858405 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: remove symtab::objfile X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 44281e6c08cae11d4e116d87ea34ad391d58ae91 X-Git-Newrev: 3c86fae3d99bf7b5360b810cc5b19522430ce39d Message-Id: <20220407170818.AF4BB3858405@sourceware.org> Date: Thu, 7 Apr 2022 17:08:18 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Apr 2022 17:08:18 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3c86fae3d99b= f7b5360b810cc5b19522430ce39d commit 3c86fae3d99bf7b5360b810cc5b19522430ce39d Author: Simon Marchi Date: Tue Mar 29 16:14:36 2022 -0400 gdb: remove symtab::objfile =20 Same idea as previous patch, but for symtab::objfile. I find it clearer without this wrapper, as it shows that the objfile is common to all symtabs of a given compunit. Otherwise, you could think that each symtab (of a given compunit) can have a specific objfile. =20 Change-Id: Ifc0dbc7ec31a06eefa2787c921196949d5a6fcc6 Diff: --- gdb/ada-lang.c | 4 ++-- gdb/annotate.c | 2 +- gdb/breakpoint.c | 9 +++++---- 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 | 20 +++++++++++--------- gdb/source-cache.c | 5 +++-- gdb/source.c | 2 +- gdb/symmisc.c | 4 ++-- gdb/symtab.c | 8 ++++---- gdb/symtab.h | 8 -------- gdb/tui/tui-source.c | 2 +- gdb/tui/tui-winsource.c | 2 +- 16 files changed, 41 insertions(+), 45 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3a1624e9d26..d819038e63b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11862,8 +11862,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 () !=3D NULL - && re_exec (objfile_name (sal.symtab->objfile ()))) + if (sal.symtab->compunit ()->objfile () !=3D NULL + && re_exec (objfile_name (sal.symtab->compunit ()->objfile ()))) return 1; } =20 diff --git a/gdb/annotate.c b/gdb/annotate.c index c16eb4651f3..6ae31457222 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -448,7 +448,7 @@ annotate_source_line (struct symtab *s, int line, int m= id_statement, return false; =20 annotate_source (s->fullname, line, (int) (*offsets)[line - 1], - mid_statement, s->objfile ()->arch (), + mid_statement, s->compunit ()->objfile ()->arch (), pc); =20 /* Update the current symtab and line. */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 1b340bd78d1..b21d83d8019 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7209,7 +7209,7 @@ get_sal_arch (struct symtab_and_line sal) if (sal.section) return sal.section->objfile->arch (); if (sal.symtab) - return sal.symtab->objfile ()->arch (); + return sal.symtab->compunit ()->objfile ()->arch (); =20 return NULL; } @@ -9251,8 +9251,9 @@ resolve_sal_pc (struct symtab_and_line *sal) sym =3D block_linkage_function (b); if (sym !=3D NULL) { - fixup_symbol_section (sym, sal->symtab->objfile ()); - sal->section =3D sym->obj_section (sal->symtab->objfile ()); + fixup_symbol_section (sym, sal->symtab->compunit ()->objfile ()); + sal->section + =3D sym->obj_section (sal->symtab->compunit ()->objfile ()); } else { @@ -14680,7 +14681,7 @@ void breakpoint_free_objfile (struct objfile *objfile) { for (bp_location *loc : all_bp_locations ()) - if (loc->symtab !=3D NULL && loc->symtab->objfile () =3D=3D objfile) + if (loc->symtab !=3D NULL && loc->symtab->compunit ()->objfile () =3D= =3D objfile) loc->symtab =3D NULL; } =20 diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 31b493e1c50..424a8740706 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1007,7 +1007,7 @@ edit_command (const char *arg, int from_tty) error (_("No source file for address %s."), paddress (get_current_arch (), sal.pc)); =20 - gdbarch =3D sal.symtab->objfile ()->arch (); + gdbarch =3D sal.symtab->compunit ()->objfile ()->arch (); sym =3D find_pc_function (sal.pc); if (sym) gdb_printf ("%s is in %s (%s:%d).\n", @@ -1346,7 +1346,7 @@ list_command (const char *arg, int from_tty) error (_("No source file for address %s."), paddress (get_current_arch (), sal.pc)); =20 - gdbarch =3D sal.symtab->objfile ()->arch (); + gdbarch =3D sal.symtab->compunit ()->objfile ()->arch (); sym =3D find_pc_function (sal.pc); if (sym) gdb_printf ("%s is in %s (%s:%d).\n", diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c index 386ccf56956..1ba5cb587b1 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 =3D symtab->objfile (); + struct objfile *objfile =3D symtab->compunit ()->objfile (); htab_t htab =3D (htab_t) objfile_data (objfile, stscm_objfile_data_key); =20 if (htab =3D=3D NULL) @@ -348,7 +348,7 @@ gdbscm_symtab_objfile (SCM self) =3D stscm_get_valid_symtab_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); const struct symtab *symtab =3D st_smob->symtab; =20 - return ofscm_scm_from_objfile (symtab->objfile ()); + return ofscm_scm_from_objfile (symtab->compunit ()->objfile ()); } =20 /* (symtab-global-block ) -> @@ -366,7 +366,7 @@ gdbscm_symtab_global_block (SCM self) blockvector =3D symtab->compunit ()->blockvector (); block =3D BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); =20 - return bkscm_scm_from_block (block, symtab->objfile ()); + return bkscm_scm_from_block (block, symtab->compunit ()->objfile ()); } =20 /* (symtab-static-block ) -> @@ -384,7 +384,7 @@ gdbscm_symtab_static_block (SCM self) blockvector =3D symtab->compunit ()->blockvector (); block =3D BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); =20 - return bkscm_scm_from_block (block, symtab->objfile ()); + return bkscm_scm_from_block (block, symtab->compunit ()->objfile ()); } =0C /* Administrivia for sal (symtab-and-line) smobs. */ diff --git a/gdb/linespec.c b/gdb/linespec.c index 5a6b620b33b..10717ac6c43 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -4245,10 +4245,10 @@ search_minsyms_for_name (struct collect_info *info, { set_current_program_space (symtab->pspace ()); iterate_over_minimal_symbols - (symtab->objfile (), name, + (symtab->compunit ()->objfile (), name, [&] (struct minimal_symbol *msym) { - add_minsym (msym, symtab->objfile (), symtab, + add_minsym (msym, symtab->compunit ()->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 1b08854296c..5d6d3412929 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 **arg= v, int argc) already sorted by increasing values in the symbol table, so no need to perform any other sorting. */ =20 - gdbarch =3D s->objfile ()->arch (); + gdbarch =3D s->compunit ()->objfile ()->arch (); =20 ui_out_emit_list list_emitter (uiout, "lines"); if (s->linetable () !=3D NULL && s->linetable ()->nitems > 0) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 35b275ad301..ddd94da42a6 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -591,7 +591,7 @@ objfile::~objfile () { struct symtab_and_line cursal =3D get_current_source_symtab_and_line (= ); =20 - if (cursal.symtab && cursal.symtab->objfile () =3D=3D this) + if (cursal.symtab && cursal.symtab->compunit ()->objfile () =3D=3D thi= s) clear_current_source_symtab_and_line (); } =20 diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 7ce4292c325..0a6ee014ea7 100644 --- a/gdb/python/py-symtab.c +++ b/gdb/python/py-symtab.c @@ -119,7 +119,7 @@ stpy_get_objfile (PyObject *self, void *closure) =20 STPY_REQUIRE_VALID (self, symtab); =20 - return objfile_to_objfile_object (symtab->objfile ()).release (); + return objfile_to_objfile_object (symtab->compunit ()->objfile ()).relea= se (); } =20 /* Getter function for symtab.producer. */ @@ -183,7 +183,7 @@ stpy_global_block (PyObject *self, PyObject *args) =20 blockvector =3D symtab->compunit ()->blockvector (); block =3D BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); - return block_to_block_object (block, symtab->objfile ()); + return block_to_block_object (block, symtab->compunit ()->objfile ()); } =20 /* Return the STATIC_BLOCK of the underlying symtab. */ @@ -199,7 +199,7 @@ stpy_static_block (PyObject *self, PyObject *args) =20 blockvector =3D symtab->compunit ()->blockvector (); block =3D BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); - return block_to_block_object (block, symtab->objfile ()); + return block_to_block_object (block, symtab->compunit ()->objfile ()); } =20 /* Implementation of gdb.Symtab.linetable (self) -> gdb.LineTable. @@ -247,7 +247,7 @@ stpy_dealloc (PyObject *obj) symtab->prev->next =3D symtab->next; else if (symtab->symtab) { - set_objfile_data (symtab->symtab->objfile (), + set_objfile_data (symtab->symtab->compunit ()->objfile (), stpy_objfile_data_key, symtab->next); } if (symtab->next) @@ -330,7 +330,7 @@ salpy_dealloc (PyObject *self) self_sal->prev->next =3D self_sal->next; else if (self_sal->symtab !=3D Py_None) set_objfile_data - (symtab_object_to_symtab (self_sal->symtab)->objfile (), + (symtab_object_to_symtab (self_sal->symtab)->compunit ()->objfile (), salpy_objfile_data_key, self_sal->next); =20 if (self_sal->next) @@ -378,12 +378,12 @@ set_sal (sal_object *sal_obj, struct symtab_and_line = sal) symtab *symtab =3D symtab_object_to_symtab (sal_obj->symtab); =20 sal_obj->next - =3D ((sal_object *) objfile_data (symtab->objfile (), + =3D ((sal_object *) objfile_data (symtab->compunit ()->objfile (), salpy_objfile_data_key)); if (sal_obj->next) sal_obj->next->prev =3D sal_obj; =20 - set_objfile_data (symtab->objfile (), + set_objfile_data (symtab->compunit ()->objfile (), salpy_objfile_data_key, sal_obj); } else @@ -406,10 +406,12 @@ set_symtab (symtab_object *obj, struct symtab *symtab) { obj->next =3D ((symtab_object *) - objfile_data (symtab->objfile (), stpy_objfile_data_key)); + objfile_data (symtab->compunit ()->objfile (), + stpy_objfile_data_key)); if (obj->next) obj->next->prev =3D obj; - set_objfile_data (symtab->objfile (), stpy_objfile_data_key, obj); + set_objfile_data (symtab->compunit ()->objfile (), + stpy_objfile_data_key, obj); } else obj->next =3D NULL; diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 3f0683b2096..2cc5b37a817 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -107,8 +107,9 @@ source_cache::get_plain_source_lines (struct symtab *s, perror_with_name (symtab_to_filename_for_display (s)); =20 time_t mtime =3D 0; - if (s->objfile () !=3D NULL && s->objfile ()->obfd !=3D NULL) - mtime =3D s->objfile ()->mtime; + if (s->compunit ()->objfile () !=3D NULL + && s->compunit ()->objfile ()->obfd !=3D NULL) + mtime =3D s->compunit ()->objfile ()->mtime; else if (current_program_space->exec_bfd ()) mtime =3D current_program_space->ebfd_mtime; =20 diff --git a/gdb/source.c b/gdb/source.c index 2025c93e93e..24f53f68e35 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1560,7 +1560,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 =3D sal.symtab->objfile ()->arch (); + gdbarch *gdbarch =3D sal.symtab->compunit ()->objfile ()->arch (); =20 if (start_pc =3D=3D end_pc) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 1843eb87d05..1779816348f 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -131,7 +131,7 @@ dump_objfile (struct objfile *objfile) gdb_printf ("%s at %s", symtab_to_filename_for_display (symtab), host_address_to_string (symtab)); - if (symtab->objfile () !=3D objfile) + if (symtab->compunit ()->objfile () !=3D objfile) gdb_printf (", NOT ON CHAIN!"); gdb_printf ("\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 =3D symtab->objfile (); + struct objfile *objfile =3D symtab->compunit ()->objfile (); struct gdbarch *gdbarch =3D objfile->arch (); int i; struct mdict_iterator miter; diff --git a/gdb/symtab.c b/gdb/symtab.c index 4204423cb25..eeb16e4643b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -338,7 +338,7 @@ search_domain_name (enum search_domain e) program_space * symtab::pspace () const { - return this->objfile ()->pspace; + return this->compunit ()->objfile ()->pspace; } =20 /* See symtab.h. */ @@ -3724,7 +3724,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_s= ection *section, && (sal.symtab->compunit ()->locations_valid () || sal.symtab->language () =3D=3D language_asm)) { - struct gdbarch *gdbarch =3D sal.symtab->objfile ()->arch (); + struct gdbarch *gdbarch =3D sal.symtab->compunit ()->objfile ()->arc= h (); =20 sal.pc =3D func_addr; if (gdbarch_skip_entrypoint_p (gdbarch)) @@ -6593,7 +6593,7 @@ struct objfile * symbol_objfile (const struct symbol *symbol) { gdb_assert (symbol->is_objfile_owned ()); - return symbol->owner.symtab->objfile (); + return symbol->owner.symtab->compunit ()->objfile (); } =20 /* See symtab.h. */ @@ -6603,7 +6603,7 @@ symbol_arch (const struct symbol *symbol) { if (!symbol->is_objfile_owned ()) return symbol->owner.arch; - return symbol->owner.symtab->objfile ()->arch (); + return symbol->owner.symtab->compunit ()->objfile ()->arch (); } =20 /* See symtab.h. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 8852590857e..87d48350529 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1476,8 +1476,6 @@ struct symtab m_language =3D language; } =20 - struct objfile *objfile () const; - program_space *pspace () const; =20 /* Unordered chain of all filetabs in the compunit, with the exception @@ -1753,12 +1751,6 @@ struct compunit_symtab =20 using compunit_symtab_range =3D next_range; =20 -inline struct objfile * -symtab::objfile () const -{ - return this->compunit ()->objfile (); -} - /* Return the language of CUST. */ =20 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 294ea1c7f13..208889d0bf7 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 =3D make_unique_xstrdup (symtab_to_fullname (s)); =20 cur_line =3D 0; - m_gdbarch =3D s->objfile ()->arch (); + m_gdbarch =3D s->compunit ()->objfile ()->arch (); m_start_line_or_addr.loa =3D LOA_LINE; cur_line_no =3D m_start_line_or_addr.u.line_no =3D line_no; =20 diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index c8a1c1aa64b..87b8dcff154 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 !=3D nullptr) { find_line_pc (sal.symtab, sal.line, &sal.pc); - gdbarch =3D sal.symtab->objfile ()->arch (); + gdbarch =3D sal.symtab->compunit ()->objfile ()->arch (); } =20 for (struct tui_source_window_base *win_info : tui_source_windows ())