aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2008-09-08 22:16:51 +0000
committerDaniel Jacobowitz <drow@false.org>2008-09-08 22:16:51 +0000
commit694182d2ba45b3a4e97846f59cf04b75ad66901a (patch)
tree941a3baa7a87ff8f6b50a2556fb61a25a5f5ac6a /gdb/valops.c
parentdcf4fbde10e63c5cc5fa08b7280b751d01a8efaf (diff)
downloadgdb-694182d2ba45b3a4e97846f59cf04b75ad66901a.zip
gdb-694182d2ba45b3a4e97846f59cf04b75ad66901a.tar.gz
gdb-694182d2ba45b3a4e97846f59cf04b75ad66901a.tar.bz2
* valops.c (value_cast_structs): Return NULL for failure.
(value_cast): Handle NULL from value_cast_structs. (value_fetch_lazy): Call check_typedef. Remove unused variable. testsuite/ * gdb.base/structs3.c, gdb.base/structs3.exp: New files.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 4910649..0d1ffdf 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -193,7 +193,8 @@ allocate_space_in_inferior (int len)
/* Cast struct value VAL to type TYPE and return as a value.
Both type and val must be of TYPE_CODE_STRUCT or TYPE_CODE_UNION
- for this to work. Typedef to one of the codes is permitted. */
+ for this to work. Typedef to one of the codes is permitted.
+ Returns NULL if the cast is neither an upcast nor a downcast. */
static struct value *
value_cast_structs (struct type *type, struct value *v2)
@@ -244,7 +245,8 @@ value_cast_structs (struct type *type, struct value *v2)
return value_at (type, addr2);
}
}
- return v2;
+
+ return NULL;
}
/* Cast one pointer or reference type to another. Both TYPE and
@@ -397,7 +399,12 @@ value_cast (struct type *type, struct value *arg2)
if ((code1 == TYPE_CODE_STRUCT || code1 == TYPE_CODE_UNION)
&& (code2 == TYPE_CODE_STRUCT || code2 == TYPE_CODE_UNION)
&& TYPE_NAME (type) != 0)
- return value_cast_structs (type, arg2);
+ {
+ struct value *v = value_cast_structs (type, arg2);
+ if (v)
+ return v;
+ }
+
if (code1 == TYPE_CODE_FLT && scalar)
return value_from_double (type, value_as_double (arg2));
else if (code1 == TYPE_CODE_DECFLOAT && scalar)
@@ -615,9 +622,8 @@ value_fetch_lazy (struct value *val)
if (VALUE_LVAL (val) == lval_memory)
{
CORE_ADDR addr = VALUE_ADDRESS (val) + value_offset (val);
- int length = TYPE_LENGTH (value_enclosing_type (val));
+ int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
- struct type *type = value_type (val);
if (length)
read_memory (addr, value_contents_all_raw (val), length);
}