forked from Imagelibrary/binutils-gdb
Make load_cu return the loaded dwarf2_cu
In a subsequent patch, the dwarf2_per_cu_data::cu link will be removed. dwarf2_cu objects will instead need to be looked up from a per-objfile map, using the dwarf2_per_cu_data object as the key. To make it easier for some callers, this patch makes load_cu return the dwarf2_cu it creates. If the caller needs to use the created dwarf2_cu, it will have it available right away, rather than having to do a map lookup. At the same time, this allows changing queue_and_load_all_dwo_tus to take a dwarf2_cu instead of a dwarf2_per_cu_data. gdb/ChangeLog: * dwarf2/read.c (load_cu): Return dwarf2_cu. (dw2_do_instantiate_symtab): Update. (queue_and_load_all_dwo_tus): Change parameter from dwarf2_per_cu_data to dwarf2_cu. (dwarf2_fetch_die_loc_sect_off): Update. (dwarf2_fetch_constant_bytes): Update. (dwarf2_fetch_die_type_sect_off): Update.
This commit is contained in:
committed by
Simon Marchi
parent
a3ddd1a46c
commit
7d58fe1431
@@ -1676,7 +1676,7 @@ static struct dwo_unit *lookup_dwo_comp_unit
|
|||||||
static struct dwo_unit *lookup_dwo_type_unit
|
static struct dwo_unit *lookup_dwo_type_unit
|
||||||
(dwarf2_cu *cu, const char *dwo_name, const char *comp_dir);
|
(dwarf2_cu *cu, const char *dwo_name, const char *comp_dir);
|
||||||
|
|
||||||
static void queue_and_load_all_dwo_tus (struct dwarf2_per_cu_data *);
|
static void queue_and_load_all_dwo_tus (dwarf2_cu *cu);
|
||||||
|
|
||||||
/* A unique pointer to a dwo_file. */
|
/* A unique pointer to a dwo_file. */
|
||||||
|
|
||||||
@@ -2335,7 +2335,7 @@ create_quick_file_names_table (unsigned int nr_initial_entries)
|
|||||||
function is unrelated to symtabs, symtab would have to be created afterwards.
|
function is unrelated to symtabs, symtab would have to be created afterwards.
|
||||||
You should call age_cached_comp_units after processing the CU. */
|
You should call age_cached_comp_units after processing the CU. */
|
||||||
|
|
||||||
static void
|
static dwarf2_cu *
|
||||||
load_cu (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
|
load_cu (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
|
||||||
bool skip_partial)
|
bool skip_partial)
|
||||||
{
|
{
|
||||||
@@ -2344,10 +2344,12 @@ load_cu (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
|
|||||||
else
|
else
|
||||||
load_full_comp_unit (per_cu, per_objfile, skip_partial, language_minimal);
|
load_full_comp_unit (per_cu, per_objfile, skip_partial, language_minimal);
|
||||||
|
|
||||||
if (per_cu->cu == NULL)
|
if (per_cu->cu == nullptr)
|
||||||
return; /* Dummy CU. */
|
return nullptr; /* Dummy CU. */
|
||||||
|
|
||||||
dwarf2_find_base_address (per_cu->cu->dies, per_cu->cu);
|
dwarf2_find_base_address (per_cu->cu->dies, per_cu->cu);
|
||||||
|
|
||||||
|
return per_cu->cu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read in the symbols for PER_CU in the context of DWARF"_PER_OBJFILE. */
|
/* Read in the symbols for PER_CU in the context of DWARF"_PER_OBJFILE. */
|
||||||
@@ -2370,19 +2372,19 @@ dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu,
|
|||||||
if (!dwarf2_per_objfile->symtab_set_p (per_cu))
|
if (!dwarf2_per_objfile->symtab_set_p (per_cu))
|
||||||
{
|
{
|
||||||
queue_comp_unit (per_cu, dwarf2_per_objfile, language_minimal);
|
queue_comp_unit (per_cu, dwarf2_per_objfile, language_minimal);
|
||||||
load_cu (per_cu, dwarf2_per_objfile, skip_partial);
|
dwarf2_cu *cu = load_cu (per_cu, dwarf2_per_objfile, skip_partial);
|
||||||
|
|
||||||
/* If we just loaded a CU from a DWO, and we're working with an index
|
/* If we just loaded a CU from a DWO, and we're working with an index
|
||||||
that may badly handle TUs, load all the TUs in that DWO as well.
|
that may badly handle TUs, load all the TUs in that DWO as well.
|
||||||
http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */
|
http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */
|
||||||
if (!per_cu->is_debug_types
|
if (!per_cu->is_debug_types
|
||||||
&& per_cu->cu != NULL
|
&& cu != NULL
|
||||||
&& per_cu->cu->dwo_unit != NULL
|
&& cu->dwo_unit != NULL
|
||||||
&& dwarf2_per_objfile->per_bfd->index_table != NULL
|
&& dwarf2_per_objfile->per_bfd->index_table != NULL
|
||||||
&& dwarf2_per_objfile->per_bfd->index_table->version <= 7
|
&& dwarf2_per_objfile->per_bfd->index_table->version <= 7
|
||||||
/* DWP files aren't supported yet. */
|
/* DWP files aren't supported yet. */
|
||||||
&& get_dwp_file (dwarf2_per_objfile) == NULL)
|
&& get_dwp_file (dwarf2_per_objfile) == NULL)
|
||||||
queue_and_load_all_dwo_tus (per_cu);
|
queue_and_load_all_dwo_tus (cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
process_queue (dwarf2_per_objfile);
|
process_queue (dwarf2_per_objfile);
|
||||||
@@ -12842,28 +12844,27 @@ queue_and_load_dwo_tu (void **slot, void *info)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Queue all TUs contained in the DWO of PER_CU to be read in.
|
/* Queue all TUs contained in the DWO of CU to be read in.
|
||||||
The DWO may have the only definition of the type, though it may not be
|
The DWO may have the only definition of the type, though it may not be
|
||||||
referenced anywhere in PER_CU. Thus we have to load *all* its TUs.
|
referenced anywhere in PER_CU. Thus we have to load *all* its TUs.
|
||||||
http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */
|
http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
queue_and_load_all_dwo_tus (struct dwarf2_per_cu_data *per_cu)
|
queue_and_load_all_dwo_tus (dwarf2_cu *cu)
|
||||||
{
|
{
|
||||||
struct dwo_unit *dwo_unit;
|
struct dwo_unit *dwo_unit;
|
||||||
struct dwo_file *dwo_file;
|
struct dwo_file *dwo_file;
|
||||||
|
|
||||||
gdb_assert (!per_cu->is_debug_types);
|
gdb_assert (cu != nullptr);
|
||||||
gdb_assert (per_cu->cu != NULL);
|
gdb_assert (!cu->per_cu->is_debug_types);
|
||||||
gdb_assert (get_dwp_file (per_cu->cu->per_objfile) == NULL);
|
gdb_assert (get_dwp_file (cu->per_objfile) == nullptr);
|
||||||
|
|
||||||
dwo_unit = per_cu->cu->dwo_unit;
|
dwo_unit = cu->dwo_unit;
|
||||||
gdb_assert (dwo_unit != NULL);
|
gdb_assert (dwo_unit != NULL);
|
||||||
|
|
||||||
dwo_file = dwo_unit->dwo_file;
|
dwo_file = dwo_unit->dwo_file;
|
||||||
if (dwo_file->tus != NULL)
|
if (dwo_file->tus != NULL)
|
||||||
htab_traverse_noresize (dwo_file->tus.get (), queue_and_load_dwo_tu,
|
htab_traverse_noresize (dwo_file->tus.get (), queue_and_load_dwo_tu, cu);
|
||||||
per_cu->cu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read in various DIEs. */
|
/* Read in various DIEs. */
|
||||||
@@ -22277,16 +22278,16 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
|
|||||||
CORE_ADDR (*get_frame_pc) (void *baton),
|
CORE_ADDR (*get_frame_pc) (void *baton),
|
||||||
void *baton, bool resolve_abstract_p)
|
void *baton, bool resolve_abstract_p)
|
||||||
{
|
{
|
||||||
struct dwarf2_cu *cu;
|
|
||||||
struct die_info *die;
|
struct die_info *die;
|
||||||
struct attribute *attr;
|
struct attribute *attr;
|
||||||
struct dwarf2_locexpr_baton retval;
|
struct dwarf2_locexpr_baton retval;
|
||||||
struct objfile *objfile = dwarf2_per_objfile->objfile;
|
struct objfile *objfile = dwarf2_per_objfile->objfile;
|
||||||
|
|
||||||
if (per_cu->cu == NULL)
|
dwarf2_cu *cu = per_cu->cu;
|
||||||
load_cu (per_cu, dwarf2_per_objfile, false);
|
if (cu == nullptr)
|
||||||
cu = per_cu->cu;
|
cu = load_cu (per_cu, dwarf2_per_objfile, false);
|
||||||
if (cu == NULL)
|
|
||||||
|
if (cu == nullptr)
|
||||||
{
|
{
|
||||||
/* We shouldn't get here for a dummy CU, but don't crash on the user.
|
/* We shouldn't get here for a dummy CU, but don't crash on the user.
|
||||||
Instead just throw an error, not much else we can do. */
|
Instead just throw an error, not much else we can do. */
|
||||||
@@ -22415,7 +22416,6 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off,
|
|||||||
obstack *obstack,
|
obstack *obstack,
|
||||||
LONGEST *len)
|
LONGEST *len)
|
||||||
{
|
{
|
||||||
struct dwarf2_cu *cu;
|
|
||||||
struct die_info *die;
|
struct die_info *die;
|
||||||
struct attribute *attr;
|
struct attribute *attr;
|
||||||
const gdb_byte *result = NULL;
|
const gdb_byte *result = NULL;
|
||||||
@@ -22424,10 +22424,11 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off,
|
|||||||
enum bfd_endian byte_order;
|
enum bfd_endian byte_order;
|
||||||
struct objfile *objfile = per_objfile->objfile;
|
struct objfile *objfile = per_objfile->objfile;
|
||||||
|
|
||||||
if (per_cu->cu == NULL)
|
dwarf2_cu *cu = per_cu->cu;
|
||||||
load_cu (per_cu, per_objfile, false);
|
if (cu == nullptr)
|
||||||
cu = per_cu->cu;
|
cu = load_cu (per_cu, per_objfile, false);
|
||||||
if (cu == NULL)
|
|
||||||
|
if (cu == nullptr)
|
||||||
{
|
{
|
||||||
/* We shouldn't get here for a dummy CU, but don't crash on the user.
|
/* We shouldn't get here for a dummy CU, but don't crash on the user.
|
||||||
Instead just throw an error, not much else we can do. */
|
Instead just throw an error, not much else we can do. */
|
||||||
@@ -22544,14 +22545,14 @@ dwarf2_fetch_die_type_sect_off (sect_offset sect_off,
|
|||||||
dwarf2_per_cu_data *per_cu,
|
dwarf2_per_cu_data *per_cu,
|
||||||
dwarf2_per_objfile *per_objfile)
|
dwarf2_per_objfile *per_objfile)
|
||||||
{
|
{
|
||||||
struct dwarf2_cu *cu;
|
|
||||||
struct die_info *die;
|
struct die_info *die;
|
||||||
|
|
||||||
if (per_cu->cu == NULL)
|
dwarf2_cu *cu = per_cu->cu;
|
||||||
load_cu (per_cu, per_objfile, false);
|
if (cu == nullptr)
|
||||||
cu = per_cu->cu;
|
cu = load_cu (per_cu, per_objfile, false);
|
||||||
if (!cu)
|
|
||||||
return NULL;
|
if (cu == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
die = follow_die_offset (sect_off, per_cu->is_dwz, &cu);
|
die = follow_die_offset (sect_off, per_cu->is_dwz, &cu);
|
||||||
if (!die)
|
if (!die)
|
||||||
|
|||||||
Reference in New Issue
Block a user