From: Luis Machado Date: Wed, 9 Sep 2020 21:30:10 +0000 (-0300) Subject: [General] Add capability casts to scalar types X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ac1e17b63616d5e6ffa886febdd1aa9278595a3;p=thirdparty%2Fbinutils-gdb.git [General] Add capability casts to scalar types Add support for casting capabilities to scalar types. We basically truncate the capability to the size of the target type. gdb/ChangeLog: 2020-10-20 Luis Machado * valops.c (value_cast): Cast from capability to scalar types. --- diff --git a/gdb/valops.c b/gdb/valops.c index 3a595125752..d4e89a3cfa6 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -529,6 +529,16 @@ value_cast (struct type *type, struct value *arg2) || code2 == TYPE_CODE_RANGE || is_fixed_point_type (type2)); + /* 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) + { + if (type->is_unsigned ()) + value_from_ulongest (to_type, value_as_long (arg2)); + else + value_from_longest (to_type, value_as_long (arg2)); + } + if ((code1 == TYPE_CODE_STRUCT || code1 == TYPE_CODE_UNION) && (code2 == TYPE_CODE_STRUCT || code2 == TYPE_CODE_UNION) && type->name () != 0)