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