Add new target_read_raw_memory function, and consolidate comments.
[deliverable/binutils-gdb.git] / gdb / buildsym.c
index 2c4a946ce5ee9f8e4f00b73941aa53d44db2016b..0326e264aba3e0e3a07fb5acb472da103842c2ae 100644 (file)
@@ -32,7 +32,7 @@
 #include "gdbtypes.h"
 #include "gdb_assert.h"
 #include "complaints.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "expression.h"                /* For "enum exp_opcode" used by...  */
 #include "bcache.h"
 #include "filenames.h"         /* For DOSish file names.  */
@@ -102,13 +102,24 @@ struct pending_block
    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
@@ -681,7 +692,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++
@@ -825,6 +836,19 @@ compare_line_numbers (const void *ln1p, const void *ln2p)
   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
@@ -835,10 +859,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 +874,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 +995,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)
@@ -1120,9 +1144,10 @@ end_symtab_from_static_block (struct block *static_block,
       blockvector = make_blockvector (objfile);
     }
 
-  /* Read the line table if it has to be read separately.  */
+  /* Read the line table if it has to be read separately.
+     This is only used by xcoffread.c.  */
   if (objfile->sf->sym_read_linetable != NULL)
-    objfile->sf->sym_read_linetable ();
+    objfile->sf->sym_read_linetable (objfile);
 
   /* Handle the case where the debug info specifies a different path
      for the main source file.  It can cause us to lose track of its
@@ -1206,8 +1231,7 @@ end_symtab_from_static_block (struct block *static_block,
          /* All symtabs for the main file and the subfiles share a
             blockvector, so we need to clear primary for everything
             but the main file.  */
-
-         symtab->primary = 0;
+         set_symtab_primary (symtab, 0);
        }
       else
         {
@@ -1255,7 +1279,7 @@ end_symtab_from_static_block (struct block *static_block,
   /* Set this for the main source file.  */
   if (symtab)
     {
-      symtab->primary = 1;
+      set_symtab_primary (symtab, 1);
 
       if (symtab->blockvector)
        {
@@ -1367,7 +1391,6 @@ void
 augment_type_symtab (struct objfile *objfile, struct symtab *primary_symtab)
 {
   struct blockvector *blockvector = primary_symtab->blockvector;
-  int i;
 
   if (context_stack_depth > 0)
     {
@@ -1500,6 +1523,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.  */
@@ -1513,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);
This page took 0.02739 seconds and 4 git commands to generate.