* buildsym.c (patch_subfile_names): Use set_last_source_file.

(start_symtab): Make 'name' and 'dirname' const.  Use
	set_last_source_file.
	(restart_symtab, reset_symtab_globals): Use set_last_source_file.
	(last_source_file): Define.  Now static.
	(set_last_source_file, get_last_source_file): New functions.
	* buildsym.h (last_source_file): Don't declare.
	(start_symtab): Update.
	(set_last_source_file, get_last_source_file): Declare.
	* coffread.c (complete_symtab): Use set_last_source_file.
	(coff_end_symtab): Likewise.
	(coff_symtab_read): Use set_last_source_file, get_last_source_file.
	* dbxread.c (read_dbx_symtab, read_ofile_symtab): Use
	set_last_source_file.
	(process_one_symbol): Use get_last_source_file.
	* mdebugread.c (parse_partial_symbols): Use set_last_source_file.
	(psymtab_to_symtab_1): Use get_last_source_file.
	* xcoffread.c (process_linenos): Use get_last_source_file.
	(complete_symtab): Use set_last_source_file.
	(read_xcoff_symtab): Use set_last_source_file, get_last_source_file.
	(scan_xcoff_symtab): Use set_last_source_file.
This commit is contained in:
Tom Tromey 2013-01-21 18:05:13 +00:00
parent 9d2ceabe7f
commit 46212e0bb5
7 changed files with 87 additions and 34 deletions

View File

@ -1,3 +1,27 @@
2013-01-21 Tom Tromey <tromey@redhat.com>
* buildsym.c (patch_subfile_names): Use set_last_source_file.
(start_symtab): Make 'name' and 'dirname' const. Use
set_last_source_file.
(restart_symtab, reset_symtab_globals): Use set_last_source_file.
(last_source_file): Define. Now static.
(set_last_source_file, get_last_source_file): New functions.
* buildsym.h (last_source_file): Don't declare.
(start_symtab): Update.
(set_last_source_file, get_last_source_file): Declare.
* coffread.c (complete_symtab): Use set_last_source_file.
(coff_end_symtab): Likewise.
(coff_symtab_read): Use set_last_source_file, get_last_source_file.
* dbxread.c (read_dbx_symtab, read_ofile_symtab): Use
set_last_source_file.
(process_one_symbol): Use get_last_source_file.
* mdebugread.c (parse_partial_symbols): Use set_last_source_file.
(psymtab_to_symtab_1): Use get_last_source_file.
* xcoffread.c (process_linenos): Use get_last_source_file.
(complete_symtab): Use set_last_source_file.
(read_xcoff_symtab): Use set_last_source_file, get_last_source_file.
(scan_xcoff_symtab): Use set_last_source_file.
2013-01-21 Tom Tromey <tromey@redhat.com>
* symtab.c (struct demangled_name_entry) <mangled>: Now const.

View File

