aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/expr.h
diff options
context:
space:
mode:
authorZoran Zaric <zoran.zaric@amd.com>2020-09-15 16:08:45 +0100
committerZoran Zaric <zoran.zaric@amd.com>2021-08-05 16:40:30 +0100
commitf4091d26441c7a3bead8bdfd1a37f072a32f40a0 (patch)
tree2396098716ede05f7779f4945fe7ccba77987fc0 /gdb/dwarf2/expr.h
parentf9e4ed8baa9eeebc71be88f863c52f81e42bed34 (diff)
downloadbinutils-f4091d26441c7a3bead8bdfd1a37f072a32f40a0.zip
binutils-f4091d26441c7a3bead8bdfd1a37f072a32f40a0.tar.gz
binutils-f4091d26441c7a3bead8bdfd1a37f072a32f40a0.tar.bz2
Move piece_closure and its support to expr.c
Following 5 patches series is trying to clean up the interface of the DWARF expression evaluator class (dwarf_expr_context). After merging all expression evaluators into one class, the next logical step is to make a clean user interface for that class. To do that, we first need to address the issue of class users writing and reading the internal data of the class directly. Fixing the case of writing is simple, it makes sense for an evaluator instance to be per architecture basis. Currently, the best separation seems to be per object file, so having that data (dwarf2_per_objfile) as a constructor argument makes sense. It also makes sense to get the address size from that object file, but unfortunately that interface does not exist at the moment. Luckily, address size information is already available to the users through other means. As a result, the address size also needs to be a class constructor argument, at least until a better interface for acquiring that information from an object file is implemented. The rest of the user written data comes down to a context of an evaluated expression (compilation unit context, frame context and passed in buffer context) and a source type information that a result of evaluating expression is representing. So, it makes sense for all of these to be arguments of an evaluation method. To address the problem of reading the dwarf_expr_context class internal data, we first need to understand why it is implemented that way? This is actualy a question of which existing class can be used to represent both values and a location descriptions and why it is not used currently? The answer is in a struct value class/structure, but the problem is that before the evaluators were merged, only one evaluator had an infrastructure to resolve composite and implicit pointer location descriptions. After the merge, we are now able to use the struct value to represent any result of the expression evaluation. It also makes sense to move all infrastructure for those location descriptions to the expr.c file considering that that is the only place using that infrastructure. What we are left with in the end is a clean public interface of the dwarf_expr_context class containing: - constructor, - destructor, - push_address method and - eval_exp method. The idea with this particular patch is to move piece_closure structure and the interface that handles it (lval_funcs) to expr.c file. While implicit pointer location descriptions are still not useful in the CFI context (of the AMD's DWARF standard extensions), the composite location descriptions are certainly necessary to describe a results of specific compiler optimizations. Considering that a piece_closure structure is used to represent both, there was no benefit in splitting them. gdb/ChangeLog: * dwarf2/expr.c (struct piece_closure): Add from loc.c. (allocate_piece_closure): Add from loc.c. (bits_to_bytes): Add from loc.c. (rw_pieced_value): Add from loc.c. (read_pieced_value): Add from loc.c. (write_pieced_value): Add from loc.c. (check_pieced_synthetic_pointer): Add from loc.c. (indirect_pieced_value): Add from loc.c. (coerce_pieced_ref): Add from loc.c. (copy_pieced_value_closure): Add from loc.c. (free_pieced_value_closure): Add from loc.c. (sect_variable_value): Add from loc.c. * dwarf2/loc.c (sect_variable_value): Move to expr.c. (struct piece_closure): Move to expr.c. (allocate_piece_closure): Move to expr.c. (bits_to_bytes): Move to expr.c. (rw_pieced_value): Move to expr.c. (read_pieced_value): Move to expr.c. (write_pieced_value): Move to expr.c. (check_pieced_synthetic_pointer): Move to expr.c. (indirect_pieced_value): Move to expr.c. (coerce_pieced_ref): Move to expr.c. (copy_pieced_value_closure): Move to expr.c. (free_pieced_value_closure): Move to expr.c.
Diffstat (limited to 'gdb/dwarf2/expr.h')
-rw-r--r--gdb/dwarf2/expr.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index 76c073c..c9ba2a6 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -26,6 +26,7 @@
#include "gdbtypes.h"
struct dwarf2_per_objfile;
+struct piece_closure;
/* The location of a value. */
enum dwarf_value_location
@@ -300,4 +301,13 @@ extern const gdb_byte *safe_read_sleb128 (const gdb_byte *buf,
extern const gdb_byte *safe_skip_leb128 (const gdb_byte *buf,
const gdb_byte *buf_end);
+extern const struct lval_funcs pieced_value_funcs;
+
+/* Allocate a closure for a value formed from separately-described
+ PIECES. */
+
+piece_closure *allocate_piece_closure
+ (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
+ std::vector<dwarf_expr_piece> &&pieces, frame_info *frame);
+
#endif /* dwarf2expr.h */