Move compilation unit info to dwarf_expr_context
authorZoran Zaric <zoran.zaric@amd.com>
Mon, 14 Sep 2020 16:02:29 +0000 (17:02 +0100)
committerZoran Zaric <zoran.zaric@amd.com>
Thu, 5 Aug 2021 15:39:36 +0000 (16:39 +0100)
commita580d9604bb71c19741465f2e3a46c5a07672be0
tree90f1099bf62a413710f2e0f464fe96ece9da0666
parent6c7779b34b38ca71df9460c07bc4c03d01dfaa0b
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.
gdb/dwarf2/expr.c
gdb/dwarf2/expr.h
gdb/dwarf2/frame.c
gdb/dwarf2/loc.c
gdb/dwarf2/loc.h