Skip to content

Commit

Permalink
libbacktrace: gather address ranges from skeleton units
Browse files Browse the repository at this point in the history
	* dwarf.c (find_address_ranges): Handle skeleton units.
	(read_function_entry): Likewise.
  • Loading branch information
ianlancetaylor committed Feb 17, 2022
1 parent 509f74a commit 2446c66
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum dwarf_tag {
DW_TAG_compile_unit = 0x11,
DW_TAG_inlined_subroutine = 0x1d,
DW_TAG_subprogram = 0x2e,
DW_TAG_skeleton_unit = 0x4a,
};

enum dwarf_form {
Expand Down Expand Up @@ -2322,42 +2323,48 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
break;

case DW_AT_stmt_list:
if (abbrev->tag == DW_TAG_compile_unit
if ((abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
&& (val.encoding == ATTR_VAL_UINT
|| val.encoding == ATTR_VAL_REF_SECTION))
u->lineoff = val.u.uint;
break;

case DW_AT_name:
if (abbrev->tag == DW_TAG_compile_unit)
if (abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
{
name_val = val;
have_name_val = 1;
}
break;

case DW_AT_comp_dir:
if (abbrev->tag == DW_TAG_compile_unit)
if (abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
{
comp_dir_val = val;
have_comp_dir_val = 1;
}
break;

case DW_AT_str_offsets_base:
if (abbrev->tag == DW_TAG_compile_unit
if ((abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
&& val.encoding == ATTR_VAL_REF_SECTION)
u->str_offsets_base = val.u.uint;
break;

case DW_AT_addr_base:
if (abbrev->tag == DW_TAG_compile_unit
if ((abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
&& val.encoding == ATTR_VAL_REF_SECTION)
u->addr_base = val.u.uint;
break;

case DW_AT_rnglists_base:
if (abbrev->tag == DW_TAG_compile_unit
if ((abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
&& val.encoding == ATTR_VAL_REF_SECTION)
u->rnglists_base = val.u.uint;
break;
Expand Down Expand Up @@ -2385,17 +2392,19 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
}

if (abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_subprogram)
|| abbrev->tag == DW_TAG_subprogram
|| abbrev->tag == DW_TAG_skeleton_unit)
{
if (!add_ranges (state, dwarf_sections, base_address,
is_bigendian, u, pcrange.lowpc, &pcrange,
add_unit_addr, (void *) u, error_callback, data,
(void *) addrs))
return 0;

/* If we found the PC range in the DW_TAG_compile_unit, we
can stop now. */
if (abbrev->tag == DW_TAG_compile_unit
/* If we found the PC range in the DW_TAG_compile_unit or
DW_TAG_skeleton_unit, we can stop now. */
if ((abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
&& (pcrange.have_ranges
|| (pcrange.have_lowpc && pcrange.have_highpc)))
return 1;
Expand Down Expand Up @@ -3607,7 +3616,8 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,

/* The compile unit sets the base address for any address
ranges in the function entries. */
if (abbrev->tag == DW_TAG_compile_unit
if ((abbrev->tag == DW_TAG_compile_unit
|| abbrev->tag == DW_TAG_skeleton_unit)
&& abbrev->attrs[i].name == DW_AT_low_pc)
{
if (val.encoding == ATTR_VAL_ADDRESS)
Expand Down

0 comments on commit 2446c66

Please sign in to comment.