1 .\" $NetBSD: dwarf_loclist.3,v 1.2 2014/03/09 16:58:04 christos Exp $
3 .\" Copyright (c) 2011 Kai Wang
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
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
27 .\" Id: dwarf_loclist.3 2122 2011-11-09 15:35:14Z jkoshy
35 .Nd retrieve DWARF location expression information
42 .Fa "Dwarf_Attribute at"
43 .Fa "Dwarf_Locdesc **llbuf"
44 .Fa "Dwarf_Signed *listlen"
45 .Fa "Dwarf_Error *error"
49 .Fa "Dwarf_Attribute at"
50 .Fa "Dwarf_Locdesc ***llbuf"
51 .Fa "Dwarf_Signed *listlen"
52 .Fa "Dwarf_Error *error"
55 These functions retrieve the location expressions
56 associated with a DWARF attribute.
61 New application code should instead use function
66 retrieves the list of location expressions associated with a DWARF
70 should reference a valid DWARF attribute.
73 should point to a location which will hold a returned array of
79 should point to a location which will be set to the number of
80 elements contained in the returned array.
83 is not NULL, it will be used to store error information in case
88 retrieves the first location expression associated with an attribute.
91 should reference a valid DWARF attribute.
94 should point to a location which will hold the returned pointer
100 should point to a location which will be always set to 1.
103 is not NULL, it will be used to store error information in case
107 descriptors are defined in the header file
109 and consist of following fields:
111 .Bl -tag -width ".Va ld_cents" -compact
113 The lowest program counter address covered by the descriptor.
114 This field will be set to 0 if the descriptor is not associated with
117 The highest program counter address covered by the descriptor.
118 This field will be set to 0 if the descriptor is not associated with
121 The number of entries returned in
125 Pointer to an array of
132 descriptor represents one operation of a location expression.
133 These descriptors are defined in the header file
135 and consist of following fields:
137 .Bl -tag -width ".Va lr_number2" -compact
139 The operator name, one of the
141 constants defined in the header file
144 The first operand of this operation.
146 The second operand of this operation.
148 The byte offset of this operation within the containing location
151 .Ss Memory Management
152 The memory area used for the descriptor array returned in argument
156 When the descriptor array is no longer needed, application code should
159 to free the memory area in the following manner:
166 descriptor should be deallocated using the allocation type
167 .Dv DW_DLA_LOC_BLOCK .
169 Then, the application should free each
171 descriptor using the allocation type
176 pointer should be deallocated using the allocation type
180 On success, these functions returns
182 In case of an error, they return
187 These functions can fail with:
188 .Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
189 .It Bq Er DW_DLE_ARGUMENT
196 .It Bq Er DW_DLE_ARGUMENT
197 The attribute provided by argument
199 does not contain a location expression or is not associated with a
200 location expression list.
203 To retrieve the location list associated with an attribute, use:
204 .Bd -literal -offset indent
206 Dwarf_Locdesc **llbuf;
212 if (dwarf_loclist_n(at, &llbuf, &lcnt, &de) != DW_DLV_OK)
213 errx(EXIT_FAILURE, "dwarf_loclist_n failed: %s",
216 for (i = 0; i < lcnt; i++) {
217 /* ... Use llbuf[i] ... */
218 for (j = 0; (Dwarf_Half) j < llbuf[i]->ld_cents; j++) {
219 lr = &llbuf[i]->ld_s[j];
220 /* ... Use each Dwarf_Loc descriptor ... */
222 dwarf_dealloc(dbg, llbuf[i]->ld_s, DW_DLA_LOC_BLOCK);
223 dwarf_dealloc(dbg, llbuf[i], DW_DLA_LOCDESC);
225 dwarf_dealloc(dbg, llbuf, DW_DLA_LIST);
229 .Xr dwarf_dealloc 3 ,
230 .Xr dwarf_loclist_from_expr 3 ,
231 .Xr dwarf_loclist_from_expr_a 3 ,
232 .Xr dwarf_get_loclist_entry 3