summaryrefslogtreecommitdiff
path: root/gdb/dwarf2expr.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/dwarf2expr.c
parent595d2e303c0ef1a5cd5af8868c1d41db0050eb29 (diff)
downloadbinutils-gdb-192ca6d8eac4a5538036ef200b95d6ef3dbe9511.tar.gz
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/dwarf2expr.c')
-rw-r--r--gdb/dwarf2expr.c136
1 files changed, 26 insertions, 110 deletions
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 1aa6afc282f..a01d6d8e3a3 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -414,20 +414,11 @@ base_types_equal_p (struct type *t1, struct type *t2)
struct type *
dwarf_expr_context::get_base_type (cu_offset die, int size)
{
- struct type *result;
-
- if (this->funcs->get_base_type)
- {
- result = this->funcs->get_base_type (this, die);
- if (result == NULL)
- error (_("Could not find type for DW_OP_GNU_const_type"));
- if (size != 0 && TYPE_LENGTH (result) != size)
- error (_("DW_OP_GNU_const_type has different sizes for type and data"));
- }
- else
- /* Anything will do. */
- result = builtin_type (this->gdbarch)->builtin_int;
-
+ struct type *result = this->impl_get_base_type (die);
+ if (result == NULL)
+ error (_("Could not find type for DW_OP_GNU_const_type"));
+ if (size != 0 && TYPE_LENGTH (result) != size)
+ error (_("DW_OP_GNU_const_type has different sizes for type and data"));
return result;
}
@@ -698,13 +689,13 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
case DW_OP_GNU_addr_index:
op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
- result = (this->funcs->get_addr_index) (this->baton, uoffset);
+ result = this->get_addr_index (uoffset);
result += this->offset;
result_val = value_from_ulongest (address_type, result);
break;
case DW_OP_GNU_const_index:
op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
- result = (this->funcs->get_addr_index) (this->baton, uoffset);
+ result = this->get_addr_index (uoffset);
result_val = value_from_ulongest (address_type, result);
break;
@@ -888,8 +879,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
case DW_OP_breg31:
{
op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
- result = (this->funcs->read_addr_from_reg) (this->baton,
- op - DW_OP_breg0);
+ result = this->read_addr_from_reg (op - DW_OP_breg0);
result += offset;
result_val = value_from_ulongest (address_type, result);
}
@@ -898,7 +888,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
{
op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
- result = (this->funcs->read_addr_from_reg) (this->baton, reg);
+ result = this->read_addr_from_reg (reg);
result += offset;
result_val = value_from_ulongest (address_type, result);
}
@@ -918,14 +908,12 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
/* FIXME: cagney/2003-03-26: This code should be using
get_frame_base_address(), and then implement a dwarf2
specific this_base method. */
- (this->funcs->get_frame_base) (this->baton, &datastart, &datalen);
+ this->get_frame_base (&datastart, &datalen);
eval (datastart, datalen);
if (this->location == DWARF_VALUE_MEMORY)
result = fetch_address (0);
else if (this->location == DWARF_VALUE_REGISTER)
- result = (this->funcs->read_addr_from_reg)
- (this->baton,
- value_as_long (fetch (0)));
+ result = this->read_addr_from_reg (value_as_long (fetch (0)));
else
error (_("Not implemented: computing frame "
"base using explicit value operator"));
@@ -1011,7 +999,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
else
type = address_type;
- (this->funcs->read_mem) (this->baton, buf, addr, addr_size);
+ this->read_mem (buf, addr, addr_size);
/* If the size of the object read from memory is different
from the type length, we need to zero-extend it. */
@@ -1220,7 +1208,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
break;
case DW_OP_call_frame_cfa:
- result = (this->funcs->get_frame_cfa) (this->baton);
+ result = this->get_frame_cfa ();
result_val = value_from_ulongest (address_type, result);
in_stack_memory = 1;
break;
@@ -1237,7 +1225,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
returned. */
result = value_as_long (fetch (0));
pop ();
- result = (this->funcs->get_tls_address) (this->baton, result);
+ result = this->get_tls_address (result);
result_val = value_from_ulongest (address_type, result);
break;
@@ -1313,7 +1301,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
offset.cu_off = extract_unsigned_integer (op_ptr, 2, byte_order);
op_ptr += 2;
- this->funcs->dwarf_call (this, offset);
+ this->dwarf_call (offset);
}
goto no_push;
@@ -1323,7 +1311,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
offset.cu_off = extract_unsigned_integer (op_ptr, 4, byte_order);
op_ptr += 4;
- this->funcs->dwarf_call (this, offset);
+ this->dwarf_call (offset);
}
goto no_push;
@@ -1341,10 +1329,9 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
if (kind_u.dwarf_reg != -1)
{
op_ptr += len;
- this->funcs->push_dwarf_reg_entry_value (this,
- CALL_SITE_PARAMETER_DWARF_REG,
- kind_u,
- -1 /* deref_size */);
+ this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_DWARF_REG,
+ kind_u,
+ -1 /* deref_size */);
goto no_push;
}
@@ -1356,9 +1343,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
if (deref_size == -1)
deref_size = this->addr_size;
op_ptr += len;
- this->funcs->push_dwarf_reg_entry_value (this,
- CALL_SITE_PARAMETER_DWARF_REG,
- kind_u, deref_size);
+ this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_DWARF_REG,
+ kind_u, deref_size);
goto no_push;
}
@@ -1374,10 +1360,9 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
kind_u.param_offset.cu_off = extract_unsigned_integer (op_ptr, 4,
byte_order);
op_ptr += 4;
- this->funcs->push_dwarf_reg_entry_value (this,
- CALL_SITE_PARAMETER_PARAM_OFFSET,
- kind_u,
- -1 /* deref_size */);
+ this->push_dwarf_reg_entry_value (CALL_SITE_PARAMETER_PARAM_OFFSET,
+ kind_u,
+ -1 /* deref_size */);
}
goto no_push;
@@ -1409,7 +1394,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
type_die.cu_off = uoffset;
type = get_base_type (type_die, 0);
- result_val = this->funcs->get_reg_value (this->baton, type, reg);
+ result_val = this->get_reg_value (type, reg);
}
break;
@@ -1448,7 +1433,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
case DW_OP_push_object_address:
/* Return the address of the object we are currently observing. */
- result = (this->funcs->get_object_address) (this->baton);
+ result = this->get_object_address ();
result_val = value_from_ulongest (address_type, result);
break;
@@ -1474,75 +1459,6 @@ abort_expression:
gdb_assert (this->recursion_depth >= 0);
}
-/* Stub dwarf_expr_context_funcs.get_frame_base implementation. */
-
-void
-ctx_no_get_frame_base (void *baton, const gdb_byte **start, size_t *length)
-{
- error (_("%s is invalid in this context"), "DW_OP_fbreg");
-}
-
-/* Stub dwarf_expr_context_funcs.get_frame_cfa implementation. */
-
-CORE_ADDR
-ctx_no_get_frame_cfa (void *baton)
-{
- error (_("%s is invalid in this context"), "DW_OP_call_frame_cfa");
-}
-
-/* Stub dwarf_expr_context_funcs.get_frame_pc implementation. */
-
-CORE_ADDR
-ctx_no_get_frame_pc (void *baton)
-{
- error (_("%s is invalid in this context"), "DW_OP_GNU_implicit_pointer");
-}
-
-/* Stub dwarf_expr_context_funcs.get_tls_address implementation. */
-
-CORE_ADDR
-ctx_no_get_tls_address (void *baton, CORE_ADDR offset)
-{
- error (_("%s is invalid in this context"), "DW_OP_form_tls_address");
-}
-
-/* Stub dwarf_expr_context_funcs.dwarf_call implementation. */
-
-void
-ctx_no_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset)
-{
- error (_("%s is invalid in this context"), "DW_OP_call*");
-}
-
-/* Stub dwarf_expr_context_funcs.get_base_type implementation. */
-
-struct type *
-ctx_no_get_base_type (struct dwarf_expr_context *ctx, cu_offset die)
-{
- error (_("Support for typed DWARF is not supported in this context"));
-}
-
-/* Stub dwarf_expr_context_funcs.push_dwarf_block_entry_value
- implementation. */
-
-void
-ctx_no_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx,
- enum call_site_parameter_kind kind,
- union call_site_parameter_u kind_u,
- int deref_size)
-{
- internal_error (__FILE__, __LINE__,
- _("Support for DW_OP_GNU_entry_value is unimplemented"));
-}
-
-/* Stub dwarf_expr_context_funcs.get_addr_index implementation. */
-
-CORE_ADDR
-ctx_no_get_addr_index (void *baton, unsigned int index)
-{
- error (_("%s is invalid in this context"), "DW_OP_GNU_addr_index");
-}
-
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_dwarf2expr;