associated dwz file, DWZ_OUT_FILE must be NULL. */
static void
-write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
- FILE *dwz_out_file)
+write_gdbindex (dwarf2_per_objfile *per_objfile,
+ cooked_index_vector *table,
+ FILE *out_file, FILE *dwz_out_file)
{
mapped_symtab symtab;
data_buf objfile_cu_list;
++this_counter;
}
- cooked_index_vector *table
- = (static_cast<cooked_index_vector *>
- (per_objfile->per_bfd->index_table.get ()));
write_cooked_index (table, cu_index_htab, &symtab);
/* Dump the address map. */
static void
write_debug_names (dwarf2_per_objfile *per_objfile,
+ cooked_index_vector *table,
FILE *out_file, FILE *out_file_str)
{
const bool dwarf5_is_dwarf64 = check_dwarf64_offsets (per_objfile);
- per_objfile->per_bfd->tu_stats.nr_tus));
gdb_assert (types_counter == per_objfile->per_bfd->tu_stats.nr_tus);
- cooked_index_vector *table
- = (static_cast<cooked_index_vector *>
- (per_objfile->per_bfd->index_table.get ()));
for (const cooked_index_entry *entry : table->all_entries ())
nametable.insert (entry);
{
struct objfile *objfile = per_objfile->objfile;
+ if (per_objfile->per_bfd->index_table == nullptr)
+ error (_("No debugging symbols"));
cooked_index_vector *table
- = (static_cast<cooked_index_vector *>
- (per_objfile->per_bfd->index_table.get ()));
- if (table == nullptr)
- {
- if (per_objfile->per_bfd->index_table != nullptr)
- error (_("Cannot use an index to create the index"));
- error (_("No debugging symbols"));
- }
+ = per_objfile->per_bfd->index_table->index_for_writing ();
if (per_objfile->per_bfd->types.size () > 1)
error (_("Cannot make an index when the file has multiple .debug_types sections"));
{
index_wip_file str_wip_file (dir, basename, DEBUG_STR_SUFFIX);
- write_debug_names (per_objfile, objfile_index_wip.out_file.get (),
+ write_debug_names (per_objfile, table, objfile_index_wip.out_file.get (),
str_wip_file.out_file.get ());
str_wip_file.finalize ();
}
else
- write_gdbindex (per_objfile, objfile_index_wip.out_file.get (),
+ write_gdbindex (per_objfile, table, objfile_index_wip.out_file.get (),
(dwz_index_wip.has_value ()
? dwz_index_wip->out_file.get () : NULL));
/* Base class for mapped indices
- Copyright (C) 2021 Free Software Foundation, Inc.
+ Copyright (C) 2021, 2022 Free Software Foundation, Inc.
This file is part of GDB.
offset_type idx;
};
+class cooked_index_vector;
+
/* Base class of all DWARF scanner types. */
struct dwarf_scanner_base
{
return true;
}
+
+ /* This is called when writing an index. For a cooked index, it
+ will return 'this' as a cooked index. For other forms, it will
+ throw an exception with an appropriate error message. */
+ virtual cooked_index_vector *index_for_writing () = 0;
};
/* Base class containing bits shared by both .gdb_index and
find_name_components_bounds (const lookup_name_info &ln_no_params,
enum language lang,
dwarf2_per_objfile *per_objfile) const;
+
+ cooked_index_vector *index_for_writing () override
+ {
+ error (_("Cannot use an index to create the index"));
+ }
};
#endif /* GDB_DWARF2_MAPPED_INDEX_H */