Skip to content

Commit 2446c66

Browse files
libbacktrace: gather address ranges from skeleton units
* dwarf.c (find_address_ranges): Handle skeleton units. (read_function_entry): Likewise.
1 parent 509f74a commit 2446c66

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

dwarf.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum dwarf_tag {
4949
DW_TAG_compile_unit = 0x11,
5050
DW_TAG_inlined_subroutine = 0x1d,
5151
DW_TAG_subprogram = 0x2e,
52+
DW_TAG_skeleton_unit = 0x4a,
5253
};
5354

5455
enum dwarf_form {
@@ -2322,42 +2323,48 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
23222323
break;
23232324

23242325
case DW_AT_stmt_list:
2325-
if (abbrev->tag == DW_TAG_compile_unit
2326+
if ((abbrev->tag == DW_TAG_compile_unit
2327+
|| abbrev->tag == DW_TAG_skeleton_unit)
23262328
&& (val.encoding == ATTR_VAL_UINT
23272329
|| val.encoding == ATTR_VAL_REF_SECTION))
23282330
u->lineoff = val.u.uint;
23292331
break;
23302332

23312333
case DW_AT_name:
2332-
if (abbrev->tag == DW_TAG_compile_unit)
2334+
if (abbrev->tag == DW_TAG_compile_unit
2335+
|| abbrev->tag == DW_TAG_skeleton_unit)
23332336
{
23342337
name_val = val;
23352338
have_name_val = 1;
23362339
}
23372340
break;
23382341

23392342
case DW_AT_comp_dir:
2340-
if (abbrev->tag == DW_TAG_compile_unit)
2343+
if (abbrev->tag == DW_TAG_compile_unit
2344+
|| abbrev->tag == DW_TAG_skeleton_unit)
23412345
{
23422346
comp_dir_val = val;
23432347
have_comp_dir_val = 1;
23442348
}
23452349
break;
23462350

23472351
case DW_AT_str_offsets_base:
2348-
if (abbrev->tag == DW_TAG_compile_unit
2352+
if ((abbrev->tag == DW_TAG_compile_unit
2353+
|| abbrev->tag == DW_TAG_skeleton_unit)
23492354
&& val.encoding == ATTR_VAL_REF_SECTION)
23502355
u->str_offsets_base = val.u.uint;
23512356
break;
23522357

23532358
case DW_AT_addr_base:
2354-
if (abbrev->tag == DW_TAG_compile_unit
2359+
if ((abbrev->tag == DW_TAG_compile_unit
2360+
|| abbrev->tag == DW_TAG_skeleton_unit)
23552361
&& val.encoding == ATTR_VAL_REF_SECTION)
23562362
u->addr_base = val.u.uint;
23572363
break;
23582364

23592365
case DW_AT_rnglists_base:
2360-
if (abbrev->tag == DW_TAG_compile_unit
2366+
if ((abbrev->tag == DW_TAG_compile_unit
2367+
|| abbrev->tag == DW_TAG_skeleton_unit)
23612368
&& val.encoding == ATTR_VAL_REF_SECTION)
23622369
u->rnglists_base = val.u.uint;
23632370
break;
@@ -2385,17 +2392,19 @@ find_address_ranges (struct backtrace_state *state, uintptr_t base_address,
23852392
}
23862393

23872394
if (abbrev->tag == DW_TAG_compile_unit
2388-
|| abbrev->tag == DW_TAG_subprogram)
2395+
|| abbrev->tag == DW_TAG_subprogram
2396+
|| abbrev->tag == DW_TAG_skeleton_unit)
23892397
{
23902398
if (!add_ranges (state, dwarf_sections, base_address,
23912399
is_bigendian, u, pcrange.lowpc, &pcrange,
23922400
add_unit_addr, (void *) u, error_callback, data,
23932401
(void *) addrs))
23942402
return 0;
23952403

2396-
/* If we found the PC range in the DW_TAG_compile_unit, we
2397-
can stop now. */
2398-
if (abbrev->tag == DW_TAG_compile_unit
2404+
/* If we found the PC range in the DW_TAG_compile_unit or
2405+
DW_TAG_skeleton_unit, we can stop now. */
2406+
if ((abbrev->tag == DW_TAG_compile_unit
2407+
|| abbrev->tag == DW_TAG_skeleton_unit)
23992408
&& (pcrange.have_ranges
24002409
|| (pcrange.have_lowpc && pcrange.have_highpc)))
24012410
return 1;
@@ -3607,7 +3616,8 @@ read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata,
36073616

36083617
/* The compile unit sets the base address for any address
36093618
ranges in the function entries. */
3610-
if (abbrev->tag == DW_TAG_compile_unit
3619+
if ((abbrev->tag == DW_TAG_compile_unit
3620+
|| abbrev->tag == DW_TAG_skeleton_unit)
36113621
&& abbrev->attrs[i].name == DW_AT_low_pc)
36123622
{
36133623
if (val.encoding == ATTR_VAL_ADDRESS)

0 commit comments

Comments
 (0)