aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/loc.c
diff options
context:
space:
mode:
authorZoran Zaric <zoran.zaric@amd.com>2020-09-14 17:02:29 +0100
committerZoran Zaric <zoran.zaric@amd.com>2021-08-05 16:39:36 +0100
commita580d9604bb71c19741465f2e3a46c5a07672be0 (patch)
tree90f1099bf62a413710f2e0f464fe96ece9da0666 /gdb/dwarf2/loc.c
parent6c7779b34b38ca71df9460c07bc4c03d01dfaa0b (diff)
downloadgdb-a580d9604bb71c19741465f2e3a46c5a07672be0.zip
gdb-a580d9604bb71c19741465f2e3a46c5a07672be0.tar.gz
gdb-a580d9604bb71c19741465f2e3a46c5a07672be0.tar.bz2
Move compilation unit info to dwarf_expr_context
This patch moves the compilation unit context information and support from dwarf_expr_executor and dwarf_evaluate_loc_desc to dwarf_expr_context evaluator. The idea is to report an error when a given operation requires a compilation unit information to be resolved, which is not available. With this change, it also makes sense to always acquire ref_addr_size information from the compilation unit context, considering that all DWARF operations that refer to that information require a compilation unit context to be present during their evaluation. gdb/ChangeLog: * dwarf2/expr.c (ensure_have_per_cu): New function. (dwarf_expr_context::dwarf_expr_context): Add compilation unit context information. (dwarf_expr_context::get_base_type): Move from dwarf_evaluate_loc_desc. (dwarf_expr_context::get_addr_index): Remove method. (dwarf_expr_context::dwarf_variable_value): Remove method. (dwarf_expr_context::execute_stack_op): Call compilation unit context info check. Inline get_addr_index and dwarf_variable_value methods. * dwarf2/expr.h (struct dwarf_expr_context): Add compilation context info. (dwarf_expr_context::get_addr_index): Remove method. (dwarf_expr_context::dwarf_variable_value): Remove method. (dwarf_expr_context::ref_addr_size): Remove member. * dwarf2/frame.c (dwarf_expr_executor::get_addr_index): Remove method. (dwarf_expr_executor::dwarf_variable_value): Remove method. * dwarf2/loc.c (sect_variable_value): Expose function. (dwarf_evaluate_loc_desc::get_addr_index): Remove method. (dwarf_evaluate_loc_desc::dwarf_variable_value): Remove method. (class dwarf_evaluate_loc_desc): Move compilation unit context information to dwarf_expr_context class. * dwarf2/loc.h (sect_variable_value): Expose function.
Diffstat (limited to 'gdb/dwarf2/loc.c')
-rw-r--r--gdb/dwarf2/loc.c37
1 files changed, 3 insertions, 34 deletions
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 723d9a4..7e565d3 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -651,12 +651,10 @@ compute_var_value (const char *name)
return nullptr;
}
-/* Given context CTX, section offset SECT_OFF, and compilation unit
- data PER_CU, execute the "variable value" operation on the DIE
- found at SECT_OFF. */
+/* See loc.h. */
-static struct value *
-sect_variable_value (struct dwarf_expr_context *ctx, sect_offset sect_off,
+struct value *
+sect_variable_value (sect_offset sect_off,
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
@@ -696,7 +694,6 @@ public:
: dwarf_expr_context (per_objfile)
{}
- struct dwarf2_per_cu_data *per_cu;
CORE_ADDR obj_address;
/* Helper function for dwarf2_evaluate_loc_desc. Computes the PC for
@@ -722,32 +719,6 @@ public:
per_cu_dwarf_call (this, die_offset, per_cu, per_objfile);
}
- /* Helper interface of sect_variable_value for
- dwarf2_evaluate_loc_desc. */
-
- struct value *dwarf_variable_value (sect_offset sect_off) override
- {
- return sect_variable_value (this, sect_off, per_cu, per_objfile);
- }
-
- struct type *get_base_type (cu_offset die_offset, int size) override
- {
- struct type *result = dwarf2_get_die_type (die_offset, per_cu, per_objfile);
- if (result == NULL)
- error (_("Could not find type for DW_OP_const_type"));
- if (size != 0 && TYPE_LENGTH (result) != size)
- error (_("DW_OP_const_type has different sizes for type and data"));
- return result;
- }
-
- /* Callback function for dwarf2_evaluate_loc_desc.
- Fetch the address indexed by DW_OP_addrx or DW_OP_GNU_addr_index. */
-
- CORE_ADDR get_addr_index (unsigned int index) override
- {
- return dwarf2_read_addr_index (per_cu, per_objfile, index);
- }
-
/* Callback function for get_object_address. Return the address of the VLA
object. */
@@ -2237,7 +2208,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
ctx.gdbarch = per_objfile->objfile->arch ();
ctx.addr_size = per_cu->addr_size ();
- ctx.ref_addr_size = per_cu->ref_addr_size ();
try
{
@@ -2504,7 +2474,6 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
ctx.gdbarch = per_objfile->objfile->arch ();
ctx.addr_size = dlbaton->per_cu->addr_size ();
- ctx.ref_addr_size = dlbaton->per_cu->ref_addr_size ();
if (push_initial_value)
ctx.push_address (ctx.obj_address, false);