diff options
-rw-r--r-- | gdb/ChangeLog | 24 | ||||
-rw-r--r-- | gdb/buildsym.c | 36 | ||||
-rw-r--r-- | gdb/buildsym.h | 18 | ||||
-rw-r--r-- | gdb/coffread.c | 16 | ||||
-rw-r--r-- | gdb/dbxread.c | 11 | ||||
-rw-r--r-- | gdb/mdebugread.c | 4 | ||||
-rw-r--r-- | gdb/xcoffread.c | 12 |
7 files changed, 87 insertions, 34 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6a15e40..6323056 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,29 @@ 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. (symbol_set_names): Remove casts. Handle field const-ness. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 2c4a946..4d861a5 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -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. */ diff --git a/gdb/buildsym.h b/gdb/buildsym.h index f44fd4b..4bde17a 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -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. */ diff --git a/gdb/coffread.c b/gdb/coffread.c index 9e62207..62565a8 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -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 diff --git a/gdb/dbxread.c b/gdb/dbxread.c index cfd8df6..5857e33 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -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. diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 79644be..aff4525 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -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') { diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index ce28eb7..a71a958 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -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; |