aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/loc.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/loc.h
parentf9e4ed8baa9eeebc71be88f863c52f81e42bed34 (diff)
downloadgdb-f4091d26441c7a3bead8bdfd1a37f072a32f40a0.zip
gdb-f4091d26441c7a3bead8bdfd1a37f072a32f40a0.tar.gz
gdb-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/loc.h')
-rw-r--r--gdb/dwarf2/loc.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
index f4dc3d7..33a5e8a 100644
--- a/gdb/dwarf2/loc.h
+++ b/gdb/dwarf2/loc.h
@@ -53,13 +53,10 @@ extern void func_get_frame_base_dwarf_block (struct symbol *framefunc,
const gdb_byte **start,
size_t *length);
-/* Given section offset SECT_OFF, and compilation unit data
- PER_CU, execute the "variable value" operation on the DIE
- found at SECT_OFF. */
+/* A helper function to find the definition of NAME and compute its
+ value. Returns nullptr if the name is not found. */
-struct value *sect_variable_value (sect_offset sect_off,
- dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *per_objfile);
+value *compute_var_value (const char *name);
/* Fetch call_site_parameter from caller matching KIND and KIND_U.
FRAME is for callee.
@@ -283,4 +280,11 @@ extern int dwarf_reg_to_regnum (struct gdbarch *arch, int dwarf_reg);
extern int dwarf_reg_to_regnum_or_error (struct gdbarch *arch,
ULONGEST dwarf_reg);
+/* Fetch the value pointed to by a synthetic pointer. */
+
+extern struct value *indirect_synthetic_pointer
+ (sect_offset die, LONGEST byte_offset, dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile, struct frame_info *frame,
+ struct type *type, bool resolve_abstract_p = false);
+
#endif /* dwarf2loc.h */