aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2loc.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2014-08-20 00:07:40 +0100
committerPedro Alves <palves@redhat.com>2014-08-20 00:07:40 +0100
commit9a0dc9e3699018b15980bb6a39eb33dea8fefa34 (patch)
tree01387811bdb9f4fcfa18caa73517c058ea91157e /gdb/dwarf2loc.c
parent6694c4110a37bc951d01132d6e56445d57350627 (diff)
downloadgdb-9a0dc9e3699018b15980bb6a39eb33dea8fefa34.zip
gdb-9a0dc9e3699018b15980bb6a39eb33dea8fefa34.tar.gz
gdb-9a0dc9e3699018b15980bb6a39eb33dea8fefa34.tar.bz2
Handle partially optimized out values similarly to unavailable values
This fixes PR symtab/14604, PR symtab/14605, and Jan's test at https://sourceware.org/ml/gdb-patches/2014-07/msg00158.html, in a tree with bddbbed reverted: 2014-07-22 Pedro Alves <palves@redhat.com> * value.c (allocate_optimized_out_value): Don't mark value as non-lazy. The PRs are about variables described by the DWARF as being split over multiple registers using DWARF piece information, but some of those registers being marked as optimised out (not saved) by a later frame. GDB currently incorrectly mishandles these partially-optimized-out values. Even though we can usually tell from the debug info whether a local or global is optimized out, handling the case of a local living in a register that was not saved in a frame requires fetching the variable. GDB also needs to fetch a value to tell whether parts of it are "<unavailable>". Given this, it's not worth it to try to avoid fetching lazy optimized-out values based on debug info alone. So this patch makes GDB track which chunks of a value's contents are optimized out like it tracks <unavailable> contents. That is, it makes value->optimized_out be a bit range vector instead of a boolean, and removes the struct lval_funcs check_validity and check_any_valid hooks. Unlike Andrew's series which this is based on (at https://sourceware.org/ml/gdb-patches/2013-08/msg00300.html, note some pieces have gone in since), this doesn't merge optimized out and unavailable contents validity/availability behind a single interface, nor does it merge the bit range vectors themselves (at least yet). While it may be desirable to have a single entry point that returns existence of contents irrespective of what may make them invalid/unavailable, several places want to treat optimized out / unavailable / etc. differently, so each spot that potentially could use it will need to be careful considered on case-by-case basis, and best done as a separate change. This fixes Jan's test, because value_available_contents_eq wasn't considering optimized out value contents. It does now, and because of that it's been renamed to value_contents_eq. A new intro comment is added to value.h describing "<optimized out>", "<not saved>" and "<unavailable>" values. gdb/ PR symtab/14604 PR symtab/14605 * ada-lang.c (coerce_unspec_val_to_type): Use value_contents_copy_raw. * ada-valprint.c (val_print_packed_array_elements): Adjust. * c-valprint.c (c_val_print): Use value_bits_any_optimized_out. * cp-valprint.c (cp_print_value_fields): Let the common printing code handle optimized out values. (cp_print_value_fields_rtti): Use value_bits_any_optimized_out. * d-valprint.c (dynamic_array_type): Use value_bits_any_optimized_out. * dwarf2loc.c (entry_data_value_funcs): Remove check_validity and check_any_valid fields. (check_pieced_value_bits): Delete and inline ... (check_pieced_synthetic_pointer): ... here. (check_pieced_value_validity): Delete. (check_pieced_value_invalid): Delete. (pieced_value_funcs): Remove check_validity and check_any_valid fields. (read_pieced_value): Use mark_value_bits_optimized_out. (write_pieced_value): Switch to use mark_value_bytes_optimized_out. (dwarf2_evaluate_loc_desc_full): Copy the value contents instead of assuming the whole value is optimized out. * findvar.c (read_frame_register_value): Remove special handling of optimized out registers. (value_from_register): Use mark_value_bytes_optimized_out. * frame-unwind.c (frame_unwind_got_optimized): Use mark_value_bytes_optimized_out. * jv-valprint.c (java_value_print): Adjust. (java_print_value_fields): Let the common printing code handle optimized out values. * mips-tdep.c (mips_print_register): Remove special handling of optimized out registers. * opencl-lang.c (lval_func_check_validity): Delete. (lval_func_check_any_valid): Delete. (opencl_value_funcs): Remove check_validity and check_any_valid fields. * p-valprint.c (pascal_object_print_value_fields): Let the common printing code handle optimized out values. * stack.c (read_frame_arg): Remove special handling of optimized out values. Fetch both VAL and ENTRYVAL before comparing contents. Adjust to value_available_contents_eq rename. * valprint.c (valprint_check_validity) (val_print_scalar_formatted): Use value_bits_any_optimized_out. (val_print_array_elements): Adjust. * value.c (struct value) <optimized_out>: Now a VEC(range_s). (value_bits_any_optimized_out): New function. (value_entirely_covered_by_range_vector): New function, factored out from value_entirely_unavailable. (value_entirely_unavailable): Reimplement. (value_entirely_optimized_out): New function. (insert_into_bit_range_vector): New function, factored out from mark_value_bits_unavailable. (mark_value_bits_unavailable): Reimplement. (struct ranges_and_idx): New struct. (find_first_range_overlap_and_match): New function, factored out from value_available_contents_bits_eq. (value_available_contents_bits_eq): Rename to ... (value_contents_bits_eq): ... this. Check both unavailable contents and optimized out contents. (value_available_contents_eq): Rename to ... (value_contents_eq): ... this. (allocate_value_lazy): Remove reference to the old optimized_out boolean. (allocate_optimized_out_value): Use mark_value_bytes_optimized_out. (require_not_optimized_out): Adjust to check whether the optimized_out vec is empty. (ranges_copy_adjusted): New function, factored out from value_contents_copy_raw. (value_contents_copy_raw): Also copy the optimized out ranges. Assert the destination ranges aren't optimized out. (value_contents_copy): Update comment, remove call to require_not_optimized_out. (value_contents_equal): Adjust to check whether the optimized_out vec is empty. (set_value_optimized_out, value_optimized_out_const): Delete. (mark_value_bytes_optimized_out, mark_value_bits_optimized_out): New functions. (value_entirely_optimized_out, value_bits_valid): Delete. (value_copy): Take a VEC copy of the 'optimized_out' field. (value_primitive_field): Remove special handling of optimized out. (value_fetch_lazy): Assert that lazy values have no unavailable regions. Use value_bits_any_optimized_out. Remove some special handling for optimized out values. * value.h: Add intro comment about <optimized out> and <unavailable>. (struct lval_funcs): Remove check_validity and check_any_valid fields. (set_value_optimized_out, value_optimized_out_const): Remove. (mark_value_bytes_optimized_out, mark_value_bits_optimized_out): New declarations. (value_bits_any_optimized_out): New declaration. (value_bits_valid): Delete declaration. (value_available_contents_eq): Rename to ... (value_contents_eq): ... this, and extend comments. gdb/testsuite/ PR symtab/14604 PR symtab/14605 * gdb.dwarf2/dw2-op-out-param.exp: Remove kfail branches and use gdb_test.
Diffstat (limited to 'gdb/dwarf2loc.c')
-rw-r--r--gdb/dwarf2loc.c81
1 files changed, 16 insertions, 65 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index fd78f6f..e347e59 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1300,8 +1300,6 @@ static const struct lval_funcs entry_data_value_funcs =
{
NULL, /* read */
NULL, /* write */
- NULL, /* check_validity */
- NULL, /* check_any_valid */
NULL, /* indirect */
entry_data_value_coerce_ref,
NULL, /* check_synthetic_pointer */
@@ -1710,7 +1708,7 @@ read_pieced_value (struct value *v)
memset (buffer, 0, this_size);
if (optim)
- set_value_optimized_out (v, 1);
+ mark_value_bits_optimized_out (v, offset, this_size_bits);
if (unavail)
mark_value_bits_unavailable (v, offset, this_size_bits);
}
@@ -1770,7 +1768,7 @@ read_pieced_value (struct value *v)
break;
case DWARF_VALUE_OPTIMIZED_OUT:
- set_value_optimized_out (v, 1);
+ mark_value_bits_optimized_out (v, offset, this_size_bits);
break;
default:
@@ -1808,7 +1806,7 @@ write_pieced_value (struct value *to, struct value *from)
if (frame == NULL)
{
- set_value_optimized_out (to, 1);
+ mark_value_bytes_optimized_out (to, 0, TYPE_LENGTH (value_type (to)));
return;
}
@@ -1940,7 +1938,7 @@ write_pieced_value (struct value *to, struct value *from)
source_buffer, this_size);
break;
default:
- set_value_optimized_out (to, 1);
+ mark_value_bytes_optimized_out (to, 0, TYPE_LENGTH (value_type (to)));
break;
}
offset += this_size_bits;
@@ -1949,24 +1947,16 @@ write_pieced_value (struct value *to, struct value *from)
do_cleanups (cleanup);
}
-/* A helper function that checks bit validity in a pieced value.
- CHECK_FOR indicates the kind of validity checking.
- DWARF_VALUE_MEMORY means to check whether any bit is valid.
- DWARF_VALUE_OPTIMIZED_OUT means to check whether any bit is
- optimized out.
- DWARF_VALUE_IMPLICIT_POINTER means to check whether the bits are an
- implicit pointer. */
+/* An implementation of an lval_funcs method to see whether a value is
+ a synthetic pointer. */
static int
-check_pieced_value_bits (const struct value *value, int bit_offset,
- int bit_length,
- enum dwarf_value_location check_for)
+check_pieced_synthetic_pointer (const struct value *value, int bit_offset,
+ int bit_length)
{
struct piece_closure *c
= (struct piece_closure *) value_computed_closure (value);
int i;
- int validity = (check_for == DWARF_VALUE_MEMORY
- || check_for == DWARF_VALUE_IMPLICIT_POINTER);
bit_offset += 8 * value_offset (value);
if (value_bitsize (value))
@@ -1991,52 +1981,11 @@ check_pieced_value_bits (const struct value *value, int bit_offset,
else
bit_length -= this_size_bits;
- if (check_for == DWARF_VALUE_IMPLICIT_POINTER)
- {
- if (p->location != DWARF_VALUE_IMPLICIT_POINTER)
- return 0;
- }
- else if (p->location == DWARF_VALUE_OPTIMIZED_OUT
- || p->location == DWARF_VALUE_IMPLICIT_POINTER)
- {
- if (validity)
- return 0;
- }
- else
- {
- if (!validity)
- return 1;
- }
+ if (p->location != DWARF_VALUE_IMPLICIT_POINTER)
+ return 0;
}
- return validity;
-}
-
-static int
-check_pieced_value_validity (const struct value *value, int bit_offset,
- int bit_length)
-{
- return check_pieced_value_bits (value, bit_offset, bit_length,
- DWARF_VALUE_MEMORY);
-}
-
-static int
-check_pieced_value_invalid (const struct value *value)
-{
- return check_pieced_value_bits (value, 0,
- 8 * TYPE_LENGTH (value_type (value)),
- DWARF_VALUE_OPTIMIZED_OUT);
-}
-
-/* An implementation of an lval_funcs method to see whether a value is
- a synthetic pointer. */
-
-static int
-check_pieced_synthetic_pointer (const struct value *value, int bit_offset,
- int bit_length)
-{
- return check_pieced_value_bits (value, bit_offset, bit_length,
- DWARF_VALUE_IMPLICIT_POINTER);
+ return 1;
}
/* A wrapper function for get_frame_address_in_block. */
@@ -2185,8 +2134,6 @@ free_pieced_value_closure (struct value *v)
static const struct lval_funcs pieced_value_funcs = {
read_pieced_value,
write_pieced_value,
- check_pieced_value_validity,
- check_pieced_value_invalid,
indirect_pieced_value,
NULL, /* coerce_ref */
check_pieced_synthetic_pointer,
@@ -2316,6 +2263,8 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
retval = value_from_register (type, gdb_regnum, frame);
if (value_optimized_out (retval))
{
+ struct value *tmp;
+
/* This means the register has undefined value / was
not saved. As we're computing the location of some
variable etc. in the program, not a value for
@@ -2323,7 +2272,9 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
generic optimized out value instead, so that we show
<optimized out> instead of <not saved>. */
do_cleanups (value_chain);
- retval = allocate_optimized_out_value (type);
+ tmp = allocate_value (type);
+ value_contents_copy (tmp, 0, retval, 0, TYPE_LENGTH (type));
+ retval = tmp;
}
}
break;