xref: /netbsd-src/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrlist.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1*5ac3bc71Schristos.\"	$NetBSD: dwarf_attrlist.3,v 1.6 2024/03/03 17:37:30 christos Exp $
2e81373b4Schristos.\"
39dd9d0cfSchristos.\" Copyright (c) 2010 Kai Wang
49dd9d0cfSchristos.\" All rights reserved.
59dd9d0cfSchristos.\"
69dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without
79dd9d0cfSchristos.\" modification, are permitted provided that the following conditions
89dd9d0cfSchristos.\" are met:
99dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright
109dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer.
119dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
129dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer in the
139dd9d0cfSchristos.\"    documentation and/or other materials provided with the distribution.
149dd9d0cfSchristos.\"
159dd9d0cfSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
169dd9d0cfSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
179dd9d0cfSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
189dd9d0cfSchristos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199dd9d0cfSchristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
209dd9d0cfSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
219dd9d0cfSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
229dd9d0cfSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
239dd9d0cfSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249dd9d0cfSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259dd9d0cfSchristos.\" SUCH DAMAGE.
269dd9d0cfSchristos.\"
27cdbf1fe1Sjkoshy.\" Id: dwarf_attrlist.3 3964 2022-03-13 21:41:26Z jkoshy
289dd9d0cfSchristos.\"
29cdbf1fe1Sjkoshy.Dd March 13, 2022
309dd9d0cfSchristos.Dt DWARF_ATTRLIST 3
31604b0842Sjkoshy.Os
329dd9d0cfSchristos.Sh NAME
339dd9d0cfSchristos.Nm dwarf_attrlist
349dd9d0cfSchristos.Nd retrieve DWARF attribute descriptors
359dd9d0cfSchristos.Sh LIBRARY
369dd9d0cfSchristos.Lb libdwarf
379dd9d0cfSchristos.Sh SYNOPSIS
389dd9d0cfSchristos.In libdwarf.h
399dd9d0cfSchristos.Ft int
409dd9d0cfSchristos.Fo dwarf_attrlist
419dd9d0cfSchristos.Fa "Dwarf_Die die"
429dd9d0cfSchristos.Fa "Dwarf_Attribute **attrbuf"
439dd9d0cfSchristos.Fa "Dwarf_Signed *attrcount"
449dd9d0cfSchristos.Fa "Dwarf_Error *err"
459dd9d0cfSchristos.Fc
469dd9d0cfSchristos.Sh DESCRIPTION
479dd9d0cfSchristosFunction
489dd9d0cfSchristos.Fn dwarf_attrlist
499dd9d0cfSchristosretrieves the DWARF attribute descriptors associated with a
509dd9d0cfSchristosdebugging information entry descriptor in argument
51cdbf1fe1Sjkoshy.Fa die .
529dd9d0cfSchristosThe descriptors are returned as an array of values of the opaque type
539dd9d0cfSchristos.Vt Dwarf_Attribute .
549dd9d0cfSchristosThe data associated with each returned attribute descriptor may be
559dd9d0cfSchristosqueried using the form query functions in the
569dd9d0cfSchristos.Xr dwarf 3
579dd9d0cfSchristosAPI set.
589dd9d0cfSchristos.Pp
599dd9d0cfSchristosArgument
60cdbf1fe1Sjkoshy.Fa attrbuf
619dd9d0cfSchristospoints to a location that will hold a pointer to the returned
629dd9d0cfSchristosarray of DWARF attribute descriptors.
639dd9d0cfSchristosArgument
64cdbf1fe1Sjkoshy.Fa attrcount
659dd9d0cfSchristospoints to a location that will hold the number of descriptors in
669dd9d0cfSchristosthe returned array.
679dd9d0cfSchristos.Pp
689dd9d0cfSchristosIf argument
69cdbf1fe1Sjkoshy.Fa err
70cdbf1fe1Sjkoshyis
71cdbf1fe1Sjkoshy.No non- Ns Dv NULL ,
72cdbf1fe1Sjkoshyit is used to return an error descriptor in case of an error.
739dd9d0cfSchristos.Ss Memory Management
749dd9d0cfSchristosIn the current implementation, the memory allocated for each DWARF
759dd9d0cfSchristosattribute descriptor and for the returned array of descriptors is
769dd9d0cfSchristosmanaged by the library and the application does not need to explicitly
779dd9d0cfSchristosfree the returned pointers.
789dd9d0cfSchristosHowever, for compatibility with other implementations of the
799dd9d0cfSchristos.Xr dwarf 3
809dd9d0cfSchristosAPI, the application is permitted to pass the pointers returned by to
819dd9d0cfSchristosthe
829dd9d0cfSchristos.Fn dwarf_dealloc
839dd9d0cfSchristosfunction.
849dd9d0cfSchristos.Sh RETURN VALUES
859dd9d0cfSchristosFunction
869dd9d0cfSchristos.Fn dwarf_attrlist
879dd9d0cfSchristosreturns
88604b0842Sjkoshy.Dv DW_DLV_OK
89604b0842Sjkoshyon success.
909dd9d0cfSchristos.Pp
919dd9d0cfSchristosIf the debugging information entry descriptor denoted by argument
92cdbf1fe1Sjkoshy.Fa die
939dd9d0cfSchristosdoes not contain any attribute, the function returns
949dd9d0cfSchristos.Dv DW_DLV_NO_ENTRY
959dd9d0cfSchristosand sets argument
96cdbf1fe1Sjkoshy.Fa err .
979dd9d0cfSchristosFor other errors, it returns
989dd9d0cfSchristos.Dv DW_DLV_ERROR
999dd9d0cfSchristosand sets argument
100cdbf1fe1Sjkoshy.Fa err .
1019dd9d0cfSchristos.Sh EXAMPLES
1029dd9d0cfSchristosTo retrieve the attribute list for a DWARF debugging information
1039dd9d0cfSchristosentry use:
1049dd9d0cfSchristos.Bd -literal -offset indent
1059dd9d0cfSchristosDwarf_Die dw_die;
1069dd9d0cfSchristosDwarf_Error dw_e;
1079dd9d0cfSchristosDwarf_Unsigned dw_count;
1089dd9d0cfSchristosDwarf_Attribute *dw_attributes;
1099dd9d0cfSchristosint error, i;
1109dd9d0cfSchristos
1119dd9d0cfSchristos\&... variable dw_die contains a reference to the DIE of interest ...
1129dd9d0cfSchristos
1139dd9d0cfSchristos/* Retrieve the attribute list from the DIE. */
1149dd9d0cfSchristosif ((error = dwarf_attrlist(dw_die, &dw_attributes, &dw_count,
1159dd9d0cfSchristos	&dw_e)) != DW_DLV_OK)
1169dd9d0cfSchristos	errx(EXIT_FAILURE, "dwarf_attrlist: %s", dwarf_errmsg(dw_e));
1179dd9d0cfSchristos
1189dd9d0cfSchristos/* Process the attribute list. */
1199dd9d0cfSchristosfor (i = 0; i < dw_count; ++i) {
1209dd9d0cfSchristos	/* Use the returned pointers in dw_attributes[i] here. */
1219dd9d0cfSchristos}
1229dd9d0cfSchristos.Ed
1239dd9d0cfSchristos.Sh ERRORS
1249dd9d0cfSchristosFunction
125cdbf1fe1Sjkoshy.Fn dwarf_attrlist
1269dd9d0cfSchristoscan fail with the following errors:
1279dd9d0cfSchristos.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
1289dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT
1299dd9d0cfSchristosArguments
130cdbf1fe1Sjkoshy.Fa die ,
131cdbf1fe1Sjkoshy.Fa attrbuf ,
1329dd9d0cfSchristosor
133cdbf1fe1Sjkoshy.Fa attrcount
134cdbf1fe1Sjkoshywere
135cdbf1fe1Sjkoshy.Dv NULL .
1369dd9d0cfSchristos.It Bq Er DW_DLE_NO_ENTRY
1379dd9d0cfSchristosArgument
138cdbf1fe1Sjkoshy.Fa die
1399dd9d0cfSchristoshad no attributes.
1409dd9d0cfSchristos.It Bq Er DW_DLE_MEMORY
1419dd9d0cfSchristosAn out of memory condition was encountered during the execution of the
1429dd9d0cfSchristosfunction.
1439dd9d0cfSchristos.El
1449dd9d0cfSchristos.Sh SEE ALSO
1459dd9d0cfSchristos.Xr dwarf 3 ,
1469dd9d0cfSchristos.Xr dwarf_attr 3 ,
1479dd9d0cfSchristos.Xr dwarf_dealloc 3 ,
1489dd9d0cfSchristos.Xr dwarf_hasattr 3 ,
1499dd9d0cfSchristos.Xr dwarf_hasform 3 ,
1509dd9d0cfSchristos.Xr dwarf_whatattr 3 ,
1519dd9d0cfSchristos.Xr dwarf_whatform 3
152