From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 2CF9A385E007 for ; Wed, 6 Apr 2022 14:42:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2CF9A385E007 X-ASG-Debug-ID: 1649256127-0c856e06adaebe40001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id iJzQ6jzhjV8DZAjx (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 06 Apr 2022 10:42:08 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id DC006441D66; Wed, 6 Apr 2022 10:42:07 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 3/4] gdb: remove symtab::objfile Date: Wed, 6 Apr 2022 10:42:04 -0400 X-ASG-Orig-Subj: [PATCH 3/4] gdb: remove symtab::objfile Message-Id: <20220406144205.1415376-4-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406144205.1415376-1-simon.marchi@polymtl.ca> References: <20220406144205.1415376-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1649256128 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 15628 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.97169 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-3613.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2022 14:42:18 -0000 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. Change-Id: Ifc0dbc7ec31a06eefa2787c921196949d5a6fcc6 --- 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 3a1624e9d26e..d819038e63b6 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 () != NULL - && re_exec (objfile_name (sal.symtab->objfile ()))) + if (sal.symtab->compunit ()->objfile () != NULL + && re_exec (objfile_name (sal.symtab->compunit ()->objfile ()))) return 1; } diff --git a/gdb/annotate.c b/gdb/annotate.c index c16eb4651f3b..6ae314572221 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, s->objfile ()->arch (), + mid_statement, s->compunit ()->objfile ()->arch (), pc); /* Update the current symtab and line. */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 1b340bd78d1c..b21d83d8019a 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 (); return NULL; } @@ -9251,8 +9251,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 = sym->obj_section (sal->symtab->objfile ()); + fixup_symbol_section (sym, sal->symtab->compunit ()->objfile ()); + sal->section + = 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 != NULL && loc->symtab->objfile () == objfile) + if (loc->symtab != NULL && loc->symtab->compunit ()->objfile () == objfile) loc->symtab = NULL; } diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 31b493e1c500..424a8740706c 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)); - gdbarch = sal.symtab->objfile ()->arch (); + gdbarch = sal.symtab->compunit ()->objfile ()->arch (); sym = 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)); - gdbarch = sal.symtab->objfile ()->arch (); + gdbarch = sal.symtab->compunit ()->objfile ()->arch (); sym = 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 386ccf569564..1ba5cb587b1f 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->compunit ()->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 ()); + return ofscm_scm_from_objfile (symtab->compunit ()->objfile ()); } /* (symtab-global-block ) -> @@ -366,7 +366,7 @@ gdbscm_symtab_global_block (SCM self) blockvector = symtab->compunit ()->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); - return bkscm_scm_from_block (block, symtab->objfile ()); + return bkscm_scm_from_block (block, symtab->compunit ()->objfile ()); } /* (symtab-static-block ) -> @@ -384,7 +384,7 @@ gdbscm_symtab_static_block (SCM self) blockvector = symtab->compunit ()->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); - return bkscm_scm_from_block (block, symtab->objfile ()); + return bkscm_scm_from_block (block, symtab->compunit ()->objfile ()); } /* Administrivia for sal (symtab-and-line) smobs. */ diff --git a/gdb/linespec.c b/gdb/linespec.c index 5a6b620b33b7..10717ac6c43f 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 1b08854296c0..5d6d34129291 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 = s->objfile ()->arch (); + gdbarch = s->compunit ()->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 35b275ad3012..ddd94da42a6f 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 && cursal.symtab->objfile () == this) + if (cursal.symtab && cursal.symtab->compunit ()->objfile () == this) clear_current_source_symtab_and_line (); } diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c index 7ce4292c325d..0a6ee014ea73 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 ()).release (); + return objfile_to_objfile_object (symtab->compunit ()->objfile ()).release (); } /* Getter function for symtab.producer. */ @@ -183,7 +183,7 @@ stpy_global_block (PyObject *self, PyObject *args) blockvector = symtab->compunit ()->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK); - return block_to_block_object (block, symtab->objfile ()); + return block_to_block_object (block, symtab->compunit ()->objfile ()); } /* Return the STATIC_BLOCK of the underlying symtab. */ @@ -199,7 +199,7 @@ stpy_static_block (PyObject *self, PyObject *args) blockvector = symtab->compunit ()->blockvector (); block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK); - return block_to_block_object (block, symtab->objfile ()); + return block_to_block_object (block, symtab->compunit ()->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->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 = self_sal->next; else if (self_sal->symtab != 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); 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 (), + = ((sal_object *) objfile_data (symtab->compunit ()->objfile (), salpy_objfile_data_key)); if (sal_obj->next) sal_obj->next->prev = sal_obj; - 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 = ((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 = 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 = NULL; diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 3f0683b2096d..2cc5b37a8179 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)); time_t mtime = 0; - if (s->objfile () != NULL && s->objfile ()->obfd != NULL) - mtime = s->objfile ()->mtime; + if (s->compunit ()->objfile () != NULL + && s->compunit ()->objfile ()->obfd != NULL) + mtime = s->compunit ()->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 2025c93e93e3..24f53f68e35b 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 = sal.symtab->objfile ()->arch (); + gdbarch *gdbarch = sal.symtab->compunit ()->objfile ()->arch (); if (start_pc == end_pc) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 1843eb87d05e..1779816348fc 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 () != objfile) + if (symtab->compunit ()->objfile () != 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 = symtab->objfile (); + struct objfile *objfile = symtab->compunit ()->objfile (); struct gdbarch *gdbarch = objfile->arch (); int i; struct mdict_iterator miter; diff --git a/gdb/symtab.c b/gdb/symtab.c index 4204423cb25f..eeb16e4643b8 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; } /* See symtab.h. */ @@ -3724,7 +3724,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 = sal.symtab->objfile ()->arch (); + struct gdbarch *gdbarch = sal.symtab->compunit ()->objfile ()->arch (); sal.pc = 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 (); } /* 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 (); } /* See symtab.h. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 8852590857e6..87d483505297 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1476,8 +1476,6 @@ struct symtab m_language = language; } - struct objfile *objfile () const; - program_space *pspace () const; /* Unordered chain of all filetabs in the compunit, with the exception @@ -1753,12 +1751,6 @@ struct compunit_symtab using compunit_symtab_range = next_range; -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 294ea1c7f136..208889d0bf7a 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 = s->objfile ()->arch (); + m_gdbarch = s->compunit ()->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 c8a1c1aa64bc..87b8dcff154b 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 = sal.symtab->objfile ()->arch (); + gdbarch = sal.symtab->compunit ()->objfile ()->arch (); } for (struct tui_source_window_base *win_info : tui_source_windows ()) -- 2.35.1