aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog18
-rw-r--r--gdb/buildsym.c29
-rw-r--r--gdb/buildsym.h33
-rw-r--r--gdb/coffread.c15
-rw-r--r--gdb/dbxread.c1
-rw-r--r--gdb/dwarf2read.c15
-rw-r--r--gdb/stabsread.c17
7 files changed, 86 insertions, 42 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b81014e..7ed39f8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,21 @@
+2013-08-20 Doug Evans <dje@google.com>
+
+ * buildsym.c (subfile_stack): Move here from buildsym.h.
+ (pending_macros): Ditto.
+ (get_macro_table): New function.
+ (buildsym_init): Initialize subfile_stack.
+ * coffread.c (type_vector,type_vector_length): Moved here from
+ buildsym.h.
+ (INITIAL_TYPE_VECTOR_LENGTH): Ditto.
+ (coff_symtab_read): Use it.
+ * dbxread.c (read_ofile_symtab): Delete init of subfile_stack.
+ * dwarf2read.c (macro_start_file): Replace uses of pending_macros
+ with call to get_macro_table.
+ * stabsread.c (type_vector,type_vector_length): Moved here from
+ buildsym.h.
+ (INITIAL_TYPE_VECTOR_LENGTH): Ditto.
+ * buildsym.h (get_macro_table): Declare.
+
2013-08-20 Tom Tromey <tromey@redhat.com>
* dbxread.c (record_minimal_symbol): Make 'name' argument const.
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 823ad41..1237e5e 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -102,13 +102,24 @@ struct pending_block
associated symtab. */
static struct pending_block *pending_blocks;
-
+
+struct subfile_stack
+ {
+ struct subfile_stack *next;
+ char *name;
+ };
+
+static struct subfile_stack *subfile_stack;
+
+/* The macro table for the compilation unit whose symbols we're
+ currently reading. All the symtabs for the CU will point to this. */
+static struct macro_table *pending_macros;
+
static int compare_line_numbers (const void *ln1p, const void *ln2p);
static void record_pending_block (struct objfile *objfile,
struct block *block,
struct pending_block *opblock);
-
/* Initial sizes of data structures. These are realloc'd larger if
needed, and realloc'd down to the size actually used, when
@@ -825,6 +836,19 @@ compare_line_numbers (const void *ln1p, const void *ln2p)
return ln1->line - ln2->line;
}
+/* Return the macro table.
+ Initialize it if this is the first use. */
+
+struct macro_table *
+get_macro_table (struct objfile *objfile, const char *comp_dir)
+{
+ if (! pending_macros)
+ pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
+ objfile->per_bfd->macro_cache,
+ comp_dir);
+ return pending_macros;
+}
+
/* Start a new symtab for a new source file. Called, for example,
when a stabs symbol of type N_SO is seen, or when a DWARF
TAG_compile_unit DIE is seen. It indicates the start of data for
@@ -1538,6 +1562,7 @@ buildsym_init (void)
pending_blocks = NULL;
pending_macros = NULL;
using_directives = NULL;
+ subfile_stack = NULL;
/* We shouldn't have any address map at this point. */
gdb_assert (! pending_addrmap);
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 4bde17a..9ac2d28 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -173,37 +173,12 @@ EXTERN int within_function;
-struct subfile_stack
- {
- struct subfile_stack *next;
- char *name;
- };
-
-EXTERN struct subfile_stack *subfile_stack;
-
#define next_symbol_text(objfile) (*next_symbol_text_func)(objfile)
/* Function to invoke get the next symbol. Return the symbol name. */
EXTERN char *(*next_symbol_text_func) (struct objfile *);
-/* Vector of types defined so far, indexed by their type numbers.
- Used for both stabs and coff. (In newer sun systems, dbx uses a
- pair of numbers in parens, as in "(SUBFILENUM,NUMWITHINSUBFILE)".
- Then these numbers must be translated through the type_translations
- hash table to get the index into the type vector.) */
-
-EXTERN struct type **type_vector;
-
-/* Number of elements allocated for type_vector currently. */
-
-EXTERN int type_vector_length;
-
-/* Initial size of type vector. Is realloc'd larger if needed, and
- realloc'd down to the size actually used, when completed. */
-
-#define INITIAL_TYPE_VECTOR_LENGTH 160
-
extern void add_symbol_to_list (struct symbol *symbol,
struct pending **listhead);
@@ -296,10 +271,10 @@ extern void set_last_source_file (const char *name);
extern const char *get_last_source_file (void);
-/* The macro table for the compilation unit whose symbols we're
- currently reading. All the symtabs for this CU will point to
- this. */
-EXTERN struct macro_table *pending_macros;
+/* Return the macro table. */
+
+extern struct macro_table *get_macro_table (struct objfile *objfile,
+ const char *comp_dir);
#undef EXTERN
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 1402247..7ade38c 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -146,6 +146,19 @@ struct coff_symbol
unsigned int c_type;
};
+/* Vector of types defined so far, indexed by their type numbers. */
+
+static struct type **type_vector;
+
+/* Number of elements allocated for type_vector currently. */
+
+static int type_vector_length;
+
+/* Initial size of type vector. Is realloc'd larger if needed, and
+ realloc'd down to the size actually used, when completed. */
+
+#define INITIAL_TYPE_VECTOR_LENGTH 160
+
extern void stabsread_clear_cache (void);
static struct type *coff_read_struct_type (int, int, int,
@@ -816,7 +829,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
if (type_vector) /* Get rid of previous one. */
xfree (type_vector);
- type_vector_length = 160;
+ type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
type_vector = (struct type **)
xmalloc (type_vector_length * sizeof (struct type *));
memset (type_vector, 0, type_vector_length * sizeof (struct type *));
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 08cfc99..283b87f 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2530,7 +2530,6 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
section_offsets = pst->section_offsets;
dbxread_objfile = objfile;
- subfile_stack = NULL;
stringtab_global = DBX_STRINGTAB (objfile);
set_last_source_file (NULL);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d08e8b8..7891e32 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -18943,19 +18943,16 @@ macro_start_file (int file, int line,
/* File name relative to the compilation directory of this source file. */
char *file_name = file_file_name (file, lh);
- /* We don't create a macro table for this compilation unit
- at all until we actually get a filename. */
- if (! pending_macros)
- pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
- objfile->per_bfd->macro_cache,
- comp_dir);
-
if (! current_file)
{
+ /* Note: We don't create a macro table for this compilation unit
+ at all until we actually get a filename. */
+ struct macro_table *macro_table = get_macro_table (objfile, comp_dir);
+
/* If we have no current file, then this must be the start_file
directive for the compilation unit's main source file. */
- current_file = macro_set_main (pending_macros, file_name);
- macro_define_special (pending_macros);
+ current_file = macro_set_main (macro_table, file_name);
+ macro_define_special (macro_table);
}
else
current_file = macro_include (current_file, line, file_name);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 875541c..f16e547 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -207,6 +207,23 @@ static int noname_undefs_length;
if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
*(pp) = next_symbol_text (objfile); \
} while (0)
+
+/* Vector of types defined so far, indexed by their type numbers.
+ (In newer sun systems, dbx uses a pair of numbers in parens,
+ as in "(SUBFILENUM,NUMWITHINSUBFILE)".
+ Then these numbers must be translated through the type_translations
+ hash table to get the index into the type vector.) */
+
+static struct type **type_vector;
+
+/* Number of elements allocated for type_vector currently. */
+
+static int type_vector_length;
+
+/* Initial size of type vector. Is realloc'd larger if needed, and
+ realloc'd down to the size actually used, when completed. */
+
+#define INITIAL_TYPE_VECTOR_LENGTH 160
/* Look up a dbx type-number pair. Return the address of the slot