* buildsym.c (patch_subfile_names): Use set_last_source_file.
authorTom Tromey <tromey@redhat.com>
Mon, 21 Jan 2013 18:05:13 +0000 (18:05 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 21 Jan 2013 18:05:13 +0000 (18:05 +0000)
(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.

gdb/ChangeLog
gdb/buildsym.c
gdb/buildsym.h
gdb/coffread.c
gdb/dbxread.c
gdb/mdebugread.c
gdb/xcoffread.c

index 6a15e400f9208a145de84f6bfb28cf6bdf1d22ff..632305668975290f1c847a7c513ced7bcfd96cac 100644 (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.
index 2c4a946ce5ee9f8e4f00b73941aa53d44db2016b..4d861a5ccf178482dd2f0d895a9b8eca237392d2 100644 (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);
 }
 \f
+
+/* 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;
+}
+
+\f
+
 /* 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.  */
index f44fd4bb0002d8c7f7d3675592364efb1dd824f7..4bde17a44c70e73658907a4294177947503f6f3c 100644 (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.  */
index 9e62207785a3dc4a79bdcee44e485e87457bedb5..62565a8d01fb561f879c1da100be1e71dcfef886 100644 (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);
 }
 \f
 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
index cfd8df615446f433575d0562cb11bc07498d4e16..5857e33ce1ed602a84dc6c69879d0368d109f04a 100644 (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.
index 79644be332142e979279c263c4a2ec317dc92b5b..aff4525928e94cdb4e99c29a091b6e56e7fc11e9 100644 (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')
                    {
index ce28eb7a14df16413d135f2b69d07f9e72d8f16f..a71a958d4e62d1e710634a1599e429711401c8b1 100644 (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;
This page took 0.032836 seconds and 4 git commands to generate.