(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 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.
associated symtab. */
static struct pending_block *pending_blocks;
-\f
+
+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);
-\f
/* Initial sizes of data structures. These are realloc'd larger if
needed, and realloc'd down to the size actually used, when
return ln1->line - ln2->line;
}
\f
+/* 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;
+}
+\f
/* 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
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);
\f
-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);
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
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,
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 *));
section_offsets = pst->section_offsets;
dbxread_objfile = objfile;
- subfile_stack = NULL;
stringtab_global = DBX_STRINGTAB (objfile);
set_last_source_file (NULL);
/* 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);
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
\f
/* Look up a dbx type-number pair. Return the address of the slot