This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 14/21] struct symtab split part 2: macroscope.c macrotab.c macrotab.h


This patch contains the changes to macroscope.c, macrotab.c, macrotab.h.

Full ChangeLog: https://sourceware.org/ml/gdb-patches/2014-11/msg00233.html

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

	* macroscope.c (sal_macro_scope): Fetch macro table from compunit.
	* macrotab.c (struct macro_table) <compunit_symtab>: Renamed from
	comp_dir.  Change type to "struct compunit_symtab *".
	All uses updated.
	(new_macro_table): Change comp_dir argument to cust,
	"struct compunit_symtab *".  All callers updated.

diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index c025eb7..6df86ea 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -40,14 +40,17 @@ sal_macro_scope (struct symtab_and_line sal)
 {
   struct macro_source_file *main_file, *inclusion;
   struct macro_scope *ms;
+  struct compunit_symtab *cust;
 
-  if (! sal.symtab
-      || ! sal.symtab->macro_table)
-    return 0;
+  if (sal.symtab == NULL)
+    return NULL;
+  cust = SYMTAB_COMPUNIT (sal.symtab);
+  if (COMPUNIT_MACRO_TABLE (cust) == NULL)
+    return NULL;
 
   ms = (struct macro_scope *) xmalloc (sizeof (*ms));
 
-  main_file = macro_main (sal.symtab->macro_table);
+  main_file = macro_main (COMPUNIT_MACRO_TABLE (cust));
   inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename);
 
   if (inclusion)
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 1e02b0a..1e21f50 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -47,9 +47,8 @@ struct macro_table
      #inclusion tree; everything else is #included from here.  */
   struct macro_source_file *main_source;
 
-  /* Compilation directory for all files of this macro table.  It is allocated
-     on objfile's obstack.  */
-  const char *comp_dir;
+  /* Backlink to containing compilation unit, or NULL if there isn't one.  */
+  struct compunit_symtab *compunit_symtab;
 
   /* True if macros in this table can be redefined without issuing an
      error.  */
@@ -1049,7 +1048,7 @@ macro_for_each_in_scope (struct macro_source_file *file, int line,
 
 struct macro_table *
 new_macro_table (struct obstack *obstack, struct bcache *b,
-		 const char *comp_dir)
+		 struct compunit_symtab *cust)
 {
   struct macro_table *t;
 
@@ -1063,7 +1062,7 @@ new_macro_table (struct obstack *obstack, struct bcache *b,
   t->obstack = obstack;
   t->bcache = b;
   t->main_source = NULL;
-  t->comp_dir = comp_dir;
+  t->compunit_symtab = cust;
   t->redef_ok = 0;
   t->definitions = (splay_tree_new_with_allocator
                     (macro_tree_compare,
@@ -1092,8 +1091,13 @@ free_macro_table (struct macro_table *table)
 char *
 macro_source_fullname (struct macro_source_file *file)
 {
-  if (file->table->comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
+  const char *comp_dir = NULL;
+
+  if (file->table->compunit_symtab != NULL)
+    comp_dir = COMPUNIT_DIRNAME (file->table->compunit_symtab);
+
+  if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
     return xstrdup (file->filename);
 
-  return concat (file->table->comp_dir, SLASH_STRING, file->filename, NULL);
+  return concat (comp_dir, SLASH_STRING, file->filename, NULL);
 }
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index aca7fd4..202b4e8 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -22,6 +22,7 @@
 
 struct obstack;
 struct bcache;
+struct compunit_symtab;
 
 /* How do we represent a source location?  I mean, how should we
    represent them within GDB; the user wants to use all sorts of
@@ -154,8 +155,8 @@ struct macro_source_file
    xmalloc if OBSTACK is zero.  Use BCACHE to store all macro names,
    arguments, definitions, and anything else that might be the same
    amongst compilation units in an executable file; if BCACHE is zero,
-   don't cache these things.  COMP_DIR optionally contains the compilation
-   directory of all files for this macro table.
+   don't cache these things.  CUST is a pointer to the containing
+   compilation unit, or NULL if there isn't one.
 
    Note that, if either OBSTACK or BCACHE are non-zero, then removing
    information from the table may leak memory.  Neither obstacks nor
@@ -168,7 +169,7 @@ struct macro_source_file
    do that in GCC 4.1.2.).  */
 struct macro_table *new_macro_table (struct obstack *obstack,
                                      struct bcache *bcache,
-				     const char *comp_dir);
+				     struct compunit_symtab *cust);
 
 
 /* Free TABLE, and any macro definitions, source file structures,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]