From 8ac1e17b63616d5e6ffa886febdd1aa9278595a3 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Wed, 9 Sep 2020 18:30:10 -0300 Subject: [PATCH] [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. --- gdb/valops.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- 2.47.2