| DWARF(3) | Library Functions Manual | DWARF(3) |
dwarf — access
debugging information in object files
DWARF Access Library (libdwarf, -ldwarf)
#include
<libdwarf.h>
The DWARF Access Library (libdwarf, -ldwarf) provides functions that allow an application to read and write debugging information in object files. The format of debugging information accessible through this API is defined by the DWARF standard, see dwarf(4).
The DWARF(3) API has two parts:
Each function referenced below is further described in its own manual page.
The DWARF library uses the following prefixes:
The DWARF(3) API uses the following data types:
Library functions that encounter an error will return with a value
other than DW_DLV_OK.
The DWARF Access Library (libdwarf, -ldwarf) allows applications to specify three levels of error handling:
NULL, then an error
descriptor is written to the location specified.NULL, but if
an error handler was defined for the debug context in use using
dwarf_init(3) or
dwarf_seterrhand(3),
then the library will invoke the specified error handler with an error
descriptor as argument.Error descriptors may be used with dwarf_errmsg(3) or dwarf_errno(3).
The DWARF consumer API permits applications to read DWARF information in an object file.
The major functional groups of functions in the consumer API are listed below.
dwarf_get_abbrev()dwarf_get_abbrev_children_flag()dwarf_get_abbrev_code()dwarf_get_abbrev_entry()dwarf_get_abbrev_tag()dwarf_get_address_size()dwarf_get_arange()dwarf_get_arange_cu_header_offset()dwarf_get_arange_info()dwarf_get_aranges()dwarf_get_cu_die_offset()dwarf_get_ranges(),
dwarf_get_ranges_a()dwarf_arrayorder()DW_AT_ordering
attribute.dwarf_attr()dwarf_attrlist()dwarf_attroffset()dwarf_attrval_flag()DW_AT_FORM_flag value.dwarf_attrval_signed()dwarf_attrval_string()dwarf_attrval_unsigned()dwarf_bitoffset(),DW_AT_bit_offset
attribute.dwarf_bitsize(),DW_AT_bit_size
attribute.dwarf_bytesize()DW_AT_byte_size
attribute.dwarf_formaddr()ADDRESS-class
attribute.dwarf_formblock()BLOCK-class
attributedwarf_formexprloc()dwarf_formflag()BOOLEAN-class
attribute.dwarf_formref(),
dwarf_global_formref()REFERENCE-class
attributes.dwarf_formsdata(),
dwarf_formudata()CONSTANT-class
attribute.dwarf_formsig8()dwarf_formstring()STRING-class
attribute.dwarf_get_form_class()dwarf_hasattr()dwarf_hasform()dwarf_whatattr()dwarf_whatform(),
dwarf_whatform_direct()dwarf_get_cie_index()dwarf_get_cie_info()dwarf_get_cie_of_fde()dwarf_get_fde_at_pc()dwarf_get_fde_info_for_all_regs()dwarf_get_fde_info_for_all_regs3()dwarf_get_fde_info_for_cfa_reg3()dwarf_get_fde_info_for_reg()dwarf_get_fde_info_for_reg3()dwarf_get_fde_instr_bytes()dwarf_get_fde_list(),
dwarf_get_fde_list_eh()dwarf_get_fde_n()dwarf_get_fde_range()dwarf_get_cu_die_offset_given_cu_header_offset(),
dwarf_get_cu_die_offset_given_cu_header_offset_b()dwarf_next_cu_header(),
dwarf_next_cu_header_b(),
dwarf_next_cu_header_c()dwarf_child()dwarf_die_abbrev_code()dwarf_die_CU_offset(),
dwarf_die_CU_offset_range()dwarf_diename()DW_AT_name attribute for a
debugging information entry.dwarf_dieoffset()dwarf_get_die_infotypes_flag()dwarf_highpc(),
dwarf_highpc_b()dwarf_lowpc()dwarf_offdie(),
dwarf_offdie_b()dwarf_siblingof(),
dwarf_siblingof_b()dwarf_srclang()dwarf_tag()dwarf_func_cu_offset()dwarf_func_die_offset()dwarf_funcname()dwarf_func_name_offsets()dwarf_get_funcs()dwarf_get_globals()dwarf_global_cu_offset()dwarf_global_die_offset()dwarf_global_name_offsets()dwarf_globname()dwarf_elf_init()
and
dwarf_init()
may be used for initialization. The function
dwarf_finish()
may be used to release resources.
The functions
dwarf_object_init()
and
dwarf_object_finish()
allow an application to specify alternate low-level file access
routines.
dwarf_lineaddr()dwarf_linebeginstatement()dwarf_lineblock()dwarf_lineendsequence()dwarf_lineno()dwarf_lineoff()dwarf_linesrc()dwarf_line_srcfileno()dwarf_srcfiles()dwarf_srclines()dwarf_get_loclist_entry()dwarf_loclist(),
dwarf_loclist_n()dwarf_loclist_from_expr(),
dwarf_loclist_from_expr_a(),
dwarf_loclist_from_expr_b()dwarf_errmsg()dwarf_errno()dwarf_seterrarg()dwarf_seterrhand()dwarf_expand_frame_instructions()dwarf_set_frame_cfa_value()dwarf_set_frame_rule_initial_value()dwarf_set_frame_rule_table_size()dwarf_set_frame_same_value()dwarf_set_frame_undefined_value()dwarf_find_macro_value_start()dwarf_get_macro_details()dwarf_dealloc() suffices.
The individual manual pages for the API's functions document the specific
memory management rules to be followed.
The function
dwarf_dealloc()
is used to mark memory arenas as unused. Additionally, the following
functions release specific types of DWARF resources:
dwarf_fde_cie_list_dealloc(),
dwarf_funcs_dealloc(),
dwarf_globals_dealloc(),
dwarf_pubtypes_dealloc(),
dwarf_ranges_dealloc(),
dwarf_srclines_dealloc(),
dwarf_types_dealloc(),
dwarf_vars_dealloc(),
and
dwarf_weaks_dealloc().
dwarf_get_ACCESS_name(),
dwarf_get_AT_name(),
dwarf_get_ATE_name(),
dwarf_get_CC_name(),
dwarf_get_CFA_name(),
dwarf_get_CHILDREN_name(),
dwarf_get_DS_name(),
dwarf_get_DSC_name(),
dwarf_get_EH_name(),
dwarf_get_END_name(),
dwarf_get_FORM_name(),
dwarf_get_ID_name(),
dwarf_get_INL_name(),
dwarf_get_LANG_name(),
dwarf_get_LNE_name(),
dwarf_get_LNS_name(),
dwarf_get_MACINFO_name(),
dwarf_get_OP_name(),
dwarf_get_ORD_name(),
dwarf_get_TAG_name(),
dwarf_get_VIRTUALITY_name(),
and
dwarf_get_VIS_name().dwarf_get_pubtypes(),
dwarf_get_types()dwarf_next_types_section()dwarf_pubtype_cu_offset(),
dwarf_type_cu_offset()dwarf_pubtype_die_offset(),
dwarf_type_die_offset()dwarf_pubtypename(),
dwarf_typename()dwarf_pubtype_name_offsets(),
dwarf_type_name_offsets()dwarf_get_vars()dwarf_var_cu_offset()dwarf_var_die_offset()dwarf_varname()dwarf_var_name_offsets()dwarf_get_weaks()dwarf_weak_cu_offset()dwarf_weak_die_offset()dwarf_weakname()dwarf_weak_name_offsets()dwarf_get_elf()dwarf_get_str()dwarf_set_reloc_application()The DWARF producer API permits applications to add DWARF information to an object file.
The major functional groups of functions in the producer API are listed below.
dwarf_add_AT_comp_dir(),
dwarf_add_AT_const_value_signedint(),
dwarf_add_AT_const_value_string(),
dwarf_add_AT_const_value_unsignedint(),
dwarf_add_AT_dataref(),
dwarf_add_AT_flag(),
dwarf_add_AT_location_expr(),
dwarf_add_AT_name(),
dwarf_add_AT_producer(),
dwarf_add_AT_ref_address(),
dwarf_add_AT_reference(),
dwarf_add_AT_signed_const(),
dwarf_add_AT_string(),
dwarf_add_AT_targ_address(),
dwarf_add_AT_targ_address_b()
and
dwarf_add_AT_unsigned_const().dwarf_add_die_to_debug()dwarf_die_link()dwarf_new_die()dwarf_producer_init()
and
dwarf_producer_init_b()
are used to initialize a producer instance.
When done, applications release
resources using the function
dwarf_producer_finish().
dwarf_get_relocation_info()dwarf_get_relocation_info_count()dwarf_get_section_bytes()dwarf_reset_section_bytes()dwarf_transform_to_disk_form()dwarf_def_macro()dwarf_end_macro_file(),
dwarf_start_macro_file()dwarf_undef_macro()dwarf_vendor_ext()dwarf_add_arange(),
dwarf_add_arange_b()dwarf_add_directory_decl()dwarf_add_fde_inst()dwarf_add_file_decl()dwarf_add_frame_cie()dwarf_add_frame_fde(),
dwarf_add_frame_fde_b()dwarf_add_funcname()dwarf_add_line_entry()dwarf_add_expr_addr(),
dwarf_add_expr_addr_b()DW_OP_addr opcode to a location
expression.dwarf_add_expr_gen()dwarf_add_pubname()dwarf_add_typename()dwarf_add_varname()dwarf_add_weakname()dwarf_expr_current_offset()dwarf_expr_into_block()dwarf_fde_cfa_offset()DW_CFA_offset operation to a frame
descriptor.dwarf_lne_end_sequence(),
dwarf_lne_set_address()dwarf_new_expr()dwarf_new_fde()dwarf_producer_set_isa()
sets the instruction set architecture for the producer instance.This implementation is believed to be source compatible with the SGI/GNU DWARF(3) library, version 20110113.
Known differences with the SGI/GNU library include:
The following APIs are extensions specific to this implementation:
dwarf_attroffset()dwarf_next_types_section()dwarf_producer_set_isa()The DWARF standard is defined by The DWARF Debugging Information Format, Version 4, http://www.dwarfstd.org/.
The DWARF(3) API originated at Silicon Graphics Inc.
A BSD-licensed implementation of a subset of the API was written by John Birrell <jb@FreeBSD.org> for the FreeBSD project. The implementation was subsequently revised and completed by Kai Wang <kaiwang27@users.sourceforge.net>.
Manual pages for this implementation were written by Joseph Koshy <jkoshy@users.sourceforge.net> and Kai Wang <kaiwang27@users.sourceforge.net>.
| December 21, 2014 | NetBSD 11.0 |