1 /* DWARF 2 location expression support for GDB.
3 Copyright (C) 2003-2016 Free Software Foundation, Inc.
5 Contributed by Daniel Jacobowitz, MontaVista Software, Inc.
7 This file is part of GDB.
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.
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.
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/>. */
35 #include "complaints.h"
37 #include "dwarf2expr.h"
38 #include "dwarf2loc.h"
39 #include "dwarf2-frame.h"
40 #include "compile/compile.h"
44 extern int dwarf_always_disassemble
;
46 static struct value
*dwarf2_evaluate_loc_desc_full (struct type
*type
,
47 struct frame_info
*frame
,
50 struct dwarf2_per_cu_data
*per_cu
,
53 static struct call_site_parameter
*dwarf_expr_reg_to_entry_parameter
54 (struct frame_info
*frame
,
55 enum call_site_parameter_kind kind
,
56 union call_site_parameter_u kind_u
,
57 struct dwarf2_per_cu_data
**per_cu_return
);
59 /* Until these have formal names, we define these here.
60 ref: http://gcc.gnu.org/wiki/DebugFission
61 Each entry in .debug_loc.dwo begins with a byte that describes the entry,
62 and is then followed by data specific to that entry. */
66 /* Indicates the end of the list of entries. */
67 DEBUG_LOC_END_OF_LIST
= 0,
69 /* This is followed by an unsigned LEB128 number that is an index into
70 .debug_addr and specifies the base address for all following entries. */
71 DEBUG_LOC_BASE_ADDRESS
= 1,
73 /* This is followed by two unsigned LEB128 numbers that are indices into
74 .debug_addr and specify the beginning and ending addresses, and then
75 a normal location expression as in .debug_loc. */
76 DEBUG_LOC_START_END
= 2,
78 /* This is followed by an unsigned LEB128 number that is an index into
79 .debug_addr and specifies the beginning address, and a 4 byte unsigned
80 number that specifies the length, and then a normal location expression
82 DEBUG_LOC_START_LENGTH
= 3,
84 /* An internal value indicating there is insufficient data. */
85 DEBUG_LOC_BUFFER_OVERFLOW
= -1,
87 /* An internal value indicating an invalid kind of entry was found. */
88 DEBUG_LOC_INVALID_ENTRY
= -2
91 /* Helper function which throws an error if a synthetic pointer is
95 invalid_synthetic_pointer (void)
97 error (_("access outside bounds of object "
98 "referenced via synthetic pointer"));
101 /* Decode the addresses in a non-dwo .debug_loc entry.
102 A pointer to the next byte to examine is returned in *NEW_PTR.
103 The encoded low,high addresses are return in *LOW,*HIGH.
104 The result indicates the kind of entry found. */
106 static enum debug_loc_kind
107 decode_debug_loc_addresses (const gdb_byte
*loc_ptr
, const gdb_byte
*buf_end
,
108 const gdb_byte
**new_ptr
,
109 CORE_ADDR
*low
, CORE_ADDR
*high
,
110 enum bfd_endian byte_order
,
111 unsigned int addr_size
,
114 CORE_ADDR base_mask
= ~(~(CORE_ADDR
)1 << (addr_size
* 8 - 1));
116 if (buf_end
- loc_ptr
< 2 * addr_size
)
117 return DEBUG_LOC_BUFFER_OVERFLOW
;
120 *low
= extract_signed_integer (loc_ptr
, addr_size
, byte_order
);
122 *low
= extract_unsigned_integer (loc_ptr
, addr_size
, byte_order
);
123 loc_ptr
+= addr_size
;
126 *high
= extract_signed_integer (loc_ptr
, addr_size
, byte_order
);
128 *high
= extract_unsigned_integer (loc_ptr
, addr_size
, byte_order
);
129 loc_ptr
+= addr_size
;
133 /* A base-address-selection entry. */
134 if ((*low
& base_mask
) == base_mask
)
135 return DEBUG_LOC_BASE_ADDRESS
;
137 /* An end-of-list entry. */
138 if (*low
== 0 && *high
== 0)
139 return DEBUG_LOC_END_OF_LIST
;
141 return DEBUG_LOC_START_END
;
144 /* Decode the addresses in .debug_loc.dwo entry.
145 A pointer to the next byte to examine is returned in *NEW_PTR.
146 The encoded low,high addresses are return in *LOW,*HIGH.
147 The result indicates the kind of entry found. */
149 static enum debug_loc_kind
150 decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data
*per_cu
,
151 const gdb_byte
*loc_ptr
,
152 const gdb_byte
*buf_end
,
153 const gdb_byte
**new_ptr
,
154 CORE_ADDR
*low
, CORE_ADDR
*high
,
155 enum bfd_endian byte_order
)
157 uint64_t low_index
, high_index
;
159 if (loc_ptr
== buf_end
)
160 return DEBUG_LOC_BUFFER_OVERFLOW
;
164 case DEBUG_LOC_END_OF_LIST
:
166 return DEBUG_LOC_END_OF_LIST
;
167 case DEBUG_LOC_BASE_ADDRESS
:
169 loc_ptr
= gdb_read_uleb128 (loc_ptr
, buf_end
, &high_index
);
171 return DEBUG_LOC_BUFFER_OVERFLOW
;
172 *high
= dwarf2_read_addr_index (per_cu
, high_index
);
174 return DEBUG_LOC_BASE_ADDRESS
;
175 case DEBUG_LOC_START_END
:
176 loc_ptr
= gdb_read_uleb128 (loc_ptr
, buf_end
, &low_index
);
178 return DEBUG_LOC_BUFFER_OVERFLOW
;
179 *low
= dwarf2_read_addr_index (per_cu
, low_index
);
180 loc_ptr
= gdb_read_uleb128 (loc_ptr
, buf_end
, &high_index
);
182 return DEBUG_LOC_BUFFER_OVERFLOW
;
183 *high
= dwarf2_read_addr_index (per_cu
, high_index
);
185 return DEBUG_LOC_START_END
;
186 case DEBUG_LOC_START_LENGTH
:
187 loc_ptr
= gdb_read_uleb128 (loc_ptr
, buf_end
, &low_index
);
189 return DEBUG_LOC_BUFFER_OVERFLOW
;
190 *low
= dwarf2_read_addr_index (per_cu
, low_index
);
191 if (loc_ptr
+ 4 > buf_end
)
192 return DEBUG_LOC_BUFFER_OVERFLOW
;
194 *high
+= extract_unsigned_integer (loc_ptr
, 4, byte_order
);
195 *new_ptr
= loc_ptr
+ 4;
196 return DEBUG_LOC_START_LENGTH
;
198 return DEBUG_LOC_INVALID_ENTRY
;
202 /* A function for dealing with location lists. Given a
203 symbol baton (BATON) and a pc value (PC), find the appropriate
204 location expression, set *LOCEXPR_LENGTH, and return a pointer
205 to the beginning of the expression. Returns NULL on failure.
207 For now, only return the first matching location expression; there
208 can be more than one in the list. */
211 dwarf2_find_location_expression (struct dwarf2_loclist_baton
*baton
,
212 size_t *locexpr_length
, CORE_ADDR pc
)
214 struct objfile
*objfile
= dwarf2_per_cu_objfile (baton
->per_cu
);
215 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
216 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
217 unsigned int addr_size
= dwarf2_per_cu_addr_size (baton
->per_cu
);
218 int signed_addr_p
= bfd_get_sign_extend_vma (objfile
->obfd
);
219 /* Adjust base_address for relocatable objects. */
220 CORE_ADDR base_offset
= dwarf2_per_cu_text_offset (baton
->per_cu
);
221 CORE_ADDR base_address
= baton
->base_address
+ base_offset
;
222 const gdb_byte
*loc_ptr
, *buf_end
;
224 loc_ptr
= baton
->data
;
225 buf_end
= baton
->data
+ baton
->size
;
229 CORE_ADDR low
= 0, high
= 0; /* init for gcc -Wall */
231 enum debug_loc_kind kind
;
232 const gdb_byte
*new_ptr
= NULL
; /* init for gcc -Wall */
235 kind
= decode_debug_loc_dwo_addresses (baton
->per_cu
,
236 loc_ptr
, buf_end
, &new_ptr
,
237 &low
, &high
, byte_order
);
239 kind
= decode_debug_loc_addresses (loc_ptr
, buf_end
, &new_ptr
,
241 byte_order
, addr_size
,
246 case DEBUG_LOC_END_OF_LIST
:
249 case DEBUG_LOC_BASE_ADDRESS
:
250 base_address
= high
+ base_offset
;
252 case DEBUG_LOC_START_END
:
253 case DEBUG_LOC_START_LENGTH
:
255 case DEBUG_LOC_BUFFER_OVERFLOW
:
256 case DEBUG_LOC_INVALID_ENTRY
:
257 error (_("dwarf2_find_location_expression: "
258 "Corrupted DWARF expression."));
260 gdb_assert_not_reached ("bad debug_loc_kind");
263 /* Otherwise, a location expression entry.
264 If the entry is from a DWO, don't add base address: the entry is from
265 .debug_addr which already has the DWARF "base address". We still add
266 base_offset in case we're debugging a PIE executable. */
275 high
+= base_address
;
278 length
= extract_unsigned_integer (loc_ptr
, 2, byte_order
);
281 if (low
== high
&& pc
== low
)
283 /* This is entry PC record present only at entry point
284 of a function. Verify it is really the function entry point. */
286 const struct block
*pc_block
= block_for_pc (pc
);
287 struct symbol
*pc_func
= NULL
;
290 pc_func
= block_linkage_function (pc_block
);
292 if (pc_func
&& pc
== BLOCK_START (SYMBOL_BLOCK_VALUE (pc_func
)))
294 *locexpr_length
= length
;
299 if (pc
>= low
&& pc
< high
)
301 *locexpr_length
= length
;
309 /* This is the baton used when performing dwarf2 expression
311 struct dwarf_expr_baton
313 struct frame_info
*frame
;
314 struct dwarf2_per_cu_data
*per_cu
;
315 CORE_ADDR obj_address
;
318 /* Implement find_frame_base_location method for LOC_BLOCK functions using
319 DWARF expression for its DW_AT_frame_base. */
322 locexpr_find_frame_base_location (struct symbol
*framefunc
, CORE_ADDR pc
,
323 const gdb_byte
**start
, size_t *length
)
325 struct dwarf2_locexpr_baton
*symbaton
326 = (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (framefunc
);
328 *length
= symbaton
->size
;
329 *start
= symbaton
->data
;
332 /* Implement the struct symbol_block_ops::get_frame_base method for
333 LOC_BLOCK functions using a DWARF expression as its DW_AT_frame_base. */
336 locexpr_get_frame_base (struct symbol
*framefunc
, struct frame_info
*frame
)
338 struct gdbarch
*gdbarch
;
340 struct dwarf2_locexpr_baton
*dlbaton
;
341 const gdb_byte
*start
;
343 struct value
*result
;
345 /* If this method is called, then FRAMEFUNC is supposed to be a DWARF block.
346 Thus, it's supposed to provide the find_frame_base_location method as
348 gdb_assert (SYMBOL_BLOCK_OPS (framefunc
)->find_frame_base_location
!= NULL
);
350 gdbarch
= get_frame_arch (frame
);
351 type
= builtin_type (gdbarch
)->builtin_data_ptr
;
352 dlbaton
= (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (framefunc
);
354 SYMBOL_BLOCK_OPS (framefunc
)->find_frame_base_location
355 (framefunc
, get_frame_pc (frame
), &start
, &length
);
356 result
= dwarf2_evaluate_loc_desc (type
, frame
, start
, length
,
359 /* The DW_AT_frame_base attribute contains a location description which
360 computes the base address itself. However, the call to
361 dwarf2_evaluate_loc_desc returns a value representing a variable at
362 that address. The frame base address is thus this variable's
364 return value_address (result
);
367 /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior
368 function uses DWARF expression for its DW_AT_frame_base. */
370 const struct symbol_block_ops dwarf2_block_frame_base_locexpr_funcs
=
372 locexpr_find_frame_base_location
,
373 locexpr_get_frame_base
376 /* Implement find_frame_base_location method for LOC_BLOCK functions using
377 DWARF location list for its DW_AT_frame_base. */
380 loclist_find_frame_base_location (struct symbol
*framefunc
, CORE_ADDR pc
,
381 const gdb_byte
**start
, size_t *length
)
383 struct dwarf2_loclist_baton
*symbaton
384 = (struct dwarf2_loclist_baton
*) SYMBOL_LOCATION_BATON (framefunc
);
386 *start
= dwarf2_find_location_expression (symbaton
, length
, pc
);
389 /* Implement the struct symbol_block_ops::get_frame_base method for
390 LOC_BLOCK functions using a DWARF location list as its DW_AT_frame_base. */
393 loclist_get_frame_base (struct symbol
*framefunc
, struct frame_info
*frame
)
395 struct gdbarch
*gdbarch
;
397 struct dwarf2_loclist_baton
*dlbaton
;
398 const gdb_byte
*start
;
400 struct value
*result
;
402 /* If this method is called, then FRAMEFUNC is supposed to be a DWARF block.
403 Thus, it's supposed to provide the find_frame_base_location method as
405 gdb_assert (SYMBOL_BLOCK_OPS (framefunc
)->find_frame_base_location
!= NULL
);
407 gdbarch
= get_frame_arch (frame
);
408 type
= builtin_type (gdbarch
)->builtin_data_ptr
;
409 dlbaton
= (struct dwarf2_loclist_baton
*) SYMBOL_LOCATION_BATON (framefunc
);
411 SYMBOL_BLOCK_OPS (framefunc
)->find_frame_base_location
412 (framefunc
, get_frame_pc (frame
), &start
, &length
);
413 result
= dwarf2_evaluate_loc_desc (type
, frame
, start
, length
,
416 /* The DW_AT_frame_base attribute contains a location description which
417 computes the base address itself. However, the call to
418 dwarf2_evaluate_loc_desc returns a value representing a variable at
419 that address. The frame base address is thus this variable's
421 return value_address (result
);
424 /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior
425 function uses DWARF location list for its DW_AT_frame_base. */
427 const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs
=
429 loclist_find_frame_base_location
,
430 loclist_get_frame_base
433 /* See dwarf2loc.h. */
436 func_get_frame_base_dwarf_block (struct symbol
*framefunc
, CORE_ADDR pc
,
437 const gdb_byte
**start
, size_t *length
)
439 if (SYMBOL_BLOCK_OPS (framefunc
) != NULL
)
441 const struct symbol_block_ops
*ops_block
= SYMBOL_BLOCK_OPS (framefunc
);
443 ops_block
->find_frame_base_location (framefunc
, pc
, start
, length
);
449 error (_("Could not find the frame base for \"%s\"."),
450 SYMBOL_NATURAL_NAME (framefunc
));
454 get_frame_pc_for_per_cu_dwarf_call (void *baton
)
456 dwarf_expr_context
*ctx
= (dwarf_expr_context
*) baton
;
458 return ctx
->get_frame_pc ();
462 per_cu_dwarf_call (struct dwarf_expr_context
*ctx
, cu_offset die_offset
,
463 struct dwarf2_per_cu_data
*per_cu
)
465 struct dwarf2_locexpr_baton block
;
467 block
= dwarf2_fetch_die_loc_cu_off (die_offset
, per_cu
,
468 get_frame_pc_for_per_cu_dwarf_call
,
471 /* DW_OP_call_ref is currently not supported. */
472 gdb_assert (block
.per_cu
== per_cu
);
474 ctx
->eval (block
.data
, block
.size
);
477 class dwarf_evaluate_loc_desc
: public dwarf_expr_context
481 struct frame_info
*frame
;
482 struct dwarf2_per_cu_data
*per_cu
;
483 CORE_ADDR obj_address
;
485 /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for
486 the frame in BATON. */
488 CORE_ADDR
get_frame_cfa () OVERRIDE
490 return dwarf2_frame_cfa (frame
);
493 /* Helper function for dwarf2_evaluate_loc_desc. Computes the PC for
494 the frame in BATON. */
496 CORE_ADDR
get_frame_pc () OVERRIDE
498 return get_frame_address_in_block (frame
);
501 /* Using the objfile specified in BATON, find the address for the
502 current thread's thread-local storage with offset OFFSET. */
503 CORE_ADDR
get_tls_address (CORE_ADDR offset
) OVERRIDE
505 struct objfile
*objfile
= dwarf2_per_cu_objfile (per_cu
);
507 return target_translate_tls_address (objfile
, offset
);
510 /* Helper interface of per_cu_dwarf_call for
511 dwarf2_evaluate_loc_desc. */
513 void dwarf_call (cu_offset die_offset
) OVERRIDE
515 per_cu_dwarf_call (this, die_offset
, per_cu
);
518 struct type
*get_base_type (cu_offset die_offset
, int size
) OVERRIDE
520 struct type
*result
= dwarf2_get_die_type (die_offset
, per_cu
);
522 error (_("Could not find type for DW_OP_GNU_const_type"));
523 if (size
!= 0 && TYPE_LENGTH (result
) != size
)
524 error (_("DW_OP_GNU_const_type has different sizes for type and data"));
528 /* Callback function for dwarf2_evaluate_loc_desc.
529 Fetch the address indexed by DW_OP_GNU_addr_index. */
531 CORE_ADDR
get_addr_index (unsigned int index
) OVERRIDE
533 return dwarf2_read_addr_index (per_cu
, index
);
536 /* Callback function for get_object_address. Return the address of the VLA
539 CORE_ADDR
get_object_address () OVERRIDE
541 if (obj_address
== 0)
542 error (_("Location address is not set."));
546 /* Execute DWARF block of call_site_parameter which matches KIND and
547 KIND_U. Choose DEREF_SIZE value of that parameter. Search
548 caller of this objects's frame.
550 The caller can be from a different CU - per_cu_dwarf_call
551 implementation can be more simple as it does not support cross-CU
554 void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind
,
555 union call_site_parameter_u kind_u
,
556 int deref_size
) OVERRIDE
558 struct frame_info
*caller_frame
;
559 struct dwarf2_per_cu_data
*caller_per_cu
;
560 struct call_site_parameter
*parameter
;
561 const gdb_byte
*data_src
;
564 caller_frame
= get_prev_frame (frame
);
566 parameter
= dwarf_expr_reg_to_entry_parameter (frame
, kind
, kind_u
,
568 data_src
= deref_size
== -1 ? parameter
->value
: parameter
->data_value
;
569 size
= deref_size
== -1 ? parameter
->value_size
: parameter
->data_value_size
;
571 /* DEREF_SIZE size is not verified here. */
572 if (data_src
== NULL
)
573 throw_error (NO_ENTRY_VALUE_ERROR
,
574 _("Cannot resolve DW_AT_GNU_call_site_data_value"));
576 scoped_restore save_frame
= make_scoped_restore (&this->frame
,
578 scoped_restore save_per_cu
= make_scoped_restore (&this->per_cu
,
580 scoped_restore save_obj_addr
= make_scoped_restore (&this->obj_address
,
583 scoped_restore save_arch
= make_scoped_restore (&this->gdbarch
);
585 = get_objfile_arch (dwarf2_per_cu_objfile (per_cu
));
586 scoped_restore save_addr_size
= make_scoped_restore (&this->addr_size
);
587 this->addr_size
= dwarf2_per_cu_addr_size (per_cu
);
588 scoped_restore save_offset
= make_scoped_restore (&this->offset
);
589 this->offset
= dwarf2_per_cu_text_offset (per_cu
);
591 this->eval (data_src
, size
);
594 /* Using the frame specified in BATON, find the location expression
595 describing the frame base. Return a pointer to it in START and
596 its length in LENGTH. */
597 void get_frame_base (const gdb_byte
**start
, size_t * length
) OVERRIDE
599 /* FIXME: cagney/2003-03-26: This code should be using
600 get_frame_base_address(), and then implement a dwarf2 specific
602 struct symbol
*framefunc
;
603 const struct block
*bl
= get_frame_block (frame
, NULL
);
606 error (_("frame address is not available."));
608 /* Use block_linkage_function, which returns a real (not inlined)
609 function, instead of get_frame_function, which may return an
611 framefunc
= block_linkage_function (bl
);
613 /* If we found a frame-relative symbol then it was certainly within
614 some function associated with a frame. If we can't find the frame,
615 something has gone wrong. */
616 gdb_assert (framefunc
!= NULL
);
618 func_get_frame_base_dwarf_block (framefunc
,
619 get_frame_address_in_block (frame
),
623 /* Read memory at ADDR (length LEN) into BUF. */
625 void read_mem (gdb_byte
*buf
, CORE_ADDR addr
, size_t len
) OVERRIDE
627 read_memory (addr
, buf
, len
);
630 /* Using the frame specified in BATON, return the value of register
631 REGNUM, treated as a pointer. */
632 CORE_ADDR
read_addr_from_reg (int dwarf_regnum
) OVERRIDE
634 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
635 int regnum
= dwarf_reg_to_regnum_or_error (gdbarch
, dwarf_regnum
);
637 return address_from_register (regnum
, frame
);
640 /* Implement "get_reg_value" callback. */
642 struct value
*get_reg_value (struct type
*type
, int dwarf_regnum
) OVERRIDE
644 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
645 int regnum
= dwarf_reg_to_regnum_or_error (gdbarch
, dwarf_regnum
);
647 return value_from_register (type
, regnum
, frame
);
651 /* See dwarf2loc.h. */
653 unsigned int entry_values_debug
= 0;
655 /* Helper to set entry_values_debug. */
658 show_entry_values_debug (struct ui_file
*file
, int from_tty
,
659 struct cmd_list_element
*c
, const char *value
)
661 fprintf_filtered (file
,
662 _("Entry values and tail call frames debugging is %s.\n"),
666 /* Find DW_TAG_GNU_call_site's DW_AT_GNU_call_site_target address.
667 CALLER_FRAME (for registers) can be NULL if it is not known. This function
668 always returns valid address or it throws NO_ENTRY_VALUE_ERROR. */
671 call_site_to_target_addr (struct gdbarch
*call_site_gdbarch
,
672 struct call_site
*call_site
,
673 struct frame_info
*caller_frame
)
675 switch (FIELD_LOC_KIND (call_site
->target
))
677 case FIELD_LOC_KIND_DWARF_BLOCK
:
679 struct dwarf2_locexpr_baton
*dwarf_block
;
681 struct type
*caller_core_addr_type
;
682 struct gdbarch
*caller_arch
;
684 dwarf_block
= FIELD_DWARF_BLOCK (call_site
->target
);
685 if (dwarf_block
== NULL
)
687 struct bound_minimal_symbol msym
;
689 msym
= lookup_minimal_symbol_by_pc (call_site
->pc
- 1);
690 throw_error (NO_ENTRY_VALUE_ERROR
,
691 _("DW_AT_GNU_call_site_target is not specified "
693 paddress (call_site_gdbarch
, call_site
->pc
),
694 (msym
.minsym
== NULL
? "???"
695 : MSYMBOL_PRINT_NAME (msym
.minsym
)));
698 if (caller_frame
== NULL
)
700 struct bound_minimal_symbol msym
;
702 msym
= lookup_minimal_symbol_by_pc (call_site
->pc
- 1);
703 throw_error (NO_ENTRY_VALUE_ERROR
,
704 _("DW_AT_GNU_call_site_target DWARF block resolving "
705 "requires known frame which is currently not "
706 "available at %s in %s"),
707 paddress (call_site_gdbarch
, call_site
->pc
),
708 (msym
.minsym
== NULL
? "???"
709 : MSYMBOL_PRINT_NAME (msym
.minsym
)));
712 caller_arch
= get_frame_arch (caller_frame
);
713 caller_core_addr_type
= builtin_type (caller_arch
)->builtin_func_ptr
;
714 val
= dwarf2_evaluate_loc_desc (caller_core_addr_type
, caller_frame
,
715 dwarf_block
->data
, dwarf_block
->size
,
716 dwarf_block
->per_cu
);
717 /* DW_AT_GNU_call_site_target is a DWARF expression, not a DWARF
719 if (VALUE_LVAL (val
) == lval_memory
)
720 return value_address (val
);
722 return value_as_address (val
);
725 case FIELD_LOC_KIND_PHYSNAME
:
727 const char *physname
;
728 struct bound_minimal_symbol msym
;
730 physname
= FIELD_STATIC_PHYSNAME (call_site
->target
);
732 /* Handle both the mangled and demangled PHYSNAME. */
733 msym
= lookup_minimal_symbol (physname
, NULL
, NULL
);
734 if (msym
.minsym
== NULL
)
736 msym
= lookup_minimal_symbol_by_pc (call_site
->pc
- 1);
737 throw_error (NO_ENTRY_VALUE_ERROR
,
738 _("Cannot find function \"%s\" for a call site target "
740 physname
, paddress (call_site_gdbarch
, call_site
->pc
),
741 (msym
.minsym
== NULL
? "???"
742 : MSYMBOL_PRINT_NAME (msym
.minsym
)));
745 return BMSYMBOL_VALUE_ADDRESS (msym
);
748 case FIELD_LOC_KIND_PHYSADDR
:
749 return FIELD_STATIC_PHYSADDR (call_site
->target
);
752 internal_error (__FILE__
, __LINE__
, _("invalid call site target kind"));
756 /* Convert function entry point exact address ADDR to the function which is
757 compliant with TAIL_CALL_LIST_COMPLETE condition. Throw
758 NO_ENTRY_VALUE_ERROR otherwise. */
760 static struct symbol
*
761 func_addr_to_tail_call_list (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
763 struct symbol
*sym
= find_pc_function (addr
);
766 if (sym
== NULL
|| BLOCK_START (SYMBOL_BLOCK_VALUE (sym
)) != addr
)
767 throw_error (NO_ENTRY_VALUE_ERROR
,
768 _("DW_TAG_GNU_call_site resolving failed to find function "
769 "name for address %s"),
770 paddress (gdbarch
, addr
));
772 type
= SYMBOL_TYPE (sym
);
773 gdb_assert (TYPE_CODE (type
) == TYPE_CODE_FUNC
);
774 gdb_assert (TYPE_SPECIFIC_FIELD (type
) == TYPE_SPECIFIC_FUNC
);
779 /* Verify function with entry point exact address ADDR can never call itself
780 via its tail calls (incl. transitively). Throw NO_ENTRY_VALUE_ERROR if it
781 can call itself via tail calls.
783 If a funtion can tail call itself its entry value based parameters are
784 unreliable. There is no verification whether the value of some/all
785 parameters is unchanged through the self tail call, we expect if there is
786 a self tail call all the parameters can be modified. */
789 func_verify_no_selftailcall (struct gdbarch
*gdbarch
, CORE_ADDR verify_addr
)
791 struct obstack addr_obstack
;
792 struct cleanup
*old_chain
;
795 /* Track here CORE_ADDRs which were already visited. */
798 /* The verification is completely unordered. Track here function addresses
799 which still need to be iterated. */
800 VEC (CORE_ADDR
) *todo
= NULL
;
802 obstack_init (&addr_obstack
);
803 old_chain
= make_cleanup_obstack_free (&addr_obstack
);
804 addr_hash
= htab_create_alloc_ex (64, core_addr_hash
, core_addr_eq
, NULL
,
805 &addr_obstack
, hashtab_obstack_allocate
,
807 make_cleanup_htab_delete (addr_hash
);
809 make_cleanup (VEC_cleanup (CORE_ADDR
), &todo
);
811 VEC_safe_push (CORE_ADDR
, todo
, verify_addr
);
812 while (!VEC_empty (CORE_ADDR
, todo
))
814 struct symbol
*func_sym
;
815 struct call_site
*call_site
;
817 addr
= VEC_pop (CORE_ADDR
, todo
);
819 func_sym
= func_addr_to_tail_call_list (gdbarch
, addr
);
821 for (call_site
= TYPE_TAIL_CALL_LIST (SYMBOL_TYPE (func_sym
));
822 call_site
; call_site
= call_site
->tail_call_next
)
824 CORE_ADDR target_addr
;
827 /* CALLER_FRAME with registers is not available for tail-call jumped
829 target_addr
= call_site_to_target_addr (gdbarch
, call_site
, NULL
);
831 if (target_addr
== verify_addr
)
833 struct bound_minimal_symbol msym
;
835 msym
= lookup_minimal_symbol_by_pc (verify_addr
);
836 throw_error (NO_ENTRY_VALUE_ERROR
,
837 _("DW_OP_GNU_entry_value resolving has found "
838 "function \"%s\" at %s can call itself via tail "
840 (msym
.minsym
== NULL
? "???"
841 : MSYMBOL_PRINT_NAME (msym
.minsym
)),
842 paddress (gdbarch
, verify_addr
));
845 slot
= htab_find_slot (addr_hash
, &target_addr
, INSERT
);
848 *slot
= obstack_copy (&addr_obstack
, &target_addr
,
849 sizeof (target_addr
));
850 VEC_safe_push (CORE_ADDR
, todo
, target_addr
);
855 do_cleanups (old_chain
);
858 /* Print user readable form of CALL_SITE->PC to gdb_stdlog. Used only for
859 ENTRY_VALUES_DEBUG. */
862 tailcall_dump (struct gdbarch
*gdbarch
, const struct call_site
*call_site
)
864 CORE_ADDR addr
= call_site
->pc
;
865 struct bound_minimal_symbol msym
= lookup_minimal_symbol_by_pc (addr
- 1);
867 fprintf_unfiltered (gdb_stdlog
, " %s(%s)", paddress (gdbarch
, addr
),
868 (msym
.minsym
== NULL
? "???"
869 : MSYMBOL_PRINT_NAME (msym
.minsym
)));
873 /* vec.h needs single word type name, typedef it. */
874 typedef struct call_site
*call_sitep
;
876 /* Define VEC (call_sitep) functions. */
877 DEF_VEC_P (call_sitep
);
879 /* Intersect RESULTP with CHAIN to keep RESULTP unambiguous, keep in RESULTP
880 only top callers and bottom callees which are present in both. GDBARCH is
881 used only for ENTRY_VALUES_DEBUG. RESULTP is NULL after return if there are
882 no remaining possibilities to provide unambiguous non-trivial result.
883 RESULTP should point to NULL on the first (initialization) call. Caller is
884 responsible for xfree of any RESULTP data. */
887 chain_candidate (struct gdbarch
*gdbarch
, struct call_site_chain
**resultp
,
888 VEC (call_sitep
) *chain
)
890 struct call_site_chain
*result
= *resultp
;
891 long length
= VEC_length (call_sitep
, chain
);
892 int callers
, callees
, idx
;
896 /* Create the initial chain containing all the passed PCs. */
898 result
= ((struct call_site_chain
*)
899 xmalloc (sizeof (*result
)
900 + sizeof (*result
->call_site
) * (length
- 1)));
901 result
->length
= length
;
902 result
->callers
= result
->callees
= length
;
903 if (!VEC_empty (call_sitep
, chain
))
904 memcpy (result
->call_site
, VEC_address (call_sitep
, chain
),
905 sizeof (*result
->call_site
) * length
);
908 if (entry_values_debug
)
910 fprintf_unfiltered (gdb_stdlog
, "tailcall: initial:");
911 for (idx
= 0; idx
< length
; idx
++)
912 tailcall_dump (gdbarch
, result
->call_site
[idx
]);
913 fputc_unfiltered ('\n', gdb_stdlog
);
919 if (entry_values_debug
)
921 fprintf_unfiltered (gdb_stdlog
, "tailcall: compare:");
922 for (idx
= 0; idx
< length
; idx
++)
923 tailcall_dump (gdbarch
, VEC_index (call_sitep
, chain
, idx
));
924 fputc_unfiltered ('\n', gdb_stdlog
);
927 /* Intersect callers. */
929 callers
= std::min ((long) result
->callers
, length
);
930 for (idx
= 0; idx
< callers
; idx
++)
931 if (result
->call_site
[idx
] != VEC_index (call_sitep
, chain
, idx
))
933 result
->callers
= idx
;
937 /* Intersect callees. */
939 callees
= std::min ((long) result
->callees
, length
);
940 for (idx
= 0; idx
< callees
; idx
++)
941 if (result
->call_site
[result
->length
- 1 - idx
]
942 != VEC_index (call_sitep
, chain
, length
- 1 - idx
))
944 result
->callees
= idx
;
948 if (entry_values_debug
)
950 fprintf_unfiltered (gdb_stdlog
, "tailcall: reduced:");
951 for (idx
= 0; idx
< result
->callers
; idx
++)
952 tailcall_dump (gdbarch
, result
->call_site
[idx
]);
953 fputs_unfiltered (" |", gdb_stdlog
);
954 for (idx
= 0; idx
< result
->callees
; idx
++)
955 tailcall_dump (gdbarch
, result
->call_site
[result
->length
956 - result
->callees
+ idx
]);
957 fputc_unfiltered ('\n', gdb_stdlog
);
960 if (result
->callers
== 0 && result
->callees
== 0)
962 /* There are no common callers or callees. It could be also a direct
963 call (which has length 0) with ambiguous possibility of an indirect
964 call - CALLERS == CALLEES == 0 is valid during the first allocation
965 but any subsequence processing of such entry means ambiguity. */
971 /* See call_site_find_chain_1 why there is no way to reach the bottom callee
972 PC again. In such case there must be two different code paths to reach
973 it. CALLERS + CALLEES equal to LENGTH in the case of self tail-call. */
974 gdb_assert (result
->callers
+ result
->callees
<= result
->length
);
977 /* Create and return call_site_chain for CALLER_PC and CALLEE_PC. All the
978 assumed frames between them use GDBARCH. Use depth first search so we can
979 keep single CHAIN of call_site's back to CALLER_PC. Function recursion
980 would have needless GDB stack overhead. Caller is responsible for xfree of
981 the returned result. Any unreliability results in thrown
982 NO_ENTRY_VALUE_ERROR. */
984 static struct call_site_chain
*
985 call_site_find_chain_1 (struct gdbarch
*gdbarch
, CORE_ADDR caller_pc
,
988 CORE_ADDR save_callee_pc
= callee_pc
;
989 struct obstack addr_obstack
;
990 struct cleanup
*back_to_retval
, *back_to_workdata
;
991 struct call_site_chain
*retval
= NULL
;
992 struct call_site
*call_site
;
994 /* Mark CALL_SITEs so we do not visit the same ones twice. */
997 /* CHAIN contains only the intermediate CALL_SITEs. Neither CALLER_PC's
998 call_site nor any possible call_site at CALLEE_PC's function is there.
999 Any CALL_SITE in CHAIN will be iterated to its siblings - via
1000 TAIL_CALL_NEXT. This is inappropriate for CALLER_PC's call_site. */
1001 VEC (call_sitep
) *chain
= NULL
;
1003 /* We are not interested in the specific PC inside the callee function. */
1004 callee_pc
= get_pc_function_start (callee_pc
);
1006 throw_error (NO_ENTRY_VALUE_ERROR
, _("Unable to find function for PC %s"),
1007 paddress (gdbarch
, save_callee_pc
));
1009 back_to_retval
= make_cleanup (free_current_contents
, &retval
);
1011 obstack_init (&addr_obstack
);
1012 back_to_workdata
= make_cleanup_obstack_free (&addr_obstack
);
1013 addr_hash
= htab_create_alloc_ex (64, core_addr_hash
, core_addr_eq
, NULL
,
1014 &addr_obstack
, hashtab_obstack_allocate
,
1016 make_cleanup_htab_delete (addr_hash
);
1018 make_cleanup (VEC_cleanup (call_sitep
), &chain
);
1020 /* Do not push CALL_SITE to CHAIN. Push there only the first tail call site
1021 at the target's function. All the possible tail call sites in the
1022 target's function will get iterated as already pushed into CHAIN via their
1024 call_site
= call_site_for_pc (gdbarch
, caller_pc
);
1028 CORE_ADDR target_func_addr
;
1029 struct call_site
*target_call_site
;
1031 /* CALLER_FRAME with registers is not available for tail-call jumped
1033 target_func_addr
= call_site_to_target_addr (gdbarch
, call_site
, NULL
);
1035 if (target_func_addr
== callee_pc
)
1037 chain_candidate (gdbarch
, &retval
, chain
);
1041 /* There is no way to reach CALLEE_PC again as we would prevent
1042 entering it twice as being already marked in ADDR_HASH. */
1043 target_call_site
= NULL
;
1047 struct symbol
*target_func
;
1049 target_func
= func_addr_to_tail_call_list (gdbarch
, target_func_addr
);
1050 target_call_site
= TYPE_TAIL_CALL_LIST (SYMBOL_TYPE (target_func
));
1055 /* Attempt to visit TARGET_CALL_SITE. */
1057 if (target_call_site
)
1061 slot
= htab_find_slot (addr_hash
, &target_call_site
->pc
, INSERT
);
1064 /* Successfully entered TARGET_CALL_SITE. */
1066 *slot
= &target_call_site
->pc
;
1067 VEC_safe_push (call_sitep
, chain
, target_call_site
);
1072 /* Backtrack (without revisiting the originating call_site). Try the
1073 callers's sibling; if there isn't any try the callers's callers's
1076 target_call_site
= NULL
;
1077 while (!VEC_empty (call_sitep
, chain
))
1079 call_site
= VEC_pop (call_sitep
, chain
);
1081 gdb_assert (htab_find_slot (addr_hash
, &call_site
->pc
,
1082 NO_INSERT
) != NULL
);
1083 htab_remove_elt (addr_hash
, &call_site
->pc
);
1085 target_call_site
= call_site
->tail_call_next
;
1086 if (target_call_site
)
1090 while (target_call_site
);
1092 if (VEC_empty (call_sitep
, chain
))
1095 call_site
= VEC_last (call_sitep
, chain
);
1100 struct bound_minimal_symbol msym_caller
, msym_callee
;
1102 msym_caller
= lookup_minimal_symbol_by_pc (caller_pc
);
1103 msym_callee
= lookup_minimal_symbol_by_pc (callee_pc
);
1104 throw_error (NO_ENTRY_VALUE_ERROR
,
1105 _("There are no unambiguously determinable intermediate "
1106 "callers or callees between caller function \"%s\" at %s "
1107 "and callee function \"%s\" at %s"),
1108 (msym_caller
.minsym
== NULL
1109 ? "???" : MSYMBOL_PRINT_NAME (msym_caller
.minsym
)),
1110 paddress (gdbarch
, caller_pc
),
1111 (msym_callee
.minsym
== NULL
1112 ? "???" : MSYMBOL_PRINT_NAME (msym_callee
.minsym
)),
1113 paddress (gdbarch
, callee_pc
));
1116 do_cleanups (back_to_workdata
);
1117 discard_cleanups (back_to_retval
);
1121 /* Create and return call_site_chain for CALLER_PC and CALLEE_PC. All the
1122 assumed frames between them use GDBARCH. If valid call_site_chain cannot be
1123 constructed return NULL. Caller is responsible for xfree of the returned
1126 struct call_site_chain
*
1127 call_site_find_chain (struct gdbarch
*gdbarch
, CORE_ADDR caller_pc
,
1128 CORE_ADDR callee_pc
)
1130 struct call_site_chain
*retval
= NULL
;
1134 retval
= call_site_find_chain_1 (gdbarch
, caller_pc
, callee_pc
);
1136 CATCH (e
, RETURN_MASK_ERROR
)
1138 if (e
.error
== NO_ENTRY_VALUE_ERROR
)
1140 if (entry_values_debug
)
1141 exception_print (gdb_stdout
, e
);
1146 throw_exception (e
);
1153 /* Return 1 if KIND and KIND_U match PARAMETER. Return 0 otherwise. */
1156 call_site_parameter_matches (struct call_site_parameter
*parameter
,
1157 enum call_site_parameter_kind kind
,
1158 union call_site_parameter_u kind_u
)
1160 if (kind
== parameter
->kind
)
1163 case CALL_SITE_PARAMETER_DWARF_REG
:
1164 return kind_u
.dwarf_reg
== parameter
->u
.dwarf_reg
;
1165 case CALL_SITE_PARAMETER_FB_OFFSET
:
1166 return kind_u
.fb_offset
== parameter
->u
.fb_offset
;
1167 case CALL_SITE_PARAMETER_PARAM_OFFSET
:
1168 return kind_u
.param_offset
.cu_off
== parameter
->u
.param_offset
.cu_off
;
1173 /* Fetch call_site_parameter from caller matching KIND and KIND_U.
1174 FRAME is for callee.
1176 Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR
1179 static struct call_site_parameter
*
1180 dwarf_expr_reg_to_entry_parameter (struct frame_info
*frame
,
1181 enum call_site_parameter_kind kind
,
1182 union call_site_parameter_u kind_u
,
1183 struct dwarf2_per_cu_data
**per_cu_return
)
1185 CORE_ADDR func_addr
, caller_pc
;
1186 struct gdbarch
*gdbarch
;
1187 struct frame_info
*caller_frame
;
1188 struct call_site
*call_site
;
1190 /* Initialize it just to avoid a GCC false warning. */
1191 struct call_site_parameter
*parameter
= NULL
;
1192 CORE_ADDR target_addr
;
1194 while (get_frame_type (frame
) == INLINE_FRAME
)
1196 frame
= get_prev_frame (frame
);
1197 gdb_assert (frame
!= NULL
);
1200 func_addr
= get_frame_func (frame
);
1201 gdbarch
= get_frame_arch (frame
);
1202 caller_frame
= get_prev_frame (frame
);
1203 if (gdbarch
!= frame_unwind_arch (frame
))
1205 struct bound_minimal_symbol msym
1206 = lookup_minimal_symbol_by_pc (func_addr
);
1207 struct gdbarch
*caller_gdbarch
= frame_unwind_arch (frame
);
1209 throw_error (NO_ENTRY_VALUE_ERROR
,
1210 _("DW_OP_GNU_entry_value resolving callee gdbarch %s "
1211 "(of %s (%s)) does not match caller gdbarch %s"),
1212 gdbarch_bfd_arch_info (gdbarch
)->printable_name
,
1213 paddress (gdbarch
, func_addr
),
1214 (msym
.minsym
== NULL
? "???"
1215 : MSYMBOL_PRINT_NAME (msym
.minsym
)),
1216 gdbarch_bfd_arch_info (caller_gdbarch
)->printable_name
);
1219 if (caller_frame
== NULL
)
1221 struct bound_minimal_symbol msym
1222 = lookup_minimal_symbol_by_pc (func_addr
);
1224 throw_error (NO_ENTRY_VALUE_ERROR
, _("DW_OP_GNU_entry_value resolving "
1225 "requires caller of %s (%s)"),
1226 paddress (gdbarch
, func_addr
),
1227 (msym
.minsym
== NULL
? "???"
1228 : MSYMBOL_PRINT_NAME (msym
.minsym
)));
1230 caller_pc
= get_frame_pc (caller_frame
);
1231 call_site
= call_site_for_pc (gdbarch
, caller_pc
);
1233 target_addr
= call_site_to_target_addr (gdbarch
, call_site
, caller_frame
);
1234 if (target_addr
!= func_addr
)
1236 struct minimal_symbol
*target_msym
, *func_msym
;
1238 target_msym
= lookup_minimal_symbol_by_pc (target_addr
).minsym
;
1239 func_msym
= lookup_minimal_symbol_by_pc (func_addr
).minsym
;
1240 throw_error (NO_ENTRY_VALUE_ERROR
,
1241 _("DW_OP_GNU_entry_value resolving expects callee %s at %s "
1242 "but the called frame is for %s at %s"),
1243 (target_msym
== NULL
? "???"
1244 : MSYMBOL_PRINT_NAME (target_msym
)),
1245 paddress (gdbarch
, target_addr
),
1246 func_msym
== NULL
? "???" : MSYMBOL_PRINT_NAME (func_msym
),
1247 paddress (gdbarch
, func_addr
));
1250 /* No entry value based parameters would be reliable if this function can
1251 call itself via tail calls. */
1252 func_verify_no_selftailcall (gdbarch
, func_addr
);
1254 for (iparams
= 0; iparams
< call_site
->parameter_count
; iparams
++)
1256 parameter
= &call_site
->parameter
[iparams
];
1257 if (call_site_parameter_matches (parameter
, kind
, kind_u
))
1260 if (iparams
== call_site
->parameter_count
)
1262 struct minimal_symbol
*msym
1263 = lookup_minimal_symbol_by_pc (caller_pc
).minsym
;
1265 /* DW_TAG_GNU_call_site_parameter will be missing just if GCC could not
1266 determine its value. */
1267 throw_error (NO_ENTRY_VALUE_ERROR
, _("Cannot find matching parameter "
1268 "at DW_TAG_GNU_call_site %s at %s"),
1269 paddress (gdbarch
, caller_pc
),
1270 msym
== NULL
? "???" : MSYMBOL_PRINT_NAME (msym
));
1273 *per_cu_return
= call_site
->per_cu
;
1277 /* Return value for PARAMETER matching DEREF_SIZE. If DEREF_SIZE is -1, return
1278 the normal DW_AT_GNU_call_site_value block. Otherwise return the
1279 DW_AT_GNU_call_site_data_value (dereferenced) block.
1281 TYPE and CALLER_FRAME specify how to evaluate the DWARF block into returned
1284 Function always returns non-NULL, non-optimized out value. It throws
1285 NO_ENTRY_VALUE_ERROR if it cannot resolve the value for any reason. */
1287 static struct value
*
1288 dwarf_entry_parameter_to_value (struct call_site_parameter
*parameter
,
1289 CORE_ADDR deref_size
, struct type
*type
,
1290 struct frame_info
*caller_frame
,
1291 struct dwarf2_per_cu_data
*per_cu
)
1293 const gdb_byte
*data_src
;
1297 data_src
= deref_size
== -1 ? parameter
->value
: parameter
->data_value
;
1298 size
= deref_size
== -1 ? parameter
->value_size
: parameter
->data_value_size
;
1300 /* DEREF_SIZE size is not verified here. */
1301 if (data_src
== NULL
)
1302 throw_error (NO_ENTRY_VALUE_ERROR
,
1303 _("Cannot resolve DW_AT_GNU_call_site_data_value"));
1305 /* DW_AT_GNU_call_site_value is a DWARF expression, not a DWARF
1306 location. Postprocessing of DWARF_VALUE_MEMORY would lose the type from
1308 data
= (gdb_byte
*) alloca (size
+ 1);
1309 memcpy (data
, data_src
, size
);
1310 data
[size
] = DW_OP_stack_value
;
1312 return dwarf2_evaluate_loc_desc (type
, caller_frame
, data
, size
+ 1, per_cu
);
1315 /* VALUE must be of type lval_computed with entry_data_value_funcs. Perform
1316 the indirect method on it, that is use its stored target value, the sole
1317 purpose of entry_data_value_funcs.. */
1319 static struct value
*
1320 entry_data_value_coerce_ref (const struct value
*value
)
1322 struct type
*checked_type
= check_typedef (value_type (value
));
1323 struct value
*target_val
;
1325 if (TYPE_CODE (checked_type
) != TYPE_CODE_REF
)
1328 target_val
= (struct value
*) value_computed_closure (value
);
1329 value_incref (target_val
);
1333 /* Implement copy_closure. */
1336 entry_data_value_copy_closure (const struct value
*v
)
1338 struct value
*target_val
= (struct value
*) value_computed_closure (v
);
1340 value_incref (target_val
);
1344 /* Implement free_closure. */
1347 entry_data_value_free_closure (struct value
*v
)
1349 struct value
*target_val
= (struct value
*) value_computed_closure (v
);
1351 value_free (target_val
);
1354 /* Vector for methods for an entry value reference where the referenced value
1355 is stored in the caller. On the first dereference use
1356 DW_AT_GNU_call_site_data_value in the caller. */
1358 static const struct lval_funcs entry_data_value_funcs
=
1362 NULL
, /* indirect */
1363 entry_data_value_coerce_ref
,
1364 NULL
, /* check_synthetic_pointer */
1365 entry_data_value_copy_closure
,
1366 entry_data_value_free_closure
1369 /* Read parameter of TYPE at (callee) FRAME's function entry. KIND and KIND_U
1370 are used to match DW_AT_location at the caller's
1371 DW_TAG_GNU_call_site_parameter.
1373 Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it
1374 cannot resolve the parameter for any reason. */
1376 static struct value
*
1377 value_of_dwarf_reg_entry (struct type
*type
, struct frame_info
*frame
,
1378 enum call_site_parameter_kind kind
,
1379 union call_site_parameter_u kind_u
)
1381 struct type
*checked_type
= check_typedef (type
);
1382 struct type
*target_type
= TYPE_TARGET_TYPE (checked_type
);
1383 struct frame_info
*caller_frame
= get_prev_frame (frame
);
1384 struct value
*outer_val
, *target_val
, *val
;
1385 struct call_site_parameter
*parameter
;
1386 struct dwarf2_per_cu_data
*caller_per_cu
;
1388 parameter
= dwarf_expr_reg_to_entry_parameter (frame
, kind
, kind_u
,
1391 outer_val
= dwarf_entry_parameter_to_value (parameter
, -1 /* deref_size */,
1395 /* Check if DW_AT_GNU_call_site_data_value cannot be used. If it should be
1396 used and it is not available do not fall back to OUTER_VAL - dereferencing
1397 TYPE_CODE_REF with non-entry data value would give current value - not the
1400 if (TYPE_CODE (checked_type
) != TYPE_CODE_REF
1401 || TYPE_TARGET_TYPE (checked_type
) == NULL
)
1404 target_val
= dwarf_entry_parameter_to_value (parameter
,
1405 TYPE_LENGTH (target_type
),
1406 target_type
, caller_frame
,
1409 release_value (target_val
);
1410 val
= allocate_computed_value (type
, &entry_data_value_funcs
,
1411 target_val
/* closure */);
1413 /* Copy the referencing pointer to the new computed value. */
1414 memcpy (value_contents_raw (val
), value_contents_raw (outer_val
),
1415 TYPE_LENGTH (checked_type
));
1416 set_value_lazy (val
, 0);
1421 /* Read parameter of TYPE at (callee) FRAME's function entry. DATA and
1422 SIZE are DWARF block used to match DW_AT_location at the caller's
1423 DW_TAG_GNU_call_site_parameter.
1425 Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it
1426 cannot resolve the parameter for any reason. */
1428 static struct value
*
1429 value_of_dwarf_block_entry (struct type
*type
, struct frame_info
*frame
,
1430 const gdb_byte
*block
, size_t block_len
)
1432 union call_site_parameter_u kind_u
;
1434 kind_u
.dwarf_reg
= dwarf_block_to_dwarf_reg (block
, block
+ block_len
);
1435 if (kind_u
.dwarf_reg
!= -1)
1436 return value_of_dwarf_reg_entry (type
, frame
, CALL_SITE_PARAMETER_DWARF_REG
,
1439 if (dwarf_block_to_fb_offset (block
, block
+ block_len
, &kind_u
.fb_offset
))
1440 return value_of_dwarf_reg_entry (type
, frame
, CALL_SITE_PARAMETER_FB_OFFSET
,
1443 /* This can normally happen - throw NO_ENTRY_VALUE_ERROR to get the message
1444 suppressed during normal operation. The expression can be arbitrary if
1445 there is no caller-callee entry value binding expected. */
1446 throw_error (NO_ENTRY_VALUE_ERROR
,
1447 _("DWARF-2 expression error: DW_OP_GNU_entry_value is supported "
1448 "only for single DW_OP_reg* or for DW_OP_fbreg(*)"));
1451 struct piece_closure
1453 /* Reference count. */
1456 /* The CU from which this closure's expression came. */
1457 struct dwarf2_per_cu_data
*per_cu
;
1459 /* The number of pieces used to describe this variable. */
1462 /* The target address size, used only for DWARF_VALUE_STACK. */
1465 /* The pieces themselves. */
1466 struct dwarf_expr_piece
*pieces
;
1469 /* Allocate a closure for a value formed from separately-described
1472 static struct piece_closure
*
1473 allocate_piece_closure (struct dwarf2_per_cu_data
*per_cu
,
1474 int n_pieces
, struct dwarf_expr_piece
*pieces
,
1477 struct piece_closure
*c
= XCNEW (struct piece_closure
);
1482 c
->n_pieces
= n_pieces
;
1483 c
->addr_size
= addr_size
;
1484 c
->pieces
= XCNEWVEC (struct dwarf_expr_piece
, n_pieces
);
1486 memcpy (c
->pieces
, pieces
, n_pieces
* sizeof (struct dwarf_expr_piece
));
1487 for (i
= 0; i
< n_pieces
; ++i
)
1488 if (c
->pieces
[i
].location
== DWARF_VALUE_STACK
)
1489 value_incref (c
->pieces
[i
].v
.value
);
1494 /* The lowest-level function to extract bits from a byte buffer.
1495 SOURCE is the buffer. It is updated if we read to the end of a
1497 SOURCE_OFFSET_BITS is the offset of the first bit to read. It is
1498 updated to reflect the number of bits actually read.
1499 NBITS is the number of bits we want to read. It is updated to
1500 reflect the number of bits actually read. This function may read
1502 BITS_BIG_ENDIAN is taken directly from gdbarch.
1503 This function returns the extracted bits. */
1506 extract_bits_primitive (const gdb_byte
**source
,
1507 unsigned int *source_offset_bits
,
1508 int *nbits
, int bits_big_endian
)
1510 unsigned int avail
, mask
, datum
;
1512 gdb_assert (*source_offset_bits
< 8);
1514 avail
= 8 - *source_offset_bits
;
1518 mask
= (1 << avail
) - 1;
1520 if (bits_big_endian
)
1521 datum
>>= 8 - (*source_offset_bits
+ *nbits
);
1523 datum
>>= *source_offset_bits
;
1527 *source_offset_bits
+= avail
;
1528 if (*source_offset_bits
>= 8)
1530 *source_offset_bits
-= 8;
1537 /* Extract some bits from a source buffer and move forward in the
1540 SOURCE is the source buffer. It is updated as bytes are read.
1541 SOURCE_OFFSET_BITS is the offset into SOURCE. It is updated as
1543 NBITS is the number of bits to read.
1544 BITS_BIG_ENDIAN is taken directly from gdbarch.
1546 This function returns the bits that were read. */
1549 extract_bits (const gdb_byte
**source
, unsigned int *source_offset_bits
,
1550 int nbits
, int bits_big_endian
)
1554 gdb_assert (nbits
> 0 && nbits
<= 8);
1556 datum
= extract_bits_primitive (source
, source_offset_bits
, &nbits
,
1562 more
= extract_bits_primitive (source
, source_offset_bits
, &nbits
,
1564 if (bits_big_endian
)
1574 /* Write some bits into a buffer and move forward in the buffer.
1576 DATUM is the bits to write. The low-order bits of DATUM are used.
1577 DEST is the destination buffer. It is updated as bytes are
1579 DEST_OFFSET_BITS is the bit offset in DEST at which writing is
1581 NBITS is the number of valid bits in DATUM.
1582 BITS_BIG_ENDIAN is taken directly from gdbarch. */
1585 insert_bits (unsigned int datum
,
1586 gdb_byte
*dest
, unsigned int dest_offset_bits
,
1587 int nbits
, int bits_big_endian
)
1591 gdb_assert (dest_offset_bits
+ nbits
<= 8);
1593 mask
= (1 << nbits
) - 1;
1594 if (bits_big_endian
)
1596 datum
<<= 8 - (dest_offset_bits
+ nbits
);
1597 mask
<<= 8 - (dest_offset_bits
+ nbits
);
1601 datum
<<= dest_offset_bits
;
1602 mask
<<= dest_offset_bits
;
1605 gdb_assert ((datum
& ~mask
) == 0);
1607 *dest
= (*dest
& ~mask
) | datum
;
1610 /* Copy bits from a source to a destination.
1612 DEST is where the bits should be written.
1613 DEST_OFFSET_BITS is the bit offset into DEST.
1614 SOURCE is the source of bits.
1615 SOURCE_OFFSET_BITS is the bit offset into SOURCE.
1616 BIT_COUNT is the number of bits to copy.
1617 BITS_BIG_ENDIAN is taken directly from gdbarch. */
1620 copy_bitwise (gdb_byte
*dest
, unsigned int dest_offset_bits
,
1621 const gdb_byte
*source
, unsigned int source_offset_bits
,
1622 unsigned int bit_count
,
1623 int bits_big_endian
)
1625 unsigned int dest_avail
;
1628 /* Reduce everything to byte-size pieces. */
1629 dest
+= dest_offset_bits
/ 8;
1630 dest_offset_bits
%= 8;
1631 source
+= source_offset_bits
/ 8;
1632 source_offset_bits
%= 8;
1634 dest_avail
= 8 - dest_offset_bits
% 8;
1636 /* See if we can fill the first destination byte. */
1637 if (dest_avail
< bit_count
)
1639 datum
= extract_bits (&source
, &source_offset_bits
, dest_avail
,
1641 insert_bits (datum
, dest
, dest_offset_bits
, dest_avail
, bits_big_endian
);
1643 dest_offset_bits
= 0;
1644 bit_count
-= dest_avail
;
1647 /* Now, either DEST_OFFSET_BITS is byte-aligned, or we have fewer
1648 than 8 bits remaining. */
1649 gdb_assert (dest_offset_bits
% 8 == 0 || bit_count
< 8);
1650 for (; bit_count
>= 8; bit_count
-= 8)
1652 datum
= extract_bits (&source
, &source_offset_bits
, 8, bits_big_endian
);
1653 *dest
++ = (gdb_byte
) datum
;
1656 /* Finally, we may have a few leftover bits. */
1657 gdb_assert (bit_count
<= 8 - dest_offset_bits
% 8);
1660 datum
= extract_bits (&source
, &source_offset_bits
, bit_count
,
1662 insert_bits (datum
, dest
, dest_offset_bits
, bit_count
, bits_big_endian
);
1667 read_pieced_value (struct value
*v
)
1671 ULONGEST bits_to_skip
;
1673 struct piece_closure
*c
1674 = (struct piece_closure
*) value_computed_closure (v
);
1675 struct frame_info
*frame
;
1677 size_t buffer_size
= 0;
1678 std::vector
<gdb_byte
> buffer
;
1680 = gdbarch_bits_big_endian (get_type_arch (value_type (v
)));
1682 /* VALUE_FRAME_ID is used instead of VALUE_NEXT_FRAME_ID here
1683 because FRAME is passed to get_frame_register_bytes(), which
1684 does its own "->next" operation. */
1685 frame
= frame_find_by_id (VALUE_FRAME_ID (v
));
1687 if (value_type (v
) != value_enclosing_type (v
))
1688 internal_error (__FILE__
, __LINE__
,
1689 _("Should not be able to create a lazy value with "
1690 "an enclosing type"));
1692 contents
= value_contents_raw (v
);
1693 bits_to_skip
= 8 * value_offset (v
);
1694 if (value_bitsize (v
))
1696 bits_to_skip
+= value_bitpos (v
);
1697 type_len
= value_bitsize (v
);
1700 type_len
= 8 * TYPE_LENGTH (value_type (v
));
1702 for (i
= 0; i
< c
->n_pieces
&& offset
< type_len
; i
++)
1704 struct dwarf_expr_piece
*p
= &c
->pieces
[i
];
1705 size_t this_size
, this_size_bits
;
1706 long dest_offset_bits
, source_offset_bits
, source_offset
;
1707 const gdb_byte
*intermediate_buffer
;
1709 /* Compute size, source, and destination offsets for copying, in
1711 this_size_bits
= p
->size
;
1712 if (bits_to_skip
> 0 && bits_to_skip
>= this_size_bits
)
1714 bits_to_skip
-= this_size_bits
;
1717 if (bits_to_skip
> 0)
1719 dest_offset_bits
= 0;
1720 source_offset_bits
= bits_to_skip
;
1721 this_size_bits
-= bits_to_skip
;
1726 dest_offset_bits
= offset
;
1727 source_offset_bits
= 0;
1729 if (this_size_bits
> type_len
- offset
)
1730 this_size_bits
= type_len
- offset
;
1732 this_size
= (this_size_bits
+ source_offset_bits
% 8 + 7) / 8;
1733 source_offset
= source_offset_bits
/ 8;
1734 if (buffer_size
< this_size
)
1736 buffer_size
= this_size
;
1737 buffer
.reserve (buffer_size
);
1739 intermediate_buffer
= buffer
.data ();
1741 /* Copy from the source to DEST_BUFFER. */
1742 switch (p
->location
)
1744 case DWARF_VALUE_REGISTER
:
1746 struct gdbarch
*arch
= get_frame_arch (frame
);
1747 int gdb_regnum
= dwarf_reg_to_regnum_or_error (arch
, p
->v
.regno
);
1749 LONGEST reg_offset
= source_offset
;
1751 if (gdbarch_byte_order (arch
) == BFD_ENDIAN_BIG
1752 && this_size
< register_size (arch
, gdb_regnum
))
1754 /* Big-endian, and we want less than full size. */
1755 reg_offset
= register_size (arch
, gdb_regnum
) - this_size
;
1756 /* We want the lower-order THIS_SIZE_BITS of the bytes
1757 we extract from the register. */
1758 source_offset_bits
+= 8 * this_size
- this_size_bits
;
1761 if (!get_frame_register_bytes (frame
, gdb_regnum
, reg_offset
,
1762 this_size
, buffer
.data (),
1765 /* Just so garbage doesn't ever shine through. */
1766 memset (buffer
.data (), 0, this_size
);
1769 mark_value_bits_optimized_out (v
, offset
, this_size_bits
);
1771 mark_value_bits_unavailable (v
, offset
, this_size_bits
);
1776 case DWARF_VALUE_MEMORY
:
1777 read_value_memory (v
, offset
,
1778 p
->v
.mem
.in_stack_memory
,
1779 p
->v
.mem
.addr
+ source_offset
,
1780 buffer
.data (), this_size
);
1783 case DWARF_VALUE_STACK
:
1785 size_t n
= this_size
;
1787 if (n
> c
->addr_size
- source_offset
)
1788 n
= (c
->addr_size
>= source_offset
1789 ? c
->addr_size
- source_offset
1797 const gdb_byte
*val_bytes
= value_contents_all (p
->v
.value
);
1799 intermediate_buffer
= val_bytes
+ source_offset
;
1804 case DWARF_VALUE_LITERAL
:
1806 size_t n
= this_size
;
1808 if (n
> p
->v
.literal
.length
- source_offset
)
1809 n
= (p
->v
.literal
.length
>= source_offset
1810 ? p
->v
.literal
.length
- source_offset
1813 intermediate_buffer
= p
->v
.literal
.data
+ source_offset
;
1817 /* These bits show up as zeros -- but do not cause the value
1818 to be considered optimized-out. */
1819 case DWARF_VALUE_IMPLICIT_POINTER
:
1822 case DWARF_VALUE_OPTIMIZED_OUT
:
1823 mark_value_bits_optimized_out (v
, offset
, this_size_bits
);
1827 internal_error (__FILE__
, __LINE__
, _("invalid location type"));
1830 if (p
->location
!= DWARF_VALUE_OPTIMIZED_OUT
1831 && p
->location
!= DWARF_VALUE_IMPLICIT_POINTER
)
1832 copy_bitwise (contents
, dest_offset_bits
,
1833 intermediate_buffer
, source_offset_bits
% 8,
1834 this_size_bits
, bits_big_endian
);
1836 offset
+= this_size_bits
;
1841 write_pieced_value (struct value
*to
, struct value
*from
)
1845 ULONGEST bits_to_skip
;
1846 const gdb_byte
*contents
;
1847 struct piece_closure
*c
1848 = (struct piece_closure
*) value_computed_closure (to
);
1849 struct frame_info
*frame
;
1851 size_t buffer_size
= 0;
1852 std::vector
<gdb_byte
> buffer
;
1854 = gdbarch_bits_big_endian (get_type_arch (value_type (to
)));
1856 /* VALUE_FRAME_ID is used instead of VALUE_NEXT_FRAME_ID here
1857 because FRAME is passed to get_frame_register_bytes() and
1858 put_frame_register_bytes(), both of which do their own "->next"
1860 frame
= frame_find_by_id (VALUE_FRAME_ID (to
));
1863 mark_value_bytes_optimized_out (to
, 0, TYPE_LENGTH (value_type (to
)));
1867 contents
= value_contents (from
);
1868 bits_to_skip
= 8 * value_offset (to
);
1869 if (value_bitsize (to
))
1871 bits_to_skip
+= value_bitpos (to
);
1872 type_len
= value_bitsize (to
);
1875 type_len
= 8 * TYPE_LENGTH (value_type (to
));
1877 for (i
= 0; i
< c
->n_pieces
&& offset
< type_len
; i
++)
1879 struct dwarf_expr_piece
*p
= &c
->pieces
[i
];
1880 size_t this_size_bits
, this_size
;
1881 long dest_offset_bits
, source_offset_bits
, dest_offset
, source_offset
;
1883 const gdb_byte
*source_buffer
;
1885 this_size_bits
= p
->size
;
1886 if (bits_to_skip
> 0 && bits_to_skip
>= this_size_bits
)
1888 bits_to_skip
-= this_size_bits
;
1891 if (this_size_bits
> type_len
- offset
)
1892 this_size_bits
= type_len
- offset
;
1893 if (bits_to_skip
> 0)
1895 dest_offset_bits
= bits_to_skip
;
1896 source_offset_bits
= 0;
1897 this_size_bits
-= bits_to_skip
;
1902 dest_offset_bits
= 0;
1903 source_offset_bits
= offset
;
1906 this_size
= (this_size_bits
+ source_offset_bits
% 8 + 7) / 8;
1907 source_offset
= source_offset_bits
/ 8;
1908 dest_offset
= dest_offset_bits
/ 8;
1909 if (dest_offset_bits
% 8 == 0 && source_offset_bits
% 8 == 0)
1911 source_buffer
= contents
+ source_offset
;
1916 if (buffer_size
< this_size
)
1918 buffer_size
= this_size
;
1919 buffer
.reserve (buffer_size
);
1921 source_buffer
= buffer
.data ();
1925 switch (p
->location
)
1927 case DWARF_VALUE_REGISTER
:
1929 struct gdbarch
*arch
= get_frame_arch (frame
);
1930 int gdb_regnum
= dwarf_reg_to_regnum_or_error (arch
, p
->v
.regno
);
1931 int reg_offset
= dest_offset
;
1933 if (gdbarch_byte_order (arch
) == BFD_ENDIAN_BIG
1934 && this_size
<= register_size (arch
, gdb_regnum
))
1936 /* Big-endian, and we want less than full size. */
1937 reg_offset
= register_size (arch
, gdb_regnum
) - this_size
;
1944 if (!get_frame_register_bytes (frame
, gdb_regnum
, reg_offset
,
1945 this_size
, buffer
.data (),
1949 throw_error (OPTIMIZED_OUT_ERROR
,
1950 _("Can't do read-modify-write to "
1951 "update bitfield; containing word "
1952 "has been optimized out"));
1954 throw_error (NOT_AVAILABLE_ERROR
,
1955 _("Can't do read-modify-write to update "
1956 "bitfield; containing word "
1959 copy_bitwise (buffer
.data (), dest_offset_bits
,
1960 contents
, source_offset_bits
,
1965 put_frame_register_bytes (frame
, gdb_regnum
, reg_offset
,
1966 this_size
, source_buffer
);
1969 case DWARF_VALUE_MEMORY
:
1972 /* Only the first and last bytes can possibly have any
1974 read_memory (p
->v
.mem
.addr
+ dest_offset
, buffer
.data (), 1);
1975 read_memory (p
->v
.mem
.addr
+ dest_offset
+ this_size
- 1,
1976 &buffer
[this_size
- 1], 1);
1977 copy_bitwise (buffer
.data (), dest_offset_bits
,
1978 contents
, source_offset_bits
,
1983 write_memory (p
->v
.mem
.addr
+ dest_offset
,
1984 source_buffer
, this_size
);
1987 mark_value_bytes_optimized_out (to
, 0, TYPE_LENGTH (value_type (to
)));
1990 offset
+= this_size_bits
;
1994 /* An implementation of an lval_funcs method to see whether a value is
1995 a synthetic pointer. */
1998 check_pieced_synthetic_pointer (const struct value
*value
, LONGEST bit_offset
,
2001 struct piece_closure
*c
2002 = (struct piece_closure
*) value_computed_closure (value
);
2005 bit_offset
+= 8 * value_offset (value
);
2006 if (value_bitsize (value
))
2007 bit_offset
+= value_bitpos (value
);
2009 for (i
= 0; i
< c
->n_pieces
&& bit_length
> 0; i
++)
2011 struct dwarf_expr_piece
*p
= &c
->pieces
[i
];
2012 size_t this_size_bits
= p
->size
;
2016 if (bit_offset
>= this_size_bits
)
2018 bit_offset
-= this_size_bits
;
2022 bit_length
-= this_size_bits
- bit_offset
;
2026 bit_length
-= this_size_bits
;
2028 if (p
->location
!= DWARF_VALUE_IMPLICIT_POINTER
)
2035 /* A wrapper function for get_frame_address_in_block. */
2038 get_frame_address_in_block_wrapper (void *baton
)
2040 return get_frame_address_in_block ((struct frame_info
*) baton
);
2043 /* Fetch a DW_AT_const_value through a synthetic pointer. */
2045 static struct value
*
2046 fetch_const_value_from_synthetic_pointer (sect_offset die
, LONGEST byte_offset
,
2047 struct dwarf2_per_cu_data
*per_cu
,
2050 struct value
*result
= NULL
;
2051 struct obstack temp_obstack
;
2052 struct cleanup
*cleanup
;
2053 const gdb_byte
*bytes
;
2056 obstack_init (&temp_obstack
);
2057 cleanup
= make_cleanup_obstack_free (&temp_obstack
);
2058 bytes
= dwarf2_fetch_constant_bytes (die
, per_cu
, &temp_obstack
, &len
);
2062 if (byte_offset
>= 0
2063 && byte_offset
+ TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) <= len
)
2065 bytes
+= byte_offset
;
2066 result
= value_from_contents (TYPE_TARGET_TYPE (type
), bytes
);
2069 invalid_synthetic_pointer ();
2072 result
= allocate_optimized_out_value (TYPE_TARGET_TYPE (type
));
2074 do_cleanups (cleanup
);
2079 /* Fetch the value pointed to by a synthetic pointer. */
2081 static struct value
*
2082 indirect_synthetic_pointer (sect_offset die
, LONGEST byte_offset
,
2083 struct dwarf2_per_cu_data
*per_cu
,
2084 struct frame_info
*frame
, struct type
*type
)
2086 /* Fetch the location expression of the DIE we're pointing to. */
2087 struct dwarf2_locexpr_baton baton
2088 = dwarf2_fetch_die_loc_sect_off (die
, per_cu
,
2089 get_frame_address_in_block_wrapper
, frame
);
2091 /* If pointed-to DIE has a DW_AT_location, evaluate it and return the
2092 resulting value. Otherwise, it may have a DW_AT_const_value instead,
2093 or it may've been optimized out. */
2094 if (baton
.data
!= NULL
)
2095 return dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type
), frame
,
2096 baton
.data
, baton
.size
, baton
.per_cu
,
2099 return fetch_const_value_from_synthetic_pointer (die
, byte_offset
, per_cu
,
2103 /* An implementation of an lval_funcs method to indirect through a
2104 pointer. This handles the synthetic pointer case when needed. */
2106 static struct value
*
2107 indirect_pieced_value (struct value
*value
)
2109 struct piece_closure
*c
2110 = (struct piece_closure
*) value_computed_closure (value
);
2112 struct frame_info
*frame
;
2113 struct dwarf2_locexpr_baton baton
;
2116 struct dwarf_expr_piece
*piece
= NULL
;
2117 LONGEST byte_offset
;
2118 enum bfd_endian byte_order
;
2120 type
= check_typedef (value_type (value
));
2121 if (TYPE_CODE (type
) != TYPE_CODE_PTR
)
2124 bit_length
= 8 * TYPE_LENGTH (type
);
2125 bit_offset
= 8 * value_offset (value
);
2126 if (value_bitsize (value
))
2127 bit_offset
+= value_bitpos (value
);
2129 for (i
= 0; i
< c
->n_pieces
&& bit_length
> 0; i
++)
2131 struct dwarf_expr_piece
*p
= &c
->pieces
[i
];
2132 size_t this_size_bits
= p
->size
;
2136 if (bit_offset
>= this_size_bits
)
2138 bit_offset
-= this_size_bits
;
2142 bit_length
-= this_size_bits
- bit_offset
;
2146 bit_length
-= this_size_bits
;
2148 if (p
->location
!= DWARF_VALUE_IMPLICIT_POINTER
)
2151 if (bit_length
!= 0)
2152 error (_("Invalid use of DW_OP_GNU_implicit_pointer"));
2158 gdb_assert (piece
!= NULL
);
2159 frame
= get_selected_frame (_("No frame selected."));
2161 /* This is an offset requested by GDB, such as value subscripts.
2162 However, due to how synthetic pointers are implemented, this is
2163 always presented to us as a pointer type. This means we have to
2164 sign-extend it manually as appropriate. Use raw
2165 extract_signed_integer directly rather than value_as_address and
2166 sign extend afterwards on architectures that would need it
2167 (mostly everywhere except MIPS, which has signed addresses) as
2168 the later would go through gdbarch_pointer_to_address and thus
2169 return a CORE_ADDR with high bits set on architectures that
2170 encode address spaces and other things in CORE_ADDR. */
2171 byte_order
= gdbarch_byte_order (get_frame_arch (frame
));
2172 byte_offset
= extract_signed_integer (value_contents (value
),
2173 TYPE_LENGTH (type
), byte_order
);
2174 byte_offset
+= piece
->v
.ptr
.offset
;
2176 return indirect_synthetic_pointer (piece
->v
.ptr
.die
, byte_offset
, c
->per_cu
,
2180 /* Implementation of the coerce_ref method of lval_funcs for synthetic C++
2183 static struct value
*
2184 coerce_pieced_ref (const struct value
*value
)
2186 struct type
*type
= check_typedef (value_type (value
));
2188 if (value_bits_synthetic_pointer (value
, value_embedded_offset (value
),
2189 TARGET_CHAR_BIT
* TYPE_LENGTH (type
)))
2191 const struct piece_closure
*closure
2192 = (struct piece_closure
*) value_computed_closure (value
);
2193 struct frame_info
*frame
2194 = get_selected_frame (_("No frame selected."));
2196 /* gdb represents synthetic pointers as pieced values with a single
2198 gdb_assert (closure
!= NULL
);
2199 gdb_assert (closure
->n_pieces
== 1);
2201 return indirect_synthetic_pointer (closure
->pieces
->v
.ptr
.die
,
2202 closure
->pieces
->v
.ptr
.offset
,
2203 closure
->per_cu
, frame
, type
);
2207 /* Else: not a synthetic reference; do nothing. */
2213 copy_pieced_value_closure (const struct value
*v
)
2215 struct piece_closure
*c
2216 = (struct piece_closure
*) value_computed_closure (v
);
2223 free_pieced_value_closure (struct value
*v
)
2225 struct piece_closure
*c
2226 = (struct piece_closure
*) value_computed_closure (v
);
2233 for (i
= 0; i
< c
->n_pieces
; ++i
)
2234 if (c
->pieces
[i
].location
== DWARF_VALUE_STACK
)
2235 value_free (c
->pieces
[i
].v
.value
);
2242 /* Functions for accessing a variable described by DW_OP_piece. */
2243 static const struct lval_funcs pieced_value_funcs
= {
2246 indirect_pieced_value
,
2248 check_pieced_synthetic_pointer
,
2249 copy_pieced_value_closure
,
2250 free_pieced_value_closure
2253 /* Evaluate a location description, starting at DATA and with length
2254 SIZE, to find the current location of variable of TYPE in the
2255 context of FRAME. BYTE_OFFSET is applied after the contents are
2258 static struct value
*
2259 dwarf2_evaluate_loc_desc_full (struct type
*type
, struct frame_info
*frame
,
2260 const gdb_byte
*data
, size_t size
,
2261 struct dwarf2_per_cu_data
*per_cu
,
2262 LONGEST byte_offset
)
2264 struct value
*retval
;
2265 struct cleanup
*value_chain
;
2266 struct objfile
*objfile
= dwarf2_per_cu_objfile (per_cu
);
2268 if (byte_offset
< 0)
2269 invalid_synthetic_pointer ();
2272 return allocate_optimized_out_value (type
);
2274 dwarf_evaluate_loc_desc ctx
;
2276 ctx
.per_cu
= per_cu
;
2277 ctx
.obj_address
= 0;
2279 value_chain
= make_cleanup_value_free_to_mark (value_mark ());
2281 ctx
.gdbarch
= get_objfile_arch (objfile
);
2282 ctx
.addr_size
= dwarf2_per_cu_addr_size (per_cu
);
2283 ctx
.ref_addr_size
= dwarf2_per_cu_ref_addr_size (per_cu
);
2284 ctx
.offset
= dwarf2_per_cu_text_offset (per_cu
);
2288 ctx
.eval (data
, size
);
2290 CATCH (ex
, RETURN_MASK_ERROR
)
2292 if (ex
.error
== NOT_AVAILABLE_ERROR
)
2294 do_cleanups (value_chain
);
2295 retval
= allocate_value (type
);
2296 mark_value_bytes_unavailable (retval
, 0, TYPE_LENGTH (type
));
2299 else if (ex
.error
== NO_ENTRY_VALUE_ERROR
)
2301 if (entry_values_debug
)
2302 exception_print (gdb_stdout
, ex
);
2303 do_cleanups (value_chain
);
2304 return allocate_optimized_out_value (type
);
2307 throw_exception (ex
);
2311 if (ctx
.num_pieces
> 0)
2313 struct piece_closure
*c
;
2314 struct frame_id frame_id
2317 : get_frame_id (get_next_frame_sentinel_okay (frame
));
2318 ULONGEST bit_size
= 0;
2321 for (i
= 0; i
< ctx
.num_pieces
; ++i
)
2322 bit_size
+= ctx
.pieces
[i
].size
;
2323 if (8 * (byte_offset
+ TYPE_LENGTH (type
)) > bit_size
)
2324 invalid_synthetic_pointer ();
2326 c
= allocate_piece_closure (per_cu
, ctx
.num_pieces
, ctx
.pieces
,
2328 /* We must clean up the value chain after creating the piece
2329 closure but before allocating the result. */
2330 do_cleanups (value_chain
);
2331 retval
= allocate_computed_value (type
, &pieced_value_funcs
, c
);
2332 VALUE_NEXT_FRAME_ID (retval
) = frame_id
;
2333 set_value_offset (retval
, byte_offset
);
2337 switch (ctx
.location
)
2339 case DWARF_VALUE_REGISTER
:
2341 struct gdbarch
*arch
= get_frame_arch (frame
);
2343 = longest_to_int (value_as_long (ctx
.fetch (0)));
2344 int gdb_regnum
= dwarf_reg_to_regnum_or_error (arch
, dwarf_regnum
);
2346 if (byte_offset
!= 0)
2347 error (_("cannot use offset on synthetic pointer to register"));
2348 do_cleanups (value_chain
);
2349 retval
= value_from_register (type
, gdb_regnum
, frame
);
2350 if (value_optimized_out (retval
))
2354 /* This means the register has undefined value / was
2355 not saved. As we're computing the location of some
2356 variable etc. in the program, not a value for
2357 inspecting a register ($pc, $sp, etc.), return a
2358 generic optimized out value instead, so that we show
2359 <optimized out> instead of <not saved>. */
2360 do_cleanups (value_chain
);
2361 tmp
= allocate_value (type
);
2362 value_contents_copy (tmp
, 0, retval
, 0, TYPE_LENGTH (type
));
2368 case DWARF_VALUE_MEMORY
:
2370 struct type
*ptr_type
;
2371 CORE_ADDR address
= ctx
.fetch_address (0);
2372 int in_stack_memory
= ctx
.fetch_in_stack_memory (0);
2374 /* DW_OP_deref_size (and possibly other operations too) may
2375 create a pointer instead of an address. Ideally, the
2376 pointer to address conversion would be performed as part
2377 of those operations, but the type of the object to
2378 which the address refers is not known at the time of
2379 the operation. Therefore, we do the conversion here
2380 since the type is readily available. */
2382 switch (TYPE_CODE (type
))
2384 case TYPE_CODE_FUNC
:
2385 case TYPE_CODE_METHOD
:
2386 ptr_type
= builtin_type (ctx
.gdbarch
)->builtin_func_ptr
;
2389 ptr_type
= builtin_type (ctx
.gdbarch
)->builtin_data_ptr
;
2392 address
= value_as_address (value_from_pointer (ptr_type
, address
));
2394 do_cleanups (value_chain
);
2395 retval
= value_at_lazy (type
, address
+ byte_offset
);
2396 if (in_stack_memory
)
2397 set_value_stack (retval
, 1);
2401 case DWARF_VALUE_STACK
:
2403 struct value
*value
= ctx
.fetch (0);
2405 const gdb_byte
*val_bytes
;
2406 size_t n
= TYPE_LENGTH (value_type (value
));
2408 if (byte_offset
+ TYPE_LENGTH (type
) > n
)
2409 invalid_synthetic_pointer ();
2411 val_bytes
= value_contents_all (value
);
2412 val_bytes
+= byte_offset
;
2415 /* Preserve VALUE because we are going to free values back
2416 to the mark, but we still need the value contents
2418 value_incref (value
);
2419 do_cleanups (value_chain
);
2420 make_cleanup_value_free (value
);
2422 retval
= allocate_value (type
);
2423 contents
= value_contents_raw (retval
);
2424 if (n
> TYPE_LENGTH (type
))
2426 struct gdbarch
*objfile_gdbarch
= get_objfile_arch (objfile
);
2428 if (gdbarch_byte_order (objfile_gdbarch
) == BFD_ENDIAN_BIG
)
2429 val_bytes
+= n
- TYPE_LENGTH (type
);
2430 n
= TYPE_LENGTH (type
);
2432 memcpy (contents
, val_bytes
, n
);
2436 case DWARF_VALUE_LITERAL
:
2439 const bfd_byte
*ldata
;
2442 if (byte_offset
+ TYPE_LENGTH (type
) > n
)
2443 invalid_synthetic_pointer ();
2445 do_cleanups (value_chain
);
2446 retval
= allocate_value (type
);
2447 contents
= value_contents_raw (retval
);
2449 ldata
= ctx
.data
+ byte_offset
;
2452 if (n
> TYPE_LENGTH (type
))
2454 struct gdbarch
*objfile_gdbarch
= get_objfile_arch (objfile
);
2456 if (gdbarch_byte_order (objfile_gdbarch
) == BFD_ENDIAN_BIG
)
2457 ldata
+= n
- TYPE_LENGTH (type
);
2458 n
= TYPE_LENGTH (type
);
2460 memcpy (contents
, ldata
, n
);
2464 case DWARF_VALUE_OPTIMIZED_OUT
:
2465 do_cleanups (value_chain
);
2466 retval
= allocate_optimized_out_value (type
);
2469 /* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced
2470 operation by execute_stack_op. */
2471 case DWARF_VALUE_IMPLICIT_POINTER
:
2472 /* DWARF_VALUE_OPTIMIZED_OUT can't occur in this context --
2473 it can only be encountered when making a piece. */
2475 internal_error (__FILE__
, __LINE__
, _("invalid location type"));
2479 set_value_initialized (retval
, ctx
.initialized
);
2481 do_cleanups (value_chain
);
2486 /* The exported interface to dwarf2_evaluate_loc_desc_full; it always
2487 passes 0 as the byte_offset. */
2490 dwarf2_evaluate_loc_desc (struct type
*type
, struct frame_info
*frame
,
2491 const gdb_byte
*data
, size_t size
,
2492 struct dwarf2_per_cu_data
*per_cu
)
2494 return dwarf2_evaluate_loc_desc_full (type
, frame
, data
, size
, per_cu
, 0);
2497 /* Evaluates a dwarf expression and stores the result in VAL, expecting
2498 that the dwarf expression only produces a single CORE_ADDR. FRAME is the
2499 frame in which the expression is evaluated. ADDR is a context (location of
2500 a variable) and might be needed to evaluate the location expression.
2501 Returns 1 on success, 0 otherwise. */
2504 dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton
*dlbaton
,
2505 struct frame_info
*frame
,
2509 struct objfile
*objfile
;
2510 struct cleanup
*cleanup
;
2512 if (dlbaton
== NULL
|| dlbaton
->size
== 0)
2515 dwarf_evaluate_loc_desc ctx
;
2518 ctx
.per_cu
= dlbaton
->per_cu
;
2519 ctx
.obj_address
= addr
;
2521 objfile
= dwarf2_per_cu_objfile (dlbaton
->per_cu
);
2523 ctx
.gdbarch
= get_objfile_arch (objfile
);
2524 ctx
.addr_size
= dwarf2_per_cu_addr_size (dlbaton
->per_cu
);
2525 ctx
.ref_addr_size
= dwarf2_per_cu_ref_addr_size (dlbaton
->per_cu
);
2526 ctx
.offset
= dwarf2_per_cu_text_offset (dlbaton
->per_cu
);
2528 ctx
.eval (dlbaton
->data
, dlbaton
->size
);
2530 switch (ctx
.location
)
2532 case DWARF_VALUE_REGISTER
:
2533 case DWARF_VALUE_MEMORY
:
2534 case DWARF_VALUE_STACK
:
2535 *valp
= ctx
.fetch_address (0);
2536 if (ctx
.location
== DWARF_VALUE_REGISTER
)
2537 *valp
= ctx
.read_addr_from_reg (*valp
);
2539 case DWARF_VALUE_LITERAL
:
2540 *valp
= extract_signed_integer (ctx
.data
, ctx
.len
,
2541 gdbarch_byte_order (ctx
.gdbarch
));
2543 /* Unsupported dwarf values. */
2544 case DWARF_VALUE_OPTIMIZED_OUT
:
2545 case DWARF_VALUE_IMPLICIT_POINTER
:
2552 /* See dwarf2loc.h. */
2555 dwarf2_evaluate_property (const struct dynamic_prop
*prop
,
2556 struct frame_info
*frame
,
2557 struct property_addr_info
*addr_stack
,
2563 if (frame
== NULL
&& has_stack_frames ())
2564 frame
= get_selected_frame (NULL
);
2570 const struct dwarf2_property_baton
*baton
2571 = (const struct dwarf2_property_baton
*) prop
->data
.baton
;
2573 if (dwarf2_locexpr_baton_eval (&baton
->locexpr
, frame
,
2574 addr_stack
? addr_stack
->addr
: 0,
2577 if (baton
->referenced_type
)
2579 struct value
*val
= value_at (baton
->referenced_type
, *value
);
2581 *value
= value_as_address (val
);
2590 struct dwarf2_property_baton
*baton
2591 = (struct dwarf2_property_baton
*) prop
->data
.baton
;
2592 CORE_ADDR pc
= get_frame_address_in_block (frame
);
2593 const gdb_byte
*data
;
2597 data
= dwarf2_find_location_expression (&baton
->loclist
, &size
, pc
);
2600 val
= dwarf2_evaluate_loc_desc (baton
->referenced_type
, frame
, data
,
2601 size
, baton
->loclist
.per_cu
);
2602 if (!value_optimized_out (val
))
2604 *value
= value_as_address (val
);
2612 *value
= prop
->data
.const_val
;
2615 case PROP_ADDR_OFFSET
:
2617 struct dwarf2_property_baton
*baton
2618 = (struct dwarf2_property_baton
*) prop
->data
.baton
;
2619 struct property_addr_info
*pinfo
;
2622 for (pinfo
= addr_stack
; pinfo
!= NULL
; pinfo
= pinfo
->next
)
2623 if (pinfo
->type
== baton
->referenced_type
)
2626 error (_("cannot find reference address for offset property"));
2627 if (pinfo
->valaddr
!= NULL
)
2628 val
= value_from_contents
2629 (baton
->offset_info
.type
,
2630 pinfo
->valaddr
+ baton
->offset_info
.offset
);
2632 val
= value_at (baton
->offset_info
.type
,
2633 pinfo
->addr
+ baton
->offset_info
.offset
);
2634 *value
= value_as_address (val
);
2642 /* See dwarf2loc.h. */
2645 dwarf2_compile_property_to_c (struct ui_file
*stream
,
2646 const char *result_name
,
2647 struct gdbarch
*gdbarch
,
2648 unsigned char *registers_used
,
2649 const struct dynamic_prop
*prop
,
2653 struct dwarf2_property_baton
*baton
2654 = (struct dwarf2_property_baton
*) prop
->data
.baton
;
2655 const gdb_byte
*data
;
2657 struct dwarf2_per_cu_data
*per_cu
;
2659 if (prop
->kind
== PROP_LOCEXPR
)
2661 data
= baton
->locexpr
.data
;
2662 size
= baton
->locexpr
.size
;
2663 per_cu
= baton
->locexpr
.per_cu
;
2667 gdb_assert (prop
->kind
== PROP_LOCLIST
);
2669 data
= dwarf2_find_location_expression (&baton
->loclist
, &size
, pc
);
2670 per_cu
= baton
->loclist
.per_cu
;
2673 compile_dwarf_bounds_to_c (stream
, result_name
, prop
, sym
, pc
,
2674 gdbarch
, registers_used
,
2675 dwarf2_per_cu_addr_size (per_cu
),
2676 data
, data
+ size
, per_cu
);
2680 /* Helper functions and baton for dwarf2_loc_desc_get_symbol_read_needs. */
2682 class symbol_needs_eval_context
: public dwarf_expr_context
2686 enum symbol_needs_kind needs
;
2687 struct dwarf2_per_cu_data
*per_cu
;
2689 /* Reads from registers do require a frame. */
2690 CORE_ADDR
read_addr_from_reg (int regnum
) OVERRIDE
2692 needs
= SYMBOL_NEEDS_FRAME
;
2696 /* "get_reg_value" callback: Reads from registers do require a
2699 struct value
*get_reg_value (struct type
*type
, int regnum
) OVERRIDE
2701 needs
= SYMBOL_NEEDS_FRAME
;
2702 return value_zero (type
, not_lval
);
2705 /* Reads from memory do not require a frame. */
2706 void read_mem (gdb_byte
*buf
, CORE_ADDR addr
, size_t len
) OVERRIDE
2708 memset (buf
, 0, len
);
2711 /* Frame-relative accesses do require a frame. */
2712 void get_frame_base (const gdb_byte
**start
, size_t *length
) OVERRIDE
2714 static gdb_byte lit0
= DW_OP_lit0
;
2719 needs
= SYMBOL_NEEDS_FRAME
;
2722 /* CFA accesses require a frame. */
2723 CORE_ADDR
get_frame_cfa () OVERRIDE
2725 needs
= SYMBOL_NEEDS_FRAME
;
2729 CORE_ADDR
get_frame_pc () OVERRIDE
2731 needs
= SYMBOL_NEEDS_FRAME
;
2735 /* Thread-local accesses require registers, but not a frame. */
2736 CORE_ADDR
get_tls_address (CORE_ADDR offset
) OVERRIDE
2738 if (needs
<= SYMBOL_NEEDS_REGISTERS
)
2739 needs
= SYMBOL_NEEDS_REGISTERS
;
2743 /* Helper interface of per_cu_dwarf_call for
2744 dwarf2_loc_desc_get_symbol_read_needs. */
2746 void dwarf_call (cu_offset die_offset
) OVERRIDE
2748 per_cu_dwarf_call (this, die_offset
, per_cu
);
2751 /* DW_OP_GNU_entry_value accesses require a caller, therefore a
2754 void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind
,
2755 union call_site_parameter_u kind_u
,
2756 int deref_size
) OVERRIDE
2758 needs
= SYMBOL_NEEDS_FRAME
;
2760 /* The expression may require some stub values on DWARF stack. */
2761 push_address (0, 0);
2764 /* DW_OP_GNU_addr_index doesn't require a frame. */
2766 CORE_ADDR
get_addr_index (unsigned int index
) OVERRIDE
2768 /* Nothing to do. */
2772 /* DW_OP_push_object_address has a frame already passed through. */
2774 CORE_ADDR
get_object_address () OVERRIDE
2776 /* Nothing to do. */
2781 /* Compute the correct symbol_needs_kind value for the location
2782 expression at DATA (length SIZE). */
2784 static enum symbol_needs_kind
2785 dwarf2_loc_desc_get_symbol_read_needs (const gdb_byte
*data
, size_t size
,
2786 struct dwarf2_per_cu_data
*per_cu
)
2789 struct cleanup
*old_chain
;
2790 struct objfile
*objfile
= dwarf2_per_cu_objfile (per_cu
);
2792 symbol_needs_eval_context ctx
;
2794 ctx
.needs
= SYMBOL_NEEDS_NONE
;
2795 ctx
.per_cu
= per_cu
;
2797 old_chain
= make_cleanup_value_free_to_mark (value_mark ());
2799 ctx
.gdbarch
= get_objfile_arch (objfile
);
2800 ctx
.addr_size
= dwarf2_per_cu_addr_size (per_cu
);
2801 ctx
.ref_addr_size
= dwarf2_per_cu_ref_addr_size (per_cu
);
2802 ctx
.offset
= dwarf2_per_cu_text_offset (per_cu
);
2804 ctx
.eval (data
, size
);
2806 in_reg
= ctx
.location
== DWARF_VALUE_REGISTER
;
2808 if (ctx
.num_pieces
> 0)
2812 /* If the location has several pieces, and any of them are in
2813 registers, then we will need a frame to fetch them from. */
2814 for (i
= 0; i
< ctx
.num_pieces
; i
++)
2815 if (ctx
.pieces
[i
].location
== DWARF_VALUE_REGISTER
)
2819 do_cleanups (old_chain
);
2822 ctx
.needs
= SYMBOL_NEEDS_FRAME
;
2826 /* A helper function that throws an unimplemented error mentioning a
2827 given DWARF operator. */
2830 unimplemented (unsigned int op
)
2832 const char *name
= get_DW_OP_name (op
);
2835 error (_("DWARF operator %s cannot be translated to an agent expression"),
2838 error (_("Unknown DWARF operator 0x%02x cannot be translated "
2839 "to an agent expression"),
2845 This is basically a wrapper on gdbarch_dwarf2_reg_to_regnum so that we
2846 can issue a complaint, which is better than having every target's
2847 implementation of dwarf2_reg_to_regnum do it. */
2850 dwarf_reg_to_regnum (struct gdbarch
*arch
, int dwarf_reg
)
2852 int reg
= gdbarch_dwarf2_reg_to_regnum (arch
, dwarf_reg
);
2856 complaint (&symfile_complaints
,
2857 _("bad DWARF register number %d"), dwarf_reg
);
2862 /* Subroutine of dwarf_reg_to_regnum_or_error to simplify it.
2863 Throw an error because DWARF_REG is bad. */
2866 throw_bad_regnum_error (ULONGEST dwarf_reg
)
2868 /* Still want to print -1 as "-1".
2869 We *could* have int and ULONGEST versions of dwarf2_reg_to_regnum_or_error
2870 but that's overkill for now. */
2871 if ((int) dwarf_reg
== dwarf_reg
)
2872 error (_("Unable to access DWARF register number %d"), (int) dwarf_reg
);
2873 error (_("Unable to access DWARF register number %s"),
2874 pulongest (dwarf_reg
));
2877 /* See dwarf2loc.h. */
2880 dwarf_reg_to_regnum_or_error (struct gdbarch
*arch
, ULONGEST dwarf_reg
)
2884 if (dwarf_reg
> INT_MAX
)
2885 throw_bad_regnum_error (dwarf_reg
);
2886 /* Yes, we will end up issuing a complaint and an error if DWARF_REG is
2887 bad, but that's ok. */
2888 reg
= dwarf_reg_to_regnum (arch
, (int) dwarf_reg
);
2890 throw_bad_regnum_error (dwarf_reg
);
2894 /* A helper function that emits an access to memory. ARCH is the
2895 target architecture. EXPR is the expression which we are building.
2896 NBITS is the number of bits we want to read. This emits the
2897 opcodes needed to read the memory and then extract the desired
2901 access_memory (struct gdbarch
*arch
, struct agent_expr
*expr
, ULONGEST nbits
)
2903 ULONGEST nbytes
= (nbits
+ 7) / 8;
2905 gdb_assert (nbytes
> 0 && nbytes
<= sizeof (LONGEST
));
2908 ax_trace_quick (expr
, nbytes
);
2911 ax_simple (expr
, aop_ref8
);
2912 else if (nbits
<= 16)
2913 ax_simple (expr
, aop_ref16
);
2914 else if (nbits
<= 32)
2915 ax_simple (expr
, aop_ref32
);
2917 ax_simple (expr
, aop_ref64
);
2919 /* If we read exactly the number of bytes we wanted, we're done. */
2920 if (8 * nbytes
== nbits
)
2923 if (gdbarch_bits_big_endian (arch
))
2925 /* On a bits-big-endian machine, we want the high-order
2927 ax_const_l (expr
, 8 * nbytes
- nbits
);
2928 ax_simple (expr
, aop_rsh_unsigned
);
2932 /* On a bits-little-endian box, we want the low-order NBITS. */
2933 ax_zero_ext (expr
, nbits
);
2937 /* A helper function to return the frame's PC. */
2940 get_ax_pc (void *baton
)
2942 struct agent_expr
*expr
= (struct agent_expr
*) baton
;
2947 /* Compile a DWARF location expression to an agent expression.
2949 EXPR is the agent expression we are building.
2950 LOC is the agent value we modify.
2951 ARCH is the architecture.
2952 ADDR_SIZE is the size of addresses, in bytes.
2953 OP_PTR is the start of the location expression.
2954 OP_END is one past the last byte of the location expression.
2956 This will throw an exception for various kinds of errors -- for
2957 example, if the expression cannot be compiled, or if the expression
2961 dwarf2_compile_expr_to_ax (struct agent_expr
*expr
, struct axs_value
*loc
,
2962 struct gdbarch
*arch
, unsigned int addr_size
,
2963 const gdb_byte
*op_ptr
, const gdb_byte
*op_end
,
2964 struct dwarf2_per_cu_data
*per_cu
)
2967 std::vector
<int> dw_labels
, patches
;
2968 const gdb_byte
* const base
= op_ptr
;
2969 const gdb_byte
*previous_piece
= op_ptr
;
2970 enum bfd_endian byte_order
= gdbarch_byte_order (arch
);
2971 ULONGEST bits_collected
= 0;
2972 unsigned int addr_size_bits
= 8 * addr_size
;
2973 int bits_big_endian
= gdbarch_bits_big_endian (arch
);
2975 std::vector
<int> offsets (op_end
- op_ptr
, -1);
2977 /* By default we are making an address. */
2978 loc
->kind
= axs_lvalue_memory
;
2980 while (op_ptr
< op_end
)
2982 enum dwarf_location_atom op
= (enum dwarf_location_atom
) *op_ptr
;
2983 uint64_t uoffset
, reg
;
2987 offsets
[op_ptr
- base
] = expr
->len
;
2990 /* Our basic approach to code generation is to map DWARF
2991 operations directly to AX operations. However, there are
2994 First, DWARF works on address-sized units, but AX always uses
2995 LONGEST. For most operations we simply ignore this
2996 difference; instead we generate sign extensions as needed
2997 before division and comparison operations. It would be nice
2998 to omit the sign extensions, but there is no way to determine
2999 the size of the target's LONGEST. (This code uses the size
3000 of the host LONGEST in some cases -- that is a bug but it is
3003 Second, some DWARF operations cannot be translated to AX.
3004 For these we simply fail. See
3005 http://sourceware.org/bugzilla/show_bug.cgi?id=11662. */
3040 ax_const_l (expr
, op
- DW_OP_lit0
);
3044 uoffset
= extract_unsigned_integer (op_ptr
, addr_size
, byte_order
);
3045 op_ptr
+= addr_size
;
3046 /* Some versions of GCC emit DW_OP_addr before
3047 DW_OP_GNU_push_tls_address. In this case the value is an
3048 index, not an address. We don't support things like
3049 branching between the address and the TLS op. */
3050 if (op_ptr
>= op_end
|| *op_ptr
!= DW_OP_GNU_push_tls_address
)
3051 uoffset
+= dwarf2_per_cu_text_offset (per_cu
);
3052 ax_const_l (expr
, uoffset
);
3056 ax_const_l (expr
, extract_unsigned_integer (op_ptr
, 1, byte_order
));
3060 ax_const_l (expr
, extract_signed_integer (op_ptr
, 1, byte_order
));
3064 ax_const_l (expr
, extract_unsigned_integer (op_ptr
, 2, byte_order
));
3068 ax_const_l (expr
, extract_signed_integer (op_ptr
, 2, byte_order
));
3072 ax_const_l (expr
, extract_unsigned_integer (op_ptr
, 4, byte_order
));
3076 ax_const_l (expr
, extract_signed_integer (op_ptr
, 4, byte_order
));
3080 ax_const_l (expr
, extract_unsigned_integer (op_ptr
, 8, byte_order
));
3084 ax_const_l (expr
, extract_signed_integer (op_ptr
, 8, byte_order
));
3088 op_ptr
= safe_read_uleb128 (op_ptr
, op_end
, &uoffset
);
3089 ax_const_l (expr
, uoffset
);
3092 op_ptr
= safe_read_sleb128 (op_ptr
, op_end
, &offset
);
3093 ax_const_l (expr
, offset
);
3128 dwarf_expr_require_composition (op_ptr
, op_end
, "DW_OP_regx");
3129 loc
->u
.reg
= dwarf_reg_to_regnum_or_error (arch
, op
- DW_OP_reg0
);
3130 loc
->kind
= axs_lvalue_register
;
3134 op_ptr
= safe_read_uleb128 (op_ptr
, op_end
, ®
);
3135 dwarf_expr_require_composition (op_ptr
, op_end
, "DW_OP_regx");
3136 loc
->u
.reg
= dwarf_reg_to_regnum_or_error (arch
, reg
);
3137 loc
->kind
= axs_lvalue_register
;
3140 case DW_OP_implicit_value
:
3144 op_ptr
= safe_read_uleb128 (op_ptr
, op_end
, &len
);
3145 if (op_ptr
+ len
> op_end
)
3146 error (_("DW_OP_implicit_value: too few bytes available."));
3147 if (len
> sizeof (ULONGEST
))
3148 error (_("Cannot translate DW_OP_implicit_value of %d bytes"),
3151 ax_const_l (expr
, extract_unsigned_integer (op_ptr
, len
,
3154 dwarf_expr_require_composition (op_ptr
, op_end
,
3155 "DW_OP_implicit_value");
3157 loc
->kind
= axs_rvalue
;
3161 case DW_OP_stack_value
:
3162 dwarf_expr_require_composition (op_ptr
, op_end
, "DW_OP_stack_value");
3163 loc
->kind
= axs_rvalue
;
3198 op_ptr
= safe_read_sleb128 (op_ptr
, op_end
, &offset
);
3199 i
= dwarf_reg_to_regnum_or_error (arch
, op
- DW_OP_breg0
);
3203 ax_const_l (expr
, offset
);
3204 ax_simple (expr
, aop_add
);
3209 op_ptr
= safe_read_uleb128 (op_ptr
, op_end
, ®
);
3210 op_ptr
= safe_read_sleb128 (op_ptr
, op_end
, &offset
);
3211 i
= dwarf_reg_to_regnum_or_error (arch
, reg
);
3215 ax_const_l (expr
, offset
);
3216 ax_simple (expr
, aop_add
);
3222 const gdb_byte
*datastart
;
3224 const struct block
*b
;
3225 struct symbol
*framefunc
;
3227 b
= block_for_pc (expr
->scope
);
3230 error (_("No block found for address"));
3232 framefunc
= block_linkage_function (b
);
3235 error (_("No function found for block"));
3237 func_get_frame_base_dwarf_block (framefunc
, expr
->scope
,
3238 &datastart
, &datalen
);
3240 op_ptr
= safe_read_sleb128 (op_ptr
, op_end
, &offset
);
3241 dwarf2_compile_expr_to_ax (expr
, loc
, arch
, addr_size
, datastart
,
3242 datastart
+ datalen
, per_cu
);
3243 if (loc
->kind
== axs_lvalue_register
)
3244 require_rvalue (expr
, loc
);
3248 ax_const_l (expr
, offset
);
3249 ax_simple (expr
, aop_add
);
3252 loc
->kind
= axs_lvalue_memory
;
3257 ax_simple (expr
, aop_dup
);
3261 ax_simple (expr
, aop_pop
);
3266 ax_pick (expr
, offset
);
3270 ax_simple (expr
, aop_swap
);
3278 ax_simple (expr
, aop_rot
);
3282 case DW_OP_deref_size
:
3286 if (op
== DW_OP_deref_size
)
3291 if (size
!= 1 && size
!= 2 && size
!= 4 && size
!= 8)
3292 error (_("Unsupported size %d in %s"),
3293 size
, get_DW_OP_name (op
));
3294 access_memory (arch
, expr
, size
* TARGET_CHAR_BIT
);
3299 /* Sign extend the operand. */
3300 ax_ext (expr
, addr_size_bits
);
3301 ax_simple (expr
, aop_dup
);
3302 ax_const_l (expr
, 0);
3303 ax_simple (expr
, aop_less_signed
);
3304 ax_simple (expr
, aop_log_not
);
3305 i
= ax_goto (expr
, aop_if_goto
);
3306 /* We have to emit 0 - X. */
3307 ax_const_l (expr
, 0);
3308 ax_simple (expr
, aop_swap
);
3309 ax_simple (expr
, aop_sub
);
3310 ax_label (expr
, i
, expr
->len
);
3314 /* No need to sign extend here. */
3315 ax_const_l (expr
, 0);
3316 ax_simple (expr
, aop_swap
);
3317 ax_simple (expr
, aop_sub
);
3321 /* Sign extend the operand. */
3322 ax_ext (expr
, addr_size_bits
);
3323 ax_simple (expr
, aop_bit_not
);
3326 case DW_OP_plus_uconst
:
3327 op_ptr
= safe_read_uleb128 (op_ptr
, op_end
, ®
);
3328 /* It would be really weird to emit `DW_OP_plus_uconst 0',
3329 but we micro-optimize anyhow. */
3332 ax_const_l (expr
, reg
);
3333 ax_simple (expr
, aop_add
);
3338 ax_simple (expr
, aop_bit_and
);
3342 /* Sign extend the operands. */
3343 ax_ext (expr
, addr_size_bits
);
3344 ax_simple (expr
, aop_swap
);
3345 ax_ext (expr
, addr_size_bits
);
3346 ax_simple (expr
, aop_swap
);
3347 ax_simple (expr
, aop_div_signed
);
3351 ax_simple (expr
, aop_sub
);
3355 ax_simple (expr
, aop_rem_unsigned
);
3359 ax_simple (expr
, aop_mul
);
3363 ax_simple (expr
, aop_bit_or
);
3367 ax_simple (expr
, aop_add
);
3371 ax_simple (expr
, aop_lsh
);
3375 ax_simple (expr
, aop_rsh_unsigned
);
3379 ax_simple (expr
, aop_rsh_signed
);
3383 ax_simple (expr
, aop_bit_xor
);
3387 /* Sign extend the operands. */
3388 ax_ext (expr
, addr_size_bits
);
3389 ax_simple (expr
, aop_swap
);
3390 ax_ext (expr
, addr_size_bits
);
3391 /* Note no swap here: A <= B is !(B < A). */
3392 ax_simple (expr
, aop_less_signed
);
3393 ax_simple (expr
, aop_log_not
);
3397 /* Sign extend the operands. */
3398 ax_ext (expr
, addr_size_bits
);
3399 ax_simple (expr
, aop_swap
);
3400 ax_ext (expr
, addr_size_bits
);
3401 ax_simple (expr
, aop_swap
);
3402 /* A >= B is !(A < B). */
3403 ax_simple (expr
, aop_less_signed
);
3404 ax_simple (expr
, aop_log_not
);
3408 /* Sign extend the operands. */
3409 ax_ext (expr
, addr_size_bits
);
3410 ax_simple (expr
, aop_swap
);
3411 ax_ext (expr
, addr_size_bits
);
3412 /* No need for a second swap here. */
3413 ax_simple (expr
, aop_equal
);
3417 /* Sign extend the operands. */
3418 ax_ext (expr
, addr_size_bits
);
3419 ax_simple (expr
, aop_swap
);
3420 ax_ext (expr
, addr_size_bits
);
3421 ax_simple (expr
, aop_swap
);
3422 ax_simple (expr
, aop_less_signed
);
3426 /* Sign extend the operands. */
3427 ax_ext (expr
, addr_size_bits
);
3428 ax_simple (expr
, aop_swap
);
3429 ax_ext (expr
, addr_size_bits
);
3430 /* Note no swap here: A > B is B < A. */
3431 ax_simple (expr
, aop_less_signed
);
3435 /* Sign extend the operands. */
3436 ax_ext (expr
, addr_size_bits
);
3437 ax_simple (expr
, aop_swap
);
3438 ax_ext (expr
, addr_size_bits
);
3439 /* No need for a swap here. */
3440 ax_simple (expr
, aop_equal
);
3441 ax_simple (expr
, aop_log_not
);
3444 case DW_OP_call_frame_cfa
:
3447 CORE_ADDR text_offset
;
3449 const gdb_byte
*cfa_start
, *cfa_end
;
3451 if (dwarf2_fetch_cfa_info (arch
, expr
->scope
, per_cu
,
3453 &text_offset
, &cfa_start
, &cfa_end
))
3456 ax_reg (expr
, regnum
);
3459 ax_const_l (expr
, off
);
3460 ax_simple (expr
, aop_add
);
3465 /* Another expression. */
3466 ax_const_l (expr
, text_offset
);
3467 dwarf2_compile_expr_to_ax (expr
, loc
, arch
, addr_size
,
3468 cfa_start
, cfa_end
, per_cu
);
3471 loc
->kind
= axs_lvalue_memory
;
3475 case DW_OP_GNU_push_tls_address
:
3476 case DW_OP_form_tls_address
:
3480 case DW_OP_push_object_address
:
3485 offset
= extract_signed_integer (op_ptr
, 2, byte_order
);
3487 i
= ax_goto (expr
, aop_goto
);
3488 dw_labels
.push_back (op_ptr
+ offset
- base
);
3489 patches
.push_back (i
);
3493 offset
= extract_signed_integer (op_ptr
, 2, byte_order
);
3495 /* Zero extend the operand. */
3496 ax_zero_ext (expr
, addr_size_bits
);
3497 i
= ax_goto (expr
, aop_if_goto
);
3498 dw_labels
.push_back (op_ptr
+ offset
- base
);
3499 patches
.push_back (i
);
3506 case DW_OP_bit_piece
:
3508 uint64_t size
, offset
;
3510 if (op_ptr
- 1 == previous_piece
)
3511 error (_("Cannot translate empty pieces to agent expressions"));
3512 previous_piece
= op_ptr
- 1;
3514 op_ptr
= safe_read_uleb128 (op_ptr
, op_end
, &size
);
3515 if (op
== DW_OP_piece
)
3521 op_ptr
= safe_read_uleb128 (op_ptr
, op_end
, &offset
);
3523 if (bits_collected
+ size
> 8 * sizeof (LONGEST
))
3524 error (_("Expression pieces exceed word size"));
3526 /* Access the bits. */
3529 case axs_lvalue_register
:
3530 ax_reg (expr
, loc
->u
.reg
);
3533 case axs_lvalue_memory
:
3534 /* Offset the pointer, if needed. */
3537 ax_const_l (expr
, offset
/ 8);
3538 ax_simple (expr
, aop_add
);
3541 access_memory (arch
, expr
, size
);
3545 /* For a bits-big-endian target, shift up what we already
3546 have. For a bits-little-endian target, shift up the
3547 new data. Note that there is a potential bug here if
3548 the DWARF expression leaves multiple values on the
3550 if (bits_collected
> 0)
3552 if (bits_big_endian
)
3554 ax_simple (expr
, aop_swap
);
3555 ax_const_l (expr
, size
);
3556 ax_simple (expr
, aop_lsh
);
3557 /* We don't need a second swap here, because
3558 aop_bit_or is symmetric. */
3562 ax_const_l (expr
, size
);
3563 ax_simple (expr
, aop_lsh
);
3565 ax_simple (expr
, aop_bit_or
);
3568 bits_collected
+= size
;
3569 loc
->kind
= axs_rvalue
;
3573 case DW_OP_GNU_uninit
:
3579 struct dwarf2_locexpr_baton block
;
3580 int size
= (op
== DW_OP_call2
? 2 : 4);
3583 uoffset
= extract_unsigned_integer (op_ptr
, size
, byte_order
);
3586 offset
.cu_off
= uoffset
;
3587 block
= dwarf2_fetch_die_loc_cu_off (offset
, per_cu
,
3590 /* DW_OP_call_ref is currently not supported. */
3591 gdb_assert (block
.per_cu
== per_cu
);
3593 dwarf2_compile_expr_to_ax (expr
, loc
, arch
, addr_size
,
3594 block
.data
, block
.data
+ block
.size
,
3599 case DW_OP_call_ref
:
3607 /* Patch all the branches we emitted. */
3608 for (i
= 0; i
< patches
.size (); ++i
)
3610 int targ
= offsets
[dw_labels
[i
]];
3612 internal_error (__FILE__
, __LINE__
, _("invalid label"));
3613 ax_label (expr
, patches
[i
], targ
);
3618 /* Return the value of SYMBOL in FRAME using the DWARF-2 expression
3619 evaluator to calculate the location. */
3620 static struct value
*
3621 locexpr_read_variable (struct symbol
*symbol
, struct frame_info
*frame
)
3623 struct dwarf2_locexpr_baton
*dlbaton
3624 = (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (symbol
);
3627 val
= dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol
), frame
, dlbaton
->data
,
3628 dlbaton
->size
, dlbaton
->per_cu
);
3633 /* Return the value of SYMBOL in FRAME at (callee) FRAME's function
3634 entry. SYMBOL should be a function parameter, otherwise NO_ENTRY_VALUE_ERROR
3637 static struct value
*
3638 locexpr_read_variable_at_entry (struct symbol
*symbol
, struct frame_info
*frame
)
3640 struct dwarf2_locexpr_baton
*dlbaton
3641 = (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (symbol
);
3643 return value_of_dwarf_block_entry (SYMBOL_TYPE (symbol
), frame
, dlbaton
->data
,
3647 /* Implementation of get_symbol_read_needs from
3648 symbol_computed_ops. */
3650 static enum symbol_needs_kind
3651 locexpr_get_symbol_read_needs (struct symbol
*symbol
)
3653 struct dwarf2_locexpr_baton
*dlbaton
3654 = (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (symbol
);
3656 return dwarf2_loc_desc_get_symbol_read_needs (dlbaton
->data
, dlbaton
->size
,
3660 /* Return true if DATA points to the end of a piece. END is one past
3661 the last byte in the expression. */
3664 piece_end_p (const gdb_byte
*data
, const gdb_byte
*end
)
3666 return data
== end
|| data
[0] == DW_OP_piece
|| data
[0] == DW_OP_bit_piece
;
3669 /* Helper for locexpr_describe_location_piece that finds the name of a
3673 locexpr_regname (struct gdbarch
*gdbarch
, int dwarf_regnum
)
3677 /* This doesn't use dwarf_reg_to_regnum_or_error on purpose.
3678 We'd rather print *something* here than throw an error. */
3679 regnum
= dwarf_reg_to_regnum (gdbarch
, dwarf_regnum
);
3680 /* gdbarch_register_name may just return "", return something more
3681 descriptive for bad register numbers. */
3684 /* The text is output as "$bad_register_number".
3685 That is why we use the underscores. */
3686 return _("bad_register_number");
3688 return gdbarch_register_name (gdbarch
, regnum
);
3691 /* Nicely describe a single piece of a location, returning an updated
3692 position in the bytecode sequence. This function cannot recognize
3693 all locations; if a location is not recognized, it simply returns
3694 DATA. If there is an error during reading, e.g. we run off the end
3695 of the buffer, an error is thrown. */
3697 static const gdb_byte
*
3698 locexpr_describe_location_piece (struct symbol
*symbol
, struct ui_file
*stream
,
3699 CORE_ADDR addr
, struct objfile
*objfile
,
3700 struct dwarf2_per_cu_data
*per_cu
,
3701 const gdb_byte
*data
, const gdb_byte
*end
,
3702 unsigned int addr_size
)
3704 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
3707 if (data
[0] >= DW_OP_reg0
&& data
[0] <= DW_OP_reg31
)
3709 fprintf_filtered (stream
, _("a variable in $%s"),
3710 locexpr_regname (gdbarch
, data
[0] - DW_OP_reg0
));
3713 else if (data
[0] == DW_OP_regx
)
3717 data
= safe_read_uleb128 (data
+ 1, end
, ®
);
3718 fprintf_filtered (stream
, _("a variable in $%s"),
3719 locexpr_regname (gdbarch
, reg
));
3721 else if (data
[0] == DW_OP_fbreg
)
3723 const struct block
*b
;
3724 struct symbol
*framefunc
;
3726 int64_t frame_offset
;
3727 const gdb_byte
*base_data
, *new_data
, *save_data
= data
;
3729 int64_t base_offset
= 0;
3731 new_data
= safe_read_sleb128 (data
+ 1, end
, &frame_offset
);
3732 if (!piece_end_p (new_data
, end
))
3736 b
= block_for_pc (addr
);
3739 error (_("No block found for address for symbol \"%s\"."),
3740 SYMBOL_PRINT_NAME (symbol
));
3742 framefunc
= block_linkage_function (b
);
3745 error (_("No function found for block for symbol \"%s\"."),
3746 SYMBOL_PRINT_NAME (symbol
));
3748 func_get_frame_base_dwarf_block (framefunc
, addr
, &base_data
, &base_size
);
3750 if (base_data
[0] >= DW_OP_breg0
&& base_data
[0] <= DW_OP_breg31
)
3752 const gdb_byte
*buf_end
;
3754 frame_reg
= base_data
[0] - DW_OP_breg0
;
3755 buf_end
= safe_read_sleb128 (base_data
+ 1, base_data
+ base_size
,
3757 if (buf_end
!= base_data
+ base_size
)
3758 error (_("Unexpected opcode after "
3759 "DW_OP_breg%u for symbol \"%s\"."),
3760 frame_reg
, SYMBOL_PRINT_NAME (symbol
));
3762 else if (base_data
[0] >= DW_OP_reg0
&& base_data
[0] <= DW_OP_reg31
)
3764 /* The frame base is just the register, with no offset. */
3765 frame_reg
= base_data
[0] - DW_OP_reg0
;
3770 /* We don't know what to do with the frame base expression,
3771 so we can't trace this variable; give up. */
3775 fprintf_filtered (stream
,
3776 _("a variable at frame base reg $%s offset %s+%s"),
3777 locexpr_regname (gdbarch
, frame_reg
),
3778 plongest (base_offset
), plongest (frame_offset
));
3780 else if (data
[0] >= DW_OP_breg0
&& data
[0] <= DW_OP_breg31
3781 && piece_end_p (data
, end
))
3785 data
= safe_read_sleb128 (data
+ 1, end
, &offset
);
3787 fprintf_filtered (stream
,
3788 _("a variable at offset %s from base reg $%s"),
3790 locexpr_regname (gdbarch
, data
[0] - DW_OP_breg0
));
3793 /* The location expression for a TLS variable looks like this (on a
3796 DW_AT_location : 10 byte block: 3 4 0 0 0 0 0 0 0 e0
3797 (DW_OP_addr: 4; DW_OP_GNU_push_tls_address)
3799 0x3 is the encoding for DW_OP_addr, which has an operand as long
3800 as the size of an address on the target machine (here is 8
3801 bytes). Note that more recent version of GCC emit DW_OP_const4u
3802 or DW_OP_const8u, depending on address size, rather than
3803 DW_OP_addr. 0xe0 is the encoding for DW_OP_GNU_push_tls_address.
3804 The operand represents the offset at which the variable is within
3805 the thread local storage. */
3807 else if (data
+ 1 + addr_size
< end
3808 && (data
[0] == DW_OP_addr
3809 || (addr_size
== 4 && data
[0] == DW_OP_const4u
)
3810 || (addr_size
== 8 && data
[0] == DW_OP_const8u
))
3811 && (data
[1 + addr_size
] == DW_OP_GNU_push_tls_address
3812 || data
[1 + addr_size
] == DW_OP_form_tls_address
)
3813 && piece_end_p (data
+ 2 + addr_size
, end
))
3816 offset
= extract_unsigned_integer (data
+ 1, addr_size
,
3817 gdbarch_byte_order (gdbarch
));
3819 fprintf_filtered (stream
,
3820 _("a thread-local variable at offset 0x%s "
3821 "in the thread-local storage for `%s'"),
3822 phex_nz (offset
, addr_size
), objfile_name (objfile
));
3824 data
+= 1 + addr_size
+ 1;
3827 /* With -gsplit-dwarf a TLS variable can also look like this:
3828 DW_AT_location : 3 byte block: fc 4 e0
3829 (DW_OP_GNU_const_index: 4;
3830 DW_OP_GNU_push_tls_address) */
3831 else if (data
+ 3 <= end
3832 && data
+ 1 + (leb128_size
= skip_leb128 (data
+ 1, end
)) < end
3833 && data
[0] == DW_OP_GNU_const_index
3835 && (data
[1 + leb128_size
] == DW_OP_GNU_push_tls_address
3836 || data
[1 + leb128_size
] == DW_OP_form_tls_address
)
3837 && piece_end_p (data
+ 2 + leb128_size
, end
))
3841 data
= safe_read_uleb128 (data
+ 1, end
, &offset
);
3842 offset
= dwarf2_read_addr_index (per_cu
, offset
);
3843 fprintf_filtered (stream
,
3844 _("a thread-local variable at offset 0x%s "
3845 "in the thread-local storage for `%s'"),
3846 phex_nz (offset
, addr_size
), objfile_name (objfile
));
3850 else if (data
[0] >= DW_OP_lit0
3851 && data
[0] <= DW_OP_lit31
3853 && data
[1] == DW_OP_stack_value
)
3855 fprintf_filtered (stream
, _("the constant %d"), data
[0] - DW_OP_lit0
);
3862 /* Disassemble an expression, stopping at the end of a piece or at the
3863 end of the expression. Returns a pointer to the next unread byte
3864 in the input expression. If ALL is nonzero, then this function
3865 will keep going until it reaches the end of the expression.
3866 If there is an error during reading, e.g. we run off the end
3867 of the buffer, an error is thrown. */
3869 static const gdb_byte
*
3870 disassemble_dwarf_expression (struct ui_file
*stream
,
3871 struct gdbarch
*arch
, unsigned int addr_size
,
3872 int offset_size
, const gdb_byte
*start
,
3873 const gdb_byte
*data
, const gdb_byte
*end
,
3874 int indent
, int all
,
3875 struct dwarf2_per_cu_data
*per_cu
)
3879 || (data
[0] != DW_OP_piece
&& data
[0] != DW_OP_bit_piece
)))
3881 enum dwarf_location_atom op
= (enum dwarf_location_atom
) *data
++;
3886 name
= get_DW_OP_name (op
);
3889 error (_("Unrecognized DWARF opcode 0x%02x at %ld"),
3890 op
, (long) (data
- 1 - start
));
3891 fprintf_filtered (stream
, " %*ld: %s", indent
+ 4,
3892 (long) (data
- 1 - start
), name
);
3897 ul
= extract_unsigned_integer (data
, addr_size
,
3898 gdbarch_byte_order (arch
));
3900 fprintf_filtered (stream
, " 0x%s", phex_nz (ul
, addr_size
));
3904 ul
= extract_unsigned_integer (data
, 1, gdbarch_byte_order (arch
));
3906 fprintf_filtered (stream
, " %s", pulongest (ul
));
3909 l
= extract_signed_integer (data
, 1, gdbarch_byte_order (arch
));
3911 fprintf_filtered (stream
, " %s", plongest (l
));
3914 ul
= extract_unsigned_integer (data
, 2, gdbarch_byte_order (arch
));
3916 fprintf_filtered (stream
, " %s", pulongest (ul
));
3919 l
= extract_signed_integer (data
, 2, gdbarch_byte_order (arch
));
3921 fprintf_filtered (stream
, " %s", plongest (l
));
3924 ul
= extract_unsigned_integer (data
, 4, gdbarch_byte_order (arch
));
3926 fprintf_filtered (stream
, " %s", pulongest (ul
));
3929 l
= extract_signed_integer (data
, 4, gdbarch_byte_order (arch
));
3931 fprintf_filtered (stream
, " %s", plongest (l
));
3934 ul
= extract_unsigned_integer (data
, 8, gdbarch_byte_order (arch
));
3936 fprintf_filtered (stream
, " %s", pulongest (ul
));
3939 l
= extract_signed_integer (data
, 8, gdbarch_byte_order (arch
));
3941 fprintf_filtered (stream
, " %s", plongest (l
));
3944 data
= safe_read_uleb128 (data
, end
, &ul
);
3945 fprintf_filtered (stream
, " %s", pulongest (ul
));
3948 data
= safe_read_sleb128 (data
, end
, &l
);
3949 fprintf_filtered (stream
, " %s", plongest (l
));
3984 fprintf_filtered (stream
, " [$%s]",
3985 locexpr_regname (arch
, op
- DW_OP_reg0
));
3989 data
= safe_read_uleb128 (data
, end
, &ul
);
3990 fprintf_filtered (stream
, " %s [$%s]", pulongest (ul
),
3991 locexpr_regname (arch
, (int) ul
));
3994 case DW_OP_implicit_value
:
3995 data
= safe_read_uleb128 (data
, end
, &ul
);
3997 fprintf_filtered (stream
, " %s", pulongest (ul
));
4032 data
= safe_read_sleb128 (data
, end
, &l
);
4033 fprintf_filtered (stream
, " %s [$%s]", plongest (l
),
4034 locexpr_regname (arch
, op
- DW_OP_breg0
));
4038 data
= safe_read_uleb128 (data
, end
, &ul
);
4039 data
= safe_read_sleb128 (data
, end
, &l
);
4040 fprintf_filtered (stream
, " register %s [$%s] offset %s",
4042 locexpr_regname (arch
, (int) ul
),
4047 data
= safe_read_sleb128 (data
, end
, &l
);
4048 fprintf_filtered (stream
, " %s", plongest (l
));
4051 case DW_OP_xderef_size
:
4052 case DW_OP_deref_size
:
4054 fprintf_filtered (stream
, " %d", *data
);
4058 case DW_OP_plus_uconst
:
4059 data
= safe_read_uleb128 (data
, end
, &ul
);
4060 fprintf_filtered (stream
, " %s", pulongest (ul
));
4064 l
= extract_signed_integer (data
, 2, gdbarch_byte_order (arch
));
4066 fprintf_filtered (stream
, " to %ld",
4067 (long) (data
+ l
- start
));
4071 l
= extract_signed_integer (data
, 2, gdbarch_byte_order (arch
));
4073 fprintf_filtered (stream
, " %ld",
4074 (long) (data
+ l
- start
));
4078 ul
= extract_unsigned_integer (data
, 2, gdbarch_byte_order (arch
));
4080 fprintf_filtered (stream
, " offset %s", phex_nz (ul
, 2));
4084 ul
= extract_unsigned_integer (data
, 4, gdbarch_byte_order (arch
));
4086 fprintf_filtered (stream
, " offset %s", phex_nz (ul
, 4));
4089 case DW_OP_call_ref
:
4090 ul
= extract_unsigned_integer (data
, offset_size
,
4091 gdbarch_byte_order (arch
));
4092 data
+= offset_size
;
4093 fprintf_filtered (stream
, " offset %s", phex_nz (ul
, offset_size
));
4097 data
= safe_read_uleb128 (data
, end
, &ul
);
4098 fprintf_filtered (stream
, " %s (bytes)", pulongest (ul
));
4101 case DW_OP_bit_piece
:
4105 data
= safe_read_uleb128 (data
, end
, &ul
);
4106 data
= safe_read_uleb128 (data
, end
, &offset
);
4107 fprintf_filtered (stream
, " size %s offset %s (bits)",
4108 pulongest (ul
), pulongest (offset
));
4112 case DW_OP_GNU_implicit_pointer
:
4114 ul
= extract_unsigned_integer (data
, offset_size
,
4115 gdbarch_byte_order (arch
));
4116 data
+= offset_size
;
4118 data
= safe_read_sleb128 (data
, end
, &l
);
4120 fprintf_filtered (stream
, " DIE %s offset %s",
4121 phex_nz (ul
, offset_size
),
4126 case DW_OP_GNU_deref_type
:
4128 int addr_size
= *data
++;
4132 data
= safe_read_uleb128 (data
, end
, &ul
);
4134 type
= dwarf2_get_die_type (offset
, per_cu
);
4135 fprintf_filtered (stream
, "<");
4136 type_print (type
, "", stream
, -1);
4137 fprintf_filtered (stream
, " [0x%s]> %d", phex_nz (offset
.cu_off
, 0),
4142 case DW_OP_GNU_const_type
:
4147 data
= safe_read_uleb128 (data
, end
, &ul
);
4148 type_die
.cu_off
= ul
;
4149 type
= dwarf2_get_die_type (type_die
, per_cu
);
4150 fprintf_filtered (stream
, "<");
4151 type_print (type
, "", stream
, -1);
4152 fprintf_filtered (stream
, " [0x%s]>", phex_nz (type_die
.cu_off
, 0));
4156 case DW_OP_GNU_regval_type
:
4162 data
= safe_read_uleb128 (data
, end
, ®
);
4163 data
= safe_read_uleb128 (data
, end
, &ul
);
4164 type_die
.cu_off
= ul
;
4166 type
= dwarf2_get_die_type (type_die
, per_cu
);
4167 fprintf_filtered (stream
, "<");
4168 type_print (type
, "", stream
, -1);
4169 fprintf_filtered (stream
, " [0x%s]> [$%s]",
4170 phex_nz (type_die
.cu_off
, 0),
4171 locexpr_regname (arch
, reg
));
4175 case DW_OP_GNU_convert
:
4176 case DW_OP_GNU_reinterpret
:
4180 data
= safe_read_uleb128 (data
, end
, &ul
);
4181 type_die
.cu_off
= ul
;
4183 if (type_die
.cu_off
== 0)
4184 fprintf_filtered (stream
, "<0>");
4189 type
= dwarf2_get_die_type (type_die
, per_cu
);
4190 fprintf_filtered (stream
, "<");
4191 type_print (type
, "", stream
, -1);
4192 fprintf_filtered (stream
, " [0x%s]>", phex_nz (type_die
.cu_off
, 0));
4197 case DW_OP_GNU_entry_value
:
4198 data
= safe_read_uleb128 (data
, end
, &ul
);
4199 fputc_filtered ('\n', stream
);
4200 disassemble_dwarf_expression (stream
, arch
, addr_size
, offset_size
,
4201 start
, data
, data
+ ul
, indent
+ 2,
4206 case DW_OP_GNU_parameter_ref
:
4207 ul
= extract_unsigned_integer (data
, 4, gdbarch_byte_order (arch
));
4209 fprintf_filtered (stream
, " offset %s", phex_nz (ul
, 4));
4212 case DW_OP_GNU_addr_index
:
4213 data
= safe_read_uleb128 (data
, end
, &ul
);
4214 ul
= dwarf2_read_addr_index (per_cu
, ul
);
4215 fprintf_filtered (stream
, " 0x%s", phex_nz (ul
, addr_size
));
4217 case DW_OP_GNU_const_index
:
4218 data
= safe_read_uleb128 (data
, end
, &ul
);
4219 ul
= dwarf2_read_addr_index (per_cu
, ul
);
4220 fprintf_filtered (stream
, " %s", pulongest (ul
));
4224 fprintf_filtered (stream
, "\n");
4230 /* Describe a single location, which may in turn consist of multiple
4234 locexpr_describe_location_1 (struct symbol
*symbol
, CORE_ADDR addr
,
4235 struct ui_file
*stream
,
4236 const gdb_byte
*data
, size_t size
,
4237 struct objfile
*objfile
, unsigned int addr_size
,
4238 int offset_size
, struct dwarf2_per_cu_data
*per_cu
)
4240 const gdb_byte
*end
= data
+ size
;
4241 int first_piece
= 1, bad
= 0;
4245 const gdb_byte
*here
= data
;
4246 int disassemble
= 1;
4251 fprintf_filtered (stream
, _(", and "));
4253 if (!dwarf_always_disassemble
)
4255 data
= locexpr_describe_location_piece (symbol
, stream
,
4256 addr
, objfile
, per_cu
,
4257 data
, end
, addr_size
);
4258 /* If we printed anything, or if we have an empty piece,
4259 then don't disassemble. */
4261 || data
[0] == DW_OP_piece
4262 || data
[0] == DW_OP_bit_piece
)
4267 fprintf_filtered (stream
, _("a complex DWARF expression:\n"));
4268 data
= disassemble_dwarf_expression (stream
,
4269 get_objfile_arch (objfile
),
4270 addr_size
, offset_size
, data
,
4272 dwarf_always_disassemble
,
4278 int empty
= data
== here
;
4281 fprintf_filtered (stream
, " ");
4282 if (data
[0] == DW_OP_piece
)
4286 data
= safe_read_uleb128 (data
+ 1, end
, &bytes
);
4289 fprintf_filtered (stream
, _("an empty %s-byte piece"),
4292 fprintf_filtered (stream
, _(" [%s-byte piece]"),
4295 else if (data
[0] == DW_OP_bit_piece
)
4297 uint64_t bits
, offset
;
4299 data
= safe_read_uleb128 (data
+ 1, end
, &bits
);
4300 data
= safe_read_uleb128 (data
, end
, &offset
);
4303 fprintf_filtered (stream
,
4304 _("an empty %s-bit piece"),
4307 fprintf_filtered (stream
,
4308 _(" [%s-bit piece, offset %s bits]"),
4309 pulongest (bits
), pulongest (offset
));
4319 if (bad
|| data
> end
)
4320 error (_("Corrupted DWARF2 expression for \"%s\"."),
4321 SYMBOL_PRINT_NAME (symbol
));
4324 /* Print a natural-language description of SYMBOL to STREAM. This
4325 version is for a symbol with a single location. */
4328 locexpr_describe_location (struct symbol
*symbol
, CORE_ADDR addr
,
4329 struct ui_file
*stream
)
4331 struct dwarf2_locexpr_baton
*dlbaton
4332 = (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (symbol
);
4333 struct objfile
*objfile
= dwarf2_per_cu_objfile (dlbaton
->per_cu
);
4334 unsigned int addr_size
= dwarf2_per_cu_addr_size (dlbaton
->per_cu
);
4335 int offset_size
= dwarf2_per_cu_offset_size (dlbaton
->per_cu
);
4337 locexpr_describe_location_1 (symbol
, addr
, stream
,
4338 dlbaton
->data
, dlbaton
->size
,
4339 objfile
, addr_size
, offset_size
,
4343 /* Describe the location of SYMBOL as an agent value in VALUE, generating
4344 any necessary bytecode in AX. */
4347 locexpr_tracepoint_var_ref (struct symbol
*symbol
, struct gdbarch
*gdbarch
,
4348 struct agent_expr
*ax
, struct axs_value
*value
)
4350 struct dwarf2_locexpr_baton
*dlbaton
4351 = (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (symbol
);
4352 unsigned int addr_size
= dwarf2_per_cu_addr_size (dlbaton
->per_cu
);
4354 if (dlbaton
->size
== 0)
4355 value
->optimized_out
= 1;
4357 dwarf2_compile_expr_to_ax (ax
, value
, gdbarch
, addr_size
,
4358 dlbaton
->data
, dlbaton
->data
+ dlbaton
->size
,
4362 /* symbol_computed_ops 'generate_c_location' method. */
4365 locexpr_generate_c_location (struct symbol
*sym
, struct ui_file
*stream
,
4366 struct gdbarch
*gdbarch
,
4367 unsigned char *registers_used
,
4368 CORE_ADDR pc
, const char *result_name
)
4370 struct dwarf2_locexpr_baton
*dlbaton
4371 = (struct dwarf2_locexpr_baton
*) SYMBOL_LOCATION_BATON (sym
);
4372 unsigned int addr_size
= dwarf2_per_cu_addr_size (dlbaton
->per_cu
);
4374 if (dlbaton
->size
== 0)
4375 error (_("symbol \"%s\" is optimized out"), SYMBOL_NATURAL_NAME (sym
));
4377 compile_dwarf_expr_to_c (stream
, result_name
,
4378 sym
, pc
, gdbarch
, registers_used
, addr_size
,
4379 dlbaton
->data
, dlbaton
->data
+ dlbaton
->size
,
4383 /* The set of location functions used with the DWARF-2 expression
4385 const struct symbol_computed_ops dwarf2_locexpr_funcs
= {
4386 locexpr_read_variable
,
4387 locexpr_read_variable_at_entry
,
4388 locexpr_get_symbol_read_needs
,
4389 locexpr_describe_location
,
4390 0, /* location_has_loclist */
4391 locexpr_tracepoint_var_ref
,
4392 locexpr_generate_c_location
4396 /* Wrapper functions for location lists. These generally find
4397 the appropriate location expression and call something above. */
4399 /* Return the value of SYMBOL in FRAME using the DWARF-2 expression
4400 evaluator to calculate the location. */
4401 static struct value
*
4402 loclist_read_variable (struct symbol
*symbol
, struct frame_info
*frame
)
4404 struct dwarf2_loclist_baton
*dlbaton
4405 = (struct dwarf2_loclist_baton
*) SYMBOL_LOCATION_BATON (symbol
);
4407 const gdb_byte
*data
;
4409 CORE_ADDR pc
= frame
? get_frame_address_in_block (frame
) : 0;
4411 data
= dwarf2_find_location_expression (dlbaton
, &size
, pc
);
4412 val
= dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol
), frame
, data
, size
,
4418 /* Read variable SYMBOL like loclist_read_variable at (callee) FRAME's function
4419 entry. SYMBOL should be a function parameter, otherwise NO_ENTRY_VALUE_ERROR
4422 Function always returns non-NULL value, it may be marked optimized out if
4423 inferior frame information is not available. It throws NO_ENTRY_VALUE_ERROR
4424 if it cannot resolve the parameter for any reason. */
4426 static struct value
*
4427 loclist_read_variable_at_entry (struct symbol
*symbol
, struct frame_info
*frame
)
4429 struct dwarf2_loclist_baton
*dlbaton
4430 = (struct dwarf2_loclist_baton
*) SYMBOL_LOCATION_BATON (symbol
);
4431 const gdb_byte
*data
;
4435 if (frame
== NULL
|| !get_frame_func_if_available (frame
, &pc
))
4436 return allocate_optimized_out_value (SYMBOL_TYPE (symbol
));
4438 data
= dwarf2_find_location_expression (dlbaton
, &size
, pc
);
4440 return allocate_optimized_out_value (SYMBOL_TYPE (symbol
));
4442 return value_of_dwarf_block_entry (SYMBOL_TYPE (symbol
), frame
, data
, size
);
4445 /* Implementation of get_symbol_read_needs from
4446 symbol_computed_ops. */
4448 static enum symbol_needs_kind
4449 loclist_symbol_needs (struct symbol
*symbol
)
4451 /* If there's a location list, then assume we need to have a frame
4452 to choose the appropriate location expression. With tracking of
4453 global variables this is not necessarily true, but such tracking
4454 is disabled in GCC at the moment until we figure out how to
4457 return SYMBOL_NEEDS_FRAME
;
4460 /* Print a natural-language description of SYMBOL to STREAM. This
4461 version applies when there is a list of different locations, each
4462 with a specified address range. */
4465 loclist_describe_location (struct symbol
*symbol
, CORE_ADDR addr
,
4466 struct ui_file
*stream
)
4468 struct dwarf2_loclist_baton
*dlbaton
4469 = (struct dwarf2_loclist_baton
*) SYMBOL_LOCATION_BATON (symbol
);
4470 const gdb_byte
*loc_ptr
, *buf_end
;
4471 struct objfile
*objfile
= dwarf2_per_cu_objfile (dlbaton
->per_cu
);
4472 struct gdbarch
*gdbarch
= get_objfile_arch (objfile
);
4473 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
4474 unsigned int addr_size
= dwarf2_per_cu_addr_size (dlbaton
->per_cu
);
4475 int offset_size
= dwarf2_per_cu_offset_size (dlbaton
->per_cu
);
4476 int signed_addr_p
= bfd_get_sign_extend_vma (objfile
->obfd
);
4477 /* Adjust base_address for relocatable objects. */
4478 CORE_ADDR base_offset
= dwarf2_per_cu_text_offset (dlbaton
->per_cu
);
4479 CORE_ADDR base_address
= dlbaton
->base_address
+ base_offset
;
4482 loc_ptr
= dlbaton
->data
;
4483 buf_end
= dlbaton
->data
+ dlbaton
->size
;
4485 fprintf_filtered (stream
, _("multi-location:\n"));
4487 /* Iterate through locations until we run out. */
4490 CORE_ADDR low
= 0, high
= 0; /* init for gcc -Wall */
4492 enum debug_loc_kind kind
;
4493 const gdb_byte
*new_ptr
= NULL
; /* init for gcc -Wall */
4495 if (dlbaton
->from_dwo
)
4496 kind
= decode_debug_loc_dwo_addresses (dlbaton
->per_cu
,
4497 loc_ptr
, buf_end
, &new_ptr
,
4498 &low
, &high
, byte_order
);
4500 kind
= decode_debug_loc_addresses (loc_ptr
, buf_end
, &new_ptr
,
4502 byte_order
, addr_size
,
4507 case DEBUG_LOC_END_OF_LIST
:
4510 case DEBUG_LOC_BASE_ADDRESS
:
4511 base_address
= high
+ base_offset
;
4512 fprintf_filtered (stream
, _(" Base address %s"),
4513 paddress (gdbarch
, base_address
));
4515 case DEBUG_LOC_START_END
:
4516 case DEBUG_LOC_START_LENGTH
:
4518 case DEBUG_LOC_BUFFER_OVERFLOW
:
4519 case DEBUG_LOC_INVALID_ENTRY
:
4520 error (_("Corrupted DWARF expression for symbol \"%s\"."),
4521 SYMBOL_PRINT_NAME (symbol
));
4523 gdb_assert_not_reached ("bad debug_loc_kind");
4526 /* Otherwise, a location expression entry. */
4527 low
+= base_address
;
4528 high
+= base_address
;
4530 low
= gdbarch_adjust_dwarf2_addr (gdbarch
, low
);
4531 high
= gdbarch_adjust_dwarf2_addr (gdbarch
, high
);
4533 length
= extract_unsigned_integer (loc_ptr
, 2, byte_order
);
4536 /* (It would improve readability to print only the minimum
4537 necessary digits of the second number of the range.) */
4538 fprintf_filtered (stream
, _(" Range %s-%s: "),
4539 paddress (gdbarch
, low
), paddress (gdbarch
, high
));
4541 /* Now describe this particular location. */
4542 locexpr_describe_location_1 (symbol
, low
, stream
, loc_ptr
, length
,
4543 objfile
, addr_size
, offset_size
,
4546 fprintf_filtered (stream
, "\n");
4552 /* Describe the location of SYMBOL as an agent value in VALUE, generating
4553 any necessary bytecode in AX. */
4555 loclist_tracepoint_var_ref (struct symbol
*symbol
, struct gdbarch
*gdbarch
,
4556 struct agent_expr
*ax
, struct axs_value
*value
)
4558 struct dwarf2_loclist_baton
*dlbaton
4559 = (struct dwarf2_loclist_baton
*) SYMBOL_LOCATION_BATON (symbol
);
4560 const gdb_byte
*data
;
4562 unsigned int addr_size
= dwarf2_per_cu_addr_size (dlbaton
->per_cu
);
4564 data
= dwarf2_find_location_expression (dlbaton
, &size
, ax
->scope
);
4566 value
->optimized_out
= 1;
4568 dwarf2_compile_expr_to_ax (ax
, value
, gdbarch
, addr_size
, data
, data
+ size
,
4572 /* symbol_computed_ops 'generate_c_location' method. */
4575 loclist_generate_c_location (struct symbol
*sym
, struct ui_file
*stream
,
4576 struct gdbarch
*gdbarch
,
4577 unsigned char *registers_used
,
4578 CORE_ADDR pc
, const char *result_name
)
4580 struct dwarf2_loclist_baton
*dlbaton
4581 = (struct dwarf2_loclist_baton
*) SYMBOL_LOCATION_BATON (sym
);
4582 unsigned int addr_size
= dwarf2_per_cu_addr_size (dlbaton
->per_cu
);
4583 const gdb_byte
*data
;
4586 data
= dwarf2_find_location_expression (dlbaton
, &size
, pc
);
4588 error (_("symbol \"%s\" is optimized out"), SYMBOL_NATURAL_NAME (sym
));
4590 compile_dwarf_expr_to_c (stream
, result_name
,
4591 sym
, pc
, gdbarch
, registers_used
, addr_size
,
4596 /* The set of location functions used with the DWARF-2 expression
4597 evaluator and location lists. */
4598 const struct symbol_computed_ops dwarf2_loclist_funcs
= {
4599 loclist_read_variable
,
4600 loclist_read_variable_at_entry
,
4601 loclist_symbol_needs
,
4602 loclist_describe_location
,
4603 1, /* location_has_loclist */
4604 loclist_tracepoint_var_ref
,
4605 loclist_generate_c_location
4608 /* Provide a prototype to silence -Wmissing-prototypes. */
4609 extern initialize_file_ftype _initialize_dwarf2loc
;
4612 _initialize_dwarf2loc (void)
4614 add_setshow_zuinteger_cmd ("entry-values", class_maintenance
,
4615 &entry_values_debug
,
4616 _("Set entry values and tail call frames "
4618 _("Show entry values and tail call frames "
4620 _("When non-zero, the process of determining "
4621 "parameter values from function entry point "
4622 "and tail call frames will be printed."),
4624 show_entry_values_debug
,
4625 &setdebuglist
, &showdebuglist
);