libdwarf
|
Functions | |
int | dwarf_die_abbrev_global_offset (Dwarf_Die dw_die, Dwarf_Off *dw_abbrev_offset, Dwarf_Unsigned *dw_abbrev_count, Dwarf_Error *dw_error) |
Return the abbrev section offset of a DIE's abbrevs. More... | |
int | dwarf_tag (Dwarf_Die dw_die, Dwarf_Half *dw_return_tag, Dwarf_Error *dw_error) |
Get TAG value of DIE. More... | |
int | dwarf_dieoffset (Dwarf_Die dw_die, Dwarf_Off *dw_return_offset, Dwarf_Error *dw_error) |
Return the global section offset of the DIE. More... | |
int | dwarf_debug_addr_index_to_addr (Dwarf_Die dw_die, Dwarf_Unsigned dw_index, Dwarf_Addr *dw_return_addr, Dwarf_Error *dw_error) |
Extract address given address index. DWARF5. More... | |
Dwarf_Bool | dwarf_addr_form_is_indexed (int dw_form) |
Informs if a DW_FORM is an indexed form. More... | |
int | dwarf_CU_dieoffset_given_die (Dwarf_Die dw_die, Dwarf_Off *dw_return_offset, Dwarf_Error *dw_error) |
Return the CU DIE offset given any DIE. More... | |
int | dwarf_get_cu_die_offset_given_cu_header_offset_b (Dwarf_Debug dw_dbg, Dwarf_Off dw_in_cu_header_offset, Dwarf_Bool dw_is_info, Dwarf_Off *dw_out_cu_die_offset, Dwarf_Error *dw_error) |
Return the CU DIE section offset given CU header offset. More... | |
int | dwarf_die_CU_offset (Dwarf_Die dw_die, Dwarf_Off *dw_return_offset, Dwarf_Error *dw_error) |
returns the CU relative offset of the DIE. More... | |
int | dwarf_die_CU_offset_range (Dwarf_Die dw_die, Dwarf_Off *dw_return_CU_header_offset, Dwarf_Off *dw_return_CU_length_bytes, Dwarf_Error *dw_error) |
Return the offset length of the entire CU of a DIE. More... | |
int | dwarf_attr (Dwarf_Die dw_die, Dwarf_Half dw_attrnum, Dwarf_Attribute *dw_returned_attr, Dwarf_Error *dw_error) |
Given DIE and attribute number return a Dwarf_attribute. More... | |
int | dwarf_die_text (Dwarf_Die dw_die, Dwarf_Half dw_attrnum, char **dw_ret_name, Dwarf_Error *dw_error) |
Given DIE and attribute number return a string. More... | |
int | dwarf_diename (Dwarf_Die dw_die, char **dw_diename, Dwarf_Error *dw_error) |
Return the string from a DW_AT_name attribute. More... | |
Dwarf_Unsigned | dwarf_die_abbrev_code (Dwarf_Die dw_die) |
Return the DIE abbrev code. More... | |
int | dwarf_die_abbrev_children_flag (Dwarf_Die dw_die, Dwarf_Half *dw_ab_has_child) |
Return TRUE if the DIE has children. More... | |
int | dwarf_validate_die_sibling (Dwarf_Die dw_sibling, Dwarf_Off *dw_offset) |
Validate a sibling DIE. More... | |
int | dwarf_hasattr (Dwarf_Die dw_die, Dwarf_Half dw_attrnum, Dwarf_Bool *dw_returned_bool, Dwarf_Error *dw_error) |
Tells whether a DIE has a particular attribute. More... | |
int | dwarf_offset_list (Dwarf_Debug dw_dbg, Dwarf_Off dw_offset, Dwarf_Bool dw_is_info, Dwarf_Off **dw_offbuf, Dwarf_Unsigned *dw_offcount, Dwarf_Error *dw_error) |
Return an array of DIE children offsets. More... | |
int | dwarf_get_die_address_size (Dwarf_Die dw_die, Dwarf_Half *dw_addr_size, Dwarf_Error *dw_error) |
Get the address size applying to a DIE. More... | |
int | dwarf_die_offsets (Dwarf_Die dw_die, Dwarf_Off *dw_global_offset, Dwarf_Off *dw_local_offset, Dwarf_Error *dw_error) |
Return section and CU-local offsets of a DIE. More... | |
int | dwarf_get_version_of_die (Dwarf_Die dw_die, Dwarf_Half *dw_version, Dwarf_Half *dw_offset_size) |
Get the version and offset size. More... | |
int | dwarf_lowpc (Dwarf_Die dw_die, Dwarf_Addr *dw_returned_addr, Dwarf_Error *dw_error) |
Return the DW_AT_low_pc value. More... | |
int | dwarf_highpc_b (Dwarf_Die dw_die, Dwarf_Addr *dw_return_addr, Dwarf_Half *dw_return_form, enum Dwarf_Form_Class *dw_return_class, Dwarf_Error *dw_error) |
Return the DW_AT_hipc address value. More... | |
int | dwarf_dietype_offset (Dwarf_Die dw_die, Dwarf_Off *dw_return_offset, Dwarf_Bool *dw_is_info, Dwarf_Error *dw_error) |
Return the offset from the DW_AT_type attribute. More... | |
int | dwarf_bytesize (Dwarf_Die dw_die, Dwarf_Unsigned *dw_returned_size, Dwarf_Error *dw_error) |
Return the value of the attribute DW_AT_byte_size. More... | |
int | dwarf_bitsize (Dwarf_Die dw_die, Dwarf_Unsigned *dw_returned_size, Dwarf_Error *dw_error) |
Return the value of the attribute DW_AT_bitsize. More... | |
int | dwarf_bitoffset (Dwarf_Die dw_die, Dwarf_Half *dw_attrnum, Dwarf_Unsigned *dw_returned_offset, Dwarf_Error *dw_error) |
Return the bit offset attribute of a DIE. More... | |
int | dwarf_srclang (Dwarf_Die dw_die, Dwarf_Unsigned *dw_returned_lang, Dwarf_Error *dw_error) |
Return the value of the DW_AT_language attribute. More... | |
int | dwarf_arrayorder (Dwarf_Die dw_die, Dwarf_Unsigned *dw_returned_order, Dwarf_Error *dw_error) |
Return the value of the DW_AT_ordering attribute. More... | |
This is the main interface to attributes of a DIE.
int dwarf_die_abbrev_global_offset | ( | Dwarf_Die | dw_die, |
Dwarf_Off * | dw_abbrev_offset, | ||
Dwarf_Unsigned * | dw_abbrev_count, | ||
Dwarf_Error * | dw_error | ||
) |
So we can associate a DIE's abbreviations with the contents the abbreviations section. Useful for detailed printing and analysis of abbreviations.
dw_die | The DIE of interest |
dw_abbrev_offset | On success is set to the global offset in the .debug_abbrev section of the abbreviations for the DIE. |
dw_abbrev_count | On success is set to the count of abbreviations in the .debug_abbrev section of the abbreviations for the DIE. |
dw_error | The usual error detail return pointer. |
int dwarf_tag | ( | Dwarf_Die | dw_die, |
Dwarf_Half * | dw_return_tag, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest |
dw_return_tag | On success, set to the DW_TAG value of the DIE. |
dw_error | The usual error detail return pointer. |
int dwarf_dieoffset | ( | Dwarf_Die | dw_die, |
Dwarf_Off * | dw_return_offset, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest |
dw_return_offset | On success the offset refers to the section of the DIE itself, which may be .debug_offset or .debug_types. |
dw_error | The usual error detail return pointer. |
int dwarf_debug_addr_index_to_addr | ( | Dwarf_Die | dw_die, |
Dwarf_Unsigned | dw_index, | ||
Dwarf_Addr * | dw_return_addr, | ||
Dwarf_Error * | dw_error | ||
) |
Useful for checking for compiler/linker errors in the creation of DWARF5.
dw_die | The DIE of interest |
dw_index | An index into .debug_addr. This will look first for .debug_addr in the dbg object DIE and if not there will look in the tied object if that is available. |
dw_return_addr | On success the address is returned through the pointer. |
dw_error | The usual error detail return pointer. |
Dwarf_Bool dwarf_addr_form_is_indexed | ( | int | dw_form | ) |
Reading a CU DIE with DW_AT_low_pc an indexed value can be problematic as several different FORMs are indexed. Some in DWARF5 others being extensions to DWARF4 and DWARF5. Indexed forms interact with DW_AT_addr_base in a DIE making this a very relevant distinction.
int dwarf_CU_dieoffset_given_die | ( | Dwarf_Die | dw_die, |
Dwarf_Off * | dw_return_offset, | ||
Dwarf_Error * | dw_error | ||
) |
Returns the global debug_info section offset of the CU DIE in the CU containing the given_die (the passed in DIE can be any DIE).
This does not identify whether the section is .debug_info or .debug_types, use dwarf_get_die_infotypes_flag() to determine the section.
dw_die | The DIE being queried. |
dw_return_offset | Returns the section offset of the CU DIE for dw_die. |
dw_error | The usual error detail return pointer. |
int dwarf_get_cu_die_offset_given_cu_header_offset_b | ( | Dwarf_Debug | dw_dbg, |
Dwarf_Off | dw_in_cu_header_offset, | ||
Dwarf_Bool | dw_is_info, | ||
Dwarf_Off * | dw_out_cu_die_offset, | ||
Dwarf_Error * | dw_error | ||
) |
Returns the CU DIE global offset if one knows the CU header global offset.
dw_dbg | The Dwarf_Debug of interest. |
dw_in_cu_header_offset | The CU header offset. |
dw_is_info | If TRUE the CU header offset is in .debug_info. Otherwise the CU header offset is in .debug_types. |
dw_out_cu_die_offset | The CU DIE offset returned through this pointer. |
dw_error | The usual error detail return pointer. |
int dwarf_die_CU_offset | ( | Dwarf_Die | dw_die, |
Dwarf_Off * | dw_return_offset, | ||
Dwarf_Error * | dw_error | ||
) |
This does not identify whether the section is .debug_info or .debug_types, use dwarf_get_die_infotypes_flag() to determine the section.
dw_die | The DIE being queried. |
dw_return_offset | Returns the CU relative offset of this DIE. |
dw_error | The usual error detail return pointer. |
int dwarf_die_CU_offset_range | ( | Dwarf_Die | dw_die, |
Dwarf_Off * | dw_return_CU_header_offset, | ||
Dwarf_Off * | dw_return_CU_length_bytes, | ||
Dwarf_Error * | dw_error | ||
) |
This does not identify whether the section is .debug_info or .debug_types, use dwarf_get_die_infotypes_flag() to determine the section.
dw_die | The DIE being queried. |
dw_return_CU_header_offset | On success returns the section offset of the CU this DIE is in. |
dw_return_CU_length_bytes | On success returns the CU length of the CU this DIE is in, including the CU length, header, and all DIEs. |
dw_error | The usual error detail return pointer. |
int dwarf_attr | ( | Dwarf_Die | dw_die, |
Dwarf_Half | dw_attrnum, | ||
Dwarf_Attribute * | dw_returned_attr, | ||
Dwarf_Error * | dw_error | ||
) |
Returns DW_DLV_NO_ENTRY if the DIE has no attribute dw_attrnum.
dw_die | The DIE of interest. |
dw_attrnum | An attribute number, for example DW_AT_name. |
dw_returned_attr | On success a Dwarf_Attribute pointer is returned and it should eventually be deallocated. |
dw_error | The usual error detail return pointer. |
int dwarf_die_text | ( | Dwarf_Die | dw_die, |
Dwarf_Half | dw_attrnum, | ||
char ** | dw_ret_name, | ||
Dwarf_Error * | dw_error | ||
) |
Returns DW_DLV_NO_ENTRY if the DIE has no attribute dw_attrnum.
dw_die | The DIE of interest. |
dw_attrnum | An attribute number, for example DW_AT_name. |
dw_ret_name | On success a pointer to the string is returned. Do not free the string. Many attributes allow various forms that directly or indirectly contain strings and this returns the string. |
dw_error | The usual error detail return pointer. |
int dwarf_diename | ( | Dwarf_Die | dw_die, |
char ** | dw_diename, | ||
Dwarf_Error * | dw_error | ||
) |
Returns DW_DLV_NO_ENTRY if the DIE has no attribute DW_AT_name
dw_die | The DIE of interest. |
dw_diename | On success a pointer to the string is returned. Do not free the string. Various forms directly or indirectly contain strings and this follows all of them to their string. |
dw_error | The usual error detail return pointer. |
Dwarf_Unsigned dwarf_die_abbrev_code | ( | Dwarf_Die | dw_die | ) |
The Abbrev code for a DIE is a positive integer assigned by the compiler within a particular CU. For .debug_names abbreviations the situation is conceptually similar. The code values are arbitrary but compilers are motivated to make them small so the object size is as small as possible.
Returns the abbrev code of the die. Cannot fail.
dw_die | The DIE of interest. |
int dwarf_die_abbrev_children_flag | ( | Dwarf_Die | dw_die, |
Dwarf_Half * | dw_ab_has_child | ||
) |
dw_die | A valid DIE pointer (not NULL). |
dw_ab_has_child | Sets TRUE though the pointer if the DIE has children. Otherwise sets FALSE. |
This is used by dwarfdump (when dwarfdump is checking for valid DWARF) to try to catch a corrupt DIE tree.
This does not identify whether the section is .debug_info or .debug_types, use dwarf_get_die_infotypes_flag() to determine the section.
dw_sibling | Pass in a DIE returned by dwarf_siblingof_b(). |
dw_offset | Set to zero through the pointer. |
int dwarf_hasattr | ( | Dwarf_Die | dw_die, |
Dwarf_Half | dw_attrnum, | ||
Dwarf_Bool * | dw_returned_bool, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest. |
dw_attrnum | The attribute number we are asking about, DW_AT_name for example. |
dw_returned_bool | On success is set TRUE if dw_die has dw_attrnum and FALSE otherwise. |
dw_error | The usual error detail return pointer. |
int dwarf_offset_list | ( | Dwarf_Debug | dw_dbg, |
Dwarf_Off | dw_offset, | ||
Dwarf_Bool | dw_is_info, | ||
Dwarf_Off ** | dw_offbuf, | ||
Dwarf_Unsigned * | dw_offcount, | ||
Dwarf_Error * | dw_error | ||
) |
Given a DIE section offset and dw_is_info, returns an array of DIE global [section] offsets of the children of DIE.
dw_dbg | The Dwarf_Debug of interest. |
dw_offset | A DIE offset. |
dw_is_info | If TRUE says to use the offset in .debug_info. Else use the offset in .debug_types. |
dw_offbuf | A pointer to an array of children DIE global [section] offsets is returned through the pointer. |
dw_offcount | The number of elements in dw_offbuf. If the DIE has no children it could be zero, in which case dw_offbuf and dw_offcount are not touched. |
dw_error | The usual error detail return pointer. |
On successful return, use dwarf_dealloc(dbg, dw_offbuf, DW_DLA_UARRAY); to dealloc the allocated space.
int dwarf_get_die_address_size | ( | Dwarf_Die | dw_die, |
Dwarf_Half * | dw_addr_size, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest. |
dw_addr_size | On success, returns the address size that applies to dw_die. Normally 4 or 8. |
dw_error | The usual error detail return pointer. |
int dwarf_die_offsets | ( | Dwarf_Die | dw_die, |
Dwarf_Off * | dw_global_offset, | ||
Dwarf_Off * | dw_local_offset, | ||
Dwarf_Error * | dw_error | ||
) |
This does not identify whether the section is .debug_info or .debug_types, use dwarf_get_die_infotypes_flag() to determine the section.
dw_die | The DIE of interest. |
dw_global_offset | On success returns the offset of the DIE in its section. |
dw_local_offset | On success returns the offset of the DIE within its CU. |
dw_error | The usual error detail return pointer. |
int dwarf_get_version_of_die | ( | Dwarf_Die | dw_die, |
Dwarf_Half * | dw_version, | ||
Dwarf_Half * | dw_offset_size | ||
) |
The values returned apply to the CU this DIE belongs to. This is useful as preparation for calling dwarf_get_form_class
dw_die | The DIE of interest. |
dw_version | Returns the version of the CU this DIE is contained in. Standard version numbers are 2 through 5. |
dw_offset_size | Returns the offset_size (4 or 8) of the CU this DIE is contained in. |
int dwarf_lowpc | ( | Dwarf_Die | dw_die, |
Dwarf_Addr * | dw_returned_addr, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest. |
dw_returned_addr | On success returns, through the pointer, the address DW_AT_low_pc defines. |
dw_error | The usual error detail return pointer. |
int dwarf_highpc_b | ( | Dwarf_Die | dw_die, |
Dwarf_Addr * | dw_return_addr, | ||
Dwarf_Half * | dw_return_form, | ||
enum Dwarf_Form_Class * | dw_return_class, | ||
Dwarf_Error * | dw_error | ||
) |
This is accessing the DW_AT_high_pc attribute. Calculating the high pc involves elements which we don't describe here, but which are shown in the example. See the DWARF5 standard.
dw_die | The DIE of interest. |
dw_return_addr | On success returns the high-pc address for this DIE. If the high-pc is a not DW_FORM_addr and is a non-indexed constant form one must add the value of the DW_AT_low_pc to this to get the true high-pc value as the value returned is an unsigned offset of the associated low-pc value. |
dw_return_form | On success returns the actual FORM for this attribute. Needed for certain cases to calculate the true dw_return_addr; |
dw_return_class | On success returns the FORM CLASS for this attribute. Needed for certain cases to calculate the true dw_return_addr; |
dw_error | The usual error detail return pointer. |
int dwarf_dietype_offset | ( | Dwarf_Die | dw_die, |
Dwarf_Off * | dw_return_offset, | ||
Dwarf_Bool * | dw_is_info, | ||
Dwarf_Error * | dw_error | ||
) |
The offset returned is is a global offset from the DW_AT_type of the DIE passed in. If this CU is DWARF4 the offset could be in .debug_types, otherwise it is in .debug_info Check the section of the DIE to know which it is, dwarf_cu_header_basics() will return that.
Added pointer argument to return the section the offset applies to. December 2022.
dw_die | The DIE of interest. |
dw_return_offset | If successful, returns the offset through the pointer. |
dw_is_info | If successful, set to TRUE if the dw_return_offset is in .debug_info and FALSE if the dw_return_offset is in .debug_types. |
dw_error | The usual error detail return pointer. |
int dwarf_bytesize | ( | Dwarf_Die | dw_die, |
Dwarf_Unsigned * | dw_returned_size, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest. |
dw_returned_size | If successful, returns the size through the pointer. |
dw_error | The usual error detail return pointer. |
int dwarf_bitsize | ( | Dwarf_Die | dw_die, |
Dwarf_Unsigned * | dw_returned_size, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest. |
dw_returned_size | If successful, returns the size through the pointer. |
dw_error | The usual error detail return pointer. |
int dwarf_bitoffset | ( | Dwarf_Die | dw_die, |
Dwarf_Half * | dw_attrnum, | ||
Dwarf_Unsigned * | dw_returned_offset, | ||
Dwarf_Error * | dw_error | ||
) |
If the attribute is DW_AT_data_bit_offset (DWARF4, DWARF5) the returned bit offset has one meaning. If the attribute is DW_AT_bit_offset (DWARF2, DWARF3) the meaning is quite different.
dw_die | The DIE of interest. |
dw_attrnum | If successful, returns the number of the attribute (DW_AT_data_bit_offset or DW_AT_bit_offset) |
dw_returned_offset | If successful, returns the bit offset value. |
dw_error | The usual error detail return pointer. |
int dwarf_srclang | ( | Dwarf_Die | dw_die, |
Dwarf_Unsigned * | dw_returned_lang, | ||
Dwarf_Error * | dw_error | ||
) |
The DIE should be a CU DIE.
dw_die | The DIE of interest. |
dw_returned_lang | On success returns the language code (normally only found on a CU DIE). For example DW_LANG_C |
dw_error | The usual error detail return pointer. |
int dwarf_arrayorder | ( | Dwarf_Die | dw_die, |
Dwarf_Unsigned * | dw_returned_order, | ||
Dwarf_Error * | dw_error | ||
) |
dw_die | The DIE of interest. |
dw_returned_order | On success returns the ordering value. For example DW_ORD_row_major |
dw_error | The usual error detail return pointer. |