case TYPE_CODE_NAMESPACE:
case TYPE_CODE_DECFLOAT:
case TYPE_CODE_FIXED_POINT:
+ case TYPE_CODE_CAPABILITY:
/* These types need no prefix. They are listed here so that
gcc -Wall will reveal any types that haven't been handled. */
break;
case TYPE_CODE_NAMESPACE:
case TYPE_CODE_DECFLOAT:
case TYPE_CODE_FIXED_POINT:
+ case TYPE_CODE_CAPABILITY:
/* These types do not need a suffix. They are listed so that
gcc -Wall will report types that may not have been
considered. */
break;
case DW_ATE_CHERI_signed_intcap:
+ type = init_capability_type (objfile, bits, false, name);
+ break;
case DW_ATE_CHERI_unsigned_intcap:
- {
- /* Turn DW_ATE_CHERI_*_intcap into a void * pointer. */
- type = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL);
- type = init_pointer_type (objfile, bits, name, type);
+ type = init_capability_type (objfile, bits, true, name);
break;
- }
default:
complaint (_("unsupported DW_AT_encoding: '%s'"),
return t;
}
+/* Allocate a TYPE_CODE_CAPABILITY type structure associated with OBJFILE.
+ BIT is the type size in bits. If UNSIGNED_P is non-zero, set
+ the type's TYPE_UNSIGNED flag. NAME is the type name. */
+
+struct type *
+init_capability_type (struct objfile *objfile,
+ int bit, bool unsigned_p, const char *name)
+{
+ struct type *t;
+
+ t = init_type (objfile, TYPE_CODE_CAPABILITY, bit, name);
+ t->set_is_unsigned (unsigned_p);
+
+ return t;
+}
+
/* See gdbtypes.h. */
unsigned
switch (type->code ())
{
case TYPE_CODE_PTR:
+ case TYPE_CODE_CAPABILITY:
case TYPE_CODE_FUNC:
case TYPE_CODE_FLAGS:
case TYPE_CODE_INT:
case TYPE_CODE_FIXED_POINT:
printf_filtered ("(TYPE_CODE_FIXED_POINT)");
break;
+ case TYPE_CODE_CAPABILITY:
+ printf_filtered ("(TYPE_CODE_CAPABILITY)");
+ break;
default:
printf_filtered ("(UNKNOWN TYPE CODE)");
break;
return t;
}
+/* Allocate a TYPE_CODE_CAPABILITY type structure associated with GDBARCH.
+ BIT is the type size in bits. If UNSIGNED_P is non-zero, set
+ the type's TYPE_UNSIGNED flag. NAME is the type name. */
+
+struct type *
+arch_capability_type (struct gdbarch *gdbarch,
+ int bit, bool unsigned_p, const char *name)
+{
+ struct type *t;
+
+ t = arch_type (gdbarch, TYPE_CODE_CAPABILITY, bit, name);
+ t->set_is_unsigned (unsigned_p);
+ return t;
+}
+
/* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH.
NAME is the type name. BIT is the size of the flag word in bits. */
/* Capability types. */
builtin_type->builtin_intcap_t
- = arch_integer_type (gdbarch, 128, 0, "__intcap_t");
+ = arch_capability_type (gdbarch, 128, 0, "__intcap_t");
builtin_type->builtin_uintcap_t
- = arch_integer_type (gdbarch, 128, 1, "__uintcap_t");
+ = arch_capability_type (gdbarch, 128, 1, "__uintcap_t");
/* Capability pointer types. */
builtin_type->builtin_data_addr_capability
struct type *);
extern struct type *init_fixed_point_type (struct objfile *, int, int,
const char *);
+extern struct type *init_capability_type (struct objfile *objfile, int bit,
+ bool unsigned_p, const char *name);
/* Helper functions to construct architecture-owned types. */
extern struct type *arch_type (struct gdbarch *, enum type_code, int,
extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *);
extern struct type *arch_pointer_type (struct gdbarch *, int, const char *,
struct type *);
+extern struct type *arch_capability_type (struct gdbarch *gdbarch, int bit,
+ bool unsigned_p, const char *name);
/* Helper functions to construct a struct or record type. An
initially empty type is created using arch_composite_type().
#include "gdbsupport/selftest.h"
#include "selftest-arch.h"
+#include "gdbsupport/capability.h"
+
/* Maximum number of wchars returned from wchar_iterate. */
#define MAX_WCHARS 4
}
}
+/* generic_value_print helper for TYPE_CODE_CAPABILITY. */
+
+static void
+generic_value_print_capability (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
+{
+ struct type *type = check_typedef (value_type (val));
+ int length = TYPE_LENGTH (type);
+ const gdb_byte *contents = value_contents_for_printing (val).data ();
+ enum bfd_endian byte_order = type_byte_order (type);
+
+ if (options->format && options->format == 'x')
+ print_hex_chars (stream, contents, length, byte_order, 0);
+ else
+ {
+ uint128_t dummy_cap;
+ memcpy (&dummy_cap, contents, length);
+ capability cap (dummy_cap, false);
+ fprintf_filtered (stream, "%s", cap.to_str ().c_str ());
+ }
+
+ return;
+}
/* Print '@' followed by the address contained in ADDRESS_BUFFER. */
generic_value_print_ptr (val, stream, options);
break;
+ case TYPE_CODE_CAPABILITY:
+ generic_value_print_capability (val, stream, options);
+ break;
+
case TYPE_CODE_REF:
case TYPE_CODE_RVALUE_REF:
generic_val_print_ref (type, 0, stream, recurse,