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_fde_info_for_reg3.3 2122 2011-11-09 15:35:14Z jkoshy $ |
---|
26 | .\" |
---|
27 | .Dd November 9, 2011 |
---|
28 | .Os |
---|
29 | .Dt DWARF_GET_FDE_INFO_FOR_REG3 3 |
---|
30 | .Sh NAME |
---|
31 | .Nm dwarf_get_fde_info_for_reg3 |
---|
32 | .Nd retrieve register rule |
---|
33 | .Sh LIBRARY |
---|
34 | .Lb libdwarf |
---|
35 | .Sh SYNOPSIS |
---|
36 | .In libdwarf.h |
---|
37 | .Ft int |
---|
38 | .Fo dwarf_get_fde_info_for_reg3 |
---|
39 | .Fa "Dwarf_Fde fde" |
---|
40 | .Fa "Dwarf_Half table_column" |
---|
41 | .Fa "Dwarf_Addr pc" |
---|
42 | .Fa "Dwarf_Small *type" |
---|
43 | .Fa "Dwarf_Signed *offset_relevant" |
---|
44 | .Fa "Dwarf_Signed *register_num" |
---|
45 | .Fa "Dwarf_Signed *offset_or_block_len" |
---|
46 | .Fa "Dwarf_Ptr *block_ptr" |
---|
47 | .Fa "Dwarf_Addr *row_pc" |
---|
48 | .Fa "Dwarf_Error *error" |
---|
49 | .Fc |
---|
50 | .Sh DESCRIPTION |
---|
51 | Function |
---|
52 | .Fn dwarf_get_fde_info_for_reg3 |
---|
53 | retrieves a register rule from the register rule table associated with |
---|
54 | a given FDE descriptor, given a program counter address and rule |
---|
55 | column number. |
---|
56 | .Pp |
---|
57 | Argument |
---|
58 | .Ar fde |
---|
59 | should reference a valid DWARF FDE descriptor. |
---|
60 | .Pp |
---|
61 | Arugment |
---|
62 | .Ar table_column |
---|
63 | should hold the column number of the register rule desired. |
---|
64 | .Pp |
---|
65 | Argument |
---|
66 | .Ar pc |
---|
67 | should hold the program counter address to be used to locate the |
---|
68 | desired register rule row. |
---|
69 | .Pp |
---|
70 | On successful execution, |
---|
71 | .Fn dwarf_get_fde_info_for_reg3 |
---|
72 | stores information about the register rule found into the locations |
---|
73 | pointed to by the arguments |
---|
74 | .Ar type , |
---|
75 | .Ar offset_relevant , |
---|
76 | .Ar register_num , |
---|
77 | .Ar offset_or_block_len , |
---|
78 | .Ar block_ptr |
---|
79 | and |
---|
80 | .Ar row_pc . |
---|
81 | .Pp |
---|
82 | Argument |
---|
83 | .Ar type |
---|
84 | should point to a location which will hold the type code of the |
---|
85 | register rule found. |
---|
86 | The returned value is one of the |
---|
87 | .Dv DW_EXPR_* |
---|
88 | contants defined in the header file |
---|
89 | .In libdwarf.h . |
---|
90 | .Pp |
---|
91 | If there is an offset value associated with the register rule, |
---|
92 | the location pointed to by argument |
---|
93 | .Ar offset_relevant |
---|
94 | will be set to 1. |
---|
95 | .Pp |
---|
96 | Argument |
---|
97 | .Ar register_num |
---|
98 | should point to a location which will hold the register number associated |
---|
99 | with the register rule. |
---|
100 | .Pp |
---|
101 | If the register rule is of type |
---|
102 | .Dv DW_EXPR_OFFSET |
---|
103 | or |
---|
104 | .Dv DW_EXPR_VAL_OFFSET , |
---|
105 | the location pointed to by argument |
---|
106 | .Ar offset_or_block_len |
---|
107 | will be set to the offset value associated with the register rule, |
---|
108 | or to 0 if the register rule does not have an offset value. |
---|
109 | If the type code is |
---|
110 | .Dv DW_EXPR_EXPRESSION |
---|
111 | or |
---|
112 | .Dv DW_EXPR_VAL_EXPRESSION , |
---|
113 | the location pointed to by argument |
---|
114 | .Ar offset_or_block_len |
---|
115 | will be set to the length in bytes of the DWARF expression block |
---|
116 | associated with the register rule. |
---|
117 | .Pp |
---|
118 | Argument |
---|
119 | .Ar block_ptr |
---|
120 | should point to a location which will be set to a pointer to the |
---|
121 | content of the DWARF expression block associated with the register |
---|
122 | rule. |
---|
123 | .Pp |
---|
124 | Argument |
---|
125 | .Ar row_pc |
---|
126 | should point to a location which will be set to the lowest program |
---|
127 | counter address associated with the register rule found. |
---|
128 | .Pp |
---|
129 | If argument |
---|
130 | .Ar err |
---|
131 | is not NULL, it will be used to return an error descriptor in case |
---|
132 | of an error. |
---|
133 | .Sh RETURN VALUES |
---|
134 | Function |
---|
135 | .Fn dwarf_get_fde_info_for_reg3 |
---|
136 | returns |
---|
137 | .Dv DW_DLV_OK |
---|
138 | when it succeeds. |
---|
139 | In case of an error, it returns |
---|
140 | .Dv DW_DLV_ERROR |
---|
141 | and sets the argument |
---|
142 | .Ar err . |
---|
143 | .Sh ERRORS |
---|
144 | Function |
---|
145 | .Fn dwarf_get_fde_info_for_reg3 |
---|
146 | can fail with: |
---|
147 | .Bl -tag -width ".Bq Er DW_DLE_FRAME_TABLE_COL_BAD" |
---|
148 | .It Bq Er DW_DLE_ARGUMENT |
---|
149 | One of the arguments |
---|
150 | .Ar block_ptr , |
---|
151 | .Ar fde , |
---|
152 | .Ar offset_or_block_len , |
---|
153 | .Ar offset_relevant , |
---|
154 | .Ar register_num , |
---|
155 | .Ar row_pc , |
---|
156 | or |
---|
157 | .Ar type |
---|
158 | was NULL. |
---|
159 | .It Bq Er DW_DLE_FRAME_TABLE_COL_BAD |
---|
160 | The column number provided in argument |
---|
161 | .Ar table_column |
---|
162 | was too large. |
---|
163 | .It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE |
---|
164 | The program counter value provided in argument |
---|
165 | .Ar pc |
---|
166 | did not fall in the range covered by argument |
---|
167 | .Ar fde . |
---|
168 | .El |
---|
169 | .Sh EXAMPLE |
---|
170 | To retrieve the register rules at column 3 from a rule table |
---|
171 | associated with a FDE descriptor: |
---|
172 | .Bd -literal -offset indent |
---|
173 | Dwarf_Fde fde; |
---|
174 | Dwarf_Off fde_offset, cie_offset; |
---|
175 | Dwarf_Unsigned func_len, fde_length; |
---|
176 | Dwarf_Signed cie_index, offset_relevant, register_num; |
---|
177 | Dwarf_Signed offset_or_block_len; |
---|
178 | Dwarf_Addr low_pc, row_pc; |
---|
179 | Dwarf_Ptr fde_addr, block_ptr; |
---|
180 | Dwarf_Small type; |
---|
181 | Dwarf_Error de; |
---|
182 | |
---|
183 | /* ... assuming `fde` references a valid FDE descriptor... */ |
---|
184 | if (dwarf_get_fde_range(fde, &low_pc, &func_len, &fde_addr, |
---|
185 | &fde_length, &cie_offset, &cie_index, &fde_offset, |
---|
186 | &de) != DW_DLV_OK) |
---|
187 | errx(EXIT_FAILURE, "dwarf_get_fde_range failed: %s", |
---|
188 | dwarf_errmsg(de)); |
---|
189 | |
---|
190 | /* Iterate all the table rows. */ |
---|
191 | for (pc = low_pc; pc < low_pc + func_len; pc++) { |
---|
192 | if (dwarf_get_fde_info_for_reg3(fde, 3, pc, &type, |
---|
193 | &offset_relevant, ®ister_num, &offset_or_block_len, |
---|
194 | &block_ptr, &row_pc, &de) != DW_DLV_OK) { |
---|
195 | warnx("dwarf_get_fde_info_for_reg3 failed: %s", |
---|
196 | dwarf_errmsg(de)); |
---|
197 | continue; |
---|
198 | } |
---|
199 | /* ... use the retrieved register rule ... */ |
---|
200 | } |
---|
201 | .Ed |
---|
202 | .Sh SEE ALSO |
---|
203 | .Xr dwarf 3 , |
---|
204 | .Xr dwarf_get_fde_at_pc 3 , |
---|
205 | .Xr dwarf_get_fde_info_for_all_regs 3 , |
---|
206 | .Xr dwarf_get_fde_info_for_all_regs3 3 , |
---|
207 | .Xr dwarf_get_fde_info_for_cfa_reg3 3 , |
---|
208 | .Xr dwarf_get_fde_info_for_reg 3 , |
---|
209 | .Xr dwarf_get_fde_n 3 , |
---|
210 | .Xr dwarf_set_frame_cfa_value 3 , |
---|
211 | .Xr dwarf_set_frame_rule_table_size 3 , |
---|
212 | .Xr dwarf_set_frame_rule_initial_value 3 , |
---|
213 | .Xr dwarf_set_frame_same_value 3 , |
---|
214 | .Xr dwarf_set_frame_undefined_value 3 |
---|