diff mbox

[1/5] struct symtab split part 1: SYMTAB_OBJFILE

Message ID m37fz112a8.fsf@sspiff.org
State New
Headers show

Commit Message

Doug Evans Nov. 12, 2014, 4:16 a.m. UTC
Hi.

This patch just adds an accessor macro to symtab.objfile.

2014-11-11  Doug Evans  <xdje42@gmail.com>

	* symtab.h (SYMTAB_OBJFILE): New macro.  All uses of member
	symtab.objfile updated to use it.
diff mbox

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 4320eec..344db2d 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 bd51f5d..6ffa3b0 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7322,7 +7322,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;
 }
@@ -10211,8 +10211,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
 	    {
@@ -16065,7 +16066,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 a9f90b2..0c3cfa7 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 67864f8..bbde77e 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 c335385..b2d662e 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 dbf9f7d..3567ad8 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 <gdb:symtab>) -> <gdb: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 <gdb:symtab>) -> <gdb: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 df008f7..e1ef0c2 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 38a365c..e8c1b97 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 3fa4530..7dee782 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 bec84ed..62176df 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 1065ba3..e4e3ec1 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 1bb19c9..894531a 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 b16abe4..01ff6ae 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 885fe12..623bcb3 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 1962e02..5b00b1b 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 257d3be..d027e07 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -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 9842bb3..5cdd2e4 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 48a95e4..9768c6d 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 ())
     {