1 .\" $NetBSD: dwarf_get_fde_list.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_get_fde_list.3 2122 2011-11-09 15:35:14Z jkoshy
31 .Dt DWARF_GET_FDE_LIST 3
33 .Nm dwarf_get_fde_list
34 .Nd retrieve frame information
40 .Fo dwarf_get_fde_list
42 .Fa "Dwarf_Cie **cie_list"
43 .Fa "Dwarf_Signed *cie_count"
44 .Fa "Dwarf_Fde **fde_list"
45 .Fa "Dwarf_Signed *fde_count"
46 .Fa "Dwarf_Error *err"
49 .Fo dwarf_get_fde_list_eh
51 .Fa "Dwarf_Cie **cie_list"
52 .Fa "Dwarf_Signed *cie_count"
53 .Fa "Dwarf_Fde **fde_list"
54 .Fa "Dwarf_Signed *fde_count"
55 .Fa "Dwarf_Error *err"
58 These functions retrieve frame related information for the specified
62 .Fn dwarf_get_fde_list
63 retrieves frame information from the DWARF section named
65 For objects containing GNU style C++ exception handling
66 information, the function
67 .Fn dwarf_get_fde_list_eh
68 retrieves frame information from the section named
71 Frame information is returned using opaque descriptors
76 Applications need to use the other frame related functions in the
77 DWARF(3) API set to retrieve the information contained in these
82 should reference a DWARF debug context allocated using
87 should point to a location that will be set to a pointer to an array
94 should point to a location that will be set to the number of
100 should point to a location that will be set to a pointer to an array
107 should point to a location that will be set to the number of
109 descriptors returned.
113 is not NULL, it will be used to store error information in case of an
115 .Ss Memory Management
116 The memory areas used for the arrays returned in arguments
122 Application code should not attempt to directly free these areas.
123 Portable applications should instead use the
124 .Xr dwarf_fde_cie_list_dealloc 3
125 function to indicate that these memory areas may be freed.
127 On success, these functions returns
131 if there is no frame information associated with the given DWARF
133 In case of an error, they return
138 These functions may fail with the following errors:
139 .Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
140 .It Bq Er DW_DLE_ARGUMENT
149 .It Bq Er DW_DLE_NO_ENTRY
150 There is no frame information associated with the giving DWARF debug
154 To obtain frame information from the
157 .Bd -literal -offset indent
159 Dwarf_Cie *cie_list, cie;
160 Dwarf_Fde *fde_list, fde;
161 Dwarf_Off fde_offset, cie_offset;
162 Dwarf_Unsigned func_len, fde_length, fde_instlen;
163 Dwarf_Signed cie_count, fde_count, cie_index;
165 Dwarf_Ptr fde_addr, fde_inst, cie_inst;
169 if (dwarf_get_fde_list(dbg, &cie_list, &cie_count,
170 &fde_list, &fde_count, &de) != DW_DLV_OK) {
171 errx(EXIT_FAILURE, "dwarf_get_fde_list failed: %s",
175 for (i = 0; i < fde_count; i++) {
176 if (dwarf_get_fde_n(fde_list, i, &fde, &de) != DW_DLV_OK) {
177 warnx("dwarf_get_fde_n failed: %s",
181 if (dwarf_get_cie_of_fde(fde, &cie, &de) != DW_DLV_OK) {
182 warnx("dwarf_get_fde_n failed: %s",
186 if (dwarf_get_fde_range(fde, &low_pc, &func_len, &fde_addr,
187 &fde_length, &cie_offset, &cie_index, &fde_offset,
189 warnx("dwarf_get_fde_range failed: %s",
193 if (dwarf_get_fde_instr_bytes(fde, &fde_inst, &fde_instlen,
195 warnx("dwarf_get_fde_instr_bytes failed: %s",
200 /* ... Use the retrieved frame information ... */
203 /* Indicate that the returned arrays may be freed. */
204 dwarf_fde_cie_list_dealloc(dbg, cie_list, cie_count, fde_list,
209 .Xr dwarf_get_cie_index 3 ,
210 .Xr dwarf_get_cie_of_fde 3 ,
211 .Xr dwarf_get_fde_at_pc 3 ,
212 .Xr dwarf_get_fde_instr_bytes 3 ,
213 .Xr dwarf_get_fde_n 3 ,
214 .Xr dwarf_get_fde_range 3 ,
215 .Xr dwarf_fde_cie_list_dealloc 3 ,
216 .Xr dwarf_set_frame_cfa_value 3 ,
217 .Xr dwarf_set_frame_rule_table_size 3 ,
218 .Xr dwarf_set_frame_rule_initial_value 3 ,
219 .Xr dwarf_set_frame_same_value 3 ,
220 .Xr dwarf_set_frame_undefined_value 3