aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-08-31 10:29:27 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2022-09-01 16:47:42 -0700
commit73f3aa500431c13c76392f5376384c91c43e5d80 (patch)
tree788ccbdadcc3cb66ad877ba70a0d6aa809b1c83c
parent9871dc5976ded0788d8fb69acd78f14e64751d2e (diff)
downloadfsf-binutils-gdb-73f3aa500431c13c76392f5376384c91c43e5d80.zip
fsf-binutils-gdb-73f3aa500431c13c76392f5376384c91c43e5d80.tar.gz
fsf-binutils-gdb-73f3aa500431c13c76392f5376384c91c43e5d80.tar.bz2
eXamine: Update to support capabilities.
- For the address ('a') size, pick a suitable size corresponding to ptraddr_t for pure capability ABIs. - Add a new 'C' size flag that prints memory as capabilities, either in the default compact format, or as hex via 'x'. The hex format does not yet include tags.
-rw-r--r--gdb/printcmd.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 751a43f..1617216 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -213,7 +213,7 @@ decode_format (const char **string_ptr, int oformat, int osize)
while (1)
{
- if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
+ if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g' || *p == 'C')
val.size = *p++;
else if (*p == 'r')
{
@@ -280,6 +280,10 @@ decode_format (const char **string_ptr, int oformat, int osize)
val.size = osize;
}
+ /* Capabilities only support 'x' and default formats. */
+ if (val.size == 'C' && val.format != 'x')
+ val.format = 0;
+
return val;
}
@@ -418,6 +422,9 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
case 'g':
newlen = 8;
break;
+ case 'C':
+ newlen = gdbarch_capability_bit (gdbarch) / TARGET_CHAR_BIT;
+ break;
default:
error (_("Undefined output size \"%c\"."), size);
}
@@ -1020,12 +1027,18 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
if (size == 'a')
{
/* Pick the appropriate size for an address. */
- if (gdbarch_ptr_bit (next_gdbarch) == 64)
+ if (gdbarch_capability_bit (next_gdbarch) == 128)
+ size = 'g';
+ else if (gdbarch_capability_bit (next_gdbarch) == 64)
+ size = 'w';
+ else if (gdbarch_ptr_bit (next_gdbarch) == 64)
size = 'g';
else if (gdbarch_ptr_bit (next_gdbarch) == 32)
size = 'w';
else if (gdbarch_ptr_bit (next_gdbarch) == 16)
size = 'h';
+ else if (gdbarch_capability_bit (next_gdbarch) == 128)
+ size = 'g';
else
/* Bad value for gdbarch_ptr_bit. */
internal_error (__FILE__, __LINE__,
@@ -1040,6 +1053,8 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
val_type = builtin_type (next_gdbarch)->builtin_int32;
else if (size == 'g')
val_type = builtin_type (next_gdbarch)->builtin_int64;
+ else if (size == 'C')
+ val_type = builtin_type (next_gdbarch)->builtin_intcap_t;
if (format == 's')
{
@@ -1068,7 +1083,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
maxelts = 4;
if (size == 'g')
maxelts = 2;
- if (format == 's' || format == 'i')
+ if (format == 's' || format == 'i' || size == 'C')
maxelts = 1;
get_formatted_print_options (&opts, format);