aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2loc.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-07-15 20:54:32 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-07-15 20:54:32 +0000
commit9e8b7a03dd9c4754ff3f18ca13a1dad851f4ec58 (patch)
tree7df265b8f00f013025d31216b505e3e2fe7a21b8 /gdb/dwarf2loc.c
parente9ea266294fcba2548c9b30d8229b1b430d45eee (diff)
downloadgdb-9e8b7a03dd9c4754ff3f18ca13a1dad851f4ec58.zip
gdb-9e8b7a03dd9c4754ff3f18ca13a1dad851f4ec58.tar.gz
gdb-9e8b7a03dd9c4754ff3f18ca13a1dad851f4ec58.tar.bz2
gdb/
Code cleanup. * dwarf2-frame.c (dwarf2_frame_ctx_funcs): New. (execute_stack_op): Use dwarf2_frame_ctx_funcs * dwarf2expr.c (dwarf_get_base_type): Access get_base_type via funcs. (execute_stack_op): Access read_reg, get_frame_base, read_mem, get_frame_cfa, get_tls_address and dwarf_call via funcs. * dwarf2expr.h (struct dwarf_expr_context): New forward declaration. (struct dwarf_expr_context_funcs): New, move here methods from ... (struct dwarf_expr_context): ... here. New fields funcs. * dwarf2loc.c (dwarf_expr_dwarf_call): Access get_frame_pc via funcs. (dwarf_expr_ctx_funcs): New. (dwarf2_evaluate_loc_desc_full): Use dwarf_expr_ctx_funcs. (needs_frame_dwarf_call): Access get_frame_pc via funcs. (needs_frame_ctx_funcs): New. (dwarf2_loc_desc_needs_frame): Use needs_frame_ctx_funcs.
Diffstat (limited to 'gdb/dwarf2loc.c')
-rw-r--r--gdb/dwarf2loc.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 7c8ffbe..fc9a417 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -283,7 +283,7 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset)
struct dwarf_expr_baton *debaton = ctx->baton;
per_cu_dwarf_call (ctx, die_offset, debaton->per_cu,
- ctx->get_frame_pc, ctx->baton);
+ ctx->funcs->get_frame_pc, ctx->baton);
}
/* Callback function for dwarf2_evaluate_loc_desc. */
@@ -1072,6 +1072,20 @@ invalid_synthetic_pointer (void)
"referenced via synthetic pointer"));
}
+/* Virtual method table for dwarf2_evaluate_loc_desc_full below. */
+
+static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs =
+{
+ dwarf_expr_read_reg,
+ dwarf_expr_read_mem,
+ dwarf_expr_frame_base,
+ dwarf_expr_frame_cfa,
+ dwarf_expr_frame_pc,
+ dwarf_expr_tls_address,
+ dwarf_expr_dwarf_call,
+ dwarf_expr_get_base_type
+};
+
/* Evaluate a location description, starting at DATA and with length
SIZE, to find the current location of variable of TYPE in the
context of FRAME. BYTE_OFFSET is applied after the contents are
@@ -1107,14 +1121,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
ctx->offset = dwarf2_per_cu_text_offset (per_cu);
ctx->baton = &baton;
- ctx->read_reg = dwarf_expr_read_reg;
- ctx->read_mem = dwarf_expr_read_mem;
- ctx->get_frame_base = dwarf_expr_frame_base;
- ctx->get_frame_cfa = dwarf_expr_frame_cfa;
- ctx->get_frame_pc = dwarf_expr_frame_pc;
- ctx->get_tls_address = dwarf_expr_tls_address;
- ctx->dwarf_call = dwarf_expr_dwarf_call;
- ctx->get_base_type = dwarf_expr_get_base_type;
+ ctx->funcs = &dwarf_expr_ctx_funcs;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
@@ -1341,9 +1348,23 @@ needs_frame_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset)
struct needs_frame_baton *nf_baton = ctx->baton;
per_cu_dwarf_call (ctx, die_offset, nf_baton->per_cu,
- ctx->get_frame_pc, ctx->baton);
+ ctx->funcs->get_frame_pc, ctx->baton);
}
+/* Virtual method table for dwarf2_loc_desc_needs_frame below. */
+
+static const struct dwarf_expr_context_funcs needs_frame_ctx_funcs =
+{
+ needs_frame_read_reg,
+ needs_frame_read_mem,
+ needs_frame_frame_base,
+ needs_frame_frame_cfa,
+ needs_frame_frame_cfa, /* get_frame_pc */
+ needs_frame_tls_address,
+ needs_frame_dwarf_call,
+ NULL /* get_base_type */
+};
+
/* Return non-zero iff the location expression at DATA (length SIZE)
requires a frame to evaluate. */
@@ -1368,13 +1389,7 @@ dwarf2_loc_desc_needs_frame (const gdb_byte *data, unsigned short size,
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
ctx->offset = dwarf2_per_cu_text_offset (per_cu);
ctx->baton = &baton;
- ctx->read_reg = needs_frame_read_reg;
- ctx->read_mem = needs_frame_read_mem;
- ctx->get_frame_base = needs_frame_frame_base;
- ctx->get_frame_cfa = needs_frame_frame_cfa;
- ctx->get_frame_pc = needs_frame_frame_cfa;
- ctx->get_tls_address = needs_frame_tls_address;
- ctx->dwarf_call = needs_frame_dwarf_call;
+ ctx->funcs = &needs_frame_ctx_funcs;
dwarf_expr_eval (ctx, data, size);