12de3b87aSKai Wang.\" Copyright (c) 2011 Joseph Koshy. All rights reserved. 22de3b87aSKai Wang.\" 32de3b87aSKai Wang.\" Redistribution and use in source and binary forms, with or without 42de3b87aSKai Wang.\" modification, are permitted provided that the following conditions 52de3b87aSKai Wang.\" are met: 62de3b87aSKai Wang.\" 1. Redistributions of source code must retain the above copyright 72de3b87aSKai Wang.\" notice, this list of conditions and the following disclaimer. 82de3b87aSKai Wang.\" 2. Redistributions in binary form must reproduce the above copyright 92de3b87aSKai Wang.\" notice, this list of conditions and the following disclaimer in the 102de3b87aSKai Wang.\" documentation and/or other materials provided with the distribution. 112de3b87aSKai Wang.\" 122de3b87aSKai Wang.\" This software is provided by Joseph Koshy ``as is'' and 132de3b87aSKai Wang.\" any express or implied warranties, including, but not limited to, the 142de3b87aSKai Wang.\" implied warranties of merchantability and fitness for a particular purpose 152de3b87aSKai Wang.\" are disclaimed. in no event shall Joseph Koshy be liable 162de3b87aSKai Wang.\" for any direct, indirect, incidental, special, exemplary, or consequential 172de3b87aSKai Wang.\" damages (including, but not limited to, procurement of substitute goods 182de3b87aSKai Wang.\" or services; loss of use, data, or profits; or business interruption) 192de3b87aSKai Wang.\" however caused and on any theory of liability, whether in contract, strict 202de3b87aSKai Wang.\" liability, or tort (including negligence or otherwise) arising in any way 212de3b87aSKai Wang.\" out of the use of this software, even if advised of the possibility of 222de3b87aSKai Wang.\" such damage. 232de3b87aSKai Wang.\" 24*b00fe64fSEd Maste.\" $Id: dwarf.3 3195 2015-05-12 17:22:19Z emaste $ 252de3b87aSKai Wang.\" 26cf781b2eSEd Maste.Dd December 21, 2014 272de3b87aSKai Wang.Os 282de3b87aSKai Wang.Dt DWARF 3 292de3b87aSKai Wang.Sh NAME 302de3b87aSKai Wang.Nm dwarf 312de3b87aSKai Wang.Nd access debugging information in object files 322de3b87aSKai Wang.Sh LIBRARY 332de3b87aSKai Wang.Lb libdwarf 342de3b87aSKai Wang.Sh SYNOPSIS 352de3b87aSKai Wang.In libdwarf.h 362de3b87aSKai Wang.Sh DESCRIPTION 372de3b87aSKai Wang.Pp 382de3b87aSKai WangThe 392de3b87aSKai Wang.Lb libdwarf 402de3b87aSKai Wangprovides functions that allow an application to read and write debugging 412de3b87aSKai Wanginformation in object files. 422de3b87aSKai WangThe format of debugging information accessible through this API 432de3b87aSKai Wangis defined by the DWARF standard, see 442de3b87aSKai Wang.Xr dwarf 4 . 452de3b87aSKai Wang.Pp 462de3b87aSKai WangThe 472de3b87aSKai Wang.Xr DWARF 3 482de3b87aSKai WangAPI has two parts: 492de3b87aSKai Wang.Bl -bullet 502de3b87aSKai Wang.It 512de3b87aSKai WangA consumer API set allows applications to read existing debug information 522de3b87aSKai Wangin a program object. 532de3b87aSKai WangThe functions that comprise the DWARF consumer API are described in 542de3b87aSKai Wangthe section 552de3b87aSKai Wang.Sx "DWARF Consumer API" 562de3b87aSKai Wangbelow. 572de3b87aSKai Wang.It 582de3b87aSKai WangA producer API set that allows applications to add debug information 592de3b87aSKai Wangto a program object. 602de3b87aSKai WangThe functions that comprise the DWARF producer API are described in 612de3b87aSKai Wangthe section 622de3b87aSKai Wang.Sx "DWARF Producer API" 632de3b87aSKai Wangbelow. 642de3b87aSKai Wang.El 652de3b87aSKai Wang.Pp 662de3b87aSKai WangEach function referenced below is further described in its own manual page. 672de3b87aSKai Wang.Ss Namespace use 682de3b87aSKai WangThe DWARF library uses the following prefixes: 692de3b87aSKai Wang.Pp 702de3b87aSKai Wang.Bl -tag -width ".Li Dwarf_*" -compact 712de3b87aSKai Wang.It Li DWARF_* 722de3b87aSKai WangUsed for error numbers and constants. 732de3b87aSKai Wang.It Li DW_* 742de3b87aSKai WangUsed for constants. 752de3b87aSKai Wang.It Li Dwarf_* 762de3b87aSKai WangUsed for types. 772de3b87aSKai Wang.It Li dwarf_* 782de3b87aSKai WangUsed for functions and macros that make up the API. 792de3b87aSKai Wang.El 802de3b87aSKai Wang.Ss Data Types 812de3b87aSKai WangThe DWARF(3) API uses the following data types: 822de3b87aSKai Wang.Pp 832de3b87aSKai Wang.Bl -tag -width ".Vt Dwarf_Unsigned" -compact 842de3b87aSKai Wang.It Vt Dwarf_Abbrev 852de3b87aSKai WangDescribes DWARF abbreviations. 862de3b87aSKai Wang.It Vt Dwarf_Addr 872de3b87aSKai WangA program address in the target object. 882de3b87aSKai Wang.It Vt Dwarf_Arange 892de3b87aSKai WangDescribes address ranges. 902de3b87aSKai Wang.It Vt Dwarf_Attribute , Vt Dwarf_P_Attribute 912de3b87aSKai WangDescribes attributes of debugging information entries. 922de3b87aSKai Wang.It Vt Dwarf_Bool 932de3b87aSKai WangUsed for boolean states. 942de3b87aSKai Wang.It Vt Dwarf_Cie , Vt Dwarf_P_Cie 952de3b87aSKai WangDescribes call information that is common to several frames. 962de3b87aSKai Wang.It Vt Dwarf_Debug , Vt Dwarf_P_Debug 972de3b87aSKai WangAn opaque type describing a debug context. 982de3b87aSKai Wang.It Vt Dwarf_Die , Vt Dwarf_P_Die 992de3b87aSKai WangA debugging information entry. 1002de3b87aSKai Wang.It Vt Dwarf_Fde , Vt Dwarf_P_Fde 1012de3b87aSKai WangA frame descriptor. 1022de3b87aSKai Wang.It Vt Dwarf_Func 1032de3b87aSKai WangA descriptor representing a function. 1042de3b87aSKai Wang.It Vt Dwarf_Global 1052de3b87aSKai WangA descriptor representing a global name. 1062de3b87aSKai Wang.It Vt Dwarf_Half 1072de3b87aSKai WangA 16-bit wide unsigned numeric type. 1082de3b87aSKai Wang.It Vt Dwarf_Handler 1092de3b87aSKai WangA pointer to an error handling function. 1102de3b87aSKai Wang.It Vt Dwarf_Line 1112de3b87aSKai WangA descriptor for a source line. 1122de3b87aSKai Wang.It Vt Dwarf_Off 1132de3b87aSKai WangAn unsigned file offset, corresponding to an 1142de3b87aSKai Wang.Vt off_t 1152de3b87aSKai Wangtype supported by the underlying operating system. 1162de3b87aSKai Wang.It Vt Dwarf_P_Expr 1172de3b87aSKai WangA descriptor for a location expression. 1182de3b87aSKai Wang.It Vt Dwarf_Ptr 1192de3b87aSKai WangA virtual address used by an application. 1202de3b87aSKai Wang.It Vt Dwarf_Signed 1212de3b87aSKai WangA 64-bit wide signed numeric type. 1222de3b87aSKai Wang.It Vt Dwarf_Small 1232de3b87aSKai WangAn 8-bit wide unsigned numeric type. 1242de3b87aSKai Wang.It Vt Dwarf_Type 1252de3b87aSKai WangA descriptor representing a user-specified type. 1262de3b87aSKai Wang.It Vt Dwarf_Unsigned 1272de3b87aSKai WangA 64-bit wide unsigned numeric type. 1282de3b87aSKai Wang.It Vt Dwarf_Var 1292de3b87aSKai WangA descriptor representing a static variable. 1302de3b87aSKai Wang.It Vt Dwarf_Weak 1312de3b87aSKai WangA descriptor representing a weak name. 1322de3b87aSKai Wang.El 1332de3b87aSKai Wang.Ss Error Handling 1342de3b87aSKai Wang.Pp 1352de3b87aSKai WangLibrary functions that encounter an error will return with a value 1362de3b87aSKai Wangother than 1372de3b87aSKai Wang.Dv DW_DLV_OK . 1382de3b87aSKai Wang.Pp 1392de3b87aSKai WangThe 1402de3b87aSKai Wang.Lb libdwarf 1412de3b87aSKai Wangallows applications to specify three levels of error handling: 1422de3b87aSKai Wang.Bl -enum -compact 1432de3b87aSKai Wang.It 1442de3b87aSKai WangMost library functions take a parameter of type 1452de3b87aSKai Wang.Vt Dwarf_Error 1462de3b87aSKai Wangthat specifies a location to store an error descriptor in 1472de3b87aSKai Wangcase of an error. 1482de3b87aSKai WangIf an error occurs during the execution on an API, and if this 1492de3b87aSKai Wangparameter is non-NULL, then an error descriptor is written to the 1502de3b87aSKai Wanglocation specified. 1512de3b87aSKai Wang.It 1522de3b87aSKai WangOtherwise, if the error parameter was NULL, but if an error handler 1532de3b87aSKai Wangwas defined for the debug context in use using 1542de3b87aSKai Wang.Xr dwarf_init 3 1552de3b87aSKai Wangor 1562de3b87aSKai Wang.Xr dwarf_seterrhand 3 , 1572de3b87aSKai Wangthen the library will invoke the specified error handler with an error 1582de3b87aSKai Wangdescriptor as argument. 1592de3b87aSKai Wang.It 1602de3b87aSKai WangOtherwise, if a library wide error handler was specified using 1612de3b87aSKai Wang.Xr dwarf_seterrhand 3 , 1622de3b87aSKai Wangit is called. 1632de3b87aSKai Wang.El 1642de3b87aSKai Wang.Pp 1652de3b87aSKai WangError descriptors may be used with 1662de3b87aSKai Wang.Xr dwarf_errmsg 3 1672de3b87aSKai Wangor 1682de3b87aSKai Wang.Xr dwarf_errno 3 . 1692de3b87aSKai Wang.Sh The DWARF Consumer API 1702de3b87aSKai WangThe DWARF consumer API permits applications to read DWARF information in 1712de3b87aSKai Wangan object file. 1722de3b87aSKai Wang.Pp 1732de3b87aSKai WangThe major functional groups of functions in the consumer API are listed 1742de3b87aSKai Wangbelow. 1752de3b87aSKai Wang.Pp 1762de3b87aSKai Wang.Bl -tag -compact -width "CCCC" 1772de3b87aSKai Wang.It Abbreviations 1782de3b87aSKai Wang.Bl -tag -compact 1792de3b87aSKai Wang.It Fn dwarf_get_abbrev 1802de3b87aSKai WangRetrieve abbreviation information at a given offset. 1812de3b87aSKai Wang.It Fn dwarf_get_abbrev_children_flag 1822de3b87aSKai WangCheck if an abbreviation has child elements. 1832de3b87aSKai Wang.It Fn dwarf_get_abbrev_code 1842de3b87aSKai WangRetrieve the abbreviation code for an abbreviation entry descriptor. 1852de3b87aSKai Wang.It Fn dwarf_get_abbrev_entry 1862de3b87aSKai WangRetrieve abbreviation information for an abbreviation entry 1872de3b87aSKai Wangdescriptor. 1882de3b87aSKai Wang.It Fn dwarf_get_abbrev_tag 1892de3b87aSKai WangRetrieve the tag for an abbreviation entry. 1902de3b87aSKai Wang.El 1912de3b87aSKai Wang.It Addresses 1922de3b87aSKai Wang.Bl -tag -compact 1932de3b87aSKai Wang.It Fn dwarf_get_address_size 1942de3b87aSKai WangReturn the number of bytes needed to represent an address. 1952de3b87aSKai Wang.It Fn dwarf_get_arange 1962de3b87aSKai WangSearch for an address range descriptor covering an address. 1972de3b87aSKai Wang.It Fn dwarf_get_arange_cu_header_offset 1982de3b87aSKai WangRetrieve the offsets associated with an address range descriptor. 1992de3b87aSKai Wang.It Fn dwarf_get_arange_info 2002de3b87aSKai WangExtract address range information from a descriptor. 2012de3b87aSKai Wang.It Fn dwarf_get_aranges 2022de3b87aSKai WangRetrieve program address space mappings. 2032de3b87aSKai Wang.It Fn dwarf_get_cu_die_offset 2042de3b87aSKai WangRetrieve the offset associated with a compilation unit for an address 2052de3b87aSKai Wangrange descriptor. 2062de3b87aSKai Wang.It Fn dwarf_get_ranges , Fn dwarf_get_ranges_a 2072de3b87aSKai WangRetrieve information about non-contiguous address ranges for 2082de3b87aSKai Wanga debugging information entry. 2092de3b87aSKai Wang.El 2102de3b87aSKai Wang.It Attributes 2112de3b87aSKai Wang.Bl -tag -compact 2122de3b87aSKai Wang.It Fn dwarf_arrayorder 2132de3b87aSKai WangRetrieve the value of a 2142de3b87aSKai Wang.Dv DW_AT_ordering 2152de3b87aSKai Wangattribute. 2162de3b87aSKai Wang.It Fn dwarf_attr 2172de3b87aSKai WangRetrieve an attribute descriptor. 2182de3b87aSKai Wang.It Fn dwarf_attrlist 2192de3b87aSKai WangRetrieve attribute descriptors for a debugging information entry. 220cf781b2eSEd Maste.It Fn dwarf_attroffset 221cf781b2eSEd MasteRetrieve the section-relative offset of an attribute descriptor. 2222de3b87aSKai Wang.It Fn dwarf_attrval_flag 2232de3b87aSKai WangRetrieve a 2242de3b87aSKai Wang.Dv DW_AT_FORM_flag 2252de3b87aSKai Wangvalue. 2262de3b87aSKai Wang.It Fn dwarf_attrval_signed 2272de3b87aSKai WangRetrieve an attribute's value as a signed integral quantity. 2282de3b87aSKai Wang.It Fn dwarf_attrval_string 2292de3b87aSKai WangRetrieve an attribute's value as a NUL-terminated string. 2302de3b87aSKai Wang.It Fn dwarf_attrval_unsigned 2312de3b87aSKai WangRetrieve an attribute's value as an unsigned integral quantity. 2322de3b87aSKai Wang.It Fn dwarf_bitoffset , 2332de3b87aSKai WangRetrieve the value of a 2342de3b87aSKai Wang.Dv DW_AT_bit_offset 2352de3b87aSKai Wangattribute. 2362de3b87aSKai Wang.It Fn dwarf_bitsize , 2372de3b87aSKai WangRetrieve the value of a 2382de3b87aSKai Wang.Dv DW_AT_bit_size 2392de3b87aSKai Wangattribute. 2402de3b87aSKai Wang.It Fn dwarf_bytesize 2412de3b87aSKai WangRetrieve the value of a 2422de3b87aSKai Wang.Dv DW_AT_byte_size 2432de3b87aSKai Wangattribute. 2442de3b87aSKai Wang.It Fn dwarf_formaddr 2452de3b87aSKai WangReturn the value of an 2462de3b87aSKai Wang.Dv ADDRESS Ns - Ns 2472de3b87aSKai Wangclass attribute. 2482de3b87aSKai Wang.It Fn dwarf_formblock 2492de3b87aSKai WangReturn the value of a 2502de3b87aSKai Wang.Dv BLOCK Ns - Ns 2512de3b87aSKai Wangclass attribute 2522de3b87aSKai Wang.It Fn dwarf_formexprloc 2532de3b87aSKai WangReturn information about a location expression. 2542de3b87aSKai Wang.It Fn dwarf_formflag 2552de3b87aSKai WangRetrieve information about a 2562de3b87aSKai Wang.Dv BOOLEAN Ns - Ns 2572de3b87aSKai Wangclass attribute. 2582de3b87aSKai Wang.It Fn dwarf_formref , Fn dwarf_global_formref 2592de3b87aSKai WangRetrieve offsets for 2602de3b87aSKai Wang.Dv REFERENCE Ns - Ns 2612de3b87aSKai Wangclass attributes. 2622de3b87aSKai Wang.It Fn dwarf_formsdata , Fn dwarf_formudata 2632de3b87aSKai WangRetrieve the value of a 2642de3b87aSKai Wang.Dv CONSTANT Ns - Ns 2652de3b87aSKai Wangclass attribute. 2662de3b87aSKai Wang.It Fn dwarf_formsig8 2672de3b87aSKai WangReturn the type signature for a DWARF type. 2682de3b87aSKai Wang.It Fn dwarf_formstring 2692de3b87aSKai WangRetrieve information about a 2702de3b87aSKai Wang.Dv STRING Ns - Ns 2712de3b87aSKai Wangclass attribute. 2722de3b87aSKai Wang.It Fn dwarf_get_form_class 2732de3b87aSKai WangRetrieve the form class for an attribute. 2742de3b87aSKai Wang.It Fn dwarf_hasattr 2752de3b87aSKai WangCheck for the presence of an attribute. 2762de3b87aSKai Wang.It Fn dwarf_hasform 2772de3b87aSKai WangCheck if an attribute has the given form. 2782de3b87aSKai Wang.It Fn dwarf_whatattr 2792de3b87aSKai WangRetrieve the attribute code for an attribute. 2802de3b87aSKai Wang.It Fn dwarf_whatform , Fn dwarf_whatform_direct 2812de3b87aSKai WangRetrieve the form of an attribute. 2822de3b87aSKai Wang.El 2832de3b87aSKai Wang.It Call Information Entries and Frame Descriptor Entries 2842de3b87aSKai Wang.Bl -tag -compact 2852de3b87aSKai Wang.It Fn dwarf_get_cie_index 2862de3b87aSKai WangRetrieve the index for a CIE descriptor. 2872de3b87aSKai Wang.It Fn dwarf_get_cie_info 2882de3b87aSKai WangRetrieve information from a CIE descriptor. 2892de3b87aSKai Wang.It Fn dwarf_get_cie_of_fde 2902de3b87aSKai WangRetrieve a CIE descriptor. 2912de3b87aSKai Wang.It Fn dwarf_get_fde_at_pc 2922de3b87aSKai WangRetrieve an FDE descriptor for an address. 2932de3b87aSKai Wang.It Fn dwarf_get_fde_info_for_all_regs 2942de3b87aSKai WangRetrieve register rule row. 2952de3b87aSKai Wang.It Fn dwarf_get_fde_info_for_all_regs3 2962de3b87aSKai WangRetrieve register rule row (revised API). 2972de3b87aSKai Wang.It Fn dwarf_get_fde_info_for_cfa_reg3 2982de3b87aSKai WangRetrieve a CFA register rule. 2992de3b87aSKai Wang.It Fn dwarf_get_fde_info_for_reg 3002de3b87aSKai WangRetrieve a register rule. 3012de3b87aSKai Wang.It Fn dwarf_get_fde_info_for_reg3 3022de3b87aSKai WangRetrieve a register rule (revised API). 3032de3b87aSKai Wang.It Fn dwarf_get_fde_instr_bytes 3042de3b87aSKai WangRetrieve instructions from an FDE descriptor. 3052de3b87aSKai Wang.It Fn dwarf_get_fde_list , Fn dwarf_get_fde_list_eh 3062de3b87aSKai WangRetrieve frame information. 3072de3b87aSKai Wang.It Fn dwarf_get_fde_n 3082de3b87aSKai WangRetrieve an FDE descriptor. 3092de3b87aSKai Wang.It Fn dwarf_get_fde_range 3102de3b87aSKai WangRetrieve range information from an FDE descriptor. 3112de3b87aSKai Wang.El 3122de3b87aSKai Wang.It Compilation Units 3132de3b87aSKai Wang.Bl -tag -compact 314cf781b2eSEd Maste.It Xo 315cf781b2eSEd Maste.Fn dwarf_get_cu_die_offset_given_cu_header_offset , 316cf781b2eSEd Maste.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b 317cf781b2eSEd Maste.Xc 3182de3b87aSKai WangRetrieve the offset of the debugging information entry for a 319cf781b2eSEd Mastecompilation or type unit. 320cf781b2eSEd Maste.It Xo 321cf781b2eSEd Maste.Fn dwarf_next_cu_header , 322cf781b2eSEd Maste.Fn dwarf_next_cu_header_b , 323cf781b2eSEd Maste.Fn dwarf_next_cu_header_c 324cf781b2eSEd Maste.Xc 3252de3b87aSKai WangStep through compilation units in a debug context. 3262de3b87aSKai Wang.El 3272de3b87aSKai Wang.It Debugging Information Entries 3282de3b87aSKai Wang.Bl -tag -compact 3292de3b87aSKai Wang.It Fn dwarf_child 3302de3b87aSKai WangReturns the child of a debugging information entry. 3312de3b87aSKai Wang.It Fn dwarf_die_abbrev_code 3322de3b87aSKai WangReturns the abbreviation code for a debugging information entry. 3332de3b87aSKai Wang.It Fn dwarf_die_CU_offset , Fn dwarf_die_CU_offset_range 3342de3b87aSKai WangRetrieve offsets and lengths for a compilation unit. 3352de3b87aSKai Wang.It Fn dwarf_diename 3362de3b87aSKai WangReturns the 3372de3b87aSKai Wang.Dv DW_AT_name 3382de3b87aSKai Wangattribute for a debugging information entry. 3392de3b87aSKai Wang.It Fn dwarf_dieoffset 3402de3b87aSKai WangRetrieves the offset for a debugging information entry. 341cf781b2eSEd Maste.It Fn dwarf_get_die_infotypes_flag 342cf781b2eSEd MasteIndicate the originating section for a debugging information entry. 343cf781b2eSEd Maste.It Fn dwarf_highpc , Fn dwarf_highpc_b 3442de3b87aSKai WangReturn the highest PC value for a debugging information entry. 3452de3b87aSKai Wang.It Fn dwarf_lowpc 3462de3b87aSKai WangReturn the lowest PC value for a debugging information entry. 347cf781b2eSEd Maste.It Fn dwarf_offdie , Fn dwarf_offdie_b 3482de3b87aSKai WangRetrieve a debugging information entry given an offset. 349cf781b2eSEd Maste.It Fn dwarf_siblingof , Fn dwarf_siblingof_b 3502de3b87aSKai WangRetrieve the sibling descriptor for a debugging information entry. 3512de3b87aSKai Wang.It Fn dwarf_srclang 352*b00fe64fSEd MasteRetrieve the source language attribute for a debugging information 3532de3b87aSKai Wangentry. 3542de3b87aSKai Wang.It Fn dwarf_tag 3552de3b87aSKai WangRetrieve the tag for a debugging information entry. 3562de3b87aSKai Wang.El 3572de3b87aSKai Wang.It Functions 3582de3b87aSKai Wang.Bl -tag -compact 3592de3b87aSKai Wang.It Fn dwarf_func_cu_offset 3602de3b87aSKai WangRetrieves the offset for the compilation unit for a function. 3612de3b87aSKai Wang.It Fn dwarf_func_die_offset 3622de3b87aSKai WangRetrieves the offset for the debugging information entry for a 3632de3b87aSKai Wangfunction. 3642de3b87aSKai Wang.It Fn dwarf_funcname 3652de3b87aSKai WangRetrieves the name of a function. 3662de3b87aSKai Wang.It Fn dwarf_func_name_offsets 3672de3b87aSKai WangRetrieve both the name and offsets for a function. 3682de3b87aSKai Wang.It Fn dwarf_get_funcs 3692de3b87aSKai WangRetrieve information about static functions. 3702de3b87aSKai Wang.El 3712de3b87aSKai Wang.It Globals 3722de3b87aSKai Wang.Bl -tag -compact 3732de3b87aSKai Wang.It Fn dwarf_get_globals 3742de3b87aSKai WangRetrieve a list of globals. 3752de3b87aSKai Wang.It Fn dwarf_global_cu_offset 3762de3b87aSKai WangReturn the offset for compilation unit for a global. 3772de3b87aSKai Wang.It Fn dwarf_global_die_offset 3782de3b87aSKai WangReturn the offset for the debugging information entry for a global. 3792de3b87aSKai Wang.It Fn dwarf_global_name_offsets 3802de3b87aSKai WangReturn the name and offsets for a global. 3812de3b87aSKai Wang.It Fn dwarf_globname 3822de3b87aSKai WangReturn the name for a global. 3832de3b87aSKai Wang.El 3842de3b87aSKai Wang.It Initialization and Finalization 3852de3b87aSKai WangFunctions 3862de3b87aSKai Wang.Fn dwarf_elf_init 3872de3b87aSKai Wangand 3882de3b87aSKai Wang.Fn dwarf_init 3892de3b87aSKai Wangmay be used for initialization. 3902de3b87aSKai WangThe function 3912de3b87aSKai Wang.Fn dwarf_finish 3922de3b87aSKai Wangmay be used to release resources. 3932de3b87aSKai Wang.Pp 3942de3b87aSKai WangThe functions 3952de3b87aSKai Wang.Fn dwarf_object_init 3962de3b87aSKai Wangand 3972de3b87aSKai Wang.Fn dwarf_object_finish 3982de3b87aSKai Wangallow an application to specify alternate low-level file access 3992de3b87aSKai Wangroutines. 4002de3b87aSKai Wang.It Line Numbers 4012de3b87aSKai Wang.Bl -tag -compact 4022de3b87aSKai Wang.It Fn dwarf_lineaddr 4032de3b87aSKai WangRetrieve the program address for a source line. 4042de3b87aSKai Wang.It Fn dwarf_linebeginstatement 4052de3b87aSKai WangCheck if a source line corresponds to the beginning of a statement. 4062de3b87aSKai Wang.It Fn dwarf_lineblock 4072de3b87aSKai WangCheck if a source line corresponds to the start of a basic block. 4082de3b87aSKai Wang.It Fn dwarf_lineendsequence 4092de3b87aSKai WangCheck if the source line corresponds to the end of a sequence of 4102de3b87aSKai Wanginstructions. 4112de3b87aSKai Wang.It Fn dwarf_lineno 4122de3b87aSKai WangRetrieve the line number for a line descriptor. 4132de3b87aSKai Wang.It Fn dwarf_lineoff 4142de3b87aSKai WangRetrieve the column number for a line descriptor. 4152de3b87aSKai Wang.It Fn dwarf_linesrc 4162de3b87aSKai WangRetrieve the source file for a line descriptor. 4172de3b87aSKai Wang.It Fn dwarf_line_srcfileno 4182de3b87aSKai WangRetrieve the index of the source file for a line descriptor. 4192de3b87aSKai Wang.It Fn dwarf_srcfiles 4202de3b87aSKai WangRetrieve source files for a compilation unit. 4212de3b87aSKai Wang.It Fn dwarf_srclines 4222de3b87aSKai WangReturn line number information for a compilation unit. 4232de3b87aSKai Wang.El 4242de3b87aSKai Wang.It Location Lists 4252de3b87aSKai Wang.Bl -tag -compact 4262de3b87aSKai Wang.It Fn dwarf_get_loclist_entry 4272de3b87aSKai WangRetrieve a location list entry. 4282de3b87aSKai Wang.It Fn dwarf_loclist , Fn dwarf_loclist_n 4292de3b87aSKai WangRetrieve location expressions. 430cf781b2eSEd Maste.It Xo 431cf781b2eSEd Maste.Fn dwarf_loclist_from_expr , 432cf781b2eSEd Maste.Fn dwarf_loclist_from_expr_a , 433cf781b2eSEd Maste.Fn dwarf_loclist_from_expr_b 434cf781b2eSEd Maste.Xc 4352de3b87aSKai WangTranslate a location expression into a location descriptor. 4362de3b87aSKai Wang.El 4372de3b87aSKai Wang.It Error Handling 4382de3b87aSKai Wang.Bl -tag -compact 4392de3b87aSKai Wang.It Fn dwarf_errmsg 4402de3b87aSKai WangRetrieve a human-readable error message. 4412de3b87aSKai Wang.It Fn dwarf_errno 4422de3b87aSKai WangRetrieve an error number from an error descriptor. 4432de3b87aSKai Wang.It Fn dwarf_seterrarg 4442de3b87aSKai WangSet the argument passed to a callback error handler. 4452de3b87aSKai Wang.It Fn dwarf_seterrhand 4462de3b87aSKai WangSet the callback handler to be called in case of an error. 4472de3b87aSKai Wang.El 4482de3b87aSKai Wang.It Frame Handling 4492de3b87aSKai Wang.Bl -tag -compact 4502de3b87aSKai Wang.It Fn dwarf_expand_frame_instructions 4512de3b87aSKai WangTranslate frame instruction bytes. 4522de3b87aSKai Wang.It Fn dwarf_set_frame_cfa_value 4532de3b87aSKai WangSet the CFA parameter for the internal register rule table. 4542de3b87aSKai Wang.It Fn dwarf_set_frame_rule_initial_value 4552de3b87aSKai WangSet the initial value of the register rules in the internal register 4562de3b87aSKai Wangrule table. 4572de3b87aSKai Wang.It Fn dwarf_set_frame_rule_table_size 4582de3b87aSKai WangSet the maximum number of columns in the register rule table. 4592de3b87aSKai Wang.It Fn dwarf_set_frame_same_value 4602de3b87aSKai WangSet the register number representing the 4612de3b87aSKai Wang.Dq "same value" 4622de3b87aSKai Wangrule. 4632de3b87aSKai Wang.It Fn dwarf_set_frame_undefined_value 4642de3b87aSKai WangSet the register number representing the 4652de3b87aSKai Wang.Dq "undefined" 4662de3b87aSKai Wangrule. 4672de3b87aSKai Wang.El 4682de3b87aSKai Wang.It Macros 4692de3b87aSKai Wang.Bl -tag -compact 4702de3b87aSKai Wang.It Fn dwarf_find_macro_value_start 4712de3b87aSKai WangReturn the macro value part of a macro string. 4722de3b87aSKai Wang.It Fn dwarf_get_macro_details 4732de3b87aSKai WangRetrieve macro information. 4742de3b87aSKai Wang.El 4752de3b87aSKai Wang.It Memory Management 4762de3b87aSKai WangIn the DWARF consumer API, the rules for memory management differ 4772de3b87aSKai Wangbetween functions. 4782de3b87aSKai WangIn some cases, the memory areas returned to the application by the 4792de3b87aSKai Wanglibrary are freed by calling specific API functions. 4802de3b87aSKai WangIn others, the deallocation function 4812de3b87aSKai Wang.Fn dwarf_dealloc 4822de3b87aSKai Wangsuffices. 4832de3b87aSKai WangThe individual manual pages for the API's functions document the 4842de3b87aSKai Wangspecific memory management rules to be followed. 4852de3b87aSKai Wang.Pp 4862de3b87aSKai WangThe function 4872de3b87aSKai Wang.Fn dwarf_dealloc 4882de3b87aSKai Wangis used to mark memory arenas as unused. 4892de3b87aSKai WangAdditionally, the following functions release specific types of 4902de3b87aSKai WangDWARF resources: 4912de3b87aSKai Wang.Fn dwarf_fde_cie_list_dealloc , 4922de3b87aSKai Wang.Fn dwarf_funcs_dealloc , 4932de3b87aSKai Wang.Fn dwarf_globals_dealloc , 4942de3b87aSKai Wang.Fn dwarf_pubtypes_dealloc , 4952de3b87aSKai Wang.Fn dwarf_ranges_dealloc , 4962de3b87aSKai Wang.Fn dwarf_srclines_dealloc , 4972de3b87aSKai Wang.Fn dwarf_types_dealloc , 4982de3b87aSKai Wang.Fn dwarf_vars_dealloc , 4992de3b87aSKai Wangand 5002de3b87aSKai Wang.Fn dwarf_weaks_dealloc . 5012de3b87aSKai Wang.It Symbol Constants 5022de3b87aSKai WangThe following functions may be used to return symbolic names 5032de3b87aSKai Wangfor DWARF constants: 5042de3b87aSKai Wang.Fn dwarf_get_ACCESS_name , 5052de3b87aSKai Wang.Fn dwarf_get_AT_name , 5062de3b87aSKai Wang.Fn dwarf_get_ATE_name , 5072de3b87aSKai Wang.Fn dwarf_get_CC_name , 5082de3b87aSKai Wang.Fn dwarf_get_CFA_name , 5092de3b87aSKai Wang.Fn dwarf_get_CHILDREN_name , 5102de3b87aSKai Wang.Fn dwarf_get_DS_name , 5112de3b87aSKai Wang.Fn dwarf_get_DSC_name , 5122de3b87aSKai Wang.Fn dwarf_get_EH_name , 5132de3b87aSKai Wang.Fn dwarf_get_END_name , 5142de3b87aSKai Wang.Fn dwarf_get_FORM_name , 5152de3b87aSKai Wang.Fn dwarf_get_ID_name , 5162de3b87aSKai Wang.Fn dwarf_get_INL_name , 5172de3b87aSKai Wang.Fn dwarf_get_LANG_name , 5182de3b87aSKai Wang.Fn dwarf_get_LNE_name , 5192de3b87aSKai Wang.Fn dwarf_get_LNS_name , 5202de3b87aSKai Wang.Fn dwarf_get_MACINFO_name , 5212de3b87aSKai Wang.Fn dwarf_get_OP_name , 5222de3b87aSKai Wang.Fn dwarf_get_ORD_name , 5232de3b87aSKai Wang.Fn dwarf_get_TAG_name , 5242de3b87aSKai Wang.Fn dwarf_get_VIRTUALITY_name , 5252de3b87aSKai Wangand 5262de3b87aSKai Wang.Fn dwarf_get_VIS_name . 5272de3b87aSKai Wang.It Types 5282de3b87aSKai Wang.Bl -tag -compact 5292de3b87aSKai Wang.It Fn dwarf_get_pubtypes , Fn dwarf_get_types 5302de3b87aSKai WangRetrieve descriptors for user-defined types. 531cf781b2eSEd Maste.It Fn dwarf_next_types_section 532cf781b2eSEd MasteStep through 533cf781b2eSEd Maste.Dq \&.debug_types 534cf781b2eSEd Mastesections in a debug context. 5352de3b87aSKai Wang.It Fn dwarf_pubtype_cu_offset , Fn dwarf_type_cu_offset 5362de3b87aSKai WangReturn the offset for the compilation unit for a type. 5372de3b87aSKai Wang.It Fn dwarf_pubtype_die_offset , Fn dwarf_type_die_offset 5382de3b87aSKai WangReturn the offset for the debugging information entry for a type. 5392de3b87aSKai Wang.It Fn dwarf_pubtypename , Fn dwarf_typename 5402de3b87aSKai WangRetrieve the name of a type. 5412de3b87aSKai Wang.It Fn dwarf_pubtype_name_offsets , Fn dwarf_type_name_offsets 5422de3b87aSKai WangRetrieve the name and offsets for a type. 5432de3b87aSKai Wang.El 5442de3b87aSKai Wang.It Variables 5452de3b87aSKai Wang.Bl -tag -compact 5462de3b87aSKai Wang.It Fn dwarf_get_vars 5472de3b87aSKai WangRetrieve descriptors for static variables. 5482de3b87aSKai Wang.It Fn dwarf_var_cu_offset 5492de3b87aSKai WangReturn the offset for the compilation unit for a variable. 5502de3b87aSKai Wang.It Fn dwarf_var_die_offset 5512de3b87aSKai WangReturn the offset for the debugging information entry for a variable. 5522de3b87aSKai Wang.It Fn dwarf_varname 5532de3b87aSKai WangRetrieve the name of a variable. 5542de3b87aSKai Wang.It Fn dwarf_var_name_offsets 5552de3b87aSKai WangRetrieve the name and offsets for a variable. 5562de3b87aSKai Wang.El 5572de3b87aSKai Wang.It Weak Symbols 5582de3b87aSKai Wang.Bl -tag -compact 5592de3b87aSKai Wang.It Fn dwarf_get_weaks 5602de3b87aSKai WangRetrieve information about weak symbols. 5612de3b87aSKai Wang.It Fn dwarf_weak_cu_offset 5622de3b87aSKai WangReturn the offset for the compilation unit for a weak symbol. 5632de3b87aSKai Wang.It Fn dwarf_weak_die_offset 5642de3b87aSKai WangReturn the offset for the debugging information entry for a weak symbol. 5652de3b87aSKai Wang.It Fn dwarf_weakname 5662de3b87aSKai WangRetrieve the name of a weak symbol. 5672de3b87aSKai Wang.It Fn dwarf_weak_name_offsets 5682de3b87aSKai WangRetrieve the name and offsets for a weak symbol. 5692de3b87aSKai Wang.El 5702de3b87aSKai Wang.It Miscellaneous 5712de3b87aSKai Wang.Bl -tag -compact 5722de3b87aSKai Wang.It Fn dwarf_get_elf 5732de3b87aSKai WangRetrieve the ELF descriptor for a debug context, see 5742de3b87aSKai Wang.Xr elf 3 . 5752de3b87aSKai Wang.It Fn dwarf_get_str 5762de3b87aSKai WangRetrieve a NUL-terminated string from the DWARF string section. 5772de3b87aSKai Wang.It Fn dwarf_set_reloc_application 5782de3b87aSKai WangControl whether relocations are to be handled by 5792de3b87aSKai Wang.Lb libdwarf . 5802de3b87aSKai Wang.El 5812de3b87aSKai Wang.El 5822de3b87aSKai Wang.Sh The DWARF Producer API 5832de3b87aSKai WangThe DWARF producer API permits applications to add DWARF information to 5842de3b87aSKai Wangan object file. 5852de3b87aSKai Wang.Pp 5862de3b87aSKai WangThe major functional groups of functions in the producer API are listed 5872de3b87aSKai Wangbelow. 5882de3b87aSKai Wang.Bl -tag -width "CCCC" 5892de3b87aSKai Wang.It Attribute Management 5902de3b87aSKai WangThe following functions are used to attach attributes to a debugging 5912de3b87aSKai Wanginformation entry: 5922de3b87aSKai Wang.Fn dwarf_add_AT_comp_dir , 5932de3b87aSKai Wang.Fn dwarf_add_AT_const_value_signedint , 5942de3b87aSKai Wang.Fn dwarf_add_AT_const_value_string , 5952de3b87aSKai Wang.Fn dwarf_add_AT_const_value_unsignedint , 5962de3b87aSKai Wang.Fn dwarf_add_AT_dataref , 5972de3b87aSKai Wang.Fn dwarf_add_AT_flag , 5982de3b87aSKai Wang.Fn dwarf_add_AT_location_expr , 5992de3b87aSKai Wang.Fn dwarf_add_AT_name , 6002de3b87aSKai Wang.Fn dwarf_add_AT_producer , 6012de3b87aSKai Wang.Fn dwarf_add_AT_ref_address , 6022de3b87aSKai Wang.Fn dwarf_add_AT_reference , 6032de3b87aSKai Wang.Fn dwarf_add_AT_signed_const , 6042de3b87aSKai Wang.Fn dwarf_add_AT_string , 6052de3b87aSKai Wang.Fn dwarf_add_AT_targ_address , 6062de3b87aSKai Wang.Fn dwarf_add_AT_targ_address_b 6072de3b87aSKai Wangand 6082de3b87aSKai Wang.Fn dwarf_add_AT_unsigned_const . 6092de3b87aSKai Wang.It Debugging Information Entry Management 6102de3b87aSKai Wang.Bl -tag -compact 6112de3b87aSKai Wang.It Fn dwarf_add_die_to_debug 6122de3b87aSKai WangSet the root debugging information entry for a DWARF producer instance. 6132de3b87aSKai Wang.It Fn dwarf_die_link 6142de3b87aSKai WangLinks debugging information entries. 6152de3b87aSKai Wang.It Fn dwarf_new_die 6162de3b87aSKai WangAllocate a new debugging information entry. 6172de3b87aSKai Wang.El 6182de3b87aSKai Wang.It Initialization and Finalization 6192de3b87aSKai WangThe functions 6202de3b87aSKai Wang.Fn dwarf_producer_init 6212de3b87aSKai Wangand 6222de3b87aSKai Wang.Fn dwarf_producer_init_b 6232de3b87aSKai Wangare used to initialize a producer instance. 6242de3b87aSKai Wang.Pp 6252de3b87aSKai WangWhen done, applications release resources using the function 6262de3b87aSKai Wang.Fn dwarf_producer_finish . 6272de3b87aSKai Wang.It Relocations and Sections 6282de3b87aSKai Wang.Bl -tag -compact 6292de3b87aSKai Wang.It Fn dwarf_get_relocation_info 6302de3b87aSKai WangRetrieve a relocation array from a producer instance. 6312de3b87aSKai Wang.It Fn dwarf_get_relocation_info_count 6322de3b87aSKai WangReturn the number of relocation arrays for a producer instance. 6332de3b87aSKai Wang.It Fn dwarf_get_section_bytes 6342de3b87aSKai WangRetrieve the ELF byte stream for a section. 6352de3b87aSKai Wang.It Fn dwarf_reset_section_bytes 6362de3b87aSKai WangReset internal state for a producer instance. 6372de3b87aSKai Wang.It Fn dwarf_transform_to_disk_form 6382de3b87aSKai WangPrepare byte streams for writing out. 6392de3b87aSKai Wang.El 6402de3b87aSKai Wang.It Macros 6412de3b87aSKai Wang.Bl -tag -compact 6422de3b87aSKai Wang.It Fn dwarf_def_macro 6432de3b87aSKai WangAdd a macro definition. 6442de3b87aSKai Wang.It Fn dwarf_end_macro_file , Fn dwarf_start_macro_file 6452de3b87aSKai WangRecord macro file related information. 6462de3b87aSKai Wang.It Fn dwarf_undef_macro 6472de3b87aSKai WangNote the removal of a macro definition. 6482de3b87aSKai Wang.It Fn dwarf_vendor_ext 6492de3b87aSKai WangEnables storing macro information as specified in the DWARF standard. 6502de3b87aSKai Wang.El 6512de3b87aSKai Wang.It Symbols, Expressions, Addresses and Offsets 6522de3b87aSKai Wang.Bl -tag -compact 6532de3b87aSKai Wang.It Fn dwarf_add_arange , Fn dwarf_add_arange_b 6542de3b87aSKai WangAdd address range information. 6552de3b87aSKai Wang.It Fn dwarf_add_directory_decl 6562de3b87aSKai WangAdd information about an include directory to a producer instance. 6572de3b87aSKai Wang.It Fn dwarf_add_fde_inst 6582de3b87aSKai WangAdd an operation to a frame descriptor entry. 6592de3b87aSKai Wang.It Fn dwarf_add_file_decl 6602de3b87aSKai WangAdd information about a source file to a producer instance. 6612de3b87aSKai Wang.It Fn dwarf_add_frame_cie 6622de3b87aSKai WangAdd call information to a frame descriptor. 6632de3b87aSKai Wang.It Fn dwarf_add_frame_fde , Fn dwarf_add_frame_fde_b 6642de3b87aSKai WangLink a frame descriptor to a producer instance. 6652de3b87aSKai Wang.It Fn dwarf_add_funcname 6662de3b87aSKai WangAdd information about a function to a producer instance. 6672de3b87aSKai Wang.It Fn dwarf_add_line_entry 6682de3b87aSKai WangRecord mapping information between machine addresses and a source line. 6692de3b87aSKai Wang.It Fn dwarf_add_expr_addr , Fn dwarf_add_expr_addr_b 6702de3b87aSKai WangAdd a 6712de3b87aSKai Wang.Dv DW_OP_addr 6722de3b87aSKai Wangopcode to a location expression. 6732de3b87aSKai Wang.It Fn dwarf_add_expr_gen 6742de3b87aSKai WangAdd an operator to a location expression. 6752de3b87aSKai Wang.It Fn dwarf_add_pubname 6762de3b87aSKai WangAdd information about a global name to a producer instance. 6772de3b87aSKai Wang.It Fn dwarf_add_typename 6782de3b87aSKai WangAdd information about a type to a producer instance. 6792de3b87aSKai Wang.It Fn dwarf_add_varname 6802de3b87aSKai WangAdd information about a static variable to a producer instance. 6812de3b87aSKai Wang.It Fn dwarf_add_weakname 6822de3b87aSKai WangAdd information about a weak symbol to a producer instance. 6832de3b87aSKai Wang.It Fn dwarf_expr_current_offset 6842de3b87aSKai WangRetrieve the current size of a location expression. 6852de3b87aSKai Wang.It Fn dwarf_expr_into_block 6862de3b87aSKai WangConvert a location expression into a byte stream. 6872de3b87aSKai Wang.It Fn dwarf_fde_cfa_offset 6882de3b87aSKai WangAppend a 6892de3b87aSKai Wang.Dv DW_CFA_offset 6902de3b87aSKai Wangoperation to a frame descriptor. 6912de3b87aSKai Wang.It Fn dwarf_lne_end_sequence , Fn dwarf_lne_set_address 6922de3b87aSKai WangNote address ranges for source lines. 6932de3b87aSKai Wang.It Fn dwarf_new_expr 6942de3b87aSKai WangAllocate a location expression descriptor. 6952de3b87aSKai Wang.It Fn dwarf_new_fde 6962de3b87aSKai WangAllocate a frame descriptor. 6972de3b87aSKai Wang.El 6982de3b87aSKai Wang.It Miscellaneous 6992de3b87aSKai WangThe function 7002de3b87aSKai Wang.Fn dwarf_producer_set_isa 7012de3b87aSKai Wangsets the instruction set architecture for the producer instance. 7022de3b87aSKai Wang.El 7032de3b87aSKai Wang.Sh COMPATIBILITY 7042de3b87aSKai WangThis implementation is believed to be source compatible with the 7052de3b87aSKai WangSGI/GNU DWARF(3) library, version 20110113. 7062de3b87aSKai Wang.Pp 7072de3b87aSKai WangKnown differences with the SGI/GNU library include: 7082de3b87aSKai Wang.Bl -bullet -compact 7092de3b87aSKai Wang.It 7102de3b87aSKai WangThe memory management scheme used differs, in a backward-compatible 7112de3b87aSKai Wangway. 7122de3b87aSKai WangSee 7132de3b87aSKai Wang.Sx Memory Management 7142de3b87aSKai Wangabove, for coding guidelines for portable applications. 7152de3b87aSKai Wang.It 7162de3b87aSKai WangThere is provision for setting a library-wide error handler in 7172de3b87aSKai Wangaddition to the per-debug context handlers supported by the SGI/GNU 7182de3b87aSKai WangAPI, see the subsection 7192de3b87aSKai Wang.Sx Error Handling 7202de3b87aSKai Wangabove. 721cf781b2eSEd Maste.El 722cf781b2eSEd Maste.Ss Extensions 723cf781b2eSEd MasteThe following APIs are extensions specific to this implementation: 724cf781b2eSEd Maste.Bl -bullet -compact 7252de3b87aSKai Wang.It 726cf781b2eSEd Maste.Fn dwarf_attroffset 727cf781b2eSEd Maste.It 728cf781b2eSEd Maste.Fn dwarf_next_types_section 729cf781b2eSEd Maste.It 730cf781b2eSEd Maste.Fn dwarf_producer_set_isa 7312de3b87aSKai Wang.El 7322de3b87aSKai Wang.Sh SEE ALSO 7332de3b87aSKai Wang.Xr elf 3 7342de3b87aSKai Wang.Sh STANDARDS 7352de3b87aSKai WangThe DWARF standard is defined by 7362de3b87aSKai Wang.Rs 7372de3b87aSKai Wang.%T "The DWARF Debugging Information Format" 7382de3b87aSKai Wang.%V "Version 4" 7392de3b87aSKai Wang.%O "http://www.dwarfstd.org/" 7402de3b87aSKai Wang.Re 7412de3b87aSKai Wang.Sh HISTORY 7422de3b87aSKai WangThe DWARF(3) API originated at Silicon Graphics Inc. 7432de3b87aSKai Wang.Pp 7442de3b87aSKai WangA BSD-licensed implementation of a subset of the API was written by 745*b00fe64fSEd Maste.An John Birrell Aq Mt jb@FreeBSD.org 7462de3b87aSKai Wangfor the FreeBSD project. 7472de3b87aSKai WangThe implementation was subsequently revised and completed by 748*b00fe64fSEd Maste.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net . 7492de3b87aSKai Wang.Pp 7502de3b87aSKai WangManual pages for this implementation were written by 751*b00fe64fSEd Maste.An Joseph Koshy Aq Mt jkoshy@users.sourceforge.net 7522de3b87aSKai Wangand 753*b00fe64fSEd Maste.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net . 754