]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/dwarf2expr.c
Fix buffer overrun parsing a corrupt tekhex binary.
[thirdparty/binutils-gdb.git] / gdb / dwarf2expr.c
1 /* DWARF 2 Expression Evaluator.
2
3 Copyright (C) 2001-2017 Free Software Foundation, Inc.
4
5 Contributed by Daniel Berlin (dan@dberlin.org)
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #include "defs.h"
23 #include "symtab.h"
24 #include "gdbtypes.h"
25 #include "value.h"
26 #include "gdbcore.h"
27 #include "dwarf2.h"
28 #include "dwarf2expr.h"
29 #include "dwarf2loc.h"
30 #include "common/underlying.h"
31
32 /* Cookie for gdbarch data. */
33
34 static struct gdbarch_data *dwarf_arch_cookie;
35
36 /* This holds gdbarch-specific types used by the DWARF expression
37 evaluator. See comments in execute_stack_op. */
38
39 struct dwarf_gdbarch_types
40 {
41 struct type *dw_types[3];
42 };
43
44 /* Allocate and fill in dwarf_gdbarch_types for an arch. */
45
46 static void *
47 dwarf_gdbarch_types_init (struct gdbarch *gdbarch)
48 {
49 struct dwarf_gdbarch_types *types
50 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf_gdbarch_types);
51
52 /* The types themselves are lazily initialized. */
53
54 return types;
55 }
56
57 /* Return the type used for DWARF operations where the type is
58 unspecified in the DWARF spec. Only certain sizes are
59 supported. */
60
61 struct type *
62 dwarf_expr_context::address_type () const
63 {
64 struct dwarf_gdbarch_types *types
65 = (struct dwarf_gdbarch_types *) gdbarch_data (this->gdbarch,
66 dwarf_arch_cookie);
67 int ndx;
68
69 if (this->addr_size == 2)
70 ndx = 0;
71 else if (this->addr_size == 4)
72 ndx = 1;
73 else if (this->addr_size == 8)
74 ndx = 2;
75 else
76 error (_("Unsupported address size in DWARF expressions: %d bits"),
77 8 * this->addr_size);
78
79 if (types->dw_types[ndx] == NULL)
80 types->dw_types[ndx]
81 = arch_integer_type (this->gdbarch,
82 8 * this->addr_size,
83 0, "<signed DWARF address type>");
84
85 return types->dw_types[ndx];
86 }
87
88 /* Create a new context for the expression evaluator. */
89
90 dwarf_expr_context::dwarf_expr_context ()
91 : stack (NULL),
92 stack_len (0),
93 stack_allocated (10),
94 gdbarch (NULL),
95 addr_size (0),
96 ref_addr_size (0),
97 offset (0),
98 recursion_depth (0),
99 max_recursion_depth (0x100),
100 location (DWARF_VALUE_MEMORY),
101 len (0),
102 data (NULL),
103 initialized (0),
104 num_pieces (0),
105 pieces (NULL)
106 {
107 this->stack = XNEWVEC (struct dwarf_stack_value, this->stack_allocated);
108 }
109
110 /* Clean up a dwarf_expr_context. */
111
112 dwarf_expr_context::~dwarf_expr_context ()
113 {
114 xfree (this->stack);
115 xfree (this->pieces);
116 }
117
118 /* Expand the memory allocated stack to contain at least
119 NEED more elements than are currently used. */
120
121 void
122 dwarf_expr_context::grow_stack (size_t need)
123 {
124 if (this->stack_len + need > this->stack_allocated)
125 {
126 size_t newlen = this->stack_len + need + 10;
127
128 this->stack = XRESIZEVEC (struct dwarf_stack_value, this->stack, newlen);
129 this->stack_allocated = newlen;
130 }
131 }
132
133 /* Push VALUE onto the stack. */
134
135 void
136 dwarf_expr_context::push (struct value *value, int in_stack_memory)
137 {
138 struct dwarf_stack_value *v;
139
140 grow_stack (1);
141 v = &this->stack[this->stack_len++];
142 v->value = value;
143 v->in_stack_memory = in_stack_memory;
144 }
145
146 /* Push VALUE onto the stack. */
147
148 void
149 dwarf_expr_context::push_address (CORE_ADDR value, int in_stack_memory)
150 {
151 push (value_from_ulongest (address_type (), value), in_stack_memory);
152 }
153
154 /* Pop the top item off of the stack. */
155
156 void
157 dwarf_expr_context::pop ()
158 {
159 if (this->stack_len <= 0)
160 error (_("dwarf expression stack underflow"));
161 this->stack_len--;
162 }
163
164 /* Retrieve the N'th item on the stack. */
165
166 struct value *
167 dwarf_expr_context::fetch (int n)
168 {
169 if (this->stack_len <= n)
170 error (_("Asked for position %d of stack, "
171 "stack only has %d elements on it."),
172 n, this->stack_len);
173 return this->stack[this->stack_len - (1 + n)].value;
174 }
175
176 /* Require that TYPE be an integral type; throw an exception if not. */
177
178 static void
179 dwarf_require_integral (struct type *type)
180 {
181 if (TYPE_CODE (type) != TYPE_CODE_INT
182 && TYPE_CODE (type) != TYPE_CODE_CHAR
183 && TYPE_CODE (type) != TYPE_CODE_BOOL)
184 error (_("integral type expected in DWARF expression"));
185 }
186
187 /* Return the unsigned form of TYPE. TYPE is necessarily an integral
188 type. */
189
190 static struct type *
191 get_unsigned_type (struct gdbarch *gdbarch, struct type *type)
192 {
193 switch (TYPE_LENGTH (type))
194 {
195 case 1:
196 return builtin_type (gdbarch)->builtin_uint8;
197 case 2:
198 return builtin_type (gdbarch)->builtin_uint16;
199 case 4:
200 return builtin_type (gdbarch)->builtin_uint32;
201 case 8:
202 return builtin_type (gdbarch)->builtin_uint64;
203 default:
204 error (_("no unsigned variant found for type, while evaluating "
205 "DWARF expression"));
206 }
207 }
208
209 /* Return the signed form of TYPE. TYPE is necessarily an integral
210 type. */
211
212 static struct type *
213 get_signed_type (struct gdbarch *gdbarch, struct type *type)
214 {
215 switch (TYPE_LENGTH (type))
216 {
217 case 1:
218 return builtin_type (gdbarch)->builtin_int8;
219 case 2:
220 return builtin_type (gdbarch)->builtin_int16;
221 case 4:
222 return builtin_type (gdbarch)->builtin_int32;
223 case 8:
224 return builtin_type (gdbarch)->builtin_int64;
225 default:
226 error (_("no signed variant found for type, while evaluating "
227 "DWARF expression"));
228 }
229 }
230
231 /* Retrieve the N'th item on the stack, converted to an address. */
232
233 CORE_ADDR
234 dwarf_expr_context::fetch_address (int n)
235 {
236 struct value *result_val = fetch (n);
237 enum bfd_endian byte_order = gdbarch_byte_order (this->gdbarch);
238 ULONGEST result;
239
240 dwarf_require_integral (value_type (result_val));
241 result = extract_unsigned_integer (value_contents (result_val),
242 TYPE_LENGTH (value_type (result_val)),
243 byte_order);
244
245 /* For most architectures, calling extract_unsigned_integer() alone
246 is sufficient for extracting an address. However, some
247 architectures (e.g. MIPS) use signed addresses and using
248 extract_unsigned_integer() will not produce a correct
249 result. Make sure we invoke gdbarch_integer_to_address()
250 for those architectures which require it. */
251 if (gdbarch_integer_to_address_p (this->gdbarch))
252 {
253 gdb_byte *buf = (gdb_byte *) alloca (this->addr_size);
254 struct type *int_type = get_unsigned_type (this->gdbarch,
255 value_type (result_val));
256
257 store_unsigned_integer (buf, this->addr_size, byte_order, result);
258 return gdbarch_integer_to_address (this->gdbarch, int_type, buf);
259 }
260
261 return (CORE_ADDR) result;
262 }
263
264 /* Retrieve the in_stack_memory flag of the N'th item on the stack. */
265
266 int
267 dwarf_expr_context::fetch_in_stack_memory (int n)
268 {
269 if (this->stack_len <= n)
270 error (_("Asked for position %d of stack, "
271 "stack only has %d elements on it."),
272 n, this->stack_len);
273 return this->stack[this->stack_len - (1 + n)].in_stack_memory;
274 }
275
276 /* Return true if the expression stack is empty. */
277
278 int
279 dwarf_expr_context::stack_empty_p () const
280 {
281 return this->stack_len == 0;
282 }
283
284 /* Add a new piece to the dwarf_expr_context's piece list. */
285 void
286 dwarf_expr_context::add_piece (ULONGEST size, ULONGEST offset)
287 {
288 struct dwarf_expr_piece *p;
289
290 this->num_pieces++;
291
292 this->pieces
293 = XRESIZEVEC (struct dwarf_expr_piece, this->pieces, this->num_pieces);
294
295 p = &this->pieces[this->num_pieces - 1];
296 p->location = this->location;
297 p->size = size;
298 p->offset = offset;
299
300 if (p->location == DWARF_VALUE_LITERAL)
301 {
302 p->v.literal.data = this->data;
303 p->v.literal.length = this->len;
304 }
305 else if (stack_empty_p ())
306 {
307 p->location = DWARF_VALUE_OPTIMIZED_OUT;
308 /* Also reset the context's location, for our callers. This is
309 a somewhat strange approach, but this lets us avoid setting
310 the location to DWARF_VALUE_MEMORY in all the individual
311 cases in the evaluator. */
312 this->location = DWARF_VALUE_OPTIMIZED_OUT;
313 }
314 else if (p->location == DWARF_VALUE_MEMORY)
315 {
316 p->v.mem.addr = fetch_address (0);
317 p->v.mem.in_stack_memory = fetch_in_stack_memory (0);
318 }
319 else if (p->location == DWARF_VALUE_IMPLICIT_POINTER)
320 {
321 p->v.ptr.die_sect_off = (sect_offset) this->len;
322 p->v.ptr.offset = value_as_long (fetch (0));
323 }
324 else if (p->location == DWARF_VALUE_REGISTER)
325 p->v.regno = value_as_long (fetch (0));
326 else
327 {
328 p->v.value = fetch (0);
329 }
330 }
331
332 /* Evaluate the expression at ADDR (LEN bytes long). */
333
334 void
335 dwarf_expr_context::eval (const gdb_byte *addr, size_t len)
336 {
337 int old_recursion_depth = this->recursion_depth;
338
339 execute_stack_op (addr, addr + len);
340
341 /* RECURSION_DEPTH becomes invalid if an exception was thrown here. */
342
343 gdb_assert (this->recursion_depth == old_recursion_depth);
344 }
345
346 /* Helper to read a uleb128 value or throw an error. */
347
348 const gdb_byte *
349 safe_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end,
350 uint64_t *r)
351 {
352 buf = gdb_read_uleb128 (buf, buf_end, r);
353 if (buf == NULL)
354 error (_("DWARF expression error: ran off end of buffer reading uleb128 value"));
355 return buf;
356 }
357
358 /* Helper to read a sleb128 value or throw an error. */
359
360 const gdb_byte *
361 safe_read_sleb128 (const gdb_byte *buf, const gdb_byte *buf_end,
362 int64_t *r)
363 {
364 buf = gdb_read_sleb128 (buf, buf_end, r);
365 if (buf == NULL)
366 error (_("DWARF expression error: ran off end of buffer reading sleb128 value"));
367 return buf;
368 }
369
370 const gdb_byte *
371 safe_skip_leb128 (const gdb_byte *buf, const gdb_byte *buf_end)
372 {
373 buf = gdb_skip_leb128 (buf, buf_end);
374 if (buf == NULL)
375 error (_("DWARF expression error: ran off end of buffer reading leb128 value"));
376 return buf;
377 }
378 \f
379
380 /* Check that the current operator is either at the end of an
381 expression, or that it is followed by a composition operator or by
382 DW_OP_GNU_uninit (which should terminate the expression). */
383
384 void
385 dwarf_expr_require_composition (const gdb_byte *op_ptr, const gdb_byte *op_end,
386 const char *op_name)
387 {
388 if (op_ptr != op_end && *op_ptr != DW_OP_piece && *op_ptr != DW_OP_bit_piece
389 && *op_ptr != DW_OP_GNU_uninit)
390 error (_("DWARF-2 expression error: `%s' operations must be "
391 "used either alone or in conjunction with DW_OP_piece "
392 "or DW_OP_bit_piece."),
393 op_name);
394 }
395
396 /* Return true iff the types T1 and T2 are "the same". This only does
397 checks that might reasonably be needed to compare DWARF base
398 types. */
399
400 static int
401 base_types_equal_p (struct type *t1, struct type *t2)
402 {
403 if (TYPE_CODE (t1) != TYPE_CODE (t2))
404 return 0;
405 if (TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2))
406 return 0;
407 return TYPE_LENGTH (t1) == TYPE_LENGTH (t2);
408 }
409
410 /* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_reg* return the
411 DWARF register number. Otherwise return -1. */
412
413 int
414 dwarf_block_to_dwarf_reg (const gdb_byte *buf, const gdb_byte *buf_end)
415 {
416 uint64_t dwarf_reg;
417
418 if (buf_end <= buf)
419 return -1;
420 if (*buf >= DW_OP_reg0 && *buf <= DW_OP_reg31)
421 {
422 if (buf_end - buf != 1)
423 return -1;
424 return *buf - DW_OP_reg0;
425 }
426
427 if (*buf == DW_OP_regval_type || *buf == DW_OP_GNU_regval_type)
428 {
429 buf++;
430 buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg);
431 if (buf == NULL)
432 return -1;
433 buf = gdb_skip_leb128 (buf, buf_end);
434 if (buf == NULL)
435 return -1;
436 }
437 else if (*buf == DW_OP_regx)
438 {
439 buf++;
440 buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg);
441 if (buf == NULL)
442 return -1;
443 }
444 else
445 return -1;
446 if (buf != buf_end || (int) dwarf_reg != dwarf_reg)
447 return -1;
448 return dwarf_reg;
449 }
450
451 /* If <BUF..BUF_END] contains DW_FORM_block* with just DW_OP_breg*(0) and
452 DW_OP_deref* return the DWARF register number. Otherwise return -1.
453 DEREF_SIZE_RETURN contains -1 for DW_OP_deref; otherwise it contains the
454 size from DW_OP_deref_size. */
455
456 int
457 dwarf_block_to_dwarf_reg_deref (const gdb_byte *buf, const gdb_byte *buf_end,
458 CORE_ADDR *deref_size_return)
459 {
460 uint64_t dwarf_reg;
461 int64_t offset;
462
463 if (buf_end <= buf)
464 return -1;
465
466 if (*buf >= DW_OP_breg0 && *buf <= DW_OP_breg31)
467 {
468 dwarf_reg = *buf - DW_OP_breg0;
469 buf++;
470 if (buf >= buf_end)
471 return -1;
472 }
473 else if (*buf == DW_OP_bregx)
474 {
475 buf++;
476 buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg);
477 if (buf == NULL)
478 return -1;
479 if ((int) dwarf_reg != dwarf_reg)
480 return -1;
481 }
482 else
483 return -1;
484
485 buf = gdb_read_sleb128 (buf, buf_end, &offset);
486 if (buf == NULL)
487 return -1;
488 if (offset != 0)
489 return -1;
490
491 if (*buf == DW_OP_deref)
492 {
493 buf++;
494 *deref_size_return = -1;
495 }
496 else if (*buf == DW_OP_deref_size)
497 {
498 buf++;
499 if (buf >= buf_end)
500 return -1;
501 *deref_size_return = *buf++;
502 }
503 else
504 return -1;
505
506 if (buf != buf_end)
507 return -1;
508
509 return dwarf_reg;
510 }
511
512 /* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_fbreg(X) fill
513 in FB_OFFSET_RETURN with the X offset and return 1. Otherwise return 0. */
514
515 int
516 dwarf_block_to_fb_offset (const gdb_byte *buf, const gdb_byte *buf_end,
517 CORE_ADDR *fb_offset_return)
518 {
519 int64_t fb_offset;
520
521 if (buf_end <= buf)
522 return 0;
523
524 if (*buf != DW_OP_fbreg)
525 return 0;
526 buf++;
527
528 buf = gdb_read_sleb128 (buf, buf_end, &fb_offset);
529 if (buf == NULL)
530 return 0;
531 *fb_offset_return = fb_offset;
532 if (buf != buf_end || fb_offset != (LONGEST) *fb_offset_return)
533 return 0;
534
535 return 1;
536 }
537
538 /* If <BUF..BUF_END] contains DW_FORM_block* with single DW_OP_bregSP(X) fill
539 in SP_OFFSET_RETURN with the X offset and return 1. Otherwise return 0.
540 The matched SP register number depends on GDBARCH. */
541
542 int
543 dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
544 const gdb_byte *buf_end, CORE_ADDR *sp_offset_return)
545 {
546 uint64_t dwarf_reg;
547 int64_t sp_offset;
548
549 if (buf_end <= buf)
550 return 0;
551 if (*buf >= DW_OP_breg0 && *buf <= DW_OP_breg31)
552 {
553 dwarf_reg = *buf - DW_OP_breg0;
554 buf++;
555 }
556 else
557 {
558 if (*buf != DW_OP_bregx)
559 return 0;
560 buf++;
561 buf = gdb_read_uleb128 (buf, buf_end, &dwarf_reg);
562 if (buf == NULL)
563 return 0;
564 }
565
566 if (dwarf_reg_to_regnum (gdbarch, dwarf_reg)
567 != gdbarch_sp_regnum (gdbarch))
568 return 0;
569
570 buf = gdb_read_sleb128 (buf, buf_end, &sp_offset);
571 if (buf == NULL)
572 return 0;
573 *sp_offset_return = sp_offset;
574 if (buf != buf_end || sp_offset != (LONGEST) *sp_offset_return)
575 return 0;
576
577 return 1;
578 }
579
580 /* The engine for the expression evaluator. Using the context in this
581 object, evaluate the expression between OP_PTR and OP_END. */
582
583 void
584 dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
585 const gdb_byte *op_end)
586 {
587 enum bfd_endian byte_order = gdbarch_byte_order (this->gdbarch);
588 /* Old-style "untyped" DWARF values need special treatment in a
589 couple of places, specifically DW_OP_mod and DW_OP_shr. We need
590 a special type for these values so we can distinguish them from
591 values that have an explicit type, because explicitly-typed
592 values do not need special treatment. This special type must be
593 different (in the `==' sense) from any base type coming from the
594 CU. */
595 struct type *address_type = this->address_type ();
596
597 this->location = DWARF_VALUE_MEMORY;
598 this->initialized = 1; /* Default is initialized. */
599
600 if (this->recursion_depth > this->max_recursion_depth)
601 error (_("DWARF-2 expression error: Loop detected (%d)."),
602 this->recursion_depth);
603 this->recursion_depth++;
604
605 while (op_ptr < op_end)
606 {
607 enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr++;
608 ULONGEST result;
609 /* Assume the value is not in stack memory.
610 Code that knows otherwise sets this to 1.
611 Some arithmetic on stack addresses can probably be assumed to still
612 be a stack address, but we skip this complication for now.
613 This is just an optimization, so it's always ok to punt
614 and leave this as 0. */
615 int in_stack_memory = 0;
616 uint64_t uoffset, reg;
617 int64_t offset;
618 struct value *result_val = NULL;
619
620 /* The DWARF expression might have a bug causing an infinite
621 loop. In that case, quitting is the only way out. */
622 QUIT;
623
624 switch (op)
625 {
626 case DW_OP_lit0:
627 case DW_OP_lit1:
628 case DW_OP_lit2:
629 case DW_OP_lit3:
630 case DW_OP_lit4:
631 case DW_OP_lit5:
632 case DW_OP_lit6:
633 case DW_OP_lit7:
634 case DW_OP_lit8:
635 case DW_OP_lit9:
636 case DW_OP_lit10:
637 case DW_OP_lit11:
638 case DW_OP_lit12:
639 case DW_OP_lit13:
640 case DW_OP_lit14:
641 case DW_OP_lit15:
642 case DW_OP_lit16:
643 case DW_OP_lit17:
644 case DW_OP_lit18:
645 case DW_OP_lit19:
646 case DW_OP_lit20:
647 case DW_OP_lit21:
648 case DW_OP_lit22:
649 case DW_OP_lit23:
650 case DW_OP_lit24:
651 case DW_OP_lit25:
652 case DW_OP_lit26:
653 case DW_OP_lit27:
654 case DW_OP_lit28:
655 case DW_OP_lit29:
656 case DW_OP_lit30:
657 case DW_OP_lit31:
658 result = op - DW_OP_lit0;
659 result_val = value_from_ulongest (address_type, result);
660 break;
661
662 case DW_OP_addr:
663 result = extract_unsigned_integer (op_ptr,
664 this->addr_size, byte_order);
665 op_ptr += this->addr_size;
666 /* Some versions of GCC emit DW_OP_addr before
667 DW_OP_GNU_push_tls_address. In this case the value is an
668 index, not an address. We don't support things like
669 branching between the address and the TLS op. */
670 if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
671 result += this->offset;
672 result_val = value_from_ulongest (address_type, result);
673 break;
674
675 case DW_OP_GNU_addr_index:
676 op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
677 result = this->get_addr_index (uoffset);
678 result += this->offset;
679 result_val = value_from_ulongest (address_type, result);
680 break;
681 case DW_OP_GNU_const_index:
682 op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
683 result = this->get_addr_index (uoffset);
684 result_val = value_from_ulongest (address_type, result);
685 break;
686
687 case DW_OP_const1u:
688 result = extract_unsigned_integer (op_ptr, 1, byte_order);
689 result_val = value_from_ulongest (address_type, result);
690 op_ptr += 1;
691 break;
692 case DW_OP_const1s:
693 result = extract_signed_integer (op_ptr, 1, byte_order);
694 result_val = value_from_ulongest (address_type, result);
695 op_ptr += 1;
696 break;
697 case DW_OP_const2u:
698 result = extract_unsigned_integer (op_ptr, 2, byte_order);
699 result_val = value_from_ulongest (address_type, result);
700 op_ptr += 2;
701 break;
702 case DW_OP_const2s:
703 result = extract_signed_integer (op_ptr, 2, byte_order);
704 result_val = value_from_ulongest (address_type, result);
705 op_ptr += 2;
706 break;
707 case DW_OP_const4u:
708 result = extract_unsigned_integer (op_ptr, 4, byte_order);
709 result_val = value_from_ulongest (address_type, result);
710 op_ptr += 4;
711 break;
712 case DW_OP_const4s:
713 result = extract_signed_integer (op_ptr, 4, byte_order);
714 result_val = value_from_ulongest (address_type, result);
715 op_ptr += 4;
716 break;
717 case DW_OP_const8u:
718 result = extract_unsigned_integer (op_ptr, 8, byte_order);
719 result_val = value_from_ulongest (address_type, result);
720 op_ptr += 8;
721 break;
722 case DW_OP_const8s:
723 result = extract_signed_integer (op_ptr, 8, byte_order);
724 result_val = value_from_ulongest (address_type, result);
725 op_ptr += 8;
726 break;
727 case DW_OP_constu:
728 op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
729 result = uoffset;
730 result_val = value_from_ulongest (address_type, result);
731 break;
732 case DW_OP_consts:
733 op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
734 result = offset;
735 result_val = value_from_ulongest (address_type, result);
736 break;
737
738 /* The DW_OP_reg operations are required to occur alone in
739 location expressions. */
740 case DW_OP_reg0:
741 case DW_OP_reg1:
742 case DW_OP_reg2:
743 case DW_OP_reg3:
744 case DW_OP_reg4:
745 case DW_OP_reg5:
746 case DW_OP_reg6:
747 case DW_OP_reg7:
748 case DW_OP_reg8:
749 case DW_OP_reg9:
750 case DW_OP_reg10:
751 case DW_OP_reg11:
752 case DW_OP_reg12:
753 case DW_OP_reg13:
754 case DW_OP_reg14:
755 case DW_OP_reg15:
756 case DW_OP_reg16:
757 case DW_OP_reg17:
758 case DW_OP_reg18:
759 case DW_OP_reg19:
760 case DW_OP_reg20:
761 case DW_OP_reg21:
762 case DW_OP_reg22:
763 case DW_OP_reg23:
764 case DW_OP_reg24:
765 case DW_OP_reg25:
766 case DW_OP_reg26:
767 case DW_OP_reg27:
768 case DW_OP_reg28:
769 case DW_OP_reg29:
770 case DW_OP_reg30:
771 case DW_OP_reg31:
772 dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_reg");
773
774 result = op - DW_OP_reg0;
775 result_val = value_from_ulongest (address_type, result);
776 this->location = DWARF_VALUE_REGISTER;
777 break;
778
779 case DW_OP_regx:
780 op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
781 dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx");
782
783 result = reg;
784 result_val = value_from_ulongest (address_type, result);
785 this->location = DWARF_VALUE_REGISTER;
786 break;
787
788 case DW_OP_implicit_value:
789 {
790 uint64_t len;
791
792 op_ptr = safe_read_uleb128 (op_ptr, op_end, &len);
793 if (op_ptr + len > op_end)
794 error (_("DW_OP_implicit_value: too few bytes available."));
795 this->len = len;
796 this->data = op_ptr;
797 this->location = DWARF_VALUE_LITERAL;
798 op_ptr += len;
799 dwarf_expr_require_composition (op_ptr, op_end,
800 "DW_OP_implicit_value");
801 }
802 goto no_push;
803
804 case DW_OP_stack_value:
805 this->location = DWARF_VALUE_STACK;
806 dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_stack_value");
807 goto no_push;
808
809 case DW_OP_implicit_pointer:
810 case DW_OP_GNU_implicit_pointer:
811 {
812 int64_t len;
813
814 if (this->ref_addr_size == -1)
815 error (_("DWARF-2 expression error: DW_OP_implicit_pointer "
816 "is not allowed in frame context"));
817
818 /* The referred-to DIE of sect_offset kind. */
819 this->len = extract_unsigned_integer (op_ptr, this->ref_addr_size,
820 byte_order);
821 op_ptr += this->ref_addr_size;
822
823 /* The byte offset into the data. */
824 op_ptr = safe_read_sleb128 (op_ptr, op_end, &len);
825 result = (ULONGEST) len;
826 result_val = value_from_ulongest (address_type, result);
827
828 this->location = DWARF_VALUE_IMPLICIT_POINTER;
829 dwarf_expr_require_composition (op_ptr, op_end,
830 "DW_OP_implicit_pointer");
831 }
832 break;
833
834 case DW_OP_breg0:
835 case DW_OP_breg1:
836 case DW_OP_breg2:
837 case DW_OP_breg3:
838 case DW_OP_breg4:
839 case DW_OP_breg5:
840 case DW_OP_breg6:
841 case DW_OP_breg7:
842 case DW_OP_breg8:
843 case DW_OP_breg9:
844 case DW_OP_breg10:
845 case DW_OP_breg11:
846 case DW_OP_breg12:
847 case DW_OP_breg13:
848 case DW_OP_breg14:
849 case DW_OP_breg15:
850 case DW_OP_breg16:
851 case DW_OP_breg17:
852 case DW_OP_breg18:
853 case DW_OP_breg19:
854 case DW_OP_breg20:
855 case DW_OP_breg21:
856 case DW_OP_breg22:
857 case DW_OP_breg23:
858 case DW_OP_breg24:
859 case DW_OP_breg25:
860 case DW_OP_breg26:
861 case DW_OP_breg27:
862 case DW_OP_breg28:
863 case DW_OP_breg29:
864 case DW_OP_breg30:
865 case DW_OP_breg31:
866 {
867 op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
868 result = this->read_addr_from_reg (op - DW_OP_breg0);
869 result += offset;
870 result_val = value_from_ulongest (address_type, result);
871 }
872 break;
873 case DW_OP_bregx:
874 {
875 op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
876 op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
877 result = this->read_addr_from_reg (reg);
878 result += offset;
879 result_val = value_from_ulongest (address_type, result);
880 }
881 break;
882 case DW_OP_fbreg:
883 {
884 const gdb_byte *datastart;
885 size_t datalen;
886 unsigned int before_stack_len;
887
888 op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
889 /* Rather than create a whole new context, we simply
890 record the stack length before execution, then reset it
891 afterwards, effectively erasing whatever the recursive
892 call put there. */
893 before_stack_len = this->stack_len;
894 /* FIXME: cagney/2003-03-26: This code should be using
895 get_frame_base_address(), and then implement a dwarf2
896 specific this_base method. */
897 this->get_frame_base (&datastart, &datalen);
898 eval (datastart, datalen);
899 if (this->location == DWARF_VALUE_MEMORY)
900 result = fetch_address (0);
901 else if (this->location == DWARF_VALUE_REGISTER)
902 result = this->read_addr_from_reg (value_as_long (fetch (0)));
903 else
904 error (_("Not implemented: computing frame "
905 "base using explicit value operator"));
906 result = result + offset;
907 result_val = value_from_ulongest (address_type, result);
908 in_stack_memory = 1;
909 this->stack_len = before_stack_len;
910 this->location = DWARF_VALUE_MEMORY;
911 }
912 break;
913
914 case DW_OP_dup:
915 result_val = fetch (0);
916 in_stack_memory = fetch_in_stack_memory (0);
917 break;
918
919 case DW_OP_drop:
920 pop ();
921 goto no_push;
922
923 case DW_OP_pick:
924 offset = *op_ptr++;
925 result_val = fetch (offset);
926 in_stack_memory = fetch_in_stack_memory (offset);
927 break;
928
929 case DW_OP_swap:
930 {
931 struct dwarf_stack_value t1, t2;
932
933 if (this->stack_len < 2)
934 error (_("Not enough elements for "
935 "DW_OP_swap. Need 2, have %d."),
936 this->stack_len);
937 t1 = this->stack[this->stack_len - 1];
938 t2 = this->stack[this->stack_len - 2];
939 this->stack[this->stack_len - 1] = t2;
940 this->stack[this->stack_len - 2] = t1;
941 goto no_push;
942 }
943
944 case DW_OP_over:
945 result_val = fetch (1);
946 in_stack_memory = fetch_in_stack_memory (1);
947 break;
948
949 case DW_OP_rot:
950 {
951 struct dwarf_stack_value t1, t2, t3;
952
953 if (this->stack_len < 3)
954 error (_("Not enough elements for "
955 "DW_OP_rot. Need 3, have %d."),
956 this->stack_len);
957 t1 = this->stack[this->stack_len - 1];
958 t2 = this->stack[this->stack_len - 2];
959 t3 = this->stack[this->stack_len - 3];
960 this->stack[this->stack_len - 1] = t2;
961 this->stack[this->stack_len - 2] = t3;
962 this->stack[this->stack_len - 3] = t1;
963 goto no_push;
964 }
965
966 case DW_OP_deref:
967 case DW_OP_deref_size:
968 case DW_OP_deref_type:
969 case DW_OP_GNU_deref_type:
970 {
971 int addr_size = (op == DW_OP_deref ? this->addr_size : *op_ptr++);
972 gdb_byte *buf = (gdb_byte *) alloca (addr_size);
973 CORE_ADDR addr = fetch_address (0);
974 struct type *type;
975
976 pop ();
977
978 if (op == DW_OP_deref_type || op == DW_OP_GNU_deref_type)
979 {
980 op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
981 cu_offset type_die_cu_off = (cu_offset) uoffset;
982 type = get_base_type (type_die_cu_off, 0);
983 }
984 else
985 type = address_type;
986
987 this->read_mem (buf, addr, addr_size);
988
989 /* If the size of the object read from memory is different
990 from the type length, we need to zero-extend it. */
991 if (TYPE_LENGTH (type) != addr_size)
992 {
993 ULONGEST result =
994 extract_unsigned_integer (buf, addr_size, byte_order);
995
996 buf = (gdb_byte *) alloca (TYPE_LENGTH (type));
997 store_unsigned_integer (buf, TYPE_LENGTH (type),
998 byte_order, result);
999 }
1000
1001 result_val = value_from_contents_and_address (type, buf, addr);
1002 break;
1003 }
1004
1005 case DW_OP_abs:
1006 case DW_OP_neg:
1007 case DW_OP_not:
1008 case DW_OP_plus_uconst:
1009 {
1010 /* Unary operations. */
1011 result_val = fetch (0);
1012 pop ();
1013
1014 switch (op)
1015 {
1016 case DW_OP_abs:
1017 if (value_less (result_val,
1018 value_zero (value_type (result_val), not_lval)))
1019 result_val = value_neg (result_val);
1020 break;
1021 case DW_OP_neg:
1022 result_val = value_neg (result_val);
1023 break;
1024 case DW_OP_not:
1025 dwarf_require_integral (value_type (result_val));
1026 result_val = value_complement (result_val);
1027 break;
1028 case DW_OP_plus_uconst:
1029 dwarf_require_integral (value_type (result_val));
1030 result = value_as_long (result_val);
1031 op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
1032 result += reg;
1033 result_val = value_from_ulongest (address_type, result);
1034 break;
1035 }
1036 }
1037 break;
1038
1039 case DW_OP_and:
1040 case DW_OP_div:
1041 case DW_OP_minus:
1042 case DW_OP_mod:
1043 case DW_OP_mul:
1044 case DW_OP_or:
1045 case DW_OP_plus:
1046 case DW_OP_shl:
1047 case DW_OP_shr:
1048 case DW_OP_shra:
1049 case DW_OP_xor:
1050 case DW_OP_le:
1051 case DW_OP_ge:
1052 case DW_OP_eq:
1053 case DW_OP_lt:
1054 case DW_OP_gt:
1055 case DW_OP_ne:
1056 {
1057 /* Binary operations. */
1058 struct value *first, *second;
1059
1060 second = fetch (0);
1061 pop ();
1062
1063 first = fetch (0);
1064 pop ();
1065
1066 if (! base_types_equal_p (value_type (first), value_type (second)))
1067 error (_("Incompatible types on DWARF stack"));
1068
1069 switch (op)
1070 {
1071 case DW_OP_and:
1072 dwarf_require_integral (value_type (first));
1073 dwarf_require_integral (value_type (second));
1074 result_val = value_binop (first, second, BINOP_BITWISE_AND);
1075 break;
1076 case DW_OP_div:
1077 result_val = value_binop (first, second, BINOP_DIV);
1078 break;
1079 case DW_OP_minus:
1080 result_val = value_binop (first, second, BINOP_SUB);
1081 break;
1082 case DW_OP_mod:
1083 {
1084 int cast_back = 0;
1085 struct type *orig_type = value_type (first);
1086
1087 /* We have to special-case "old-style" untyped values
1088 -- these must have mod computed using unsigned
1089 math. */
1090 if (orig_type == address_type)
1091 {
1092 struct type *utype
1093 = get_unsigned_type (this->gdbarch, orig_type);
1094
1095 cast_back = 1;
1096 first = value_cast (utype, first);
1097 second = value_cast (utype, second);
1098 }
1099 /* Note that value_binop doesn't handle float or
1100 decimal float here. This seems unimportant. */
1101 result_val = value_binop (first, second, BINOP_MOD);
1102 if (cast_back)
1103 result_val = value_cast (orig_type, result_val);
1104 }
1105 break;
1106 case DW_OP_mul:
1107 result_val = value_binop (first, second, BINOP_MUL);
1108 break;
1109 case DW_OP_or:
1110 dwarf_require_integral (value_type (first));
1111 dwarf_require_integral (value_type (second));
1112 result_val = value_binop (first, second, BINOP_BITWISE_IOR);
1113 break;
1114 case DW_OP_plus:
1115 result_val = value_binop (first, second, BINOP_ADD);
1116 break;
1117 case DW_OP_shl:
1118 dwarf_require_integral (value_type (first));
1119 dwarf_require_integral (value_type (second));
1120 result_val = value_binop (first, second, BINOP_LSH);
1121 break;
1122 case DW_OP_shr:
1123 dwarf_require_integral (value_type (first));
1124 dwarf_require_integral (value_type (second));
1125 if (!TYPE_UNSIGNED (value_type (first)))
1126 {
1127 struct type *utype
1128 = get_unsigned_type (this->gdbarch, value_type (first));
1129
1130 first = value_cast (utype, first);
1131 }
1132
1133 result_val = value_binop (first, second, BINOP_RSH);
1134 /* Make sure we wind up with the same type we started
1135 with. */
1136 if (value_type (result_val) != value_type (second))
1137 result_val = value_cast (value_type (second), result_val);
1138 break;
1139 case DW_OP_shra:
1140 dwarf_require_integral (value_type (first));
1141 dwarf_require_integral (value_type (second));
1142 if (TYPE_UNSIGNED (value_type (first)))
1143 {
1144 struct type *stype
1145 = get_signed_type (this->gdbarch, value_type (first));
1146
1147 first = value_cast (stype, first);
1148 }
1149
1150 result_val = value_binop (first, second, BINOP_RSH);
1151 /* Make sure we wind up with the same type we started
1152 with. */
1153 if (value_type (result_val) != value_type (second))
1154 result_val = value_cast (value_type (second), result_val);
1155 break;
1156 case DW_OP_xor:
1157 dwarf_require_integral (value_type (first));
1158 dwarf_require_integral (value_type (second));
1159 result_val = value_binop (first, second, BINOP_BITWISE_XOR);
1160 break;
1161 case DW_OP_le:
1162 /* A <= B is !(B < A). */
1163 result = ! value_less (second, first);
1164 result_val = value_from_ulongest (address_type, result);
1165 break;
1166 case DW_OP_ge:
1167 /* A >= B is !(A < B). */
1168 result = ! value_less (first, second);
1169 result_val = value_from_ulongest (address_type, result);
1170 break;
1171 case DW_OP_eq:
1172 result = value_equal (first, second);
1173 result_val = value_from_ulongest (address_type, result);
1174 break;
1175 case DW_OP_lt:
1176 result = value_less (first, second);
1177 result_val = value_from_ulongest (address_type, result);
1178 break;
1179 case DW_OP_gt:
1180 /* A > B is B < A. */
1181 result = value_less (second, first);
1182 result_val = value_from_ulongest (address_type, result);
1183 break;
1184 case DW_OP_ne:
1185 result = ! value_equal (first, second);
1186 result_val = value_from_ulongest (address_type, result);
1187 break;
1188 default:
1189 internal_error (__FILE__, __LINE__,
1190 _("Can't be reached."));
1191 }
1192 }
1193 break;
1194
1195 case DW_OP_call_frame_cfa:
1196 result = this->get_frame_cfa ();
1197 result_val = value_from_ulongest (address_type, result);
1198 in_stack_memory = 1;
1199 break;
1200
1201 case DW_OP_GNU_push_tls_address:
1202 case DW_OP_form_tls_address:
1203 /* Variable is at a constant offset in the thread-local
1204 storage block into the objfile for the current thread and
1205 the dynamic linker module containing this expression. Here
1206 we return returns the offset from that base. The top of the
1207 stack has the offset from the beginning of the thread
1208 control block at which the variable is located. Nothing
1209 should follow this operator, so the top of stack would be
1210 returned. */
1211 result = value_as_long (fetch (0));
1212 pop ();
1213 result = this->get_tls_address (result);
1214 result_val = value_from_ulongest (address_type, result);
1215 break;
1216
1217 case DW_OP_skip:
1218 offset = extract_signed_integer (op_ptr, 2, byte_order);
1219 op_ptr += 2;
1220 op_ptr += offset;
1221 goto no_push;
1222
1223 case DW_OP_bra:
1224 {
1225 struct value *val;
1226
1227 offset = extract_signed_integer (op_ptr, 2, byte_order);
1228 op_ptr += 2;
1229 val = fetch (0);
1230 dwarf_require_integral (value_type (val));
1231 if (value_as_long (val) != 0)
1232 op_ptr += offset;
1233 pop ();
1234 }
1235 goto no_push;
1236
1237 case DW_OP_nop:
1238 goto no_push;
1239
1240 case DW_OP_piece:
1241 {
1242 uint64_t size;
1243
1244 /* Record the piece. */
1245 op_ptr = safe_read_uleb128 (op_ptr, op_end, &size);
1246 add_piece (8 * size, 0);
1247
1248 /* Pop off the address/regnum, and reset the location
1249 type. */
1250 if (this->location != DWARF_VALUE_LITERAL
1251 && this->location != DWARF_VALUE_OPTIMIZED_OUT)
1252 pop ();
1253 this->location = DWARF_VALUE_MEMORY;
1254 }
1255 goto no_push;
1256
1257 case DW_OP_bit_piece:
1258 {
1259 uint64_t size, offset;
1260
1261 /* Record the piece. */
1262 op_ptr = safe_read_uleb128 (op_ptr, op_end, &size);
1263 op_ptr = safe_read_uleb128 (op_ptr, op_end, &offset);
1264 add_piece (size, offset);
1265
1266 /* Pop off the address/regnum, and reset the location
1267 type. */
1268 if (this->location != DWARF_VALUE_LITERAL
1269 && this->location != DWARF_VALUE_OPTIMIZED_OUT)
1270 pop ();
1271 this->location = DWARF_VALUE_MEMORY;
1272 }
1273 goto no_push;
1274
1275 case DW_OP_GNU_uninit:
1276 if (op_ptr != op_end)
1277 error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always "
1278 "be the very last op."));
1279
1280 this->initialized = 0;
1281 goto no_push;
1282
1283 case DW_OP_call2:
1284 {
1285 cu_offset cu_off
1286 = (cu_offset) extract_unsigned_integer (op_ptr, 2, byte_order);
1287 op_ptr += 2;
1288 this->dwarf_call (cu_off);
1289 }
1290 goto no_push;
1291
1292 case DW_OP_call4:
1293 {
1294 cu_offset cu_off
1295 = (cu_offset) extract_unsigned_integer (op_ptr, 4, byte_order);
1296 op_ptr += 4;
1297 this->dwarf_call (cu_off);
1298 }
1299 goto no_push;
1300
1301 case DW_OP_entry_value:
1302 case DW_OP_GNU_entry_value:
1303 {
1304 uint64_t len;
1305 CORE_ADDR deref_size;
1306 union call_site_parameter_u kind_u;
1307
1308 op_ptr = safe_read_uleb128 (op_ptr, op_end, &len);
1309 if (op_ptr + len > op_end)
1310 error (_("DW_OP_entry_value: too few bytes available."));
1311
1312 kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (op_ptr, op_ptr + len);
1313 if (kind_u.dwarf_reg != -1)
1314 {
1315 op_ptr += len;
1316 this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_DWARF_REG,
1317 kind_u,
1318 -1 /* deref_size */);
1319 goto no_push;
1320 }
1321
1322 kind_u.dwarf_reg = dwarf_block_to_dwarf_reg_deref (op_ptr,
1323 op_ptr + len,
1324 &deref_size);
1325 if (kind_u.dwarf_reg != -1)
1326 {
1327 if (deref_size == -1)
1328 deref_size = this->addr_size;
1329 op_ptr += len;
1330 this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_DWARF_REG,
1331 kind_u, deref_size);
1332 goto no_push;
1333 }
1334
1335 error (_("DWARF-2 expression error: DW_OP_entry_value is "
1336 "supported only for single DW_OP_reg* "
1337 "or for DW_OP_breg*(0)+DW_OP_deref*"));
1338 }
1339
1340 case DW_OP_GNU_parameter_ref:
1341 {
1342 union call_site_parameter_u kind_u;
1343
1344 kind_u.param_cu_off
1345 = (cu_offset) extract_unsigned_integer (op_ptr, 4, byte_order);
1346 op_ptr += 4;
1347 this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_PARAM_OFFSET,
1348 kind_u,
1349 -1 /* deref_size */);
1350 }
1351 goto no_push;
1352
1353 case DW_OP_const_type:
1354 case DW_OP_GNU_const_type:
1355 {
1356 int n;
1357 const gdb_byte *data;
1358 struct type *type;
1359
1360 op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
1361 cu_offset type_die_cu_off = (cu_offset) uoffset;
1362
1363 n = *op_ptr++;
1364 data = op_ptr;
1365 op_ptr += n;
1366
1367 type = get_base_type (type_die_cu_off, n);
1368 result_val = value_from_contents (type, data);
1369 }
1370 break;
1371
1372 case DW_OP_regval_type:
1373 case DW_OP_GNU_regval_type:
1374 {
1375 struct type *type;
1376
1377 op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
1378 op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
1379 cu_offset type_die_cu_off = (cu_offset) uoffset;
1380
1381 type = get_base_type (type_die_cu_off, 0);
1382 result_val = this->get_reg_value (type, reg);
1383 }
1384 break;
1385
1386 case DW_OP_convert:
1387 case DW_OP_GNU_convert:
1388 case DW_OP_reinterpret:
1389 case DW_OP_GNU_reinterpret:
1390 {
1391 struct type *type;
1392
1393 op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
1394 cu_offset type_die_cu_off = (cu_offset) uoffset;
1395
1396 if (to_underlying (type_die_cu_off) == 0)
1397 type = address_type;
1398 else
1399 type = get_base_type (type_die_cu_off, 0);
1400
1401 result_val = fetch (0);
1402 pop ();
1403
1404 if (op == DW_OP_convert || op == DW_OP_GNU_convert)
1405 result_val = value_cast (type, result_val);
1406 else if (type == value_type (result_val))
1407 {
1408 /* Nothing. */
1409 }
1410 else if (TYPE_LENGTH (type)
1411 != TYPE_LENGTH (value_type (result_val)))
1412 error (_("DW_OP_reinterpret has wrong size"));
1413 else
1414 result_val
1415 = value_from_contents (type,
1416 value_contents_all (result_val));
1417 }
1418 break;
1419
1420 case DW_OP_push_object_address:
1421 /* Return the address of the object we are currently observing. */
1422 result = this->get_object_address ();
1423 result_val = value_from_ulongest (address_type, result);
1424 break;
1425
1426 default:
1427 error (_("Unhandled dwarf expression opcode 0x%x"), op);
1428 }
1429
1430 /* Most things push a result value. */
1431 gdb_assert (result_val != NULL);
1432 push (result_val, in_stack_memory);
1433 no_push:
1434 ;
1435 }
1436
1437 /* To simplify our main caller, if the result is an implicit
1438 pointer, then make a pieced value. This is ok because we can't
1439 have implicit pointers in contexts where pieces are invalid. */
1440 if (this->location == DWARF_VALUE_IMPLICIT_POINTER)
1441 add_piece (8 * this->addr_size, 0);
1442
1443 abort_expression:
1444 this->recursion_depth--;
1445 gdb_assert (this->recursion_depth >= 0);
1446 }
1447
1448 /* Provide a prototype to silence -Wmissing-prototypes. */
1449 extern initialize_file_ftype _initialize_dwarf2expr;
1450
1451 void
1452 _initialize_dwarf2expr (void)
1453 {
1454 dwarf_arch_cookie
1455 = gdbarch_data_register_post_init (dwarf_gdbarch_types_init);
1456 }