aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2-frame.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-26 08:59:13 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:38 -0600
commit192ca6d8eac4a5538036ef200b95d6ef3dbe9511 (patch)
treee08b28a382817a8a1d639d7775dfa9442452eb46 /gdb/dwarf2-frame.c
parent595d2e303c0ef1a5cd5af8868c1d41db0050eb29 (diff)
downloadgdb-192ca6d8eac4a5538036ef200b95d6ef3dbe9511.zip
gdb-192ca6d8eac4a5538036ef200b95d6ef3dbe9511.tar.gz
gdb-192ca6d8eac4a5538036ef200b95d6ef3dbe9511.tar.bz2
Convert dwarf_expr_context_funcs to methods
This patch converts the function pointers in dwarf_expr_context_funcs into methods on dwarf_expr_context, and then updates the various implementations and callers to follow. NB this patch uses "override" (which caught a couple of renaming bugs during development) -- but this is C++11, so this patch at least has to wait for Pedro's patch that adds the OVERRIDE macro. After this patch it would be possible to do one more, that makes various members of dwarf_expr_context "protected"; but I haven't done this. 2016-10-21 Tom Tromey <tom@tromey.com> * dwarf2loc.c (struct dwarf_expr_context_funcs): Don't declare. (dwarf_expr_read_addr_from_reg, dwarf_expr_get_reg_value) (dwarf_expr_read_mem, dwarf_expr_frame_base): Rename; turn into methods. (get_frame_pc_for_per_cu_dwarf_call): New function. (dwarf_expr_frame_cfa, dwarf_expr_frame_pc) (dwarf_expr_tls_address): Rename; turn into methods. (per_cu_dwarf_call): Remove arguments. Use get_frame_pc_for_per_cu_dwarf_call. (dwarf_evaluate_loc_desc): New class. (dwarf_expr_dwarf_call, dwarf_expr_context) (dwarf_expr_push_dwarf_reg_entry_value) (dwarf_expr_get_addr_index, dwarf_expr_get_obj_addr): Rename; turn into methods. (dwarf_expr_ctx_funcs): Remove. (dwarf2_evaluate_loc_desc_full): Update. (dwarf2_locexpr_baton_eval): Update. (symbol_needs_eval_context): New class. (symbol_needs_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call, needs_dwarf_reg_entry_value): Rename; turn into methods. (needs_get_addr_index, needs_get_obj_addr): Remove; turn into methods. (symbol_needs_ctx_funcs): Remove. (dwarf2_loc_desc_get_symbol_read_needs): Update. * dwarf2expr.h (struct dwarf_expr_context_funcs): Remove; turn contents into methods. (struct dwarf_expr_context) <baton, funcs>: Remove. <read_addr_from_reg, get_reg_value, read_mem, get_frame_base, get_frame_cfa, get_frame_pc, get_tls_address, dwarf_call, impl_get_base_type, push_dwarf_block_entry_value, get_addr_index, get_object_address>: Declare new methods. (ctx_no_get_frame_base, ctx_no_get_frame_cfa) (ctx_no_get_frame_pc, ctx_no_get_tls_address, ctx_no_dwarf_call) (ctx_no_get_base_type, ctx_no_push_dwarf_reg_entry_value) (ctx_no_get_addr_index): Don't declare. * dwarf2expr.c (get_base_type): Use impl_get_base_type. (execute_stack_op): Update. (ctx_no_get_frame_base, ctx_no_get_frame_cfa) (ctx_no_get_frame_pc, ctx_no_get_tls_address, ctx_no_dwarf_call) (ctx_no_get_base_type, ctx_no_push_dwarf_reg_entry_value) (ctx_no_get_addr_index): Remove; now methods on dwarf_expr_context. * dwarf2-frame.c (read_addr_from_reg): Take a frame_info, not a baton. (class dwarf_expr_executor): New class. (get_reg_value, read_mem): Rename, turn into methods. (execute_stack_op): Use dwarf_expr_executor.
Diffstat (limited to 'gdb/dwarf2-frame.c')
-rw-r--r--gdb/dwarf2-frame.c65
1 files changed, 26 insertions, 39 deletions
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index c93c362..c9962e1 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -288,33 +288,14 @@ dwarf2_frame_state_free (void *p)
/* Helper functions for execute_stack_op. */
static CORE_ADDR
-read_addr_from_reg (void *baton, int reg)
+read_addr_from_reg (struct frame_info *this_frame, int reg)
{
- struct frame_info *this_frame = (struct frame_info *) baton;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
return address_from_register (regnum, this_frame);
}
-/* Implement struct dwarf_expr_context_funcs' "get_reg_value" callback. */
-
-static struct value *
-get_reg_value (void *baton, struct type *type, int reg)
-{
- struct frame_info *this_frame = (struct frame_info *) baton;
- struct gdbarch *gdbarch = get_frame_arch (this_frame);
- int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
-
- return value_from_register (type, regnum, this_frame);
-}
-
-static void
-read_mem (void *baton, gdb_byte *buf, CORE_ADDR addr, size_t len)
-{
- read_memory (addr, buf, len);
-}
-
/* Execute the required actions for both the DW_CFA_restore and
DW_CFA_restore_extended instructions. */
static void
@@ -347,21 +328,29 @@ register %s (#%d) at %s"),
}
}
-/* Virtual method table for execute_stack_op below. */
-
-static const struct dwarf_expr_context_funcs dwarf2_frame_ctx_funcs =
+class dwarf_expr_executor : public dwarf_expr_context
{
- read_addr_from_reg,
- get_reg_value,
- read_mem,
- ctx_no_get_frame_base,
- ctx_no_get_frame_cfa,
- ctx_no_get_frame_pc,
- ctx_no_get_tls_address,
- ctx_no_dwarf_call,
- ctx_no_get_base_type,
- ctx_no_push_dwarf_reg_entry_value,
- ctx_no_get_addr_index
+ public:
+
+ struct frame_info *this_frame;
+
+ CORE_ADDR read_addr_from_reg (int reg) OVERRIDE
+ {
+ return ::read_addr_from_reg (this_frame, reg);
+ }
+
+ struct value *get_reg_value (struct type *type, int reg) OVERRIDE
+ {
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
+
+ return value_from_register (type, regnum, this_frame);
+ }
+
+ void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t len) OVERRIDE
+ {
+ read_memory (addr, buf, len);
+ }
};
static CORE_ADDR
@@ -372,15 +361,14 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
CORE_ADDR result;
struct cleanup *old_chain;
- dwarf_expr_context ctx;
+ dwarf_expr_executor ctx;
old_chain = make_cleanup_value_free_to_mark (value_mark ());
+ ctx.this_frame = this_frame;
ctx.gdbarch = get_frame_arch (this_frame);
ctx.addr_size = addr_size;
ctx.ref_addr_size = -1;
ctx.offset = offset;
- ctx.baton = this_frame;
- ctx.funcs = &dwarf2_frame_ctx_funcs;
ctx.push_address (initial, initial_in_stack_memory);
ctx.eval (exp, len);
@@ -388,8 +376,7 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
if (ctx.location == DWARF_VALUE_MEMORY)
result = ctx.fetch_address (0);
else if (ctx.location == DWARF_VALUE_REGISTER)
- result = read_addr_from_reg (this_frame,
- value_as_long (ctx.fetch (0)));
+ result = ctx.read_addr_from_reg (value_as_long (ctx.fetch (0)));
else
{
/* This is actually invalid DWARF, but if we ever do run across