|
1 /* |
|
2 |
|
3 Copyright (C) 2000,2004,2006 Silicon Graphics, Inc. All Rights Reserved. |
|
4 Portions Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
|
5 |
|
6 This program is free software; you can redistribute it and/or modify it |
|
7 under the terms of version 2.1 of the GNU Lesser General Public License |
|
8 as published by the Free Software Foundation. |
|
9 |
|
10 This program is distributed in the hope that it would be useful, but |
|
11 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13 |
|
14 Further, this software is distributed without any warranty that it is |
|
15 free of the rightful claim of any third person regarding infringement |
|
16 or the like. Any license provided herein, whether implied or |
|
17 otherwise, applies only to this software file. Patent licenses, if |
|
18 any, provided herein do not apply to combinations of this program with |
|
19 other software, or any other product whatsoever. |
|
20 |
|
21 You should have received a copy of the GNU Lesser General Public |
|
22 License along with this program; if not, write the Free Software |
|
23 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, |
|
24 USA. |
|
25 |
|
26 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, |
|
27 Mountain View, CA 94043, or: |
|
28 |
|
29 http://www.sgi.com |
|
30 |
|
31 For further information regarding this notice, see: |
|
32 |
|
33 http://oss.sgi.com/projects/GenInfo/NoticeExplan |
|
34 |
|
35 */ |
|
36 |
|
37 |
|
38 |
|
39 #include "config.h" |
|
40 #include "libdwarfdefs.h" |
|
41 #include <stdio.h> |
|
42 #include <string.h> |
|
43 #include "pro_incl.h" |
|
44 #include "pro_expr.h" |
|
45 |
|
46 /* |
|
47 This function creates a new expression |
|
48 struct that can be used to build up a |
|
49 location expression. |
|
50 */ |
|
51 Dwarf_P_Expr |
|
52 dwarf_new_expr(Dwarf_P_Debug dbg, Dwarf_Error * error) |
|
53 { |
|
54 Dwarf_P_Expr ret_expr; |
|
55 |
|
56 if (dbg == NULL) { |
|
57 _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL); |
|
58 return (NULL); |
|
59 } |
|
60 |
|
61 ret_expr = (Dwarf_P_Expr) |
|
62 _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Expr_s)); |
|
63 if (ret_expr == NULL) { |
|
64 _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL); |
|
65 return (NULL); |
|
66 } |
|
67 |
|
68 ret_expr->ex_dbg = dbg; |
|
69 |
|
70 return (ret_expr); |
|
71 } |
|
72 |
|
73 |
|
74 Dwarf_Unsigned |
|
75 dwarf_add_expr_gen(Dwarf_P_Expr expr, |
|
76 Dwarf_Small opcode, |
|
77 Dwarf_Unsigned val1, |
|
78 Dwarf_Unsigned val2, Dwarf_Error * error) |
|
79 { |
|
80 char encode_buffer[2 * ENCODE_SPACE_NEEDED]; /* 2* since |
|
81 used to |
|
82 concatenate |
|
83 2 leb's |
|
84 below */ |
|
85 char encode_buffer2[ENCODE_SPACE_NEEDED]; |
|
86 int res; |
|
87 Dwarf_P_Debug dbg = expr->ex_dbg; |
|
88 |
|
89 /* |
|
90 Give the buffer where the operands are first going to be |
|
91 assembled the largest alignment. */ |
|
92 Dwarf_Unsigned operand_buffer[10]; |
|
93 |
|
94 /* |
|
95 Size of the byte stream buffer that needs to be memcpy-ed. */ |
|
96 int operand_size; |
|
97 |
|
98 /* |
|
99 Points to the byte stream for the first operand, and finally to |
|
100 the buffer that is memcp-ed into the Dwarf_P_Expr_s struct. */ |
|
101 Dwarf_Small *operand; |
|
102 |
|
103 /* Size of the byte stream for second operand. */ |
|
104 int operand2_size; |
|
105 |
|
106 /* Points to next byte to be written in Dwarf_P_Expr_s struct. */ |
|
107 Dwarf_Small *next_byte_ptr; |
|
108 |
|
109 /* Offset past the last byte written into Dwarf_P_Expr_s. */ |
|
110 int next_byte_offset; |
|
111 |
|
112 /* ***** BEGIN CODE ***** */ |
|
113 |
|
114 if (expr == NULL) { |
|
115 _dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL); |
|
116 return (DW_DLV_NOCOUNT); |
|
117 } |
|
118 |
|
119 if (expr->ex_dbg == NULL) { |
|
120 _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL); |
|
121 return (DW_DLV_NOCOUNT); |
|
122 } |
|
123 |
|
124 operand = NULL; |
|
125 operand_size = 0; |
|
126 |
|
127 switch (opcode) { |
|
128 case DW_OP_reg0: |
|
129 case DW_OP_reg1: |
|
130 case DW_OP_reg2: |
|
131 case DW_OP_reg3: |
|
132 case DW_OP_reg4: |
|
133 case DW_OP_reg5: |
|
134 case DW_OP_reg6: |
|
135 case DW_OP_reg7: |
|
136 case DW_OP_reg8: |
|
137 case DW_OP_reg9: |
|
138 case DW_OP_reg10: |
|
139 case DW_OP_reg11: |
|
140 case DW_OP_reg12: |
|
141 case DW_OP_reg13: |
|
142 case DW_OP_reg14: |
|
143 case DW_OP_reg15: |
|
144 case DW_OP_reg16: |
|
145 case DW_OP_reg17: |
|
146 case DW_OP_reg18: |
|
147 case DW_OP_reg19: |
|
148 case DW_OP_reg20: |
|
149 case DW_OP_reg21: |
|
150 case DW_OP_reg22: |
|
151 case DW_OP_reg23: |
|
152 case DW_OP_reg24: |
|
153 case DW_OP_reg25: |
|
154 case DW_OP_reg26: |
|
155 case DW_OP_reg27: |
|
156 case DW_OP_reg28: |
|
157 case DW_OP_reg29: |
|
158 case DW_OP_reg30: |
|
159 case DW_OP_reg31: |
|
160 break; |
|
161 |
|
162 case DW_OP_breg0: |
|
163 case DW_OP_breg1: |
|
164 case DW_OP_breg2: |
|
165 case DW_OP_breg3: |
|
166 case DW_OP_breg4: |
|
167 case DW_OP_breg5: |
|
168 case DW_OP_breg6: |
|
169 case DW_OP_breg7: |
|
170 case DW_OP_breg8: |
|
171 case DW_OP_breg9: |
|
172 case DW_OP_breg10: |
|
173 case DW_OP_breg11: |
|
174 case DW_OP_breg12: |
|
175 case DW_OP_breg13: |
|
176 case DW_OP_breg14: |
|
177 case DW_OP_breg15: |
|
178 case DW_OP_breg16: |
|
179 case DW_OP_breg17: |
|
180 case DW_OP_breg18: |
|
181 case DW_OP_breg19: |
|
182 case DW_OP_breg20: |
|
183 case DW_OP_breg21: |
|
184 case DW_OP_breg22: |
|
185 case DW_OP_breg23: |
|
186 case DW_OP_breg24: |
|
187 case DW_OP_breg25: |
|
188 case DW_OP_breg26: |
|
189 case DW_OP_breg27: |
|
190 case DW_OP_breg28: |
|
191 case DW_OP_breg29: |
|
192 case DW_OP_breg30: |
|
193 case DW_OP_breg31: |
|
194 res = _dwarf_pro_encode_signed_leb128_nm(val1, |
|
195 &operand_size, |
|
196 encode_buffer, |
|
197 sizeof(encode_buffer)); |
|
198 if (res != DW_DLV_OK) { |
|
199 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
200 return (DW_DLV_NOCOUNT); |
|
201 } |
|
202 operand = (Dwarf_Small *) encode_buffer; |
|
203 break; |
|
204 |
|
205 case DW_OP_regx: |
|
206 res = _dwarf_pro_encode_leb128_nm(val1, &operand_size, |
|
207 encode_buffer, |
|
208 sizeof(encode_buffer)); |
|
209 if (res != DW_DLV_OK) { |
|
210 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
211 return (DW_DLV_NOCOUNT); |
|
212 } |
|
213 operand = (Dwarf_Small *) encode_buffer; |
|
214 break; |
|
215 |
|
216 case DW_OP_lit0: |
|
217 case DW_OP_lit1: |
|
218 case DW_OP_lit2: |
|
219 case DW_OP_lit3: |
|
220 case DW_OP_lit4: |
|
221 case DW_OP_lit5: |
|
222 case DW_OP_lit6: |
|
223 case DW_OP_lit7: |
|
224 case DW_OP_lit8: |
|
225 case DW_OP_lit9: |
|
226 case DW_OP_lit10: |
|
227 case DW_OP_lit11: |
|
228 case DW_OP_lit12: |
|
229 case DW_OP_lit13: |
|
230 case DW_OP_lit14: |
|
231 case DW_OP_lit15: |
|
232 case DW_OP_lit16: |
|
233 case DW_OP_lit17: |
|
234 case DW_OP_lit18: |
|
235 case DW_OP_lit19: |
|
236 case DW_OP_lit20: |
|
237 case DW_OP_lit21: |
|
238 case DW_OP_lit22: |
|
239 case DW_OP_lit23: |
|
240 case DW_OP_lit24: |
|
241 case DW_OP_lit25: |
|
242 case DW_OP_lit26: |
|
243 case DW_OP_lit27: |
|
244 case DW_OP_lit28: |
|
245 case DW_OP_lit29: |
|
246 case DW_OP_lit30: |
|
247 case DW_OP_lit31: |
|
248 break; |
|
249 |
|
250 case DW_OP_addr: |
|
251 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_BAD_EXPR_OPCODE); |
|
252 return (DW_DLV_NOCOUNT); |
|
253 |
|
254 case DW_OP_const1u: |
|
255 case DW_OP_const1s: |
|
256 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
257 WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 1); |
|
258 operand_size = 1; |
|
259 break; |
|
260 |
|
261 case DW_OP_const2u: |
|
262 case DW_OP_const2s: |
|
263 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
264 WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 2); |
|
265 operand_size = 2; |
|
266 break; |
|
267 |
|
268 case DW_OP_const4u: |
|
269 case DW_OP_const4s: |
|
270 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
271 WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 4); |
|
272 operand_size = 4; |
|
273 break; |
|
274 |
|
275 case DW_OP_const8u: |
|
276 case DW_OP_const8s: |
|
277 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
278 WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 8); |
|
279 operand_size = 8; |
|
280 break; |
|
281 |
|
282 case DW_OP_constu: |
|
283 res = _dwarf_pro_encode_leb128_nm(val1, |
|
284 &operand_size, |
|
285 encode_buffer, |
|
286 sizeof(encode_buffer)); |
|
287 if (res != DW_DLV_OK) { |
|
288 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
289 return (DW_DLV_NOCOUNT); |
|
290 } |
|
291 operand = (Dwarf_Small *) encode_buffer; |
|
292 break; |
|
293 |
|
294 case DW_OP_consts: |
|
295 res = _dwarf_pro_encode_signed_leb128_nm(val1, |
|
296 &operand_size, |
|
297 encode_buffer, |
|
298 sizeof(encode_buffer)); |
|
299 if (res != DW_DLV_OK) { |
|
300 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
301 return (DW_DLV_NOCOUNT); |
|
302 } |
|
303 operand = (Dwarf_Small *) encode_buffer; |
|
304 break; |
|
305 |
|
306 case DW_OP_fbreg: |
|
307 res = _dwarf_pro_encode_signed_leb128_nm(val1, |
|
308 &operand_size, |
|
309 encode_buffer, |
|
310 sizeof(encode_buffer)); |
|
311 if (res != DW_DLV_OK) { |
|
312 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
313 return (DW_DLV_NOCOUNT); |
|
314 } |
|
315 operand = (Dwarf_Small *) encode_buffer; |
|
316 break; |
|
317 |
|
318 case DW_OP_bregx: |
|
319 res = _dwarf_pro_encode_leb128_nm(val1, &operand_size, |
|
320 encode_buffer, |
|
321 sizeof(encode_buffer)); |
|
322 if (res != DW_DLV_OK) { |
|
323 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
324 return (DW_DLV_NOCOUNT); |
|
325 } |
|
326 operand = (Dwarf_Small *) encode_buffer; |
|
327 /* put this one directly into 'operand' at tail of prev value */ |
|
328 res = _dwarf_pro_encode_signed_leb128_nm(val2, &operand2_size, |
|
329 ((char *) operand) + |
|
330 operand_size, |
|
331 sizeof |
|
332 (encode_buffer2)); |
|
333 if (res != DW_DLV_OK) { |
|
334 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
335 return (DW_DLV_NOCOUNT); |
|
336 } |
|
337 operand_size += operand2_size; |
|
338 |
|
339 case DW_OP_dup: |
|
340 case DW_OP_drop: |
|
341 break; |
|
342 |
|
343 case DW_OP_pick: |
|
344 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
345 WRITE_UNALIGNED(dbg, operand, (const void *) &val1, |
|
346 sizeof(val1), 1); |
|
347 operand_size = 1; |
|
348 break; |
|
349 |
|
350 case DW_OP_over: |
|
351 case DW_OP_swap: |
|
352 case DW_OP_rot: |
|
353 case DW_OP_deref: |
|
354 case DW_OP_xderef: |
|
355 break; |
|
356 |
|
357 case DW_OP_deref_size: |
|
358 case DW_OP_xderef_size: |
|
359 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
360 WRITE_UNALIGNED(dbg, operand, (const void *) &val1, |
|
361 sizeof(val1), 1); |
|
362 operand_size = 1; |
|
363 break; |
|
364 |
|
365 case DW_OP_abs: |
|
366 case DW_OP_and: |
|
367 case DW_OP_div: |
|
368 case DW_OP_minus: |
|
369 case DW_OP_mod: |
|
370 case DW_OP_mul: |
|
371 case DW_OP_neg: |
|
372 case DW_OP_not: |
|
373 case DW_OP_or: |
|
374 case DW_OP_plus: |
|
375 break; |
|
376 |
|
377 case DW_OP_plus_uconst: |
|
378 res = _dwarf_pro_encode_leb128_nm(val1, &operand_size, |
|
379 encode_buffer, |
|
380 sizeof(encode_buffer)); |
|
381 if (res != DW_DLV_OK) { |
|
382 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
383 return (DW_DLV_NOCOUNT); |
|
384 } |
|
385 operand = (Dwarf_Small *) encode_buffer; |
|
386 break; |
|
387 |
|
388 case DW_OP_shl: |
|
389 case DW_OP_shr: |
|
390 case DW_OP_shra: |
|
391 case DW_OP_xor: |
|
392 break; |
|
393 |
|
394 case DW_OP_le: |
|
395 case DW_OP_ge: |
|
396 case DW_OP_eq: |
|
397 case DW_OP_lt: |
|
398 case DW_OP_gt: |
|
399 case DW_OP_ne: |
|
400 break; |
|
401 |
|
402 case DW_OP_skip: |
|
403 case DW_OP_bra: |
|
404 /* FIX: unhandled! OP_bra, OP_skip! */ |
|
405 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_BAD_EXPR_OPCODE); |
|
406 return (DW_DLV_NOCOUNT); |
|
407 |
|
408 case DW_OP_piece: |
|
409 res = _dwarf_pro_encode_leb128_nm(val1, &operand_size, |
|
410 encode_buffer, |
|
411 sizeof(encode_buffer)); |
|
412 if (res != DW_DLV_OK) { |
|
413 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
414 return (DW_DLV_NOCOUNT); |
|
415 } |
|
416 operand = (Dwarf_Small *) encode_buffer; |
|
417 break; |
|
418 |
|
419 case DW_OP_nop: |
|
420 break; |
|
421 case DW_OP_push_object_address: /* DWARF3 */ |
|
422 break; |
|
423 case DW_OP_call2: /* DWARF3 */ |
|
424 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
425 WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 2); |
|
426 operand_size = 2; |
|
427 break; |
|
428 |
|
429 case DW_OP_call4: /* DWARF3 */ |
|
430 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
431 WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 4); |
|
432 operand_size = 4; |
|
433 break; |
|
434 |
|
435 case DW_OP_call_ref: /* DWARF3 */ |
|
436 operand = (Dwarf_Small *) & operand_buffer[0]; |
|
437 WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), |
|
438 dbg->de_offset_size); |
|
439 operand_size = dbg->de_offset_size; |
|
440 break; |
|
441 case DW_OP_form_tls_address: /* DWARF3f */ |
|
442 break; |
|
443 case DW_OP_call_frame_cfa: /* DWARF3f */ |
|
444 break; |
|
445 case DW_OP_bit_piece: /* DWARF3f */ |
|
446 res = _dwarf_pro_encode_leb128_nm(val1, &operand_size, |
|
447 encode_buffer, |
|
448 sizeof(encode_buffer)); |
|
449 if (res != DW_DLV_OK) { |
|
450 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
451 return (DW_DLV_NOCOUNT); |
|
452 } |
|
453 operand = (Dwarf_Small *) encode_buffer; |
|
454 /* put this one directly into 'operand' at tail of prev value */ |
|
455 res = _dwarf_pro_encode_leb128_nm(val2, &operand2_size, |
|
456 ((char *) operand) + |
|
457 operand_size, |
|
458 sizeof(encode_buffer2)); |
|
459 if (res != DW_DLV_OK) { |
|
460 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
461 return (DW_DLV_NOCOUNT); |
|
462 } |
|
463 operand_size += operand2_size; |
|
464 |
|
465 |
|
466 default: |
|
467 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_BAD_EXPR_OPCODE); |
|
468 return (DW_DLV_NOCOUNT); |
|
469 } |
|
470 |
|
471 next_byte_offset = expr->ex_next_byte_offset + operand_size + 1; |
|
472 |
|
473 if (next_byte_offset > MAXIMUM_LOC_EXPR_LENGTH) { |
|
474 _dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
475 return (DW_DLV_NOCOUNT); |
|
476 } |
|
477 |
|
478 next_byte_ptr = |
|
479 &(expr->ex_byte_stream[0]) + expr->ex_next_byte_offset; |
|
480 |
|
481 *next_byte_ptr = opcode; |
|
482 next_byte_ptr++; |
|
483 memcpy(next_byte_ptr, operand, operand_size); |
|
484 |
|
485 expr->ex_next_byte_offset = next_byte_offset; |
|
486 return (next_byte_offset); |
|
487 } |
|
488 |
|
489 Dwarf_Unsigned |
|
490 dwarf_add_expr_addr_b(Dwarf_P_Expr expr, |
|
491 Dwarf_Unsigned addr, |
|
492 Dwarf_Unsigned sym_index, Dwarf_Error * error) |
|
493 { |
|
494 Dwarf_P_Debug dbg; |
|
495 Dwarf_Small *next_byte_ptr; |
|
496 Dwarf_Unsigned next_byte_offset; |
|
497 int upointer_size; |
|
498 |
|
499 if (expr == NULL) { |
|
500 _dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL); |
|
501 return (DW_DLV_NOCOUNT); |
|
502 } |
|
503 |
|
504 dbg = expr->ex_dbg; |
|
505 if (dbg == NULL) { |
|
506 _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL); |
|
507 return (DW_DLV_NOCOUNT); |
|
508 } |
|
509 |
|
510 upointer_size = dbg->de_pointer_size; |
|
511 next_byte_offset = expr->ex_next_byte_offset + upointer_size + 1; |
|
512 if (next_byte_offset > MAXIMUM_LOC_EXPR_LENGTH) { |
|
513 _dwarf_p_error(dbg, error, DW_DLE_EXPR_LENGTH_BAD); |
|
514 return (DW_DLV_NOCOUNT); |
|
515 } |
|
516 |
|
517 next_byte_ptr = |
|
518 &(expr->ex_byte_stream[0]) + expr->ex_next_byte_offset; |
|
519 |
|
520 *next_byte_ptr = DW_OP_addr; |
|
521 next_byte_ptr++; |
|
522 WRITE_UNALIGNED(dbg, next_byte_ptr, (const void *) &addr, |
|
523 sizeof(addr), upointer_size); |
|
524 |
|
525 if (expr->ex_reloc_offset != 0) { |
|
526 _dwarf_p_error(dbg, error, DW_DLE_MULTIPLE_RELOC_IN_EXPR); |
|
527 return (DW_DLV_NOCOUNT); |
|
528 } |
|
529 |
|
530 expr->ex_reloc_sym_index = sym_index; |
|
531 expr->ex_reloc_offset = expr->ex_next_byte_offset + 1; |
|
532 |
|
533 expr->ex_next_byte_offset = next_byte_offset; |
|
534 return (next_byte_offset); |
|
535 } |
|
536 |
|
537 Dwarf_Unsigned |
|
538 dwarf_add_expr_addr(Dwarf_P_Expr expr, |
|
539 Dwarf_Unsigned addr, |
|
540 Dwarf_Signed sym_index, Dwarf_Error * error) |
|
541 { |
|
542 return |
|
543 dwarf_add_expr_addr_b(expr, addr, (Dwarf_Unsigned) sym_index, |
|
544 error); |
|
545 } |
|
546 |
|
547 |
|
548 Dwarf_Unsigned |
|
549 dwarf_expr_current_offset(Dwarf_P_Expr expr, Dwarf_Error * error) |
|
550 { |
|
551 if (expr == NULL) { |
|
552 _dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL); |
|
553 return (DW_DLV_NOCOUNT); |
|
554 } |
|
555 |
|
556 if (expr->ex_dbg == NULL) { |
|
557 _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL); |
|
558 return (DW_DLV_NOCOUNT); |
|
559 } |
|
560 |
|
561 return (expr->ex_next_byte_offset); |
|
562 } |
|
563 |
|
564 void |
|
565 dwarf_expr_reset(Dwarf_P_Expr expr, Dwarf_Error * error) |
|
566 { |
|
567 if (expr == NULL) { |
|
568 _dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL); |
|
569 return; |
|
570 } |
|
571 expr->ex_next_byte_offset=0; |
|
572 } |
|
573 |
|
574 |
|
575 Dwarf_Addr |
|
576 dwarf_expr_into_block(Dwarf_P_Expr expr, |
|
577 Dwarf_Unsigned * length, Dwarf_Error * error) |
|
578 { |
|
579 if (expr == NULL) { |
|
580 _dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL); |
|
581 return (DW_DLV_BADADDR); |
|
582 } |
|
583 |
|
584 if (expr->ex_dbg == NULL) { |
|
585 _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL); |
|
586 return (DW_DLV_BADADDR); |
|
587 } |
|
588 |
|
589 if (length != NULL) |
|
590 *length = expr->ex_next_byte_offset; |
|
591 /* The following cast from pointer to integer is ok as long as |
|
592 Dwarf_Addr is at least as large as a pointer. Which is a |
|
593 requirement of libdwarf so must be satisfied (some compilers |
|
594 emit a warning about the following line). */ |
|
595 return ((Dwarf_Addr) & (expr->ex_byte_stream[0])); |
|
596 } |