2013-08-30 Phil Muldoon <pmuldoon@redhat.com>
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index 7891e32d7535f9a3d28cb0c0eef0c891266691b3..03b956ac634808c9f3a6597478342d4b8d2e4bc6 100644 (file)
@@ -439,7 +439,7 @@ struct dwarf2_cu
      compilation units are cached...  */
   struct dwarf2_per_cu_data *read_in_chain;
 
-  /* Backchain to our per_cu entry if the tree has been built.  */
+  /* Backlink to our per_cu entry.  */
   struct dwarf2_per_cu_data *per_cu;
 
   /* How many compilation units ago was this CU last referenced?  */
@@ -610,7 +610,8 @@ struct dwarf2_per_cu_data
      DW_TAG_imported_unit, so we just use the same mechanism: For
      .gdb_index version <=7 this also records the TUs that the CU referred
      to.  Concurrently with this change gdb was modified to emit version 8
-     indices so we only pay a price for gold generated indices.  */
+     indices so we only pay a price for gold generated indices.
+     http://sourceware.org/bugzilla/show_bug.cgi?id=15021.  */
   VEC (dwarf2_per_cu_ptr) *imported_symtabs;
 };
 
@@ -1737,10 +1738,6 @@ static void dwarf2_release_queue (void *dummy);
 static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
                             enum language pretend_language);
 
-static int maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
-                                 struct dwarf2_per_cu_data *per_cu,
-                                 enum language pretend_language);
-
 static void process_queue (void);
 
 static void find_file_and_directory (struct die_info *die,
@@ -3357,10 +3354,25 @@ dw2_print_stats (struct objfile *objfile)
   printf_filtered (_("  Number of unread CUs: %d\n"), count);
 }
 
+/* This dumps minimal information about the index.
+   It is called via "mt print objfiles".
+   One use is to verify .gdb_index has been loaded by the
+   gdb.dwarf2/gdb-index.exp testcase.  */
+
 static void
 dw2_dump (struct objfile *objfile)
 {
-  /* Nothing worth printing.  */
+  dw2_setup (objfile);
+  gdb_assert (dwarf2_per_objfile->using_index);
+  printf_filtered (".gdb_index:");
+  if (dwarf2_per_objfile->index_table != NULL)
+    {
+      printf_filtered (" version %d\n",
+                      dwarf2_per_objfile->index_table->version);
+    }
+  else
+    printf_filtered (" faked for \"readnow\"\n");
+  printf_filtered ("\n");
 }
 
 static void
@@ -6931,7 +6943,10 @@ queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
 /* THIS_CU has a reference to PER_CU.  If necessary, load the new compilation
    unit and add it to our queue.
    The result is non-zero if PER_CU was queued, otherwise the result is zero
-   meaning either PER_CU is already queued or it is already loaded.  */
+   meaning either PER_CU is already queued or it is already loaded.
+
+   N.B. There is an invariant here that if a CU is queued then it is loaded.
+   The caller is required to load PER_CU if we return non-zero.  */
 
 static int
 maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
@@ -7651,7 +7666,7 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu)
       is_dwz = (attr->form == DW_FORM_GNU_ref_alt || cu->per_cu->is_dwz);
       per_cu = dwarf2_find_containing_comp_unit (offset, is_dwz, cu->objfile);
 
-      /* Queue the unit, if needed.  */
+      /* If necessary, add it to the queue and load its DIEs.  */
       if (maybe_queue_comp_unit (cu, per_cu, cu->language))
        load_full_comp_unit (per_cu, cu->language);
 
@@ -18350,9 +18365,8 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type,
   if (maybe_queue_comp_unit (*ref_cu, &sig_type->per_cu, language_minimal))
     read_signatured_type (sig_type);
 
-  gdb_assert (sig_type->per_cu.cu != NULL);
-
   sig_cu = sig_type->per_cu.cu;
+  gdb_assert (sig_cu != NULL);
   gdb_assert (sig_type->type_offset_in_section.sect_off != 0);
   temp_die.offset = sig_type->type_offset_in_section;
   die = htab_find_with_hash (sig_cu->die_hash, &temp_die,
@@ -21263,15 +21277,15 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   htab_t cu_index_htab;
   struct psymtab_cu_index_map *psymtab_cu_index_map;
 
-  if (!objfile->psymtabs || !objfile->psymtabs_addrmap)
-    return;
-
   if (dwarf2_per_objfile->using_index)
     error (_("Cannot use an index to create the index"));
 
   if (VEC_length (dwarf2_section_info_def, dwarf2_per_objfile->types) > 1)
     error (_("Cannot make an index when the file has multiple .debug_types sections"));
 
+  if (!objfile->psymtabs || !objfile->psymtabs_addrmap)
+    return;
+
   if (stat (objfile->name, &st) < 0)
     perror_with_name (objfile->name);
 
This page took 0.030516 seconds and 4 git commands to generate.