[PATCH 02/12]: Remove set_value_optimized_out

Andrew Burgess
2013-08-12T12:18:45Z

In this patch I change the API used to mark a value as optimized
out, the API now matches that used for marking a value unavailable.

This patch does revert a recent change by Pedro:
http://sourceware.org/ml/gdb-patches/2013-07/msg00178.html

however, later patches will change the code to be more acceptable.

OK to apply?

Thanks,
Andrew

gdb/ChangeLog

2013-08-08 Andrew Burgess <aburgess@broadcom.com>

* ada-lang.c (coerce_unspec_val_to_type): Switch to
mark_value_bytes_optimized_out, and only mark non-lazy values as
optimized out.
* dwarf2loc.c (read_pieced_value): Switch to use
mark_value_bytes_optimized_out, or mark_value_bits_optimized_out.
(write_pieced_value): Switch to use
mark_value_bytes_optimized_out.
* findvar.c (read_frame_register_value): Switch to use
mark_value_bytes_optimized_out.
(value_from_register): Likewise.
* value.c (allocate_optimized_out_value, value_fetch_lazy): Switch
to use mark_value_bytes_optimized_out.
(value_optimized_out_const, set_value_optimized_out): Remove.
(mark_value_bytes_optimized_out, mark_value_bits_optimized_out):
New function definition.
* value.h (value_optimized_out_const, set_value_optimized_out):
Remove.
(mark_value_bytes_optimized_out, mark_value_bits_optimized_out):
Add new declaration.

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index ba59913..20a0f02 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -576,12 +576,13 @@ coerce_unspec_val_to_type (struct value *val,
struct type *type)
result = allocate_value (type);
memcpy (value_contents_raw (result), value_contents (val),
TYPE_LENGTH (type));
+ if (value_optimized_out (val))
+ mark_value_bytes_optimized_out (result, 0, TYPE_LENGTH (type));
}
set_value_component_location (result, val);
set_value_bitsize (result, value_bitsize (val));
set_value_bitpos (result, value_bitpos (val));
set_value_address (result, value_address (val));
- set_value_optimized_out (result, value_optimized_out_const (val));
return result;
}
}
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 3b843fa..36b80fb 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1694,7 +1694,7 @@ read_pieced_value (struct value *v)
memset (buffer, 0, this_size);
if (optim)
- set_value_optimized_out (v, 1);
+ mark_value_bytes_optimized_out (v, offset, this_size);
if (unavail)
mark_value_bytes_unavailable (v, offset, this_size);
}
@@ -1754,7 +1754,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:
@@ -1792,7 +1792,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;
}
@@ -1923,7 +1923,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;
diff --git a/gdb/findvar.c b/gdb/findvar.c
index f586ce2..f2bb247 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -713,7 +713,11 @@ read_frame_register_value (struct value *value,
struct frame_info *frame)
if (value_optimized_out (regval))
{
- set_value_optimized_out (value, 1);
+ /* If any one of the component registers is marked optimized out
+ then we just mark the whole composite register as optimized
+ out. We could do better, but this style of composite register
+ passing is not standard, and is only used on a few targets. */
+ mark_value_bytes_optimized_out (value, 0, TYPE_LENGTH (value_type
(value)));
break;
}
@@ -762,7 +766,7 @@ value_from_register (struct type *type, int regnum,
struct frame_info *frame)
if (!ok)
{
if (optim)
- set_value_optimized_out (v, 1);
+ mark_value_bytes_optimized_out (v, 0, TYPE_LENGTH (type));
if (unavail)
mark_value_bytes_unavailable (v, 0, TYPE_LENGTH (type));
}
diff --git a/gdb/value.c b/gdb/value.c
index 09ab1bb..462244e 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -742,7 +742,7 @@ allocate_optimized_out_value (struct type *type)
{
struct value *retval = allocate_value_lazy (type);
- set_value_optimized_out (retval, 1);
+ mark_value_bytes_optimized_out (retval, 0, TYPE_LENGTH (type));
return retval;
}
@@ -1062,16 +1062,28 @@ value_optimized_out (struct value *value)
return value->optimized_out;
}
-int
-value_optimized_out_const (const struct value *value)
+/* Mark contents of VALUE as optimized out, starting at OFFSET bytes, and
+ the following LENGTH bytes. */
+
+void
+mark_value_bytes_optimized_out (struct value *value, int offset, int
length)
{
- return value->optimized_out;
+ mark_value_bits_optimized_out (value,
+ offset * TARGET_CHAR_BIT,
+ length * TARGET_CHAR_BIT);
}
+/* Mark contents of VALUE as optimized out, starting at OFFSET bits, and
+ the following LENGTH bits. */
+
void
-set_value_optimized_out (struct value *value, int val)
+mark_value_bits_optimized_out (struct value *value,
+ int offset ATTRIBUTE_UNUSED,
+ int length ATTRIBUTE_UNUSED)
{
- value->optimized_out = val;
+ /* For now just set the optimized out flag to indicate that part of the
+ value is optimized out, this will be expanded upon in later
patches. */
+ value->optimized_out = 1; }
int
@@ -3439,7 +3451,8 @@ value_fetch_lazy (struct value *val)
if (!value_bits_valid (parent,
TARGET_CHAR_BIT * offset + value_bitpos (val),
value_bitsize (val)))
- set_value_optimized_out (val, 1);
+ mark_value_bytes_optimized_out (val, value_embedded_offset (val),
+ TYPE_LENGTH (type));
else if (!unpack_value_bits_as_long (value_type (val),
value_contents_for_printing (parent),
offset,
@@ -3498,7 +3511,7 @@ value_fetch_lazy (struct value *val)
/* If the register was not saved, mark it optimized out. */
if (value_optimized_out (new_val))
- set_value_optimized_out (val, 1);
+ mark_value_bytes_optimized_out (val, 0, TYPE_LENGTH (value_type (val)));
else
{
set_value_lazy (val, 0);
diff --git a/gdb/value.h b/gdb/value.h
index 599850e..dd8a0c1 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -322,12 +322,18 @@ extern int value_contents_equal (struct value
*val1, struct value *val2);
exist in the program, at least partially. If the value is lazy,
this may fetch it now. */
extern int value_optimized_out (struct value *value);
-extern void set_value_optimized_out (struct value *value, int val);
-/* Like value_optimized_out, but don't fetch the value even if it is
- lazy. Mainly useful for constructing other values using VALUE as
- template. */
-extern int value_optimized_out_const (const struct value *value);
+/* Mark VALUE's content bytes starting at OFFSET and extending for
+ LENGTH bytes as optimized out. */
+
+extern void mark_value_bytes_optimized_out (struct value *value,
+ int offset, int length);
+
+/* Mark VALUE's content bits starting at OFFSET and extending for
+ LENGTH bits as optimized out. */
+
+extern void mark_value_bits_optimized_out (struct value *value,
+ int offset, int length);
/* Like value_optimized_out, but return false if any bit in the object
is valid. */