1 .\" $NetBSD: dwarf_expand_frame_instructions.3,v 1.2 2014/03/09 16:58:03 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_expand_frame_instructions.3 2122 2011-11-09 15:35:14Z jkoshy
31 .Dt DWARF_EXPAND_FRAME_INSTRUCTIONS 3
33 .Nm dwarf_expand_frame_instructions
34 .Nd expand frame instructions
40 .Fo dwarf_expand_frame_instructions
42 .Fa "Dwarf_Ptr instructions"
43 .Fa "Dwarf_Unsigned len"
44 .Fa "Dwarf_Frame_Op **ret_ops"
45 .Fa "Dwarf_Signed *ret_opcnt"
46 .Fa "Dwarf_Error *error"
50 .Fn dwarf_expand_frame_instructions
51 translates DWARF frame instruction bytes into an array of
57 should reference the CIE descriptor associated with the instructions
62 should point to an array of frame instruction bytes, as
63 returned by the functions
64 .Xr dwarf_get_cie_info 3
66 .Xr dwarf_get_fde_instr_bytes 3 .
70 should specify the number of the frame instruction bytes to be
75 should point to a location that will be set to a pointer to
76 an array of translated
82 should point to a location that will hold the total number of the
87 is not NULL, it will be used to store error information in case of an
90 The memory area used for the descriptor array returned in argument
94 Application code should use function
97 .Dv DW_DLA_FRAME_BLOCK
98 to free the memory area when the descriptor array is no longer needed.
101 .Fn dwarf_expand_frame_instructions
105 In case of an error, it returns
107 and sets the argument
111 .Fn dwarf_expand_frame_instructions
113 .Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
114 .It Bq Er DW_DLE_ARGUMENT
122 .It Bq Er DW_DLE_ARGUMENT
126 .It Bq Er DW_DLE_MEMORY
127 An out of memory condition was encountered during the execution of
129 .It Bq Er DW_DLE_FRAME_INSTR_EXEC_ERROR
130 An unknown instruction was found in the instruction bytes provided
135 To retrieve and expand the frame instructions for a given FDE
137 .Bd -literal -offset indent
142 Dwarf_Unsigned fde_instlen;
147 /* ... assuming `dbg` references a valid DWARF debugging context,
148 `fde` references a valid FDE descriptor and `cie` holds the CIE
149 descriptor associated with the FDE descriptor ... */
151 if (dwarf_get_fde_instr_bytes(fde, &fde_inst, &fde_instlen,
153 errx(EXIT_FAILURE, "dwarf_get_fde_instr_bytes failed: %s",
156 if (dwarf_expand_frame_instructions(cie, fde_inst, fde_instlen,
157 &ops, &opcnt, &de) != DW_DLV_OK)
159 "dwarf_expand_frame_instructions failed: %s",
162 for (i = 0; i < opcnt; i++) {
163 /* ... use ops[i] ... */
166 /* Free the memory area when no longer needed. */
167 dwarf_dealloc(dbg, ops, DW_DLA_FRAME_BLOCK);
171 .Xr dwarf_frame_instructions_dealloc 3 ,
172 .Xr dwarf_get_cie_info 3 ,
173 .Xr dwarf_get_cie_index 3 ,
174 .Xr dwarf_get_cie_of_fde ,
175 .Xr dwarf_get_fde_at_pc 3 ,
176 .Xr dwarf_get_fde_info_for_all_regs 3 ,
177 .Xr dwarf_get_fde_info_for_all_regs3 3 ,
178 .Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
179 .Xr dwarf_get_fde_info_for_reg 3 ,
180 .Xr dwarf_get_fde_info_for_reg3 3 ,
181 .Xr dwarf_get_fde_instr_bytes 3 ,
182 .Xr dwarf_get_fde_list 3 ,
183 .Xr dwarf_get_fde_list_eh 3 ,
184 .Xr dwarf_get_fde_n 3