public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: remove symtab::objfile
@ 2022-04-07 17:08 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2022-04-07 17:08 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3c86fae3d99bf7b5360b810cc5b19522430ce39d

commit 3c86fae3d99bf7b5360b810cc5b19522430ce39d
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Tue Mar 29 16:14:36 2022 -0400

    gdb: remove symtab::objfile
    
    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

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 () != 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 c16eb4651f3..6ae31457222 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 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 ();
 
   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 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));
 
-	  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 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 = 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 <gdb:symtab>) -> <gdb: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 <gdb:symtab>) -> <gdb: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 ());
 }
 \f
 /* 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 **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 35b275ad301..ddd94da42a6 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 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)
 
   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 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));
 
   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 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 = 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 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 () != 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 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;
 }
 
 /* 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 8852590857e..87d48350529 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<compunit_symtab>;
 
-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 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 = 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 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 != 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 ())


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-07 17:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 17:08 [binutils-gdb] gdb: remove symtab::objfile Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).