Remove compunit_symtab::block_line_section

Message ID 20200516154507.28433-1-tom@tromey.com
State New
Headers show
Series
  • Remove compunit_symtab::block_line_section
Related show

Commit Message

Tom Tromey May 16, 2020, 3:45 p.m.
compunit_symtab::block_line_section can only ever be SECT_OFF_TEXT.  I
think it was used at one point by some code (perhaps SOM?) that was
removed.

This patch removes it.  My main motivation for removing this is that
it will make it simpler to make blocks objfile-independent.  If this
were to remain, then relocation-at-use would require finding the
compunit to fetch the section index; this could be fixed to be more
efficient, but that seemed like a waste of time, given that this code
isn't currently needed.

gdb/ChangeLog
2020-05-16  Tom Tromey  <tom@tromey.com>

	* mdebugread.c (mdebug_expand_psymtab): Update.
	* dbxread.c (read_ofile_symtab): Update.
	(process_one_symbol): Update.
	* coffread.c (coff_end_symtab): Update.
	* xcoffread.c (read_xcoff_symtab): Update.
	* buildsym-legacy.h (end_symtab): Update.
	* objfiles.c (objfile_relocate1): Use SECT_OFF_TEXT.
	* dwarf2/read.c (process_full_comp_unit, process_full_type_unit):
	Update.
	* ctfread.c (ctf_end_symtab): Remove "section" parameter
	(ctf_psymtab::read_symtab): Update.
	* buildsym-legacy.c (end_symtab): Remove "section" parameter.
	* buildsym.h (struct buildsym_compunit): Update.
	* buildsym.c (buildsym_compunit::end_symtab_with_blockvector):
	Update.  Remove "section" parameter.
	(buildsym_compunit::end_symtab_from_static_block): Remove
	"section" parameter.
	(buildsym_compunit::end_symtab)
	(buildsym_compunit::end_expandable_symtab): Likewise.
	* symtab.h (COMPUNIT_BLOCK_LINE_SECTION): Remove.
	(struct compunit_symtab) <block_line_section>: Remove.
---
 gdb/ChangeLog         | 24 ++++++++++++++++++++++++
 gdb/buildsym-legacy.c |  5 ++---
 gdb/buildsym-legacy.h |  2 +-
 gdb/buildsym.c        | 23 ++++++++---------------
 gdb/buildsym.h        |  9 ++++-----
 gdb/coffread.c        |  2 +-
 gdb/ctfread.c         | 12 ++++--------
 gdb/dbxread.c         |  5 ++---
 gdb/dwarf2/read.c     |  7 ++-----
 gdb/mdebugread.c      |  4 ++--
 gdb/objfiles.c        |  4 ++--
 gdb/symtab.h          |  5 -----
 gdb/xcoffread.c       |  9 ++++-----
 13 files changed, 56 insertions(+), 55 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c
index d9c27ebc956..76150b4246e 100644
--- a/gdb/buildsym-legacy.c
+++ b/gdb/buildsym-legacy.c
@@ -207,11 +207,10 @@  free_buildsym_compunit (void)
 }
 
 struct compunit_symtab *
-end_symtab (CORE_ADDR end_addr, int section)
+end_symtab (CORE_ADDR end_addr)
 {
   gdb_assert (buildsym_compunit != nullptr);
-  struct compunit_symtab *result
-    = buildsym_compunit->end_symtab (end_addr, section);
+  struct compunit_symtab *result = buildsym_compunit->end_symtab (end_addr);
   free_buildsym_compunit ();
   return result;
 }
diff --git a/gdb/buildsym-legacy.h b/gdb/buildsym-legacy.h
index 37b2275fd9f..d1e8fe716b7 100644
--- a/gdb/buildsym-legacy.h
+++ b/gdb/buildsym-legacy.h
@@ -73,7 +73,7 @@  extern void push_subfile ();
 
 extern const char *pop_subfile ();
 
