From 73f3aa500431c13c76392f5376384c91c43e5d80 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 31 Aug 2022 10:29:27 -0700 Subject: 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. --- gdb/printcmd.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 751a43f4d3d..1617216778d 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); -- cgit v1.2.1