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