-extern struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
+extern struct compunit_symtab *end_symtab (CORE_ADDR end_addr);
 
 extern struct context_stack *push_context (int desc, CORE_ADDR valu);
 
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b9bcc33080a..2270f47d0be 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -896,7 +896,7 @@  buildsym_compunit::end_symtab_get_static_block (CORE_ADDR end_addr,
 
 struct compunit_symtab *
 buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
-						int section, int expandable)
+						int expandable)
 {
   struct compunit_symtab *cu = m_compunit_symtab;
   struct blockvector *blockvector;
@@ -1032,8 +1032,6 @@  buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
     set_block_compunit_symtab (b, cu);
   }
 
-  COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
-
   COMPUNIT_MACRO_TABLE (cu) = release_macros ();
 
   /* Default any symbols without a specified symtab to the primary symtab.  */
@@ -1072,15 +1070,12 @@  buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 /* Implementation of the second part of end_symtab.  Pass STATIC_BLOCK
    as value returned by end_symtab_get_static_block.
 
-   SECTION is the same as for end_symtab: the section number
-   (in objfile->section_offsets) of the blockvector and linetable.
-
    If EXPANDABLE is non-zero the GLOBAL_BLOCK dictionary is made
    expandable.  */
 
 struct compunit_symtab *
 buildsym_compunit::end_symtab_from_static_block (struct block *static_block,
-						 int section, int expandable)
+						 int expandable)
 {
   struct compunit_symtab *cu;
 
@@ -1098,7 +1093,7 @@  buildsym_compunit::end_symtab_from_static_block (struct block *static_block,
       cu = NULL;
     }
   else
-    cu = end_symtab_with_blockvector (static_block, section, expandable);
+    cu = end_symtab_with_blockvector (static_block, expandable);
 
   return cu;
 }
@@ -1108,9 +1103,7 @@  buildsym_compunit::end_symtab_from_static_block (struct block *static_block,
    them), then make the struct symtab for that file and put it in the
    list of all such.
 
-   END_ADDR is the address of the end of the file's text.  SECTION is
-   the section number (in objfile->section_offsets) of the blockvector
-   and linetable.
+   END_ADDR is the address of the end of the file's text.
 
    Note that it is possible for end_symtab() to return NULL.  In
    particular, for the DWARF case at least, it will return NULL when
