1 | .\" Copyright (c) 2011 Kai Wang |
---|
2 | .\" All rights reserved. |
---|
3 | .\" |
---|
4 | .\" Redistribution and use in source and binary forms, with or without |
---|
5 | .\" modification, are permitted provided that the following conditions |
---|
6 | .\" are met: |
---|
7 | .\" 1. Redistributions of source code must retain the above copyright |
---|
8 | .\" notice, this list of conditions and the following disclaimer. |
---|
9 | .\" 2. Redistributions in binary form must reproduce the above copyright |
---|
10 | .\" notice, this list of conditions and the following disclaimer in the |
---|
11 | .\" documentation and/or other materials provided with the distribution. |
---|
12 | .\" |
---|
13 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
---|
14 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
15 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
16 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
---|
17 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
18 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
19 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
20 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
21 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
22 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
23 | .\" SUCH DAMAGE. |
---|
24 | .\" |
---|
25 | .\" $Id: dwarf_get_pubtypes.3 2071 2011-10-27 03:20:00Z jkoshy $ |
---|
26 | .\" |
---|
27 | .Dd April 4, 2011 |
---|
28 | .Os |
---|
29 | .Dt DWARF_GET_PUBTYPES 3 |
---|
30 | .Sh NAME |
---|
31 | .Nm dwarf_get_pubtypes , |
---|
32 | .Nm dwarf_pubtype_cu_offset , |
---|
33 | .Nm dwarf_pubtype_die_offset , |
---|
34 | .Nm dwarf_pubtype_name_offsets , |
---|
35 | .Nm dwarf_pubtypename |
---|
36 | .Nd retrieve information about user-defined types |
---|
37 | .Sh LIBRARY |
---|
38 | .Lb libdwarf |
---|
39 | .Sh SYNOPSIS |
---|
40 | .In libdwarf.h |
---|
41 | .Ft int |
---|
42 | .Fo dwarf_get_pubtypes |
---|
43 | .Fa "Dwarf_Debug dbg" |
---|
44 | .Fa "Dwarf_Type **types" |
---|
45 | .Fa "Dwarf_Signed *ntypes" |
---|
46 | .Fa "Dwarf_Error *err" |
---|
47 | .Fc |
---|
48 | .Ft int |
---|
49 | .Fo dwarf_pubtype_cu_offset |
---|
50 | .Fa "Dwarf_Type type" |
---|
51 | .Fa "Dwarf_Off *cu_offset" |
---|
52 | .Fa "Dwarf_Error *err" |
---|
53 | .Fc |
---|
54 | .Ft int |
---|
55 | .Fo dwarf_pubtype_die_offset |
---|
56 | .Fa "Dwarf_Type type" |
---|
57 | .Fa "Dwarf_Off *die_offset" |
---|
58 | .Fa "Dwarf_Error *err" |
---|
59 | .Fc |
---|
60 | .Ft int |
---|
61 | .Fo dwarf_pubtype_name_offsets |
---|
62 | .Fa "Dwarf_Type type" |
---|
63 | .Fa "char **name" |
---|
64 | .Fa "Dwarf_Off *die_offset" |
---|
65 | .Fa "Dwarf_Off *cu_die_offset" |
---|
66 | .Fa "Dwarf_Error *err" |
---|
67 | .Fc |
---|
68 | .Ft int |
---|
69 | .Fo dwarf_pubtypename |
---|
70 | .Fa "Dwarf_Type type" |
---|
71 | .Fa "char **name" |
---|
72 | .Fa "Dwarf_Error *err" |
---|
73 | .Fc |
---|
74 | .Sh DESCRIPTION |
---|
75 | These functions retrieve information about file-scope, user-defined |
---|
76 | types recorded in lookup tables in the |
---|
77 | .Dq ".debug_pubtypes" |
---|
78 | DWARF section. |
---|
79 | Information about these types is returned using opaque descriptors |
---|
80 | of type |
---|
81 | .Vt Dwarf_Type . |
---|
82 | Applications need to use the functions described below to retrieve |
---|
83 | the name and offset information contained in these descriptors. |
---|
84 | .Pp |
---|
85 | Function |
---|
86 | .Fn dwarf_get_pubtypes |
---|
87 | retrieves descriptors for all the user-defined types associated with the |
---|
88 | DWARF debug context specified by argument |
---|
89 | .Ar dbg . |
---|
90 | The argument |
---|
91 | .Ar types |
---|
92 | should point to a location that will be set to a pointer to an array |
---|
93 | of |
---|
94 | .Vt Dwarf_Type |
---|
95 | descriptors. |
---|
96 | The argument |
---|
97 | .Ar ntypes |
---|
98 | should point to a location that will be set to the number of |
---|
99 | descriptors returned. |
---|
100 | .Pp |
---|
101 | Function |
---|
102 | .Fn dwarf_pubtype_cu_offset |
---|
103 | returns the offset, relative to the |
---|
104 | .Dq ".debug_info" |
---|
105 | section, of the compilation unit that contains the debugging |
---|
106 | information entry associated with the argument |
---|
107 | .Ar type . |
---|
108 | Argument |
---|
109 | .Ar cu_offset |
---|
110 | should point to a location that will hold the returned offset. |
---|
111 | .Pp |
---|
112 | Function |
---|
113 | .Fn dwarf_pubtype_die_offset |
---|
114 | retrieves the offset, relative to the |
---|
115 | .Dq ".debug_info" |
---|
116 | section, of the debugging information entry associated with the |
---|
117 | argument |
---|
118 | .Ar type , |
---|
119 | and stores it into the location pointed to by the argument |
---|
120 | .Ar die_offset . |
---|
121 | .Pp |
---|
122 | Function |
---|
123 | .Fn dwarf_pubtype_name_offsets |
---|
124 | retrieves the name and offsets for the debugging information entry for |
---|
125 | argument |
---|
126 | .Ar type . |
---|
127 | Argument |
---|
128 | .Ar name |
---|
129 | should point to a location which will be set to a pointer to a |
---|
130 | NUL-terminated string containing the name of the associated debugging |
---|
131 | information entry. |
---|
132 | Argument |
---|
133 | .Ar die_offset |
---|
134 | should point to a location which will be set to the |
---|
135 | offset, relative to the |
---|
136 | .Dq ".debug_info" |
---|
137 | section, of the associated debugging information entry. |
---|
138 | Argument |
---|
139 | .Ar cu_die_offset |
---|
140 | should point to a location which will be set to the |
---|
141 | offset, relative to the |
---|
142 | .Dq ".debug_info" |
---|
143 | section, of the first debugging information entry in the compilation |
---|
144 | unit associated with argument |
---|
145 | .Ar type . |
---|
146 | .Pp |
---|
147 | Function |
---|
148 | .Fn dwarf_pubtypename |
---|
149 | sets the location pointed to by argument |
---|
150 | .Ar name |
---|
151 | to a pointer to a NUL-terminated string holding the name of the |
---|
152 | debugging information entry associated with the argument |
---|
153 | .Ar type . |
---|
154 | .Ss Memory Management |
---|
155 | The memory area used for the array of |
---|
156 | .Vt Dwarf_Type |
---|
157 | descriptors returned in argument |
---|
158 | .Ar types |
---|
159 | by function |
---|
160 | .Fn dwarf_get_pubtypes |
---|
161 | is owned by the |
---|
162 | .Lb libdwarf . |
---|
163 | Application code should not attempt to directly free this pointer. |
---|
164 | Portable code should instead use the function |
---|
165 | .Xr dwarf_types_dealloc 3 |
---|
166 | to indicate that the memory area may be freed. |
---|
167 | .Pp |
---|
168 | The memory area used for the string returned in the |
---|
169 | .Ar name |
---|
170 | argument to functions |
---|
171 | .Fn dwarf_pubtype_name_offsets |
---|
172 | and |
---|
173 | .Fn dwarf_pubtypename |
---|
174 | is owned by the |
---|
175 | .Lb libdwarf . |
---|
176 | Portable code should indicate that the memory area can |
---|
177 | be freed using the |
---|
178 | .Xr dwarf_dealloc 3 |
---|
179 | function. |
---|
180 | .Ss Error Returns |
---|
181 | If argument |
---|
182 | .Ar err |
---|
183 | is not NULL, these functions will use it to store error information, |
---|
184 | in case of an error. |
---|
185 | .Sh RETURN VALUES |
---|
186 | On success, these functions returns |
---|
187 | .Dv DW_DLV_OK . |
---|
188 | In case of an error, they return |
---|
189 | .Dv DW_DLV_ERROR |
---|
190 | and set the argument |
---|
191 | .Ar err . |
---|
192 | .Sh EXAMPLES |
---|
193 | To retrieve the list of file scope user-defined types and print |
---|
194 | their names, use: |
---|
195 | .Bd -literal -offset indent |
---|
196 | Dwarf_Debug dbg; |
---|
197 | Dwarf_Signed ntypes; |
---|
198 | Dwarf_Type *types; |
---|
199 | Dwarf_Error err; |
---|
200 | int n, result; |
---|
201 | char *typename; |
---|
202 | |
---|
203 | /* Initialize dbg etc. */; |
---|
204 | result = dwarf_get_pubtypes(dbg, &types, &ntypes, &err); |
---|
205 | if (result != DW_DLV_OK) /* Handle the error. */ |
---|
206 | ; |
---|
207 | |
---|
208 | /* Iterate over the returned array of descriptors. */ |
---|
209 | for (n = 0; n < ntypes; n++) { |
---|
210 | result = dwarf_pubtypename(types[n], &typename, &err); |
---|
211 | if (result != DW_DLV_OK) /* Handle the error. */ |
---|
212 | ; |
---|
213 | printf("%s\en", typename); |
---|
214 | } |
---|
215 | |
---|
216 | /* Deallocate the returned array. */ |
---|
217 | dwarf_types_dealloc(dbg, types, ntypes); |
---|
218 | .Ed |
---|
219 | .Sh ERRORS |
---|
220 | These functions may fail with the following errors: |
---|
221 | .Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" |
---|
222 | .It Bq Er DW_DLE_ARGUMENT |
---|
223 | One of the arguments |
---|
224 | .Va cu_die_offset , |
---|
225 | .Va cu_offset , |
---|
226 | .Va dbg , |
---|
227 | .Va die_offset , |
---|
228 | .Va type , |
---|
229 | .Va types , |
---|
230 | .Va name , |
---|
231 | or |
---|
232 | .Va ntypes |
---|
233 | was NULL. |
---|
234 | .It Bq Er DW_DLE_NO_ENTRY |
---|
235 | The DWARF debugging context referenced by argument |
---|
236 | .Ar dbg |
---|
237 | did not contain information about user-defined types. |
---|
238 | .El |
---|
239 | .Sh SEE ALSO |
---|
240 | .Xr dwarf 3 , |
---|
241 | .Xr dwarf_dealloc 3 , |
---|
242 | .Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 , |
---|
243 | .Xr dwarf_pubtypes_dealloc 3 |
---|