Use a stamp file for version.c
[deliverable/binutils-gdb.git] / gdb / dwarf-index-write.c
index 3059e0b776a311223b777a9331be91c7f1ba4c2a..d2831461ca3c7911fa95000788c4fa22c138ed2f 100644 (file)
@@ -34,6 +34,7 @@
 #include "psympriv.h"
 
 #include <algorithm>
+#include <cmath>
 #include <set>
 #include <unordered_map>
 #include <unordered_set>
@@ -153,7 +154,7 @@ private:
   gdb_byte *grow (size_t size)
   {
     m_vec.resize (m_vec.size () + size);
-    return &*m_vec.end () - size;
+    return &*(m_vec.end () - size);
   }
 
   gdb::byte_vector m_vec;
@@ -587,12 +588,14 @@ write_one_signatured_type (void **slot, void *d)
 
   write_psymbols (info->symtab,
                  info->psyms_seen,
-                 &info->objfile->global_psymbols[psymtab->globals_offset],
+                 (info->objfile->global_psymbols.data ()
+                  + psymtab->globals_offset),
                  psymtab->n_global_syms, info->cu_index,
                  0);
   write_psymbols (info->symtab,
                  info->psyms_seen,
-                 &info->objfile->static_psymbols[psymtab->statics_offset],
+                 (info->objfile->static_psymbols.data ()
+                  + psymtab->statics_offset),
                  psymtab->n_static_syms, info->cu_index,
                  1);
 
@@ -642,12 +645,12 @@ recursively_write_psymbols (struct objfile *objfile,
 
   write_psymbols (symtab,
                  psyms_seen,
-                 &objfile->global_psymbols[psymtab->globals_offset],
+                 objfile->global_psymbols.data () + psymtab->globals_offset,
                  psymtab->n_global_syms, cu_index,
                  0);
   write_psymbols (symtab,
                  psyms_seen,
-                 &objfile->static_psymbols[psymtab->statics_offset],
+                 objfile->static_psymbols.data () + psymtab->statics_offset,
                  psymtab->n_static_syms, cu_index,
                  1);
 }
@@ -838,10 +841,10 @@ public:
                                    psyms_seen, cu_index);
 
     write_psymbols (psyms_seen,
-                   &objfile->global_psymbols[psymtab->globals_offset],
+                   objfile->global_psymbols.data () + psymtab->globals_offset,
                    psymtab->n_global_syms, cu_index, false, unit_kind::cu);
     write_psymbols (psyms_seen,
-                   &objfile->static_psymbols[psymtab->statics_offset],
+                   objfile->static_psymbols.data () + psymtab->statics_offset,
                    psymtab->n_static_syms, cu_index, true, unit_kind::cu);
   }
 
@@ -930,8 +933,7 @@ private:
            = m_str_table.emplace (c_str_view (s),
                                   data - dwarf2_per_objfile->str.buffer);
          if (!insertpair.second)
-           complaint (&symfile_complaints,
-                      _("Duplicate string \"%s\" in "
+           complaint (_("Duplicate string \"%s\" in "
                         ".debug_str section [in module %s]"),
                       s, bfd_get_filename (m_abfd));
          data += strlen (s) + 1;
@@ -1199,11 +1201,13 @@ private:
     struct partial_symtab *psymtab = entry->per_cu.v.psymtab;
 
     write_psymbols (info->psyms_seen,
-                   &info->objfile->global_psymbols[psymtab->globals_offset],
+                   (info->objfile->global_psymbols.data ()
+                    + psymtab->globals_offset),
                    psymtab->n_global_syms, info->cu_index, false,
                    unit_kind::tu);
     write_psymbols (info->psyms_seen,
-                   &info->objfile->static_psymbols[psymtab->statics_offset],
+                   (info->objfile->static_psymbols.data ()
+                    + psymtab->statics_offset),
                    psymtab->n_static_syms, info->cu_index, true,
                    unit_kind::tu);
 
@@ -1250,17 +1254,14 @@ private:
 static bool
 check_dwarf64_offsets (struct dwarf2_per_objfile *dwarf2_per_objfile)
 {
-  for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
     {
-      const dwarf2_per_cu_data &per_cu = *dwarf2_per_objfile->all_comp_units[i];
-
-      if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32))
+      if (to_underlying (per_cu->sect_off) >= (static_cast<uint64_t> (1) << 32))
        return true;
     }
-  for (int i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
+  for (const signatured_type *sigtype : dwarf2_per_objfile->all_type_units)
     {
-      const signatured_type &sigtype = *dwarf2_per_objfile->all_type_units[i];
-      const dwarf2_per_cu_data &per_cu = sigtype.per_cu;
+      const dwarf2_per_cu_data &per_cu = sigtype->per_cu;
 
       if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32))
        return true;
@@ -1278,10 +1279,8 @@ static size_t
 psyms_seen_size (struct dwarf2_per_objfile *dwarf2_per_objfile)
 {
   size_t psyms_count = 0;
-  for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
     {
-      struct dwarf2_per_cu_data *per_cu
-       = dwarf2_per_objfile->all_comp_units[i];
       struct partial_symtab *psymtab = per_cu->v.psymtab;
 
       if (psymtab != NULL && psymtab->user == NULL)
@@ -1307,7 +1306,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file)
      in the index file).  This will later be needed to write the address
      table.  */
   psym_index_map cu_index_htab;
-  cu_index_htab.reserve (dwarf2_per_objfile->n_comp_units);
+  cu_index_htab.reserve (dwarf2_per_objfile->all_comp_units.size ());
 
   /* 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
@@ -1315,7 +1314,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file)
 
   std::unordered_set<partial_symbol *> psyms_seen
     (psyms_seen_size (dwarf2_per_objfile));
-  for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i)
     {
       struct dwarf2_per_cu_data *per_cu
        = dwarf2_per_objfile->all_comp_units[i];
@@ -1352,7 +1351,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->n_comp_units;
+      sig_data.cu_index = dwarf2_per_objfile->all_comp_units.size ();
       htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
                              write_one_signatured_type, &sig_data);
     }
@@ -1427,7 +1426,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
                         dwarf5_byte_order);
   std::unordered_set<partial_symbol *>
     psyms_seen (psyms_seen_size (dwarf2_per_objfile));
-  for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  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];
       partial_symtab *psymtab = per_cu->v.psymtab;
@@ -1495,11 +1494,13 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
   header.append_uint (2, dwarf5_byte_order, 0);
 
   /* comp_unit_count - The number of CUs in the CU list.  */
-  header.append_uint (4, dwarf5_byte_order, dwarf2_per_objfile->n_comp_units);
+  header.append_uint (4, dwarf5_byte_order,
+                     dwarf2_per_objfile->all_comp_units.size ());
 
   /* local_type_unit_count - The number of TUs in the local TU
      list.  */
-  header.append_uint (4, dwarf5_byte_order, dwarf2_per_objfile->n_type_units);
+  header.append_uint (4, dwarf5_byte_order,
+                     dwarf2_per_objfile->all_type_units.size ());
 
   /* foreign_type_unit_count - The number of TUs in the foreign TU
      list.  */
This page took 0.025491 seconds and 4 git commands to generate.