1.\" $NetBSD: dwarf_attrval_signed.3,v 1.2 2014/03/09 16:58:03 christos Exp $ 2.\" 3.\" Copyright (c) 2011 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_attrval_signed.3 2072 2011-10-27 03:26:49Z jkoshy 28.\" 29.Dd January 18, 2014 30.Os 31.Dt DWARF_ATTRVAL_SIGNED 3 32.Sh NAME 33.Nm dwarf_attrval_flag , 34.Nm dwarf_attrval_signed , 35.Nm dwarf_attrval_string , 36.Nm dwarf_attrval_unsigned 37.Nd retrieve the value of an attribute within a DWARF debugging information entry 38.Sh LIBRARY 39.Lb libdwarf 40.Sh SYNOPSIS 41.In libdwarf.h 42.Ft int 43.Fo dwarf_attrval_flag 44.Fa "Dwarf_Die die" 45.Fa "Dwarf_Half attr" 46.Fa "Dwarf_Bool *ret" 47.Fa "Dwarf_Error *err" 48.Fc 49.Ft int 50.Fo dwarf_attrval_signed 51.Fa "Dwarf_Die die" 52.Fa "Dwarf_Half attr" 53.Fa "Dwarf_Signed *ret" 54.Fa "Dwarf_Error *err" 55.Fc 56.Ft int 57.Fo dwarf_attrval_string 58.Fa "Dwarf_Die die" 59.Fa "Dwarf_Half attr" 60.Fa "const char **ret" 61.Fa "Dwarf_Error *err" 62.Fc 63.Ft int 64.Fo dwarf_attrval_unsigned 65.Fa "Dwarf_Die die" 66.Fa "Dwarf_Half attr" 67.Fa "Dwarf_Unsigned *ret" 68.Fa "Dwarf_Error *err" 69.Fc 70.Sh DESCRIPTION 71These functions search the debugging information entry referenced 72by argument 73.Ar die 74for the attribute named by argument 75.Ar attr . 76If the named attribute is found, the functions set the location 77pointed to by argument 78.Ar ret 79to the value of the attribute. 80The argument 81.Ar err , 82if non NULL, 83will be used to return an error descriptor in case of an error. 84.Pp 85Function 86.Fn dwarf_attrval_flag 87sets the location pointed to by argument 88.Ar ret 89to either 0 or 1. If the form of the attribute named by argument 90.Ar attr 91is 92.Dv DW_FORM_flag , 93function 94.Fn dwarf_attrval_flag 95sets the location pointed to by argument 96.Ar ret 97to 1 if the attribute has a non-zero value, or to 0 otherwise. 98If the form of the attribute named by argument 99.Ar attr 100is 101.Dv DW_FORM_flag_present , 102function 103.Fn dwarf_attrval_flag 104unconditionally sets the location pointed to by argument 105.Ar ret 106to 1. 107The form of the attribute must be one of 108.Dv DW_FORM_flag 109or 110.Dv DW_FORM_flag_present . 111.Pp 112Function 113.Fn dwarf_attrval_signed 114stores the value for the attribute named by argument 115.Ar attr , 116into the location pointed to by argument 117.Ar ret . 118The attribute's value is treated as a signed integral quantity and is 119sign-extended as needed. 120The attribute named by the argument 121.Ar attr 122must belong to the 123.Dv CONSTANT 124class and must have one of the following forms: 125.Dv DW_FORM_data1 , 126.Dv DW_FORM_data2 , 127.Dv DW_FORM_data4 , 128.Dv DW_FORM_data8 129or 130.Dv DW_FORM_sdata . 131.Pp 132Function 133.Fn dwarf_attrval_string 134sets the location pointed to by argument 135.Ar ret 136to a pointer to a NUL-terminated string that is the value of the 137attribute named by argument 138.Ar attr . 139The form of the attribute must be one of 140.Dv DW_FORM_string 141or 142.Dv DW_FORM_strp . 143.Pp 144Function 145.Fn dwarf_attrval_unsigned 146stores the value for the attribute named by argument 147.Ar attr 148into the location pointed to by argument 149.Ar ret . 150The attribute's value is treated as an unsigned integral quantity, and 151is zero-extended as needed. 152The named attribute must belong to one of the 153.Dv CONSTANT , 154.Dv ADDRESS 155or 156.Dv REFERENCE 157classes and must have one of the following forms: 158.Dv DW_FORM_addr , 159.Dv DW_FORM_data1 , 160.Dv DW_FORM_data2 , 161.Dv DW_FORM_data4 , 162.Dv DW_FORM_data8 , 163.Dv DW_FORM_udata , 164.Dv DW_FORM_ref1 , 165.Dv DW_FORM_ref2 , 166.Dv DW_FORM_ref4 , 167.Dv DW_FORM_ref8 , 168or 169.Dv DW_FORM_ref_udata . 170.Pp 171If the attribute named by argument 172.Ar attr 173is not present in the debugging information entry referenced by 174argument 175.Ar die , 176and if a 177.Dv DW_AT_abstract_origin 178attribute is present in the debugging information entry, 179function 180.Fn dwarf_attrval_unsigned 181will search for the named attribute in the debugging information entry 182referenced by the 183.Dv DW_AT_abstract_origin 184attribute. 185.Sh RETURN VALUES 186On success, these functions returns 187.Dv DW_DLV_OK . 188If the named attribute was not found in the specified debugging 189information entry descriptor these functions return 190.Dv DW_DLV_NO_ENTRY 191and set argument 192.Ar err . 193For other errors, these functions return 194.Dv DW_DLV_ERROR 195and set argument 196.Ar err . 197.Sh COMPATIBILITY 198These functions are extensions added by this implementation of the 199DWARF(3) API. 200.Sh ERRORS 201These functions may fail with the following errors: 202.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD" 203.It Bq Er DW_DLE_ARGUMENT 204Either of the arguments 205.Va die 206or 207.Va ret 208was NULL. 209.It Bq Er DW_DLE_NO_ENTRY 210Argument 211.Ar die 212did not contain an attribute corresponding to the value in argument 213.Ar attr . 214.It Bq Er DW_DLE_ATTR_FORM_BAD 215The attribute named by argument 216.Ar attr 217was not of a permitted form. 218.El 219.Sh SEE ALSO 220.Xr dwarf 3 , 221.Xr dwarf_attr 3 , 222.Xr dwarf_hasattr 3 223