26#include "gdb/gdb-index.h"
27#include "gdbsupport/gdb-checked-static-cast.h"
116 return (
const char *) (this->constant_pool.data ()
121 {
return this->symbol_table.
size () / 2; }
148 gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
150 gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
151 gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
152 block_search_flags search_flags,
203 gdb::optional<block_enum> block_index,
233 offset_type cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
234 gdb_index_symbol_kind symbol_kind =
235 GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
240 int attrs_valid = (
index.version >= 7
241 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
246 complaint (_(
".gdb_index entry has bad CU index"
260 bool is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
266 if (is_static != want_static)
272 && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE)
287 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE
288 && symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION
290 && symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
294 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
298 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER)
302 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER)
330 = *(gdb::checked_static_cast<mapped_gdb_index *>
333 const char *match_name =
name.ada ().lookup_name ().c_str ();
334 auto matcher = [&] (
const char *symname)
336 if (ordered_compare ==
nullptr)
338 return ordered_compare (symname, match_name) == 0;
363 gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
364 gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
365 block_search_flags search_flags,
369 bool global_seen =
false;
371 = *(gdb::checked_static_cast<mapped_gdb_index *>
376 for (vec_idx = 0; vec_idx < vec_len; ++vec_idx)
380 int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
381 gdb_index_symbol_kind symbol_kind =
382 GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
383 int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
390 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
395 && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE)
420 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE)
424 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION)
428 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
432 if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER)
443 complaint (_(
".gdb_index entry has bad CU index"
460 gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
462 gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
463 gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
464 block_search_flags search_flags,
473 gdb_assert (lookup_name !=
nullptr || symbol_matcher ==
nullptr);
474 if (lookup_name ==
nullptr)
490 = *(gdb::checked_static_cast<mapped_gdb_index *>
499 expansion_notify, search_flags, kind))
527 gdb::array_view<const gdb_byte> buffer,
529 const gdb_byte **cu_list,
531 const gdb_byte **types_list,
534 const gdb_byte *addr = &buffer[0];
545 static int warning_printed = 0;
546 if (!warning_printed)
548 warning (_(
"Skipping obsolete .gdb_index section in %s."),
562 if (
version < 6 && !deprecated_ok)
564 static int warning_printed = 0;
565 if (!warning_printed)
568Skipping deprecated .gdb_index section in %s.\n\
569Do \"set use-deprecated-index-sections on\" before the file is read\n\
570to use the section anyway."),
592 *cu_list = addr + metadata[i];
593 *cu_list_elements = (metadata[i + 1] - metadata[i]) / 8;
596 *types_list = addr + metadata[i];
597 *types_list_elements = (metadata[i + 1] - metadata[i]) / 8;
600 const gdb_byte *address_table = addr + metadata[i];
601 const gdb_byte *address_table_end = addr + metadata[i + 1];
603 = gdb::array_view<const gdb_byte> (address_table, address_table_end);
606 const gdb_byte *symbol_table = addr + metadata[i];
607 const gdb_byte *symbol_table_end = addr + metadata[i + 1];
609 =
offset_view (gdb::array_view<const gdb_byte> (symbol_table,
620 =
offset_view (gdb::array_view<const gdb_byte> (symbol_table,
657 const gdb_byte *cu_list,
offset_type cu_list_elements,
658 const gdb_byte *dwz_list,
offset_type dwz_elements)
666 if (dwz_elements == 0)
688 cu_offset type_offset_in_tu;
700 sig_type->type_offset_in_tu = type_offset_in_tu;
704 slot = htab_find_slot (sig_types_hash.get (), sig_type.get (), INSERT);
705 *slot = sig_type.get ();
721 const gdb_byte *iter, *end;
725 iter =
index->address_table.data ();
726 end = iter +
index->address_table.size ();
730 ULONGEST hi, lo, cu_index;
740 complaint (_(
".gdb_index address table has invalid range (%s - %s)"),
741 hex_string (lo), hex_string (hi));
747 complaint (_(
".gdb_index address table has invalid CU number %u"),
748 (
unsigned) cu_index);
752 lo = (ULONGEST) per_objfile->
adjust ((unrelocated_addr) lo);
753 hi = (ULONGEST) per_objfile->
adjust ((unrelocated_addr) hi);
769 const gdb_byte *cu_list, *types_list, *dwz_list = NULL;
770 offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
775 gdb::array_view<const gdb_byte> main_index_contents
778 if (main_index_contents.empty ())
781 auto map = gdb::make_unique<mapped_gdb_index> ();
784 main_index_contents, map.get (), &cu_list,
785 &cu_list_elements, &types_list,
786 &types_list_elements))
790 if (map->symbol_table.empty ())
799 const gdb_byte *dwz_types_ignore;
802 gdb::array_view<const gdb_byte> dwz_index_content
803 = get_gdb_index_contents_dwz (
objfile, dwz);
805 if (dwz_index_content.empty ())
809 1, dwz_index_content, &dwz_map,
810 &dwz_list, &dwz_list_elements,
812 &dwz_types_elements_ignore))
814 warning (_(
"could not read '.gdb_index' section from %s; skipping"),
815 bfd_get_filename (dwz->
dwz_bfd.get ()));
823 if (types_list_elements)
827 if (
per_bfd->types.size () > 1)
839 types_list_elements);
846 per_bfd->index_table = std::move (map);
847 per_bfd->quick_file_names_table =
860Set whether to use deprecated gdb_index sections."), _(
"\
861Show whether to use deprecated gdb_index sections."), _(
"\
862When enabled, deprecated .gdb_index sections are used anyway.\n\
863Normally they are ignored either because of a missing feature or\n\
865Warning: This option must be enabled before gdb reads the file."),
gdb_static_assert(sizeof(splay_tree_key) >=sizeof(CORE_ADDR *))
offset_type operator[](size_t index) const
offset_view(gdb::array_view< const gdb_byte > bytes)
gdb::array_view< const gdb_byte > m_bytes
struct cmd_list_element * showlist
struct cmd_list_element * setlist
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
#define complaint(FMT,...)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
struct dwz_file * dwarf2_get_dwz_file(dwarf2_per_bfd *per_bfd, bool require)
const char * objfile_name(const struct objfile *objfile)
int symbol_compare_ftype(const char *string1, const char *string2)
std::unique_ptr< quick_symbol_functions > quick_symbol_functions_up
static void dw2_symtab_iter_init(struct dw2_symtab_iterator *iter, dwarf2_per_objfile *per_objfile, gdb::optional< block_enum > block_index, domain_enum domain, offset_type namei, mapped_gdb_index &index)
void _initialize_read_gdb_index()
static bool dw2_expand_marked_cus(dwarf2_per_objfile *per_objfile, offset_type idx, gdb::function_view< expand_symtabs_file_matcher_ftype > file_matcher, gdb::function_view< expand_symtabs_exp_notify_ftype > expansion_notify, block_search_flags search_flags, search_domain kind)
static void create_cus_from_gdb_index(dwarf2_per_bfd *per_bfd, const gdb_byte *cu_list, offset_type cu_list_elements, const gdb_byte *dwz_list, offset_type dwz_elements)
int dwarf2_read_gdb_index(dwarf2_per_objfile *per_objfile, get_gdb_index_contents_ftype get_gdb_index_contents, get_gdb_index_contents_dwz_ftype get_gdb_index_contents_dwz)
static struct dwarf2_per_cu_data * dw2_symtab_iter_next(struct dw2_symtab_iterator *iter, mapped_gdb_index &index)
static void create_cus_from_gdb_index_list(dwarf2_per_bfd *per_bfd, const gdb_byte *cu_list, offset_type n_elements, struct dwarf2_section_info *section, int is_dwz)
static void create_addrmap_from_gdb_index(dwarf2_per_objfile *per_objfile, mapped_gdb_index *index)
static bool read_gdb_index_from_buffer(const char *filename, bool deprecated_ok, gdb::array_view< const gdb_byte > buffer, mapped_gdb_index *map, const gdb_byte **cu_list, offset_type *cu_list_elements, const gdb_byte **types_list, offset_type *types_list_elements)
static bool use_deprecated_index_sections
static void create_signatured_type_table_from_gdb_index(dwarf2_per_bfd *per_bfd, struct dwarf2_section_info *section, const gdb_byte *bytes, offset_type elements)
gdb::function_view< gdb::array_view< const gdb_byte >(objfile *, dwz_file *) get_gdb_index_contents_dwz_ftype)
gdb::function_view< gdb::array_view< const gdb_byte >(objfile *, dwarf2_per_bfd *) get_gdb_index_contents_ftype)
htab_up create_quick_file_names_table(unsigned int nr_initial_entries)
bool dw2_expand_symtabs_matching_symbol(mapped_index_base &index, const lookup_name_info &lookup_name_in, gdb::function_view< expand_symtabs_symbol_matcher_ftype > symbol_matcher, gdb::function_view< bool(offset_type)> match_callback, dwarf2_per_objfile *per_objfile)
dwarf2_per_cu_data_up create_cu_from_index_list(dwarf2_per_bfd *per_bfd, struct dwarf2_section_info *section, int is_dwz, sect_offset sect_off, ULONGEST length)
void finalize_all_units(dwarf2_per_bfd *per_bfd)
void dw_expand_symtabs_matching_file_matcher(dwarf2_per_objfile *per_objfile, gdb::function_view< expand_symtabs_file_matcher_ftype > file_matcher)
bool dw2_expand_symtabs_matching_one(dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, gdb::function_view< expand_symtabs_file_matcher_ftype > file_matcher, gdb::function_view< expand_symtabs_exp_notify_ftype > expansion_notify)
htab_up allocate_signatured_type_table()
dwarf2_per_objfile * get_dwarf2_per_objfile(struct objfile *objfile)
std::unique_ptr< signatured_type > signatured_type_up
std::unique_ptr< dwarf2_per_cu_data, dwarf2_per_cu_data_deleter > dwarf2_per_cu_data_up
void set_empty(CORE_ADDR start, CORE_ADDR end_inclusive, void *obj) override
gdb::optional< block_enum > block_index
dwarf2_per_objfile * per_objfile
bool expand_symtabs_matching(struct objfile *objfile, gdb::function_view< expand_symtabs_file_matcher_ftype > file_matcher, const lookup_name_info *lookup_name, gdb::function_view< expand_symtabs_symbol_matcher_ftype > symbol_matcher, gdb::function_view< expand_symtabs_exp_notify_ftype > expansion_notify, block_search_flags search_flags, domain_enum domain, enum search_domain kind) override
void expand_matching_symbols(struct objfile *, const lookup_name_info &lookup_name, domain_enum domain, int global, symbol_compare_ftype *ordered_compare) override
void dump(struct objfile *objfile) override
struct addrmap * index_addrmap
dwarf2_per_cu_data * get_cu(int index) const
std::unique_ptr< dwarf_scanner_base > index_table
signatured_type_up allocate_signatured_type(ULONGEST signature)
std::vector< dwarf2_per_cu_data_up > all_units
struct dwarf2_section_info * section
unsigned int length() const
unrelocated_addr adjust(unrelocated_addr addr)
struct dwarf2_per_bfd * per_bfd
bool symtab_set_p(const dwarf2_per_cu_data *per_cu) const
bool symbol_name_slot_invalid(offset_type idx) const override
gdb::array_view< const gdb_byte > address_table
quick_symbol_functions_up make_quick_functions() const override
offset_type symbol_vec_index(offset_type idx) const
gdb::array_view< const gdb_byte > constant_pool
const char * symbol_name_at(offset_type idx, dwarf2_per_objfile *per_objfile) const override
bool version_check() const override
size_t symbol_name_count() const override
offset_type symbol_name_index(offset_type idx) const
struct objfile_per_bfd_storage * per_bfd
void gdb_printf(struct ui_file *stream, const char *format,...)