libdwarf: Location/expression access

libdwarf

Loading...
Searching...
No Matches
Location/expression access

Example using DWARF2-5 loclists and loc-expressions.

Example using DWARF2-5 loclists and loc-expressions.

Valid for DWARF2 and later DWARF.

This example simply assumes the attribute has a form which relates to location lists or location expressions. Use dwarf_get_form_class() to determine if this attribute fits. Use dwarf_get_version_of_die() to help get the data you need.

See also
  dwarf_get_form_class
  dwarf_get_version_of_die
  Reading a location expression

*/
int example_loclistcv5(Dwarf_Attribute someattr,
Dwarf_Error *error)
{
Dwarf_Unsigned lcount = 0;
Dwarf_Loc_Head_c loclist_head = 0;
int lres = 0;
lres = dwarf_get_loclist_c(someattr,&loclist_head,
&lcount,error);
if (lres == DW_DLV_OK) {
Dwarf_Unsigned i = 0;
/* Before any return remember to call
dwarf_loc_head_c_dealloc(loclist_head);
Dwarf_Attribute
struct Dwarf_Attribute_s * Dwarf_Attribute
Definition libdwarf.h:677
Dwarf_Loc_Head_c
struct Dwarf_Loc_Head_c_s * Dwarf_Loc_Head_c
Definition libdwarf.h:347
Dwarf_Error
struct Dwarf_Error_s * Dwarf_Error
Definition libdwarf.h:611
Dwarf_Unsigned
unsigned long long Dwarf_Unsigned
Definition libdwarf.h:196
dwarf_get_loclist_c
DW_API int dwarf_get_loclist_c(Dwarf_Attribute dw_attr, Dwarf_Loc_Head_c *dw_loclist_head, Dwarf_Unsigned *dw_locentry_count, Dwarf_Error *dw_error)
Location Lists and Expressions.