Move the rust "{" hack
[deliverable/binutils-gdb.git] / gdb / dwarf2 / index-write.c
index 3c9ccbba46d30094f63e5ee268306bb7c2ed2526..fc42816b1e7c517ef93649a949fb74f000d53acb 100644 (file)
@@ -32,6 +32,7 @@
 #include "dwarf2/index-common.h"
 #include "dwarf2.h"
 #include "dwarf2/read.h"
+#include "dwarf2/dwz.h"
 #include "gdb/gdb-index.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
@@ -399,7 +400,7 @@ write_hash_table (mapped_symtab *symtab, data_buf &output, data_buf &cpool)
     }
 }
 
-typedef std::unordered_map<dwarf2_psymtab *, unsigned int> psym_index_map;
+typedef std::unordered_map<partial_symtab *, unsigned int> psym_index_map;
 
 /* Helper struct for building the address table.  */
 struct addrmap_index_data
@@ -439,7 +440,7 @@ static int
 add_address_entry_worker (void *datap, CORE_ADDR start_addr, void *obj)
 {
   struct addrmap_index_data *data = (struct addrmap_index_data *) datap;
-  dwarf2_psymtab *pst = (dwarf2_psymtab *) obj;
+  partial_symtab *pst = (partial_symtab *) obj;
 
   if (data->previous_valid)
     add_address_entry (data->objfile, data->addr_vec,
@@ -582,7 +583,7 @@ write_one_signatured_type (void **slot, void *d)
   struct signatured_type_index_data *info
     = (struct signatured_type_index_data *) d;
   struct signatured_type *entry = (struct signatured_type *) *slot;
-  dwarf2_psymtab *psymtab = entry->per_cu.v.psymtab;
+  partial_symtab *psymtab = entry->per_cu.v.psymtab;
 
   write_psymbols (info->symtab,
                  info->psyms_seen,
@@ -612,12 +613,12 @@ write_one_signatured_type (void **slot, void *d)
    if they appeared in this psymtab.  */
 
 static void
-recursively_count_psymbols (dwarf2_psymtab *psymtab,
+recursively_count_psymbols (partial_symtab *psymtab,
                            size_t &psyms_seen)
 {
   for (int i = 0; i < psymtab->number_of_dependencies; ++i)
     if (psymtab->dependencies[i]->user != NULL)
-      recursively_count_psymbols ((dwarf2_psymtab *) psymtab->dependencies[i],
+      recursively_count_psymbols (psymtab->dependencies[i],
                                  psyms_seen);
 
   psyms_seen += psymtab->n_global_syms;
@@ -629,7 +630,7 @@ recursively_count_psymbols (dwarf2_psymtab *psymtab,
 
 static void
 recursively_write_psymbols (struct objfile *objfile,
-                           dwarf2_psymtab *psymtab,
+                           partial_symtab *psymtab,
                            struct mapped_symtab *symtab,
                            std::unordered_set<partial_symbol *> &psyms_seen,
                            offset_type cu_index)
@@ -639,7 +640,7 @@ recursively_write_psymbols (struct objfile *objfile,
   for (i = 0; i < psymtab->number_of_dependencies; ++i)
     if (psymtab->dependencies[i]->user != NULL)
       recursively_write_psymbols (objfile,
-                                 (dwarf2_psymtab *) psymtab->dependencies[i],
+                                 psymtab->dependencies[i],
                                  symtab, psyms_seen, cu_index);
 
   write_psymbols (symtab,
@@ -869,14 +870,14 @@ public:
      as if they appeared in this psymtab.  */
   void recursively_write_psymbols
     (struct objfile *objfile,
-     dwarf2_psymtab *psymtab,
+     partial_symtab *psymtab,
      std::unordered_set<partial_symbol *> &psyms_seen,
      int cu_index)
   {
     for (int i = 0; i < psymtab->number_of_dependencies; ++i)
       if (psymtab->dependencies[i]->user != NULL)
        recursively_write_psymbols
-         (objfile, (dwarf2_psymtab *) psymtab->dependencies[i], psyms_seen, cu_index);
+         (objfile, psymtab->dependencies[i], psyms_seen, cu_index);
 
     write_psymbols (psyms_seen,
                    (objfile->partial_symtabs->global_psymbols.data ()
@@ -1234,7 +1235,7 @@ private:
   write_one_signatured_type (struct signatured_type *entry,
                             struct signatured_type_index_data *info)
   {
-    dwarf2_psymtab *psymtab = entry->per_cu.v.psymtab;
+    partial_symtab *psymtab = entry->per_cu.v.psymtab;
 
     write_psymbols (info->psyms_seen,
                    (info->objfile->partial_symtabs->global_psymbols.data ()
@@ -1320,7 +1321,7 @@ psyms_seen_size (struct dwarf2_per_objfile *dwarf2_per_objfile)
   size_t psyms_count = 0;
   for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
     {
-      dwarf2_psymtab *psymtab = per_cu->v.psymtab;
+      partial_symtab *psymtab = per_cu->v.psymtab;
 
       if (psymtab != NULL && psymtab->user == NULL)
        recursively_count_psymbols (psymtab, psyms_count);
@@ -1423,20 +1424,17 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
     {
       struct dwarf2_per_cu_data *per_cu
        = dwarf2_per_objfile->all_comp_units[i];
-      dwarf2_psymtab *psymtab = per_cu->v.psymtab;
+      partial_symtab *psymtab = per_cu->v.psymtab;
 
-      /* CU of a shared file from 'dwz -m' may be unused by this main file.
-        It may be referenced from a local scope but in such case it does not
-        need to be present in .gdb_index.  */
-      if (psymtab == NULL)
-       continue;
-
-      if (psymtab->user == NULL)
-       recursively_write_psymbols (objfile, psymtab, &symtab,
-                                   psyms_seen, i);
+      if (psymtab != NULL)
+       {
+         if (psymtab->user == NULL)
+           recursively_write_psymbols (objfile, psymtab, &symtab,
+                                       psyms_seen, i);
 
-      const auto insertpair = cu_index_htab.emplace (psymtab, i);
-      gdb_assert (insertpair.second);
+         const auto insertpair = cu_index_htab.emplace (psymtab, i);
+         gdb_assert (insertpair.second);
+       }
 
       /* The all_comp_units list contains CUs read from the objfile as well as
         from the eventual dwz file.  We need to place the entry in the
@@ -1461,7 +1459,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
       sig_data.objfile = objfile;
       sig_data.symtab = &symtab;
       sig_data.cu_index = dwarf2_per_objfile->all_comp_units.size ();
-      htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
+      htab_traverse_noresize (dwarf2_per_objfile->signatured_types.get (),
                              write_one_signatured_type, &sig_data);
     }
 
@@ -1495,7 +1493,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
   const bool dwarf5_is_dwarf64 = check_dwarf64_offsets (dwarf2_per_objfile);
   struct objfile *objfile = dwarf2_per_objfile->objfile;
   const enum bfd_endian dwarf5_byte_order
-    = gdbarch_byte_order (get_objfile_arch (objfile));
+    = gdbarch_byte_order (objfile->arch ());
 
   /* The CU list is already sorted, so we don't need to do additional
      work here.  Also, the debug_types entries do not appear in
@@ -1508,7 +1506,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
   for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i)
     {
       const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i];
-      dwarf2_psymtab *psymtab = per_cu->v.psymtab;
+      partial_symtab *psymtab = per_cu->v.psymtab;
 
       /* CU of a shared file from 'dwz -m' may be unused by this main
         file.  It may be referenced from a local scope but in such
@@ -1534,7 +1532,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
       /* It is used only for gdb_index.  */
       sig_data.info.symtab = nullptr;
       sig_data.info.cu_index = 0;
-      htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
+      htab_traverse_noresize (dwarf2_per_objfile->signatured_types.get (),
                              debug_names::write_one_signatured_type,
                              &sig_data);
     }
This page took 0.025611 seconds and 4 git commands to generate.