[PATCH 11/43] Remove empty frame and full evaluators

Zoran Zaric via Gdb-patches
2021-03-01T14:47:03Z

From: Zoran Zaric <zoran.zaric@amd.com>

There are no virtual methods that require different specialization in
dwarf_expr_context class. This means that derived classes
dwarf_expr_executor and dwarf_evaluate_loc_desc are not needed any
more.

As a result of this, the evaluate_for_locexpr_baton class base class
is now the dwarf_expr_context class.

There might be a need for a better class hierarchy when we know more
about the direction of the future DWARF versions and gdb extensions,
but that is out of the scope of this patch series.

gdb/ChangeLog:

* dwarf2/frame.c (class dwarf_expr_executor): Remove class.
(execute_stack_op): Instantiate dwarf_expr_context instead of
dwarf_evaluate_loc_desc class.
* dwarf2/loc.c (class dwarf_evaluate_loc_desc): Remove class.
(dwarf2_evaluate_loc_desc_full): Instantiate dwarf_expr_context
instead of dwarf_evaluate_loc_desc class.
(struct evaluate_for_locexpr_baton): Derive from
dwarf_expr_context.
---
gdb/dwarf2/frame.c | 18 +-----------------
gdb/dwarf2/loc.c | 16 ++++------------
2 files changed, 5 insertions(+), 29 deletions(-)

diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index abbd24b8ed0..8faadeb3469 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -223,22 +223,6 @@ register %s (#%d) at %s"),
}
}

-class dwarf_expr_executor : public dwarf_expr_context
-{
-public:
-
- dwarf_expr_executor (dwarf2_per_objfile *per_objfile)
- : dwarf_expr_context (per_objfile)
- {}
-
- private:
-
- void invalid (const char *op) ATTRIBUTE_NORETURN
- {
- error (_("%s is invalid in this context"), op);
- }
-};
-
static CORE_ADDR
execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
struct frame_info *this_frame, CORE_ADDR initial,
@@ -246,7 +230,7 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
{
CORE_ADDR result;

- dwarf_expr_executor ctx (per_objfile);
+ dwarf_expr_context ctx (per_objfile);
scoped_value_mark free_values;

ctx.frame = this_frame;
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 1779241d9dc..bd3f7d4d46a 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -618,14 +618,6 @@ sect_variable_value (sect_offset sect_off,
type, true);
}

-class dwarf_evaluate_loc_desc : public dwarf_expr_context
-{
-public:
- dwarf_evaluate_loc_desc (dwarf2_per_objfile *per_objfile)
- : dwarf_expr_context (per_objfile)
- {}
-};
-
/* See dwarf2loc.h. */

unsigned int entry_values_debug = 0;
@@ -2029,7 +2021,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
if (size == 0)
return allocate_optimized_out_value (subobj_type);

- dwarf_evaluate_loc_desc ctx (per_objfile);
+ dwarf_expr_context ctx (per_objfile);
ctx.frame = frame;
ctx.per_cu = per_cu;
ctx.obj_address = 0;
@@ -2229,16 +2221,16 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
per_objfile, NULL, 0);
}

-/* A specialization of dwarf_evaluate_loc_desc that is used by
+/* A specialization of dwarf_expr_context that is used by
dwarf2_locexpr_baton_eval. This subclass exists to handle the case
where a caller of dwarf2_locexpr_baton_eval passes in some data,
but with the address being 0. In this situation, we arrange for
memory reads to come from the passed-in buffer. */

-struct evaluate_for_locexpr_baton : public dwarf_evaluate_loc_desc
+struct evaluate_for_locexpr_baton : public dwarf_expr_context
{
evaluate_for_locexpr_baton (dwarf2_per_objfile *per_objfile)
- : dwarf_evaluate_loc_desc (per_objfile)
+ : dwarf_expr_context (per_objfile)
{}

/* The data that was passed in. */
--
2.17.1