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