aboutsummaryrefslogtreecommitdiff
path: root/libdwarf/dwarf_attrval_signed.3
blob: 93d4ae0596ed93b2cebfc55971b713f8f83ccbf7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
.\" Copyright (c) 2011 Kai Wang
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $Id: dwarf_attrval_signed.3 2980 2014-01-21 20:15:54Z kaiwang27 $
.\"
.Dd January 18, 2014
.Os
.Dt DWARF_ATTRVAL_SIGNED 3
.Sh NAME
.Nm dwarf_attrval_flag ,
.Nm dwarf_attrval_signed ,
.Nm dwarf_attrval_string ,
.Nm dwarf_attrval_unsigned
.Nd retrieve the value of an attribute within a DWARF debugging information entry
.Sh LIBRARY
.Lb libdwarf
.Sh SYNOPSIS
.In libdwarf.h
.Ft int
.Fo dwarf_attrval_flag
.Fa "Dwarf_Die die"
.Fa "Dwarf_Half attr"
.Fa "Dwarf_Bool *ret"
.Fa "Dwarf_Error *err"
.Fc
.Ft int
.Fo dwarf_attrval_signed
.Fa "Dwarf_Die die"
.Fa "Dwarf_Half attr"
.Fa "Dwarf_Signed *ret"
.Fa "Dwarf_Error *err"
.Fc
.Ft int
.Fo dwarf_attrval_string
.Fa "Dwarf_Die die"
.Fa "Dwarf_Half attr"
.Fa "const char **ret"
.Fa "Dwarf_Error *err"
.Fc
.Ft int
.Fo dwarf_attrval_unsigned
.Fa "Dwarf_Die die"
.Fa "Dwarf_Half attr"
.Fa "Dwarf_Unsigned *ret"
.Fa "Dwarf_Error *err"
.Fc
.Sh DESCRIPTION
These functions search the debugging information entry referenced
by argument
.Ar die
for the attribute named by argument
.Ar attr .
If the named attribute is found, the functions set the location
pointed to by argument
.Ar ret
to the value of the attribute.
The argument
.Ar err ,
if non NULL,
will be used to return an error descriptor in case of an error.
.Pp
Function
.Fn dwarf_attrval_flag
sets the location pointed to by argument
.Ar ret
to either 0 or 1. If the form of the attribute named by argument
.Ar attr
is
.Dv DW_FORM_flag ,
function
.Fn dwarf_attrval_flag
sets the location pointed to by argument
.Ar ret
to 1 if the attribute has a non-zero value, or to 0 otherwise.
If the form of the attribute named by argument
.Ar attr
is
.Dv DW_FORM_flag_present ,
function
.Fn dwarf_attrval_flag
unconditionally sets the location pointed to by argument
.Ar ret
to 1.
The form of the attribute must be one of
.Dv DW_FORM_flag
or
.Dv DW_FORM_flag_present .
.Pp
Function
.Fn dwarf_attrval_signed
stores the value for the attribute named by argument
.Ar attr ,
into the location pointed to by argument
.Ar ret .
The attribute's value is treated as a signed integral quantity and is
sign-extended as needed.
The attribute named by the argument
.Ar attr
must belong to the
.Dv CONSTANT
class and must have one of the following forms:
.Dv DW_FORM_data1 ,
.Dv DW_FORM_data2 ,
.Dv DW_FORM_data4 ,
.Dv DW_FORM_data8
or
.Dv DW_FORM_sdata .
.Pp
Function
.Fn dwarf_attrval_string
sets the location pointed to by argument
.Ar ret
to a pointer to a NUL-terminated string that is the value of the
attribute named by argument
.Ar attr .
The form of the attribute must be one of
.Dv DW_FORM_string
or
.Dv DW_FORM_strp .
.Pp
Function
.Fn dwarf_attrval_unsigned
stores the value for the attribute named by argument
.Ar attr
into the location pointed to by argument
.Ar ret .
The attribute's value is treated as an unsigned integral quantity, and
is zero-extended as needed.
The named attribute must belong to one of the
.Dv CONSTANT ,
.Dv ADDRESS
or
.Dv REFERENCE
classes and must have one of the following forms:
.Dv DW_FORM_addr ,
.Dv DW_FORM_data1 ,
.Dv DW_FORM_data2 ,
.Dv DW_FORM_data4 ,
.Dv DW_FORM_data8 ,
.Dv DW_FORM_udata ,
.Dv DW_FORM_ref1 ,
.Dv DW_FORM_ref2 ,
.Dv DW_FORM_ref4 ,
.Dv DW_FORM_ref8 ,
or
.Dv DW_FORM_ref_udata .
.Pp
If the attribute named by argument
.Ar attr
is not present in the debugging information entry referenced by
argument
.Ar die ,
and if a
.Dv DW_AT_abstract_origin
attribute is present in the debugging information entry,
function
.Fn dwarf_attrval_unsigned
will search for the named attribute in the debugging information entry
referenced by the
.Dv DW_AT_abstract_origin
attribute.
.Sh RETURN VALUES
On success, these functions returns
.Dv DW_DLV_OK .
If the named attribute was not found in the specified debugging
information entry descriptor these functions return
.Dv DW_DLV_NO_ENTRY
and set argument
.Ar err .
For other errors, these functions return
.Dv DW_DLV_ERROR
and set argument
.Ar err .
.Sh COMPATIBILITY
These functions are extensions added by this implementation of the
DWARF(3) API.
.Sh ERRORS
These functions may fail with the following errors:
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
.It Bq Er DW_DLE_ARGUMENT
Either of the arguments
.Va die
or
.Va ret
was NULL.
.It Bq Er DW_DLE_NO_ENTRY
Argument
.Ar die
did not contain an attribute corresponding to the value in argument
.Ar attr .
.It Bq Er DW_DLE_ATTR_FORM_BAD
The attribute named by argument
.Ar attr
was not of a permitted form.
.El
.Sh SEE ALSO
.Xr dwarf 3 ,
.Xr dwarf_attr 3 ,
.Xr dwarf_hasattr 3