Simplify the public DWARF API
dwarf2_has_info and dwarf2_initialize_objfile are only separate because the DWARF reader implemented lazy psymtab reading. However, now that this is gone, we can simplify the public DWARF API again.
This commit is contained in:
parent
33c6eaaefc
commit
aecbdf5f34
6 changed files with 43 additions and 50 deletions
|
@ -716,10 +716,10 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||||
*info->stabsects,
|
*info->stabsects,
|
||||||
info->stabstrsect->filepos, stabstrsize);
|
info->stabstrsect->filepos, stabstrsize);
|
||||||
}
|
}
|
||||||
if (dwarf2_has_info (objfile, NULL))
|
|
||||||
|
if (dwarf2_initialize_objfile (objfile))
|
||||||
{
|
{
|
||||||
/* DWARF2 sections. */
|
/* Nothing. */
|
||||||
dwarf2_initialize_objfile (objfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to add separate debug file if no symbols table found. */
|
/* Try to add separate debug file if no symbols table found. */
|
||||||
|
|
|
@ -20,10 +20,6 @@
|
||||||
#ifndef DWARF2_PUBLIC_H
|
#ifndef DWARF2_PUBLIC_H
|
||||||
#define DWARF2_PUBLIC_H
|
#define DWARF2_PUBLIC_H
|
||||||
|
|
||||||
extern bool dwarf2_has_info (struct objfile *,
|
|
||||||
const struct dwarf2_debug_sections *,
|
|
||||||
bool = false);
|
|
||||||
|
|
||||||
/* A DWARF names index variant. */
|
/* A DWARF names index variant. */
|
||||||
enum class dw_index_kind
|
enum class dw_index_kind
|
||||||
{
|
{
|
||||||
|
@ -34,9 +30,17 @@ enum class dw_index_kind
|
||||||
DEBUG_NAMES,
|
DEBUG_NAMES,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Initialize for reading DWARF for OBJFILE, and push the appropriate
|
/* Try to locate the sections we need for DWARF 2 debugging
|
||||||
entry on the objfile's "qf" list. */
|
information. If these are found, begin reading the DWARF and
|
||||||
extern void dwarf2_initialize_objfile (struct objfile *objfile);
|
return true. Otherwise, return false. NAMES points to the dwarf2
|
||||||
|
section names, or is NULL if the standard ELF names are used.
|
||||||
|
CAN_COPY is true for formats where symbol interposition is possible
|
||||||
|
and so symbol values must follow copy relocation rules. */
|
||||||
|
|
||||||
|
extern bool dwarf2_initialize_objfile
|
||||||
|
(struct objfile *,
|
||||||
|
const struct dwarf2_debug_sections * = nullptr,
|
||||||
|
bool = false);
|
||||||
|
|
||||||
extern void dwarf2_build_frame_info (struct objfile *);
|
extern void dwarf2_build_frame_info (struct objfile *);
|
||||||
|
|
||||||
|
|
|
@ -1354,14 +1354,10 @@ dwarf2_per_objfile::set_symtab (const dwarf2_per_cu_data *per_cu,
|
||||||
this->m_symtabs[per_cu->index] = symtab;
|
this->m_symtabs[per_cu->index] = symtab;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to locate the sections we need for DWARF 2 debugging
|
/* Helper function for dwarf2_initialize_objfile that creates the
|
||||||
information and return true if we have enough to do something.
|
per-BFD object. */
|
||||||
NAMES points to the dwarf2 section names, or is NULL if the standard
|
|
||||||
ELF names are used. CAN_COPY is true for formats where symbol
|
|
||||||
interposition is possible and so symbol values must follow copy
|
|
||||||
relocation rules. */
|
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
dwarf2_has_info (struct objfile *objfile,
|
dwarf2_has_info (struct objfile *objfile,
|
||||||
const struct dwarf2_debug_sections *names,
|
const struct dwarf2_debug_sections *names,
|
||||||
bool can_copy)
|
bool can_copy)
|
||||||
|
@ -3199,9 +3195,14 @@ static quick_symbol_functions_up make_cooked_index_funcs
|
||||||
|
|
||||||
/* See dwarf2/public.h. */
|
/* See dwarf2/public.h. */
|
||||||
|
|
||||||
void
|
bool
|
||||||
dwarf2_initialize_objfile (struct objfile *objfile)
|
dwarf2_initialize_objfile (struct objfile *objfile,
|
||||||
|
const struct dwarf2_debug_sections *names,
|
||||||
|
bool can_copy)
|
||||||
{
|
{
|
||||||
|
if (!dwarf2_has_info (objfile, names, can_copy))
|
||||||
|
return false;
|
||||||
|
|
||||||
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
|
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
|
||||||
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
|
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
|
||||||
|
|
||||||
|
@ -3231,48 +3232,42 @@ dwarf2_initialize_objfile (struct objfile *objfile)
|
||||||
= create_quick_file_names_table (per_bfd->all_units.size ());
|
= create_quick_file_names_table (per_bfd->all_units.size ());
|
||||||
|
|
||||||
objfile->qf.emplace_front (new readnow_functions);
|
objfile->qf.emplace_front (new readnow_functions);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Was a GDB index already read when we processed an objfile sharing
|
/* Was a GDB index already read when we processed an objfile sharing
|
||||||
PER_BFD? */
|
PER_BFD? */
|
||||||
if (per_bfd->index_table != nullptr)
|
else if (per_bfd->index_table != nullptr)
|
||||||
{
|
{
|
||||||
dwarf_read_debug_printf ("re-using symbols");
|
dwarf_read_debug_printf ("re-using symbols");
|
||||||
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
|
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (dwarf2_read_debug_names (per_objfile))
|
||||||
if (dwarf2_read_debug_names (per_objfile))
|
|
||||||
{
|
{
|
||||||
dwarf_read_debug_printf ("found debug names");
|
dwarf_read_debug_printf ("found debug names");
|
||||||
objfile->qf.push_front
|
objfile->qf.push_front
|
||||||
(per_bfd->index_table->make_quick_functions ());
|
(per_bfd->index_table->make_quick_functions ());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (dwarf2_read_gdb_index (per_objfile,
|
||||||
if (dwarf2_read_gdb_index (per_objfile,
|
get_gdb_index_contents_from_section<struct dwarf2_per_bfd>,
|
||||||
get_gdb_index_contents_from_section<struct dwarf2_per_bfd>,
|
get_gdb_index_contents_from_section<dwz_file>))
|
||||||
get_gdb_index_contents_from_section<dwz_file>))
|
|
||||||
{
|
{
|
||||||
dwarf_read_debug_printf ("found gdb index from file");
|
dwarf_read_debug_printf ("found gdb index from file");
|
||||||
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
|
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ... otherwise, try to find the index in the index cache. */
|
/* ... otherwise, try to find the index in the index cache. */
|
||||||
if (dwarf2_read_gdb_index (per_objfile,
|
else if (dwarf2_read_gdb_index (per_objfile,
|
||||||
get_gdb_index_contents_from_cache,
|
get_gdb_index_contents_from_cache,
|
||||||
get_gdb_index_contents_from_cache_dwz))
|
get_gdb_index_contents_from_cache_dwz))
|
||||||
{
|
{
|
||||||
dwarf_read_debug_printf ("found gdb index from cache");
|
dwarf_read_debug_printf ("found gdb index from cache");
|
||||||
global_index_cache.hit ();
|
global_index_cache.hit ();
|
||||||
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
|
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
global_index_cache.miss ();
|
{
|
||||||
objfile->qf.push_front (make_cooked_index_funcs (per_objfile));
|
global_index_cache.miss ();
|
||||||
|
objfile->qf.push_front (make_cooked_index_funcs (per_objfile));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1198,8 +1198,10 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
|
||||||
{
|
{
|
||||||
bool has_dwarf2 = true;
|
bool has_dwarf2 = true;
|
||||||
|
|
||||||
if (dwarf2_has_info (objfile, NULL, true))
|
if (dwarf2_initialize_objfile (objfile, nullptr, true))
|
||||||
dwarf2_initialize_objfile (objfile);
|
{
|
||||||
|
/* Nothing. */
|
||||||
|
}
|
||||||
/* If the file has its own symbol tables it has no separate debug
|
/* If the file has its own symbol tables it has no separate debug
|
||||||
info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to
|
info. `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to
|
||||||
SYMTABS/PSYMTABS. `.gnu_debuglink' may no longer be present with
|
SYMTABS/PSYMTABS. `.gnu_debuglink' may no longer be present with
|
||||||
|
|
|
@ -785,6 +785,8 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||||
macho_symfile_read_all_oso at the end of this function. */
|
macho_symfile_read_all_oso at the end of this function. */
|
||||||
gdb::def_vector<asymbol *> symbol_table;
|
gdb::def_vector<asymbol *> symbol_table;
|
||||||
|
|
||||||
|
dwarf2_initialize_objfile (objfile);
|
||||||
|
|
||||||
/* Get symbols from the symbol table only if the file is an executable.
|
/* Get symbols from the symbol table only if the file is an executable.
|
||||||
The symbol table of object files is not relocated and is expected to
|
The symbol table of object files is not relocated and is expected to
|
||||||
be in the executable. */
|
be in the executable. */
|
||||||
|
@ -822,9 +824,6 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to read .eh_frame / .debug_frame. */
|
/* Try to read .eh_frame / .debug_frame. */
|
||||||
/* First, locate these sections. We ignore the result status
|
|
||||||
as it only checks for debug info. */
|
|
||||||
dwarf2_has_info (objfile, NULL);
|
|
||||||
dwarf2_build_frame_info (objfile);
|
dwarf2_build_frame_info (objfile);
|
||||||
|
|
||||||
/* Check for DSYM file. */
|
/* Check for DSYM file. */
|
||||||
|
@ -854,12 +853,6 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dwarf2_has_info (objfile, NULL))
|
|
||||||
{
|
|
||||||
/* DWARF 2 sections */
|
|
||||||
dwarf2_initialize_objfile (objfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Then the oso. */
|
/* Then the oso. */
|
||||||
if (!oso_vector.empty ())
|
if (!oso_vector.empty ())
|
||||||
macho_symfile_read_all_oso (&oso_vector, objfile, symfile_flags);
|
macho_symfile_read_all_oso (&oso_vector, objfile, symfile_flags);
|
||||||
|
|
|
@ -2871,8 +2871,7 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
|
||||||
|
|
||||||
/* DWARF2 sections. */
|
/* DWARF2 sections. */
|
||||||
|
|
||||||
if (dwarf2_has_info (objfile, &dwarf2_xcoff_names))
|
dwarf2_initialize_objfile (objfile, &dwarf2_xcoff_names);
|
||||||
dwarf2_initialize_objfile (objfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Reference in a new issue