From: Luis Machado luis.machado@arm.com
When displaying a capability pointer, don't truncate the length of the type.
Also, update the instance flags to mark capability pointers as TYPE_INSTANCE_FLAG_CAPABILITY.
gdb/ChangeLog:
YYYY-MM-DD Luis Machado luis.machado@arm.com
* aarch64-tdep.c (aarch64_address_class_type_flags) (aarch64_address_class_type_flags_to_name) (aarch64_address_class_name_to_type_flags): Use TYPE_INSTANCE_FLAG_CAPABILITY instead of TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1. * gdbtypes.h (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL): Include TYPE_INSTANCE_FLAG_CAPABILITY. * printcmd.c (print_scalar_formatted): Don't truncate capability pointers. --- gdb/aarch64-tdep.c | 6 +++--- gdb/gdbtypes.h | 3 ++- gdb/printcmd.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index c8ca8ac736..6fab1cc2fb 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -3767,7 +3767,7 @@ aarch64_address_class_type_flags (int byte_size, int dwarf2_addr_class) __capability qualifier, meaning a capability for Morello. */
if (dwarf2_addr_class == 1) - return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; + return TYPE_INSTANCE_FLAG_CAPABILITY; return 0; }
@@ -3779,7 +3779,7 @@ static const char* aarch64_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags) { - if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1) + if (type_flags & TYPE_INSTANCE_FLAG_CAPABILITY) return "__capability"; else return NULL; @@ -3796,7 +3796,7 @@ aarch64_address_class_name_to_type_flags (struct gdbarch *gdbarch, { if (strcmp (name, "__capability") == 0) { - *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1; + *type_flags_ptr = TYPE_INSTANCE_FLAG_CAPABILITY; return true; } else diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index fb2062d8d5..a876cebcd1 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -324,7 +324,8 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); #define TYPE_ADDRESS_CLASS_2(t) (((t)->instance_flags ()) \ & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2) #define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \ - (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2) + (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 \ + | TYPE_INSTANCE_FLAG_CAPABILITY) #define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \ & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c index f9b42cfda7..c0e59301db 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -362,7 +362,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, /* If the value is a pointer, and pointers and addresses are not the same, then at this point, the value's length (in target bytes) is gdbarch_addr_bit/TARGET_CHAR_BIT, not TYPE_LENGTH (type). */ - if (type->code () == TYPE_CODE_PTR) + if (type->code () == TYPE_CODE_PTR && !TYPE_CAPABILITY (type)) len = gdbarch_addr_bit (gdbarch) / TARGET_CHAR_BIT;
/* If we are printing it as unsigned, truncate it in case it is actually