From: Luis Machado luis.machado@arm.com
When casting capabilities and capability pointers to other types, we truncate the value to the appropriate size, given some capabilities are greater than 8 bytes in size.
gdb/ChangeLog:
YYYY-MM-DD Luis Machado luis.machado@arm.com
* valops.c (value_cast): Handle casting from capabilities and capability pointers. --- gdb/valops.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/gdb/valops.c b/gdb/valops.c index 3c0ed38a97..d0f1a1ed60 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -441,14 +441,20 @@ value_cast (struct type *type, struct value *arg2) || code2 == TYPE_CODE_DECFLOAT || code2 == TYPE_CODE_ENUM || code2 == TYPE_CODE_RANGE);
- /* Handle casting capabilities to other scalar types. For now we truncate - the capability value to the size of the target type. */ - if (scalar && code2 == TYPE_CODE_CAPABILITY) + int to_scalar = (code1 == TYPE_CODE_INT || code1 == TYPE_CODE_FLT + || code1 == TYPE_CODE_DECFLOAT || code1 == TYPE_CODE_ENUM + || code1 == TYPE_CODE_RANGE); + + /* Handle casting capabilities/capability pointers to other scalar types. + For now we truncate the capability value to the size of the target + type. */ + if (to_scalar && (code2 == TYPE_CODE_CAPABILITY + || (code2 == TYPE_CODE_PTR && TYPE_CAPABILITY (type2)))) { if (type->is_unsigned ()) - value_from_ulongest (to_type, value_as_long (arg2)); + return value_from_ulongest (to_type, value_as_long (arg2)); else - value_from_longest (to_type, value_as_long (arg2)); + return value_from_longest (to_type, value_as_long (arg2)); }
if ((code1 == TYPE_CODE_STRUCT || code1 == TYPE_CODE_UNION)