1*0a6a1f1dSLionel Sambuc.\" $NetBSD: dwarf_attrlist.3,v 1.2 2014/03/09 16:58:03 christos Exp $ 2*0a6a1f1dSLionel Sambuc.\" 3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 2010 Kai Wang 4*0a6a1f1dSLionel Sambuc.\" All rights reserved. 5*0a6a1f1dSLionel Sambuc.\" 6*0a6a1f1dSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 7*0a6a1f1dSLionel Sambuc.\" modification, are permitted provided that the following conditions 8*0a6a1f1dSLionel Sambuc.\" are met: 9*0a6a1f1dSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 10*0a6a1f1dSLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 11*0a6a1f1dSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 12*0a6a1f1dSLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 13*0a6a1f1dSLionel Sambuc.\" documentation and/or other materials provided with the distribution. 14*0a6a1f1dSLionel Sambuc.\" 15*0a6a1f1dSLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*0a6a1f1dSLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*0a6a1f1dSLionel Sambuc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*0a6a1f1dSLionel Sambuc.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*0a6a1f1dSLionel Sambuc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*0a6a1f1dSLionel Sambuc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*0a6a1f1dSLionel Sambuc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*0a6a1f1dSLionel Sambuc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*0a6a1f1dSLionel Sambuc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*0a6a1f1dSLionel Sambuc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*0a6a1f1dSLionel Sambuc.\" SUCH DAMAGE. 26*0a6a1f1dSLionel Sambuc.\" 27*0a6a1f1dSLionel Sambuc.\" Id: dwarf_attrlist.3 2122 2011-11-09 15:35:14Z jkoshy 28*0a6a1f1dSLionel Sambuc.\" 29*0a6a1f1dSLionel Sambuc.Dd November 9, 2011 30*0a6a1f1dSLionel Sambuc.Os 31*0a6a1f1dSLionel Sambuc.Dt DWARF_ATTRLIST 3 32*0a6a1f1dSLionel Sambuc.Sh NAME 33*0a6a1f1dSLionel Sambuc.Nm dwarf_attrlist 34*0a6a1f1dSLionel Sambuc.Nd retrieve DWARF attribute descriptors 35*0a6a1f1dSLionel Sambuc.Sh LIBRARY 36*0a6a1f1dSLionel Sambuc.Lb libdwarf 37*0a6a1f1dSLionel Sambuc.Sh SYNOPSIS 38*0a6a1f1dSLionel Sambuc.In libdwarf.h 39*0a6a1f1dSLionel Sambuc.Ft int 40*0a6a1f1dSLionel Sambuc.Fo dwarf_attrlist 41*0a6a1f1dSLionel Sambuc.Fa "Dwarf_Die die" 42*0a6a1f1dSLionel Sambuc.Fa "Dwarf_Attribute **attrbuf" 43*0a6a1f1dSLionel Sambuc.Fa "Dwarf_Signed *attrcount" 44*0a6a1f1dSLionel Sambuc.Fa "Dwarf_Error *err" 45*0a6a1f1dSLionel Sambuc.Fc 46*0a6a1f1dSLionel Sambuc.Sh DESCRIPTION 47*0a6a1f1dSLionel SambucFunction 48*0a6a1f1dSLionel Sambuc.Fn dwarf_attrlist 49*0a6a1f1dSLionel Sambucretrieves the DWARF attribute descriptors associated with a 50*0a6a1f1dSLionel Sambucdebugging information entry descriptor in argument 51*0a6a1f1dSLionel Sambuc.Ar die . 52*0a6a1f1dSLionel SambucThe descriptors are returned as an array of values of the opaque type 53*0a6a1f1dSLionel Sambuc.Vt Dwarf_Attribute . 54*0a6a1f1dSLionel SambucThe data associated with each returned attribute descriptor may be 55*0a6a1f1dSLionel Sambucqueried using the form query functions in the 56*0a6a1f1dSLionel Sambuc.Xr dwarf 3 57*0a6a1f1dSLionel SambucAPI set. 58*0a6a1f1dSLionel Sambuc.Pp 59*0a6a1f1dSLionel SambucArgument 60*0a6a1f1dSLionel Sambuc.Ar attrbuf 61*0a6a1f1dSLionel Sambucpoints to a location that will hold a pointer to the returned 62*0a6a1f1dSLionel Sambucarray of DWARF attribute descriptors. 63*0a6a1f1dSLionel SambucArgument 64*0a6a1f1dSLionel Sambuc.Ar attrcount 65*0a6a1f1dSLionel Sambucpoints to a location that will hold the number of descriptors in 66*0a6a1f1dSLionel Sambucthe returned array. 67*0a6a1f1dSLionel Sambuc.Pp 68*0a6a1f1dSLionel SambucIf argument 69*0a6a1f1dSLionel Sambuc.Ar err 70*0a6a1f1dSLionel Sambucis non-NULL, it is used to return an error descriptor in case of an 71*0a6a1f1dSLionel Sambucerror. 72*0a6a1f1dSLionel Sambuc.Ss Memory Management 73*0a6a1f1dSLionel SambucIn the current implementation, the memory allocated for each DWARF 74*0a6a1f1dSLionel Sambucattribute descriptor and for the returned array of descriptors is 75*0a6a1f1dSLionel Sambucmanaged by the library and the application does not need to explicitly 76*0a6a1f1dSLionel Sambucfree the returned pointers. 77*0a6a1f1dSLionel SambucHowever, for compatibility with other implementations of the 78*0a6a1f1dSLionel Sambuc.Xr dwarf 3 79*0a6a1f1dSLionel SambucAPI, the application is permitted to pass the pointers returned by to 80*0a6a1f1dSLionel Sambucthe 81*0a6a1f1dSLionel Sambuc.Fn dwarf_dealloc 82*0a6a1f1dSLionel Sambucfunction. 83*0a6a1f1dSLionel Sambuc.Sh RETURN VALUES 84*0a6a1f1dSLionel SambucFunction 85*0a6a1f1dSLionel Sambuc.Fn dwarf_attrlist 86*0a6a1f1dSLionel Sambucreturns 87*0a6a1f1dSLionel Sambuc.Dv DW_DLV_OK on success. 88*0a6a1f1dSLionel Sambuc.Pp 89*0a6a1f1dSLionel SambucIf the debugging information entry descriptor denoted by argument 90*0a6a1f1dSLionel Sambuc.Ar die 91*0a6a1f1dSLionel Sambucdoes not contain any attribute, the function returns 92*0a6a1f1dSLionel Sambuc.Dv DW_DLV_NO_ENTRY 93*0a6a1f1dSLionel Sambucand sets argument 94*0a6a1f1dSLionel Sambuc.Ar err . 95*0a6a1f1dSLionel SambucFor other errors, it returns 96*0a6a1f1dSLionel Sambuc.Dv DW_DLV_ERROR 97*0a6a1f1dSLionel Sambucand sets argument 98*0a6a1f1dSLionel Sambuc.Ar err . 99*0a6a1f1dSLionel Sambuc.Sh EXAMPLES 100*0a6a1f1dSLionel SambucTo retrieve the attribute list for a DWARF debugging information 101*0a6a1f1dSLionel Sambucentry use: 102*0a6a1f1dSLionel Sambuc.Bd -literal -offset indent 103*0a6a1f1dSLionel SambucDwarf_Die dw_die; 104*0a6a1f1dSLionel SambucDwarf_Error dw_e; 105*0a6a1f1dSLionel SambucDwarf_Unsigned dw_count; 106*0a6a1f1dSLionel SambucDwarf_Attribute *dw_attributes; 107*0a6a1f1dSLionel Sambucint error, i; 108*0a6a1f1dSLionel Sambuc 109*0a6a1f1dSLionel Sambuc\&... variable dw_die contains a reference to the DIE of interest ... 110*0a6a1f1dSLionel Sambuc 111*0a6a1f1dSLionel Sambuc/* Retrieve the attribute list from the DIE. */ 112*0a6a1f1dSLionel Sambucif ((error = dwarf_attrlist(dw_die, &dw_attributes, &dw_count, 113*0a6a1f1dSLionel Sambuc &dw_e)) != DW_DLV_OK) 114*0a6a1f1dSLionel Sambuc errx(EXIT_FAILURE, "dwarf_attrlist: %s", dwarf_errmsg(dw_e)); 115*0a6a1f1dSLionel Sambuc 116*0a6a1f1dSLionel Sambuc/* Process the attribute list. */ 117*0a6a1f1dSLionel Sambucfor (i = 0; i < dw_count; ++i) { 118*0a6a1f1dSLionel Sambuc /* Use the returned pointers in dw_attributes[i] here. */ 119*0a6a1f1dSLionel Sambuc} 120*0a6a1f1dSLionel Sambuc.Ed 121*0a6a1f1dSLionel Sambuc.Sh ERRORS 122*0a6a1f1dSLionel SambucFunction 123*0a6a1f1dSLionel Sambuc.Fn dwarf_diename 124*0a6a1f1dSLionel Sambuccan fail with the following errors: 125*0a6a1f1dSLionel Sambuc.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 126*0a6a1f1dSLionel Sambuc.It Bq Er DW_DLE_ARGUMENT 127*0a6a1f1dSLionel SambucArguments 128*0a6a1f1dSLionel Sambuc.Ar die , 129*0a6a1f1dSLionel Sambuc.Ar attrbuf , 130*0a6a1f1dSLionel Sambucor 131*0a6a1f1dSLionel Sambuc.Ar attrcount 132*0a6a1f1dSLionel Sambucwere NULL. 133*0a6a1f1dSLionel Sambuc.It Bq Er DW_DLE_NO_ENTRY 134*0a6a1f1dSLionel SambucArgument 135*0a6a1f1dSLionel Sambuc.Ar die 136*0a6a1f1dSLionel Sambuchad no attributes. 137*0a6a1f1dSLionel Sambuc.It Bq Er DW_DLE_MEMORY 138*0a6a1f1dSLionel SambucAn out of memory condition was encountered during the execution of the 139*0a6a1f1dSLionel Sambucfunction. 140*0a6a1f1dSLionel Sambuc.El 141*0a6a1f1dSLionel Sambuc.Sh SEE ALSO 142*0a6a1f1dSLionel Sambuc.Xr dwarf 3 , 143*0a6a1f1dSLionel Sambuc.Xr dwarf_attr 3 , 144*0a6a1f1dSLionel Sambuc.Xr dwarf_dealloc 3 , 145*0a6a1f1dSLionel Sambuc.Xr dwarf_hasattr 3 , 146*0a6a1f1dSLionel Sambuc.Xr dwarf_hasform 3 , 147*0a6a1f1dSLionel Sambuc.Xr dwarf_whatattr 3 , 148*0a6a1f1dSLionel Sambuc.Xr dwarf_whatform 3 149