mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-15 05:01:13 +08:00
Refactor: Move some generic code out of .gdb_index code
Preparation for the next patch. gdb/ChangeLog 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (create_cu_from_index_list): New from ... (create_cus_from_index_list): ... this function, use it. (dw_expand_symtabs_matching_file_matcher) (dw2_expand_symtabs_matching_one): New from ... (dw2_expand_symtabs_matching): ... this function, use them.
This commit is contained in:

committed by
Pedro Alves

parent
abccd1e7b7
commit
4b514bc808
@ -1,3 +1,11 @@
|
|||||||
|
2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* dwarf2read.c (create_cu_from_index_list): New from ...
|
||||||
|
(create_cus_from_index_list): ... this function, use it.
|
||||||
|
(dw_expand_symtabs_matching_file_matcher)
|
||||||
|
(dw2_expand_symtabs_matching_one): New from ...
|
||||||
|
(dw2_expand_symtabs_matching): ... this function, use them.
|
||||||
|
|
||||||
2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
* defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index): Move here
|
* defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index): Move here
|
||||||
|
122
gdb/dwarf2read.c
122
gdb/dwarf2read.c
@ -3061,6 +3061,29 @@ dw2_get_cu (int index)
|
|||||||
return dwarf2_per_objfile->all_comp_units[index];
|
return dwarf2_per_objfile->all_comp_units[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return a new dwarf2_per_cu_data allocated on OBJFILE's
|
||||||
|
objfile_obstack, and constructed with the specified field
|
||||||
|
values. */
|
||||||
|
|
||||||
|
static dwarf2_per_cu_data *
|
||||||
|
create_cu_from_index_list (struct objfile *objfile,
|
||||||
|
struct dwarf2_section_info *section,
|
||||||
|
int is_dwz,
|
||||||
|
sect_offset sect_off, ULONGEST length)
|
||||||
|
{
|
||||||
|
dwarf2_per_cu_data *the_cu
|
||||||
|
= OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
||||||
|
struct dwarf2_per_cu_data);
|
||||||
|
the_cu->sect_off = sect_off;
|
||||||
|
the_cu->length = length;
|
||||||
|
the_cu->objfile = objfile;
|
||||||
|
the_cu->section = section;
|
||||||
|
the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
||||||
|
struct dwarf2_per_cu_quick_data);
|
||||||
|
the_cu->is_dwz = is_dwz;
|
||||||
|
return the_cu;
|
||||||
|
}
|
||||||
|
|
||||||
/* A helper for create_cus_from_index that handles a given list of
|
/* A helper for create_cus_from_index that handles a given list of
|
||||||
CUs. */
|
CUs. */
|
||||||
|
|
||||||
@ -3082,17 +3105,8 @@ create_cus_from_index_list (struct objfile *objfile,
|
|||||||
ULONGEST length = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE);
|
ULONGEST length = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE);
|
||||||
cu_list += 2 * 8;
|
cu_list += 2 * 8;
|
||||||
|
|
||||||
dwarf2_per_cu_data *the_cu
|
dwarf2_per_objfile->all_comp_units[base_offset + i / 2]
|
||||||
= OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
= create_cu_from_index_list (objfile, section, is_dwz, sect_off, length);
|
||||||
struct dwarf2_per_cu_data);
|
|
||||||
the_cu->sect_off = sect_off;
|
|
||||||
the_cu->length = length;
|
|
||||||
the_cu->objfile = objfile;
|
|
||||||
the_cu->section = section;
|
|
||||||
the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
|
||||||
struct dwarf2_per_cu_quick_data);
|
|
||||||
the_cu->is_dwz = is_dwz;
|
|
||||||
dwarf2_per_objfile->all_comp_units[base_offset + i / 2] = the_cu;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4939,6 +4953,31 @@ run_test ()
|
|||||||
|
|
||||||
#endif /* GDB_SELF_TEST */
|
#endif /* GDB_SELF_TEST */
|
||||||
|
|
||||||
|
/* If FILE_MATCHER is NULL or if PER_CU has
|
||||||
|
dwarf2_per_cu_quick_data::MARK set (see
|
||||||
|
dw_expand_symtabs_matching_file_matcher), expand the CU and call
|
||||||
|
EXPANSION_NOTIFY on it. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
dw2_expand_symtabs_matching_one
|
||||||
|
(struct dwarf2_per_cu_data *per_cu,
|
||||||
|
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
|
||||||
|
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify)
|
||||||
|
{
|
||||||
|
if (file_matcher == NULL || per_cu->v.quick->mark)
|
||||||
|
{
|
||||||
|
bool symtab_was_null
|
||||||
|
= (per_cu->v.quick->compunit_symtab == NULL);
|
||||||
|
|
||||||
|
dw2_instantiate_symtab (per_cu);
|
||||||
|
|
||||||
|
if (expansion_notify != NULL
|
||||||
|
&& symtab_was_null
|
||||||
|
&& per_cu->v.quick->compunit_symtab != NULL)
|
||||||
|
expansion_notify (per_cu->v.quick->compunit_symtab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Helper for dw2_expand_matching symtabs. Called on each symbol
|
/* Helper for dw2_expand_matching symtabs. Called on each symbol
|
||||||
matched, to expand corresponding CUs that were marked. IDX is the
|
matched, to expand corresponding CUs that were marked. IDX is the
|
||||||
index of the symbol name that matched. */
|
index of the symbol name that matched. */
|
||||||
@ -5016,40 +5055,24 @@ dw2_expand_marked_cus
|
|||||||
}
|
}
|
||||||
|
|
||||||
per_cu = dw2_get_cutu (cu_index);
|
per_cu = dw2_get_cutu (cu_index);
|
||||||
if (file_matcher == NULL || per_cu->v.quick->mark)
|
dw2_expand_symtabs_matching_one (per_cu, file_matcher,
|
||||||
{
|
expansion_notify);
|
||||||
int symtab_was_null =
|
}
|
||||||
(per_cu->v.quick->compunit_symtab == NULL);
|
}
|
||||||
|
|
||||||
dw2_instantiate_symtab (per_cu);
|
/* If FILE_MATCHER is non-NULL, set all the
|
||||||
|
dwarf2_per_cu_quick_data::MARK of the current DWARF2_PER_OBJFILE
|
||||||
if (expansion_notify != NULL
|
that match FILE_MATCHER. */
|
||||||
&& symtab_was_null
|
|
||||||
&& per_cu->v.quick->compunit_symtab != NULL)
|
|
||||||
expansion_notify (per_cu->v.quick->compunit_symtab);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dw2_expand_symtabs_matching
|
dw_expand_symtabs_matching_file_matcher
|
||||||
(struct objfile *objfile,
|
(gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher)
|
||||||
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,
|
|
||||||
enum search_domain kind)
|
|
||||||
{
|
{
|
||||||
int i;
|
if (file_matcher == NULL)
|
||||||
|
|
||||||
dw2_setup (objfile);
|
|
||||||
|
|
||||||
/* index_table is NULL if OBJF_READNOW. */
|
|
||||||
if (!dwarf2_per_objfile->index_table)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (file_matcher != NULL)
|
objfile *const objfile = dwarf2_per_objfile->objfile;
|
||||||
{
|
|
||||||
htab_up visited_found (htab_create_alloc (10, htab_hash_pointer,
|
htab_up visited_found (htab_create_alloc (10, htab_hash_pointer,
|
||||||
htab_eq_pointer,
|
htab_eq_pointer,
|
||||||
NULL, xcalloc, xfree));
|
NULL, xcalloc, xfree));
|
||||||
@ -5060,7 +5083,7 @@ dw2_expand_symtabs_matching
|
|||||||
/* The rule is CUs specify all the files, including those used by
|
/* The rule is CUs specify all the files, including those used by
|
||||||
any TU, so there's no need to scan TUs here. */
|
any TU, so there's no need to scan TUs here. */
|
||||||
|
|
||||||
for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
|
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
|
struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
|
||||||
@ -5120,6 +5143,25 @@ dw2_expand_symtabs_matching
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dw2_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,
|
||||||
|
enum search_domain kind)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
dw2_setup (objfile);
|
||||||
|
|
||||||
|
/* index_table is NULL if OBJF_READNOW. */
|
||||||
|
if (!dwarf2_per_objfile->index_table)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dw_expand_symtabs_matching_file_matcher (file_matcher);
|
||||||
|
|
||||||
mapped_index &index = *dwarf2_per_objfile->index_table;
|
mapped_index &index = *dwarf2_per_objfile->index_table;
|
||||||
|
|
||||||
dw2_expand_symtabs_matching_symbol (index, lookup_name,
|
dw2_expand_symtabs_matching_symbol (index, lookup_name,
|
||||||
|
Reference in New Issue
Block a user