Display @entry parameter values (without references).
	* dwarf2expr.c (dwarf_block_to_fb_offset, dwarf_block_to_sp_offset):
	New functions.
	* dwarf2expr.h (dwarf_block_to_fb_offset, dwarf_block_to_sp_offset):
	New declarations.
	* dwarf2loc.c (dwarf2_find_location_expression): Support location list
	entry record.
	(dwarf_entry_parameter_to_value, value_of_dwarf_reg_entry)
	(value_of_dwarf_block_entry, locexpr_read_variable_at_entry): New
	functions.
	(dwarf2_locexpr_funcs): Install locexpr_read_variable_at_entry.
	(loclist_read_variable_at_entry): New function.
	(dwarf2_loclist_funcs): Install loclist_read_variable_at_entry.
	* dwarf2read.c (read_call_site_scope): Support also DW_OP_fbreg in
	DW_AT_location, call dwarf_block_to_sp_offset for it.
	* frame.h (print_entry_values_no, print_entry_values_only)
	(print_entry_values_preferred, print_entry_values_if_needed)
	(print_entry_values_both, print_entry_values_compact)
	(print_entry_values_default, print_entry_values): New declarations.
	(struct frame_arg): New field entry_kind.
	(read_frame_arg): New parameter entryargp.
	* mi/mi-cmd-stack.c (list_arg_or_local): New gdb_assert for
	arg->entry_kind.  Optionally print the `@entry' suffix.
	(list_args_or_locals): New variable entryarg, initialize it.
	Initialize also entry_kind of arg and entryarg.  Conditionalize
	list_arg_or_local for arg, add list_arg_or_local for entryarg.  Call
	xfree for entryarg.error.
	* stack.c (print_entry_values_no, print_entry_values_only)
	(print_entry_values_preferred, print_entry_values_if_needed)
	(print_entry_values_both, print_entry_values_compact)
	(print_entry_values_default, print_entry_values_choices)
	(print_entry_values): New variables.
	(print_frame_arg): New gdb_assert for arg->entry_kind.  Optionally
	print the `@entry' suffix, possibly in combination for
	print_entry_values_compact.
	(read_frame_arg): New parameter entryargp, new variables entryval,
	entryval_error and val_equal.  Read in also entryargp, respect
	print_entry_values, compare the values using val_equal, fill in also
	argp->entry_kind (together with entryargp->entry_kind).
	(print_frame_args): New variable entryarg, initialize it.
	Conditionalize print_frame_arg for arg, add print_frame_arg for
	entryarg.  Call xfree for entryarg.error.
	(_initialize_stack): Call add_setshow_enum_cmd for `entry-values'.
	* symtab.h (struct symbol_computed_ops): New field
	read_variable_at_entry.

gdb/doc/
	Display @entry parameter values (without references).
	* gdb.texinfo (Tail Call Frames): Add anchor.  Add self tail call
	example.
	(Print Settings): New description of set print entry-values and show
	print entry-values.

gdb/testsuite/
	Display @entry parameter values (without references).
	* gdb.arch/amd64-entry-value.cc (locexpr, stacktest, data, data2)
	(different, validity, invalid): New functions.
	(main): Call them.
	* gdb.arch/amd64-entry-value.exp: New breakpoints breakhere_locexpr,
	stacktest, breakhere_stacktest, different, breakhere_different,
	breakhere_validity and breakhere_invalid.
	(entry: bt): Update for @entry.
	(entry_locexpr: *, entry_stack: *, entry_equal: *, entry_different: *)
	(entry_validity: *, entry_invalid: *): Many new tests.
	* gdb.base/break.exp
	(run until breakpoint set at small function, optimized file): Accept
	also the @entry suffix.
	* gdb.mi/Makefile.in (PROGS): Add mi2-amd64-entry-value.
	* gdb.mi/mi2-amd64-entry-value.c: New files.
	* gdb.mi/mi2-amd64-entry-value.exp: New files.
This commit is contained in:
Jan Kratochvil
2011-10-09 19:34:19 +00:00
parent 93d86cefdf
commit e18b27534c
18 changed files with 1088 additions and 25 deletions

View File

@@ -121,6 +121,24 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
length = extract_unsigned_integer (loc_ptr, 2, byte_order);
loc_ptr += 2;
if (low == high && pc == low)
{
/* This is entry PC record present only at entry point
of a function. Verify it is really the function entry point. */
struct block *pc_block = block_for_pc (pc);
struct symbol *pc_func = NULL;
if (pc_block)
pc_func = block_linkage_function (pc_block);
if (pc_func && pc == BLOCK_START (SYMBOL_BLOCK_VALUE (pc_func)))
{
*locexpr_length = length;
return loc_ptr;
}
}
if (pc >= low && pc < high)
{
*locexpr_length = length;
@@ -892,6 +910,33 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, int dwarf_reg,
return parameter;
}
/* Return value for PARAMETER for DW_AT_GNU_call_site_value.
TYPE and CALLER_FRAME specify how to evaluate the DWARF block into returned
struct value.
Function always returns non-NULL, non-optimized out value. It throws
NO_ENTRY_VALUE_ERROR if it cannot resolve the value for any reason. */
static struct value *
dwarf_entry_parameter_to_value (struct call_site_parameter *parameter,
struct type *type,
struct frame_info *caller_frame,
struct dwarf2_per_cu_data *per_cu)
{
gdb_byte *data;
/* DW_AT_GNU_call_site_value is a DWARF expression, not a DWARF
location. Postprocessing of DWARF_VALUE_MEMORY would lose the type from
DWARF block. */
data = alloca (parameter->value_size + 1);
memcpy (data, parameter->value, parameter->value_size);
data[parameter->value_size] = DW_OP_stack_value;
return dwarf2_evaluate_loc_desc (type, caller_frame, data,
parameter->value_size + 1, per_cu);
}
/* Execute call_site_parameter's DWARF block for caller of the CTX's frame.
CTX must be of dwarf_expr_ctx_funcs kind. See DWARF_REG and FB_OFFSET
description at struct dwarf_expr_context_funcs->push_dwarf_reg_entry_value.
@@ -942,6 +987,58 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx,
ctx->baton = saved_ctx.baton;
}
/* Read parameter of TYPE at (callee) FRAME's function entry. DWARF_REG and
FB_OFFSET are used to match DW_AT_location at the caller's
DW_TAG_GNU_call_site_parameter. See DWARF_REG and FB_OFFSET description at
struct dwarf_expr_context_funcs->push_dwarf_reg_entry_value.
Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it
cannot resolve the parameter for any reason. */
static struct value *
value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
int dwarf_reg, CORE_ADDR fb_offset)
{
struct frame_info *caller_frame = get_prev_frame (frame);
struct call_site_parameter *parameter;
struct dwarf2_per_cu_data *caller_per_cu;
parameter = dwarf_expr_reg_to_entry_parameter (frame, dwarf_reg, fb_offset,
&caller_per_cu);
return dwarf_entry_parameter_to_value (parameter, type, caller_frame,
caller_per_cu);
}
/* Read parameter of TYPE at (callee) FRAME's function entry. DATA and
SIZE are DWARF block used to match DW_AT_location at the caller's
DW_TAG_GNU_call_site_parameter.
Function always returns non-NULL value. It throws NO_ENTRY_VALUE_ERROR if it
cannot resolve the parameter for any reason. */
static struct value *
value_of_dwarf_block_entry (struct type *type, struct frame_info *frame,
const gdb_byte *block, size_t block_len)
{
int dwarf_reg;
CORE_ADDR fb_offset;
dwarf_reg = dwarf_block_to_dwarf_reg (block, block + block_len);
if (dwarf_reg != -1)
return value_of_dwarf_reg_entry (type, frame, dwarf_reg, 0 /* unused */);
if (dwarf_block_to_fb_offset (block, block + block_len, &fb_offset))
return value_of_dwarf_reg_entry (type, frame, -1, fb_offset);
/* This can normally happen - throw NO_ENTRY_VALUE_ERROR to get the message
suppressed during normal operation. The expression can be arbitrary if
there is no caller-callee entry value binding expected. */
throw_error (NO_ENTRY_VALUE_ERROR,
_("DWARF-2 expression error: DW_OP_GNU_entry_value is supported "
"only for single DW_OP_reg* or for DW_OP_fbreg(*)"));
}
struct piece_closure
{
/* Reference count. */
@@ -2853,6 +2950,19 @@ locexpr_read_variable (struct symbol *symbol, struct frame_info *frame)
return val;
}
/* Return the value of SYMBOL in FRAME at (callee) FRAME's function
entry. SYMBOL should be a function parameter, otherwise NO_ENTRY_VALUE_ERROR
will be thrown. */
static struct value *
locexpr_read_variable_at_entry (struct symbol *symbol, struct frame_info *frame)
{
struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
return value_of_dwarf_block_entry (SYMBOL_TYPE (symbol), frame, dlbaton->data,
dlbaton->size);
}
/* Return non-zero iff we need a frame to evaluate SYMBOL. */
static int
locexpr_read_needs_frame (struct symbol *symbol)
@@ -3494,6 +3604,7 @@ locexpr_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
evaluator. */
const struct symbol_computed_ops dwarf2_locexpr_funcs = {
locexpr_read_variable,
locexpr_read_variable_at_entry,
locexpr_read_needs_frame,
locexpr_describe_location,
locexpr_tracepoint_var_ref
@@ -3524,6 +3635,32 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
return val;
}
/* Read variable SYMBOL like loclist_read_variable at (callee) FRAME's function
entry. SYMBOL should be a function parameter, otherwise NO_ENTRY_VALUE_ERROR
will be thrown.
Function always returns non-NULL value, it may be marked optimized out if
inferior frame information is not available. It throws NO_ENTRY_VALUE_ERROR
if it cannot resolve the parameter for any reason. */
static struct value *
loclist_read_variable_at_entry (struct symbol *symbol, struct frame_info *frame)
{
struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
const gdb_byte *data;
size_t size;
CORE_ADDR pc;
if (frame == NULL || !get_frame_func_if_available (frame, &pc))
return allocate_optimized_out_value (SYMBOL_TYPE (symbol));
data = dwarf2_find_location_expression (dlbaton, &size, pc);
if (data == NULL)
return allocate_optimized_out_value (SYMBOL_TYPE (symbol));
return value_of_dwarf_block_entry (SYMBOL_TYPE (symbol), frame, data, size);
}
/* Return non-zero iff we need a frame to evaluate SYMBOL. */
static int
loclist_read_needs_frame (struct symbol *symbol)
@@ -3643,6 +3780,7 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
evaluator and location lists. */
const struct symbol_computed_ops dwarf2_loclist_funcs = {
loclist_read_variable,
loclist_read_variable_at_entry,
loclist_read_needs_frame,
loclist_describe_location,
loclist_tracepoint_var_ref