diff options
author | Tom Tromey <tromey@adacore.com> | 2020-04-24 13:40:31 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-24 13:40:31 -0600 |
commit | b249d2c2c01775fb015b38b272389b8693e414f6 (patch) | |
tree | 5c41219789c65cf9f6f65f46568a432c063f68c4 /gdb/findvar.c | |
parent | 61122aa9ed4096c3d85b01d52a0c0f67fb441533 (diff) | |
download | gdb-b249d2c2c01775fb015b38b272389b8693e414f6.zip gdb-b249d2c2c01775fb015b38b272389b8693e414f6.tar.gz gdb-b249d2c2c01775fb015b38b272389b8693e414f6.tar.bz2 |
Prefer existing data when evaluating DWARF expression
When evaluating a DWARF expression, the dynamic type resolution code
will pass in a buffer of bytes via the property_addr_info. However,
the DWARF expression evaluator will then proceed to read memory from
the inferior, even when the request could be filled from this buffer.
This, in turn, is a problem in some cases; and specifically when
trying to handle the Ada scenario of extracting a variable-length
value from a packed array. Here, the ordinary DWARF expression cannot
be directly evaluated, because the data may appear at some arbitrary
bit offset. So, it is unpacked into a staging area and then the
expression is evaluated -- using an address of 0.
This patch fixes the problem by arranging for the DWARF evaluator, in
this case, to prefer passed-in memory when possible. The type of the
buffer in the property_addr_info is changed to an array_view so that
bounds checking can be done.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_discrete_type_high_bound, ada_discrete_type_low)
(ada_value_primitive_packed_val): Update.
* ada-valprint.c (ada_value_print_1): Update.
* dwarf2/loc.c (evaluate_for_locexpr_baton): New struct.
(dwarf2_locexpr_baton_eval): Take a property_addr_info rather than
just an address. Use evaluate_for_locexpr_baton.
(dwarf2_evaluate_property): Update.
* dwarf2/loc.h (struct property_addr_info) <valaddr>: Now an
array_view.
* findvar.c (default_read_var_value): Update.
* gdbtypes.c (compute_variant_fields_inner)
(resolve_dynamic_type_internal): Update.
(resolve_dynamic_type): Change type of valaddr parameter.
* gdbtypes.h (resolve_dynamic_type): Update.
* valarith.c (value_subscripted_rvalue): Update.
* value.c (value_from_contents_and_address): Update.
Diffstat (limited to 'gdb/findvar.c')
-rw-r--r-- | gdb/findvar.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gdb/findvar.c b/gdb/findvar.c index a836c63..ac4f5c3 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -615,7 +615,7 @@ default_read_var_value (struct symbol *var, const struct block *var_block, if (is_dynamic_type (type)) { /* Value is a constant byte-sequence and needs no memory access. */ - type = resolve_dynamic_type (type, NULL, /* Unused address. */ 0); + type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); } /* Put the constant back in target format. */ v = allocate_value (type); @@ -647,7 +647,7 @@ default_read_var_value (struct symbol *var, const struct block *var_block, if (is_dynamic_type (type)) { /* Value is a constant byte-sequence and needs no memory access. */ - type = resolve_dynamic_type (type, NULL, /* Unused address. */ 0); + type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); } v = allocate_value (type); memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), @@ -788,7 +788,7 @@ default_read_var_value (struct symbol *var, const struct block *var_block, case LOC_OPTIMIZED_OUT: if (is_dynamic_type (type)) - type = resolve_dynamic_type (type, NULL, /* Unused address. */ 0); + type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); return allocate_optimized_out_value (type); default: |