aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2loc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/dwarf2loc.c')
-rw-r--r--gdb/dwarf2loc.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index d8e432e..efe4357 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -381,12 +381,47 @@ locexpr_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc,
*start = symbaton->data;
}
+/* Implement the struct symbol_block_ops::get_frame_base method. */
+
+static CORE_ADDR
+block_op_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
+{
+ struct gdbarch *gdbarch;
+ struct type *type;
+ struct dwarf2_locexpr_baton *dlbaton;
+ const gdb_byte *start;
+ size_t length;
+ struct value *result;
+
+ /* If this method is called, then FRAMEFUNC is supposed to be a DWARF block.
+ Thus, it's supposed to provide the find_frame_base_location method as
+ well. */
+ gdb_assert (SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location != NULL);
+
+ gdbarch = get_frame_arch (frame);
+ type = builtin_type (gdbarch)->builtin_data_ptr;
+ dlbaton = SYMBOL_LOCATION_BATON (framefunc);
+
+ SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location
+ (framefunc, get_frame_pc (frame), &start, &length);
+ result = dwarf2_evaluate_loc_desc (type, frame, start, length,
+ dlbaton->per_cu);
+
+ /* The DW_AT_frame_base attribute contains a location description which
+ computes the base address itself. However, the call to
+ dwarf2_evaluate_loc_desc returns a value representing a variable at
+ that address. The frame base address is thus this variable's
+ address. */
+ return value_address (result);
+}
+
/* Vector for inferior functions as represented by LOC_BLOCK, if the inferior
function uses DWARF expression for its DW_AT_frame_base. */
const struct symbol_block_ops dwarf2_block_frame_base_locexpr_funcs =
{
- locexpr_find_frame_base_location
+ locexpr_find_frame_base_location,
+ block_op_get_frame_base
};
/* Implement find_frame_base_location method for LOC_BLOCK functions using
@@ -406,7 +441,8 @@ loclist_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc,
const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs =
{
- loclist_find_frame_base_location
+ loclist_find_frame_base_location,
+ block_op_get_frame_base
};
/* See dwarf2loc.h. */
@@ -2396,13 +2432,14 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
}
/* Evaluates a dwarf expression and stores the result in VAL, expecting
- that the dwarf expression only produces a single CORE_ADDR. ADDR is a
- context (location of a variable) and might be needed to evaluate the
- location expression.
+ that the dwarf expression only produces a single CORE_ADDR. FRAME is the
+ frame in which the expression is evaluated. ADDR is a context (location of
+ a variable) and might be needed to evaluate the location expression.
Returns 1 on success, 0 otherwise. */
static int
dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
+ struct frame_info *frame,
CORE_ADDR addr,
CORE_ADDR *valp)
{
@@ -2417,7 +2454,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
ctx = new_dwarf_expr_context ();
cleanup = make_cleanup_free_dwarf_expr_context (ctx);
- baton.frame = get_selected_frame (NULL);
+ baton.frame = frame;
baton.per_cu = dlbaton->per_cu;
baton.obj_address = addr;
@@ -2461,19 +2498,24 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
int
dwarf2_evaluate_property (const struct dynamic_prop *prop,
+ struct frame_info *frame,
struct property_addr_info *addr_stack,
CORE_ADDR *value)
{
if (prop == NULL)
return 0;
+ if (frame == NULL && has_stack_frames ())
+ frame = get_selected_frame (NULL);
+
switch (prop->kind)
{
case PROP_LOCEXPR:
{
const struct dwarf2_property_baton *baton = prop->data.baton;
- if (dwarf2_locexpr_baton_eval (&baton->locexpr, addr_stack->addr,
+ if (dwarf2_locexpr_baton_eval (&baton->locexpr, frame,
+ addr_stack ? addr_stack->addr : 0,
value))
{
if (baton->referenced_type)
@@ -2490,7 +2532,6 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
case PROP_LOCLIST:
{
struct dwarf2_property_baton *baton = prop->data.baton;
- struct frame_info *frame = get_selected_frame (NULL);
CORE_ADDR pc = get_frame_address_in_block (frame);
const gdb_byte *data;
struct value *val;