]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[General] Add capability casts to scalar types
authorLuis Machado <luis.machado@arm.com>
Wed, 9 Sep 2020 21:30:10 +0000 (18:30 -0300)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 22:53:22 +0000 (15:53 -0700)
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  <luis.machado@arm.com>

* valops.c (value_cast): Cast from capability to scalar types.

gdb/valops.c

index 3a595125752f0d0c3bef1ee40a62ca36e447fa62..d4e89a3cfa6840ef4988f53cd36f930c40025fd9 100644 (file)
@@ -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)