@ -681,7 +681,7 @@ patch_subfile_names (struct subfile *subfile, char *name)
{
subfile->dirname = subfile->name;
subfile->name = xstrdup (name);
last_source_file = name;
set_last_source_file (name);
/* Default the source language to whatever can be deduced from
the filename. If nothing can be deduced (such as for a C/C++
@ -835,10 +835,10 @@ compare_line_numbers (const void *ln1p, const void *ln2p)
lowest address of objects in the file (or 0 if not known). */
void
start_symtab (char *name, char *dirname, CORE_ADDR start_addr)
start_symtab (const char *name, const char *dirname, CORE_ADDR start_addr)
{
restart_symtab (start_addr);
last_source_file = name;
set_last_source_file (name);
start_subfile (name, dirname);
}
@ -850,7 +850,7 @@ start_symtab (char *name, char *dirname, CORE_ADDR start_addr)
void
restart_symtab (CORE_ADDR start_addr)
{
last_source_file = NULL;
set_last_source_file (NULL);
last_source_start_addr = start_addr;
file_symbols = NULL;
global_symbols = NULL;
@ -971,7 +971,7 @@ block_compar (const void *ap, const void *bp)
static void
reset_symtab_globals (void)
{
last_source_file = NULL;
set_last_source_file (NULL);
current_subfile = NULL;
pending_macros = NULL;
if (pending_addrmap)
@ -1500,6 +1500,32 @@ merge_symbol_lists (struct pending **srclist, struct pending **targetlist)
free_pendings = (*srclist);
}
/* Name of source file whose symbol data we are now processing. This
comes from a symbol of type N_SO for stabs. For Dwarf it comes
from the DW_AT_name attribute of a DW_TAG_compile_unit DIE. */
static char *last_source_file;
/* See buildsym.h. */
void
set_last_source_file (const char *name)
{
xfree (last_source_file);
last_source_file = name == NULL ? NULL : xstrdup (name);
}
/* See buildsym.h. */
const char *
get_last_source_file (void)
{
return last_source_file;
}
/* Initialize anything that needs initializing when starting to read a
fresh piece of a symbol file, e.g. reading in the stuff
corresponding to a psymtab. */

View File

@ -45,12 +45,6 @@ struct pending_block;
#define HASHSIZE 127 /* Size of things hashed via
hashname(). */
/* Name of source file whose symbol data we are now processing. This
comes from a symbol of type N_SO for stabs. For Dwarf it comes
from the DW_AT_name attribute of a DW_TAG_compile_unit DIE. */
EXTERN char *last_source_file;
/* Core address of start of text of current source file. This too
comes from the N_SO symbol. For Dwarf it typically comes from the
DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE. */
@ -269,7 +263,8 @@ extern struct context_stack *pop_context (void);
extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
extern void start_symtab (char *name, char *dirname, CORE_ADDR start_addr);
extern void start_symtab (const char *name, const char *dirname,
CORE_ADDR start_addr);
extern void restart_symtab (CORE_ADDR start_addr);
@ -292,6 +287,15 @@ extern void record_producer (const char *producer);
extern void merge_symbol_lists (struct pending **srclist,
struct pending **targetlist);
/* Set the name of the last source file. NAME is copied by this
function. */
extern void set_last_source_file (const char *name);
/* Fetch the name of the last source file. */
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. */

View File

@ -396,9 +396,7 @@ coff_start_symtab (const char *name)
static void
complete_symtab (const char *name, CORE_ADDR start_addr, unsigned int size)
{
if (last_source_file != NULL)
xfree (last_source_file);
last_source_file = xstrdup (name);
set_last_source_file (name);
current_source_start_addr = start_addr;
current_source_end_addr = start_addr + size;
}
@ -417,7 +415,7 @@ coff_end_symtab (struct objfile *objfile)
SECT_OFF_TEXT (objfile));
/* Reinitialize for beginning of new file. */
last_source_file = NULL;
set_last_source_file (NULL);
}
static struct minimal_symbol *
@ -745,7 +743,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
coffread_objfile = objfile;
nlist_bfd_global = objfile->obfd;
nlist_nsyms_global = nsyms;
last_source_file = NULL;
set_last_source_file (NULL);
memset (opaque_type_chain, 0, sizeof opaque_type_chain);
if (type_vector) /* Get rid of previous one. */
@ -766,7 +764,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE)
{
if (last_source_file)
if (get_last_source_file ())
coff_end_symtab (objfile);
coff_start_symtab ("_globals_");
@ -782,7 +780,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
/* Special case for file with type declarations only, no
text. */
if (!last_source_file && SDB_TYPE (cs->c_type)
if (!get_last_source_file () && SDB_TYPE (cs->c_type)
&& cs->c_secnum == N_DEBUG)
complete_symtab (filestring, 0, 0);
@ -831,7 +829,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
/* Complete symbol table for last object file
containing debugging information. */
if (last_source_file)
if (get_last_source_file ())
{
coff_end_symtab (objfile);
coff_start_symtab (filestring);
@ -1121,7 +1119,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
read_pe_exported_syms (objfile);
}
if (last_source_file)
if (get_last_source_file ())
coff_end_symtab (objfile);
/* Patch up any opaque types (references to types that are not defined

View File

@ -1255,7 +1255,7 @@ read_dbx_symtab (struct objfile *objfile)
init_bincl_list (20, objfile);
back_to = make_cleanup_free_bincl_list (objfile);
last_source_file = NULL;
set_last_source_file (NULL);
lowest_text_address = (CORE_ADDR) -1;
@ -2541,7 +2541,7 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
subfile_stack = NULL;
stringtab_global = DBX_STRINGTAB (objfile);
last_source_file = NULL;
set_last_source_file (NULL);
abfd = objfile->obfd;
symfile_bfd = objfile->obfd; /* Implicit param to next_text_symbol. */
@ -2765,7 +2765,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
/* Something is wrong if we see real data before seeing a source
file name. */
if (last_source_file == NULL && type != (unsigned char) N_SO)
if (get_last_source_file () == NULL && type != (unsigned char) N_SO)
{
/* Ignore any symbols which appear before an N_SO symbol.
Currently no one puts symbols there, but we should deal
@ -2941,7 +2941,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
n_opt_found = 0;
if (last_source_file)
if (get_last_source_file ())
{
/* Check if previous symbol was also an N_SO (with some
sanity checks). If so, that one was actually the
@ -3174,7 +3174,8 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
&& gdbarch_sofun_address_maybe_missing (gdbarch))
{
CORE_ADDR minsym_valu =
find_stab_function_addr (name, last_source_file, objfile);
find_stab_function_addr (name, get_last_source_file (),
objfile);
/* The function find_stab_function_addr will return
0 if the minimal symbol wasn't found.

View File

@ -2394,7 +2394,7 @@ parse_partial_symbols (struct objfile *objfile)
(struct partial_symtab **) alloca (dependencies_allocated *
sizeof (struct partial_symtab *));
last_source_file = NULL;
set_last_source_file (NULL);
/*
* Big plan:
@ -4079,7 +4079,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
would otherwise be ended twice, once in
process_one_symbol, and once after this loop. */
if (type_code == N_SO
&& last_source_file
&& get_last_source_file ()
&& previous_stab_code != (unsigned char) N_SO
&& *name == '\000')
{

View File

@ -655,7 +655,7 @@ process_linenos (CORE_ADDR start, CORE_ADDR end)
start, 0, &main_source_baseline);
}
if (strcmp (inclTable[ii].name, last_source_file) == 0)
if (strcmp (inclTable[ii].name, get_last_source_file ()) == 0)
{
/* The entry in the include table refers to the main source
file. Add the lines to the main subfile. */
@ -894,7 +894,7 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset,
text address for the file, and SIZE is the number of bytes of text. */
#define complete_symtab(name, start_addr) { \
last_source_file = xstrdup (name); \
set_last_source_file (name); \
last_source_start_addr = start_addr; \
}
@ -1031,7 +1031,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
handling. */
local_symesz = coff_data (abfd)->local_symesz;
last_source_file = NULL;
set_last_source_file (NULL);
last_csect_name = 0;
start_stabs ();
@ -1119,7 +1119,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE)
{
if (last_source_file)
if (get_last_source_file ())
{
pst->symtab = end_symtab (cur_src_end_addr, objfile,
SECT_OFF_TEXT (objfile));
@ -1488,7 +1488,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
}
}
if (last_source_file)
if (get_last_source_file ())
{
struct symtab *s;
@ -2225,7 +2225,7 @@ scan_xcoff_symtab (struct objfile *objfile)
(struct partial_symtab **) alloca (dependencies_allocated *
sizeof (struct partial_symtab *));
last_source_file = NULL;
set_last_source_file (NULL);
abfd = objfile->obfd;
next_symbol_text_func = xcoff_next_symbol_text;