]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Simplify dwarf_expr_context class interface
authorZoran Zaric <Zoran.Zaric@amd.com>
Mon, 7 Dec 2020 19:00:15 +0000 (19:00 +0000)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 8 Dec 2020 16:16:19 +0000 (11:16 -0500)
commite6bada58ebb64f9356e8912f921f30715b6c7308
tree0b02fa82a522ba5a6983c719f87631ee6f915343
parent5e8cb1a0bb6a262b39f487f3341dd276fe5eda22
Simplify dwarf_expr_context class interface

Idea of this patch is to get a clean and simple public interface for
the dwarf_expr_context class, looking like:

- constructor,
- destructor,
- push_address method and
- eval_exp method.

Where constructor should only ever require a target architecture
information. This information is held in per object file
(dwarf2_per_objfile) structure, so it makes sense to keep that
structure as a constructor argument. It also makes sense to get the
address size from that structure, but unfortunately that interface
doesn't exist at the moment, so the dwarf_expr_context class user
needs to provide that information.

The push_address method is used to push a CORE_ADDR as a value on
top of the DWARF stack before the evaluation. This method can be
later changed to push any struct value object on the stack.

The eval_exp method is the method that evaluates a DWARF expression
and provides the evaluation result, in a form of a single struct
value object that describes a location. To do this, the method requires
a context of the evaluation, as well as expected result type
information. If the type information is not provided, the DWARF generic
type will be used instead.

gdb/ChangeLog:

* dwarf2/expr.c (dwarf_expr_context::dwarf_expr_context): Add
address size argument.
(dwarf_expr_context::read_mem): Change to use property_addr_info
structure.
(dwarf_expr_context::eval_exp): New function.
(dwarf_expr_context::execute_stack_op): Change to use
property_addr_info structure.
* dwarf2/expr.h (struct dwarf_expr_context): New eval_exp
declaration. Change eval and fetch_result method to private.
* dwarf2/frame.c (execute_stack_op): Change to call eval_exp
method.
* dwarf2/loc.c (dwarf2_evaluate_loc_desc_full): Change to call
eval_exp method.
(dwarf2_locexpr_baton_eval): Change to call eval_exp method.

Change-Id: I8abd0dbf93e74a8a5adce143bfdea83c802233c3
gdb/dwarf2/expr.c
gdb/dwarf2/expr.h
gdb/dwarf2/frame.c
gdb/dwarf2/loc.c