@@ -1125,23 +1118,23 @@  buildsym_compunit::end_symtab_from_static_block (struct block *static_block,
    yourself.  */
 
 struct compunit_symtab *
-buildsym_compunit::end_symtab (CORE_ADDR end_addr, int section)
+buildsym_compunit::end_symtab (CORE_ADDR end_addr)
 {
   struct block *static_block;
 
   static_block = end_symtab_get_static_block (end_addr, 0, 0);
-  return end_symtab_from_static_block (static_block, section, 0);
+  return end_symtab_from_static_block (static_block, 0);
 }
 
 /* Same as end_symtab except create a symtab that can be later added to.  */
 
 struct compunit_symtab *
-buildsym_compunit::end_expandable_symtab (CORE_ADDR end_addr, int section)
+buildsym_compunit::end_expandable_symtab (CORE_ADDR end_addr)
 {
   struct block *static_block;
 
   static_block = end_symtab_get_static_block (end_addr, 1, 0);
-  return end_symtab_from_static_block (static_block, section, 1);
+  return end_symtab_from_static_block (static_block, 1);
 }
 
 /* Subroutine of augment_type_symtab to simplify it.
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index c768a4c2dae..45ca4ae95a0 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -275,12 +275,11 @@  struct buildsym_compunit
 					     int expandable, int required);
 
   struct compunit_symtab *end_symtab_from_static_block
-      (struct block *static_block, int section, int expandable);
+      (struct block *static_block, int expandable);
 
-  struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
+  struct compunit_symtab *end_symtab (CORE_ADDR end_addr);
 
-  struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
-						 int section);
+  struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr);
 
   void augment_type_symtab ();
 
@@ -300,7 +299,7 @@  struct buildsym_compunit
   void watch_main_source_file_lossage ();
 
   struct compunit_symtab *end_symtab_with_blockvector
-      (struct block *static_block, int section, int expandable);
+      (struct block *static_block, int expandable);
 
   /* The objfile we're reading debug info from.  */
   struct objfile *m_objfile;
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 7e3cb4a6fda..377db50419e 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -403,7 +403,7 @@  coff_end_symtab (struct objfile *objfile)
 {
   set_last_source_start_addr (current_source_start_addr);
 
-  end_symtab (current_source_end_addr, SECT_OFF_TEXT (objfile));
+  end_symtab (current_source_end_addr);
 
   /* Reinitialize for beginning of new file.  */
   set_last_source_file (NULL);
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 74355a019b9..eeb759ceb10 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -1196,18 +1196,15 @@  ctf_start_symtab (ctf_psymtab *pst,
 }
 
 /* Finish reading symbol/type definitions in CTF format.
-   END_ADDR is the end address of the file's text.  SECTION is
-   the .text section number.  */
+   END_ADDR is the end address of the file's text.  */
 
 static struct compunit_symtab *
-ctf_end_symtab (ctf_psymtab *pst,
-		CORE_ADDR end_addr, int section)
+ctf_end_symtab (ctf_psymtab *pst, CORE_ADDR end_addr)
 {
   struct ctf_context *ccp;
 
   ccp = pst->context;
-  struct compunit_symtab *result
-    = ccp->builder->end_symtab (end_addr, section);
+  struct compunit_symtab *result = ccp->builder->end_symtab (end_addr);
   delete ccp->builder;
   ccp->builder = NULL;
   return result;
@@ -1282,8 +1279,7 @@  ctf_psymtab::read_symtab (struct objfile *objfile)
 
       set_text_low (offset);
       set_text_high (offset + tsize);
-      compunit_symtab = ctf_end_symtab (this, offset + tsize,
-					SECT_OFF_TEXT (objfile));
+      compunit_symtab = ctf_end_symtab (this, offset + tsize);
 
       /* Finish up the debug error message.  */
       if (info_verbose)
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 1e1a5dc9b97..cc7d1758884 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2281,8 +2281,7 @@  read_ofile_symtab (struct objfile *objfile, legacy_psymtab *pst)
   if (get_last_source_start_addr () > text_offset)
     set_last_source_start_addr (text_offset);
 
-  pst->compunit_symtab = end_symtab (text_offset + text_size,
-				     SECT_OFF_TEXT (objfile));
+  pst->compunit_symtab = end_symtab (text_offset + text_size);
 
   end_stabs ();
 
@@ -2538,7 +2537,7 @@  process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 	      patch_subfile_names (get_current_subfile (), name);
 	      break;		/* Ignore repeated SOs.  */
 	    }
-	  end_symtab (valu, SECT_OFF_TEXT (objfile));
+	  end_symtab (valu);
 	  end_stabs ();
 	}
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 245ce07de74..6fea89233c4 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9679,9 +9679,7 @@  process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
      this comp unit.  */
   dwarf2_record_block_ranges (cu->dies, static_block, baseaddr, cu);
 
-  cust = cu->get_builder ()->end_symtab_from_static_block (static_block,
-						    SECT_OFF_TEXT (objfile),
-						    0);
+  cust = cu->get_builder ()->end_symtab_from_static_block (static_block, 0);
 
   if (cust != NULL)
     {
@@ -9740,7 +9738,6 @@  process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
 {
   struct dwarf2_cu *cu = per_cu->cu;
   struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
-  struct objfile *objfile = dwarf2_per_objfile->objfile;
   struct compunit_symtab *cust;
   struct signatured_type *sig_type;
 
@@ -9775,7 +9772,7 @@  process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
   if (sig_type->type_unit_group->compunit_symtab == NULL)
     {
       buildsym_compunit *builder = cu->get_builder ();
-      cust = builder->end_expandable_symtab (0, SECT_OFF_TEXT (objfile));
+      cust = builder->end_expandable_symtab (0);
       sig_type->type_unit_group->compunit_symtab = cust;
 
       if (cust != NULL)
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index ba53512636e..971ce5de278 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3945,7 +3945,7 @@  mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 		    {
 		      valu += section_offsets[SECT_OFF_TEXT (objfile)];
 		      previous_stab_code = N_SO;
-		      cust = end_symtab (valu, SECT_OFF_TEXT (objfile));
+		      cust = end_symtab (valu);
 		      end_stabs ();
 		      last_symtab_ended = 1;
 		    }
@@ -4005,7 +4005,7 @@  mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 
       if (! last_symtab_ended)
 	{
-	  cust = end_symtab (pst->raw_text_high (), SECT_OFF_TEXT (objfile));
+	  cust = end_symtab (pst->raw_text_high ());
 	  end_stabs ();
 	}
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 3aa7973e0d5..c1ee3e9dc1c 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -670,7 +670,7 @@  objfile_relocate1 (struct objfile *objfile,
 	    if (l)
 	      {
 		for (int i = 0; i < l->nitems; ++i)
-		  l->item[i].pc += delta[COMPUNIT_BLOCK_LINE_SECTION (cust)];
+		  l->item[i].pc += delta[SECT_OFF_TEXT (objfile)];
 	      }
 	  }
       }
@@ -678,7 +678,7 @@  objfile_relocate1 (struct objfile *objfile,
     for (compunit_symtab *cust : objfile->compunits ())
       {
 	const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
-	int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
+	int block_line_section = SECT_OFF_TEXT (objfile);
 
 	if (BLOCKVECTOR_MAP (bv))
 	  addrmap_relocate (BLOCKVECTOR_MAP (bv), delta[block_line_section]);
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 05e6a311b87..c029b07da91 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1472,10 +1472,6 @@  struct compunit_symtab
      all symtabs in a given compilation unit.  */
   const struct blockvector *blockvector;
 
-  /* Section in objfile->section_offsets for the blockvector and
-     the linetable.  Probably always SECT_OFF_TEXT.  */
-  int block_line_section;
-
   /* Symtab has been compiled with both optimizations and debug info so that
      GDB may stop skipping prologues as variables locations are valid already
      at function entry points.  */
@@ -1516,7 +1512,6 @@  struct compunit_symtab
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
 #define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
 #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
-#define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
 #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
 #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
 #define COMPUNIT_CALL_SITE_HTAB(cust) ((cust)->call_site_htab)
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 93bdb9b6a65..e6e6db44b88 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1126,8 +1126,7 @@  read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
 	{
 	  if (get_last_source_file ())
 	    {
-	      pst->compunit_symtab = end_symtab (cur_src_end_addr,
-						 SECT_OFF_TEXT (objfile));
+	      pst->compunit_symtab = end_symtab (cur_src_end_addr);
 	      end_stabs ();
 	    }
 
@@ -1217,7 +1216,7 @@  read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
 			{
 			  complete_symtab (filestring, file_start_addr);
 			  cur_src_end_addr = file_end_addr;
-			  end_symtab (file_end_addr, SECT_OFF_TEXT (objfile));
+			  end_symtab (file_end_addr);
 			  end_stabs ();
 			  start_stabs ();
 			  /* Give all csects for this source file the same
@@ -1323,7 +1322,7 @@  read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
 
 	  complete_symtab (filestring, file_start_addr);
 	  cur_src_end_addr = file_end_addr;
-	  end_symtab (file_end_addr, SECT_OFF_TEXT (objfile));
+	  end_symtab (file_end_addr);
 	  end_stabs ();
 
 	  /* XCOFF, according to the AIX 3.2 documentation, puts the
@@ -1510,7 +1509,7 @@  read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
 
       complete_symtab (filestring, file_start_addr);
       cur_src_end_addr = file_end_addr;
-      cust = end_symtab (file_end_addr, SECT_OFF_TEXT (objfile));
+      cust = end_symtab (file_end_addr);
       /* When reading symbols for the last C_FILE of the objfile, try
          to make sure that we set pst->compunit_symtab to the symtab for the
          file, not to the _globals_ symtab.  I'm not sure whether this