+2020-11-11 Luis Machado <luis.machado@arm.com>
+
+ * c-valprint.c (c_value_print_ptr): Adjust to print capability
+ pointers as capabilities.
+ (c_value_print_inner): Handle TYPE_CODE_CAPABILITY.
+ * findvar.c (extract_integer): Truncate scalars instead of erroring out.
+ * valprint.c (generic_value_print_capability): Make non-static and
+ print additional space.
+ * valprint.h (generic_value_print_capability): New prototype.
+
2020-11-11 Luis Machado <luis.machado@arm.com>
* valprint.c (generic_value_print_capability): Use compact form.
c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse,
const struct value_print_options *options)
{
+ struct type *type = check_typedef (value_type (val));
+
+ /* If we have a pointer to a capability, handle it as a capability. */
+ if (options->format == 0 && (type->code () == TYPE_CODE_PTR
+ && TYPE_CAPABILITY (type)))
+ generic_value_print_capability (val, stream, options);
+
if (options->format && options->format != 's')
{
value_print_scalar_formatted (val, options, 0, stream);
return;
}
- struct type *type = check_typedef (value_type (val));
struct gdbarch *arch = get_type_arch (type);
const gdb_byte *valaddr = value_contents_for_printing (val);
case TYPE_CODE_UNDEF:
case TYPE_CODE_COMPLEX:
case TYPE_CODE_CHAR:
+ case TYPE_CODE_CAPABILITY:
default:
generic_value_print (val, stream, recurse, options, &c_decorations);
break;
/* Basic byte-swapping routines. All 'extract' functions return a
host-format integer from a target-format integer at ADDR which is
- LEN bytes long. */
+ LEN bytes long.
+
+ FIXME-Morello: This is a temporary hack to address GDB's inability to cope
+ with 128-bit scalar types. Instead of erroring out and giving up, just
+ truncate the scalar to the size of T. */
#if TARGET_CHAR_BIT != 8 || HOST_CHAR_BIT != 8
/* 8 bit characters are a pretty safe assumption these days, so we
typename std::make_unsigned<T>::type retval = 0;
const unsigned char *p;
const unsigned char *startaddr = addr;
+ size_t max_len = (len > sizeof (T))? sizeof (T) : len;
const unsigned char *endaddr = startaddr + len;
- if (len > (int) sizeof (T))
- error (_("\
-That operation is not available on integers of more than %d bytes."),
- (int) sizeof (T));
-
/* Start at the most significant end of the integer, and work towards
the least significant. */
if (byte_order == BFD_ENDIAN_BIG)
{
- p = startaddr;
+ p = endaddr - max_len;
if (std::is_signed<T>::value)
{
/* Do the sign extension once at the start. */
}
else
{
- p = endaddr - 1;
+ p = startaddr + max_len - 1;
if (std::is_signed<T>::value)
{
/* Do the sign extension once at the start. */
/* generic_value_print helper for TYPE_CODE_CAPABILITY. */
-static void
+void
generic_value_print_capability (struct value *val, struct ui_file *stream,
const struct value_print_options *options)
{
uint128_t dummy_cap;
memcpy (&dummy_cap, contents, length);
capability cap (dummy_cap, tag);
- fprintf_filtered (stream, "%s", cap.to_str (true).c_str ());
+ fprintf_filtered (stream, "%s ", cap.to_str (true).c_str ());
}
return;
int quote_char, int c_style_terminator,
const struct value_print_options *options);
+extern void generic_value_print_capability (struct value *val,
+ struct ui_file *stream,
+ const struct value_print_options *options);
+
/* Run the "output" command. ARGS and FROM_TTY are the usual
arguments passed to all command implementations, except ARGS is
const. */