1*2de3b87aSKai Wang.\" Copyright (c) 2011 Kai Wang 2*2de3b87aSKai Wang.\" All rights reserved. 3*2de3b87aSKai Wang.\" 4*2de3b87aSKai Wang.\" Redistribution and use in source and binary forms, with or without 5*2de3b87aSKai Wang.\" modification, are permitted provided that the following conditions 6*2de3b87aSKai Wang.\" are met: 7*2de3b87aSKai Wang.\" 1. Redistributions of source code must retain the above copyright 8*2de3b87aSKai Wang.\" notice, this list of conditions and the following disclaimer. 9*2de3b87aSKai Wang.\" 2. Redistributions in binary form must reproduce the above copyright 10*2de3b87aSKai Wang.\" notice, this list of conditions and the following disclaimer in the 11*2de3b87aSKai Wang.\" documentation and/or other materials provided with the distribution. 12*2de3b87aSKai Wang.\" 13*2de3b87aSKai Wang.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*2de3b87aSKai Wang.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*2de3b87aSKai Wang.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*2de3b87aSKai Wang.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*2de3b87aSKai Wang.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*2de3b87aSKai Wang.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*2de3b87aSKai Wang.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*2de3b87aSKai Wang.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*2de3b87aSKai Wang.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*2de3b87aSKai Wang.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*2de3b87aSKai Wang.\" SUCH DAMAGE. 24*2de3b87aSKai Wang.\" 25*2de3b87aSKai Wang.\" $Id: dwarf_get_vars.3 2071 2011-10-27 03:20:00Z jkoshy $ 26*2de3b87aSKai Wang.\" 27*2de3b87aSKai Wang.Dd April 2, 2011 28*2de3b87aSKai Wang.Os 29*2de3b87aSKai Wang.Dt DWARF_GET_VARS 3 30*2de3b87aSKai Wang.Sh NAME 31*2de3b87aSKai Wang.Nm dwarf_get_vars , 32*2de3b87aSKai Wang.Nm dwarf_var_cu_offset , 33*2de3b87aSKai Wang.Nm dwarf_var_die_offset , 34*2de3b87aSKai Wang.Nm dwarf_var_name_offsets , 35*2de3b87aSKai Wang.Nm dwarf_varname 36*2de3b87aSKai Wang.Nd retrieve information about static variables 37*2de3b87aSKai Wang.Sh LIBRARY 38*2de3b87aSKai Wang.Lb libdwarf 39*2de3b87aSKai Wang.Sh SYNOPSIS 40*2de3b87aSKai Wang.In libdwarf.h 41*2de3b87aSKai Wang.Ft int 42*2de3b87aSKai Wang.Fo dwarf_get_vars 43*2de3b87aSKai Wang.Fa "Dwarf_Debug dbg" 44*2de3b87aSKai Wang.Fa "Dwarf_Var **vars" 45*2de3b87aSKai Wang.Fa "Dwarf_Signed *nvars" 46*2de3b87aSKai Wang.Fa "Dwarf_Error *err" 47*2de3b87aSKai Wang.Fc 48*2de3b87aSKai Wang.Ft int 49*2de3b87aSKai Wang.Fo dwarf_var_cu_offset 50*2de3b87aSKai Wang.Fa "Dwarf_Var var" 51*2de3b87aSKai Wang.Fa "Dwarf_Off *cu_offset" 52*2de3b87aSKai Wang.Fa "Dwarf_Error *err" 53*2de3b87aSKai Wang.Fc 54*2de3b87aSKai Wang.Ft int 55*2de3b87aSKai Wang.Fo dwarf_var_die_offset 56*2de3b87aSKai Wang.Fa "Dwarf_Var var" 57*2de3b87aSKai Wang.Fa "Dwarf_Off *die_offset" 58*2de3b87aSKai Wang.Fa "Dwarf_Error *err" 59*2de3b87aSKai Wang.Fc 60*2de3b87aSKai Wang.Ft int 61*2de3b87aSKai Wang.Fo dwarf_var_name_offsets 62*2de3b87aSKai Wang.Fa "Dwarf_Var var" 63*2de3b87aSKai Wang.Fa "char **name" 64*2de3b87aSKai Wang.Fa "Dwarf_Off *die_offset" 65*2de3b87aSKai Wang.Fa "Dwarf_Off *cu_die_offset" 66*2de3b87aSKai Wang.Fa "Dwarf_Error *err" 67*2de3b87aSKai Wang.Fc 68*2de3b87aSKai Wang.Ft int 69*2de3b87aSKai Wang.Fo dwarf_varname 70*2de3b87aSKai Wang.Fa "Dwarf_Var var" 71*2de3b87aSKai Wang.Fa "char **name" 72*2de3b87aSKai Wang.Fa "Dwarf_Error *err" 73*2de3b87aSKai Wang.Fc 74*2de3b87aSKai Wang.Sh DESCRIPTION 75*2de3b87aSKai WangThese functions retrieve information about the file scope static 76*2de3b87aSKai Wangvariables associated with a DWARF debug context. 77*2de3b87aSKai WangInformation about these static variables is returned using opaque 78*2de3b87aSKai Wangdescriptors of type 79*2de3b87aSKai Wang.Vt Dwarf_Var . 80*2de3b87aSKai WangApplications need to use the functions described below to retrieve 81*2de3b87aSKai Wangthe name and offset information contained in these descriptors. 82*2de3b87aSKai Wang.Pp 83*2de3b87aSKai WangFunction 84*2de3b87aSKai Wang.Fn dwarf_get_vars 85*2de3b87aSKai Wangretrieves descriptors for all the static variables associated with the 86*2de3b87aSKai WangDWARF debug context specified by argument 87*2de3b87aSKai Wang.Ar dbg . 88*2de3b87aSKai WangThe argument 89*2de3b87aSKai Wang.Ar vars 90*2de3b87aSKai Wangshould point to a location that will be set to a pointer to an array 91*2de3b87aSKai Wangof 92*2de3b87aSKai Wang.Vt Dwarf_Var 93*2de3b87aSKai Wangdescriptors. 94*2de3b87aSKai WangThe argument 95*2de3b87aSKai Wang.Ar nvars 96*2de3b87aSKai Wangshould point to a location that will be set to the number of 97*2de3b87aSKai Wangdescriptors returned. 98*2de3b87aSKai Wang.Pp 99*2de3b87aSKai WangFunction 100*2de3b87aSKai Wang.Fn dwarf_var_cu_offset 101*2de3b87aSKai Wangreturns the section-relative offset, relative to the 102*2de3b87aSKai Wang.Dq ".debug_info" 103*2de3b87aSKai Wangsection, of the compilation unit that 104*2de3b87aSKai Wangcontains the debugging information entry associated with the argument 105*2de3b87aSKai Wang.Ar var . 106*2de3b87aSKai WangArgument 107*2de3b87aSKai Wang.Ar cu_offset 108*2de3b87aSKai Wangshould point to a location that will hold the returned offset. 109*2de3b87aSKai Wang.Pp 110*2de3b87aSKai WangFunction 111*2de3b87aSKai Wang.Fn dwarf_var_die_offset 112*2de3b87aSKai Wangretrieves the section-relative offset, relative to the 113*2de3b87aSKai Wang.Dq ".debug_info" 114*2de3b87aSKai Wangsection, of the debugging information 115*2de3b87aSKai Wangentry associated with the argument 116*2de3b87aSKai Wang.Ar var , 117*2de3b87aSKai Wangand stores it into the location pointed to by the argument 118*2de3b87aSKai Wang.Ar die_offset . 119*2de3b87aSKai Wang.Pp 120*2de3b87aSKai WangFunction 121*2de3b87aSKai Wang.Fn dwarf_var_name_offsets 122*2de3b87aSKai Wangretrieves both the name and the associated offsets for the debugging 123*2de3b87aSKai Wanginformation entry for argument 124*2de3b87aSKai Wang.Ar var . 125*2de3b87aSKai WangArgument 126*2de3b87aSKai Wang.Ar name 127*2de3b87aSKai Wangshould point to a location which will be set to a pointer to a 128*2de3b87aSKai WangNUL-terminated string containing the name of the associated debugging 129*2de3b87aSKai Wanginformation entry. 130*2de3b87aSKai WangArgument 131*2de3b87aSKai Wang.Ar die_offset 132*2de3b87aSKai Wangshould point to a location which will be set to a section-relative 133*2de3b87aSKai Wangoffset, relative to the 134*2de3b87aSKai Wang.Dq ".debug_info" 135*2de3b87aSKai Wangsection, of the associated debugging information entry. 136*2de3b87aSKai WangArgument 137*2de3b87aSKai Wang.Ar cu_die_offset 138*2de3b87aSKai Wangshould point to a location which will be set to a 139*2de3b87aSKai Wangsection-relative offset, relative to the 140*2de3b87aSKai Wang.Dq ".debug_info" 141*2de3b87aSKai Wangsection, of the first debugging information entry in 142*2de3b87aSKai Wangthe compilation unit associated with argument 143*2de3b87aSKai Wang.Ar var . 144*2de3b87aSKai Wang.Pp 145*2de3b87aSKai WangFunction 146*2de3b87aSKai Wang.Fn dwarf_varname 147*2de3b87aSKai Wangsets the location pointed to by argument 148*2de3b87aSKai Wang.Ar name 149*2de3b87aSKai Wangto a pointer to a NUL-terminated string holding the name of the 150*2de3b87aSKai Wangdebugging information entry associated with the argument 151*2de3b87aSKai Wang.Ar var . 152*2de3b87aSKai Wang.Ss Memory Management 153*2de3b87aSKai WangThe memory area used for the array of 154*2de3b87aSKai Wang.Vt Dwarf_Var 155*2de3b87aSKai Wangdescriptors returned in argument 156*2de3b87aSKai Wang.Ar vars 157*2de3b87aSKai Wangby function 158*2de3b87aSKai Wang.Fn dwarf_get_vars 159*2de3b87aSKai Wangis owned by the 160*2de3b87aSKai Wang.Lb libdwarf . 161*2de3b87aSKai WangApplication code should not attempt to directly free this pointer. 162*2de3b87aSKai WangPortable code should instead use the function 163*2de3b87aSKai Wang.Xr dwarf_vars_dealloc 3 164*2de3b87aSKai Wangto indicate that the memory area may be freed. 165*2de3b87aSKai Wang.Pp 166*2de3b87aSKai WangThe memory area used for the string returned in the 167*2de3b87aSKai Wang.Ar name 168*2de3b87aSKai Wangargument to functions 169*2de3b87aSKai Wang.Fn dwarf_var_name_offsets 170*2de3b87aSKai Wangand 171*2de3b87aSKai Wang.Fn dwarf_varname 172*2de3b87aSKai Wangis owned by the 173*2de3b87aSKai Wang.Lb libdwarf . 174*2de3b87aSKai WangPortable code should indicate that the memory area can 175*2de3b87aSKai Wangbe freed using the 176*2de3b87aSKai Wang.Xr dwarf_dealloc 3 177*2de3b87aSKai Wangfunction. 178*2de3b87aSKai Wang.Ss Error Returns 179*2de3b87aSKai WangIf argument 180*2de3b87aSKai Wang.Ar err 181*2de3b87aSKai Wangis not NULL, these functions will use it to store error information, 182*2de3b87aSKai Wangin case of an error. 183*2de3b87aSKai Wang.Sh RETURN VALUES 184*2de3b87aSKai WangOn success, these functions returns 185*2de3b87aSKai Wang.Dv DW_DLV_OK . 186*2de3b87aSKai WangIn case of an error, they return 187*2de3b87aSKai Wang.Dv DW_DLV_ERROR 188*2de3b87aSKai Wangand set the argument 189*2de3b87aSKai Wang.Ar err . 190*2de3b87aSKai Wang.Sh ERRORS 191*2de3b87aSKai WangThese functions may fail with the following errors: 192*2de3b87aSKai Wang.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 193*2de3b87aSKai Wang.It Bq Er DW_DLE_ARGUMENT 194*2de3b87aSKai WangOne of the arguments 195*2de3b87aSKai Wang.Va cu_die_offset , 196*2de3b87aSKai Wang.Va cu_offset , 197*2de3b87aSKai Wang.Va dbg , 198*2de3b87aSKai Wang.Va die_offset , 199*2de3b87aSKai Wang.Va var , 200*2de3b87aSKai Wang.Va vars , 201*2de3b87aSKai Wang.Va name , 202*2de3b87aSKai Wangor 203*2de3b87aSKai Wang.Va nvars 204*2de3b87aSKai Wangwas NULL. 205*2de3b87aSKai Wang.El 206*2de3b87aSKai Wang.Sh SEE ALSO 207*2de3b87aSKai Wang.Xr dwarf 3 , 208*2de3b87aSKai Wang.Xr dwarf_dealloc 3 , 209*2de3b87aSKai Wang.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 , 210*2de3b87aSKai Wang.Xr dwarf_vars_dealloc 3 211