]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add gdbarch methods for printing capabilities.
authorJohn Baldwin <jhb@FreeBSD.org>
Thu, 28 Jul 2022 23:54:21 +0000 (16:54 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 23:43:06 +0000 (16:43 -0700)
gdbarch_print_cap prints a full capability in either verbose or
compat forms.

gdbarch_print_cap_attributes prints just the metadata such as bounds
and permissions of a capability without the address.

gdb/arch-utils.c
gdb/arch-utils.h
gdb/gdbarch-components.py
gdb/gdbarch-gen.h
gdb/gdbarch.c

index b0a10b5e2a6dcbe8eb017886d67728855972e477..e81c4596a3b3c1524eb5d767f9fbb29ea3ee6197 100644 (file)
@@ -1107,6 +1107,24 @@ default_set_cap_tag_from_address (struct gdbarch *gdbarch,
   return;
 }
 
+/* See arch-utils.h.  */
+
+void
+default_print_cap (struct gdbarch *gdbarch, const gdb_byte *contents, bool tag,
+                  bool compact, struct ui_file *stream)
+{
+  return;
+}
+
+/* See arch-utils.h.  */
+
+void
+default_print_cap_attributes (struct gdbarch *gdbarch, const gdb_byte *contents,
+                             bool tag, struct ui_file *stream)
+{
+  return;
+}
+
 /* Static function declarations */
 
 static void alloc_gdbarch_data (struct gdbarch *);
index 334ab5f72871378c673d6a973fbc99b1881eb50f..c665b0b68696ef41b7004f727fe9b7470bc3b33b 100644 (file)
@@ -308,4 +308,15 @@ extern bool default_get_cap_tag_from_address (struct gdbarch *gdbarch,
 /* Default implementation of gdbarch_set_cap_tag_from_address.  */
 extern void default_set_cap_tag_from_address (struct gdbarch *gdbarch,
                                              CORE_ADDR addr, bool tag);
+
+/* Default implementation of gdbarch_print_cap_attributes.  */
+extern void default_print_cap (struct gdbarch *gdbarch,
+                              const gdb_byte *contents, bool tag, bool compact,
+                              struct ui_file *stream);
+
+/* Default implementation of gdbarch_print_cap_attributes.  */
+extern void default_print_cap_attributes (struct gdbarch *gdbarch,
+                                         const gdb_byte *contents, bool tag,
+                                         struct ui_file *stream);
+
 #endif /* ARCH_UTILS_H */
index 44eac608b48b31aa1b4d9ccf570bcf40119da304..2ce2162734fa317d9457da00b679cd949c513c2d 100644 (file)
@@ -1045,6 +1045,38 @@ Set the tag from a capability stored at address ADDR to TAG.
     invalid=False,
 )
 
+Method(
+    comment="""
+Print value of a capability containing CONTENTS and TAG to STREAM.
+""",
+    type="void",
+    name="print_cap",
+    params=[
+        ("const gdb_byte *", "contents"),
+        ("bool", "tag"),
+        ("bool", "compact"),
+        ("struct ui_file *", "stream"),
+    ],
+    predefault="default_print_cap",
+    invalid=False,
+)
+
+Method(
+    comment="""
+Print additional attributes for a capability containing CONTENTS and
+TAG to STREAM.
+""",
+    type="void",
+    name="print_cap_attributes",
+    params=[
+        ("const gdb_byte *", "contents"),
+        ("bool", "tag"),
+        ("struct ui_file *", "stream"),
+    ],
+    predefault="default_print_cap_attributes",
+    invalid=False,
+)
+
 Function(
     comment="""
 Fetch the target specific address used to represent a load module.
index 2be9b2bc37867262d3ba44d52d95ba3f5922267b..5593da3ce81361d2ee3887fc8fc447bd0d79ecda 100644 (file)
@@ -559,6 +559,19 @@ typedef void (gdbarch_set_cap_tag_from_address_ftype) (struct gdbarch *gdbarch,
 extern void gdbarch_set_cap_tag_from_address (struct gdbarch *gdbarch, CORE_ADDR addr, bool tag);
 extern void set_gdbarch_set_cap_tag_from_address (struct gdbarch *gdbarch, gdbarch_set_cap_tag_from_address_ftype *set_cap_tag_from_address);
 
+/* Print value of a capability containing CONTENTS and TAG to STREAM. */
+
+typedef void (gdbarch_print_cap_ftype) (struct gdbarch *gdbarch, const gdb_byte *contents, bool tag, bool compact, struct ui_file *stream);
+extern void gdbarch_print_cap (struct gdbarch *gdbarch, const gdb_byte *contents, bool tag, bool compact, struct ui_file *stream);
+extern void set_gdbarch_print_cap (struct gdbarch *gdbarch, gdbarch_print_cap_ftype *print_cap);
+
+/* Print additional attributes for a capability containing CONTENTS and
+   TAG to STREAM. */
+
+typedef void (gdbarch_print_cap_attributes_ftype) (struct gdbarch *gdbarch, const gdb_byte *contents, bool tag, struct ui_file *stream);
+extern void gdbarch_print_cap_attributes (struct gdbarch *gdbarch, const gdb_byte *contents, bool tag, struct ui_file *stream);
+extern void set_gdbarch_print_cap_attributes (struct gdbarch *gdbarch, gdbarch_print_cap_attributes_ftype *print_cap_attributes);
+
 /* Fetch the target specific address used to represent a load module. */
 
 extern bool gdbarch_fetch_tls_load_module_address_p (struct gdbarch *gdbarch);
index ae9335c71ba4e7825d2b80438928f14c1d4ab2f6..cdd7f76e65777437d9f8dcefce94933d598ce1c0 100644 (file)
@@ -132,6 +132,8 @@ struct gdbarch
   gdbarch_remote_register_number_ftype *remote_register_number;
   gdbarch_get_cap_tag_from_address_ftype *get_cap_tag_from_address;
   gdbarch_set_cap_tag_from_address_ftype *set_cap_tag_from_address;
+  gdbarch_print_cap_ftype *print_cap;
+  gdbarch_print_cap_attributes_ftype *print_cap_attributes;
   gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address;
   gdbarch_get_thread_local_address_ftype *get_thread_local_address;
   CORE_ADDR frame_args_skip;
@@ -330,6 +332,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->remote_register_number = default_remote_register_number;
   gdbarch->get_cap_tag_from_address = default_get_cap_tag_from_address;
   gdbarch->set_cap_tag_from_address = default_set_cap_tag_from_address;
+  gdbarch->print_cap = default_print_cap;
+  gdbarch->print_cap_attributes = default_print_cap_attributes;
   gdbarch->unwind_pc = default_unwind_pc;
   gdbarch->unwind_sp = default_unwind_sp;
   gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
@@ -497,6 +501,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of remote_register_number, invalid_p == 0 */
   /* Skip verify of get_cap_tag_from_address, invalid_p == 0 */
   /* Skip verify of set_cap_tag_from_address, invalid_p == 0 */
+  /* Skip verify of print_cap, invalid_p == 0 */
+  /* Skip verify of print_cap_attributes, invalid_p == 0 */
   /* Skip verify of fetch_tls_load_module_address, has predicate.  */
   /* Skip verify of get_thread_local_address, has predicate.  */
   /* Skip verify of frame_args_skip, invalid_p == 0 */
@@ -952,6 +958,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_filtered (file,
                       "gdbarch_dump: set_cap_tag_from_address = <%s>\n",
                       host_address_to_string (gdbarch->set_cap_tag_from_address));
+  fprintf_filtered (file,
+                      "gdbarch_dump: print_cap = <%s>\n",
+                      host_address_to_string (gdbarch->print_cap));
+  fprintf_filtered (file,
+                      "gdbarch_dump: print_cap_attributes = <%s>\n",
+                      host_address_to_string (gdbarch->print_cap_attributes));
   fprintf_filtered (file,
                       "gdbarch_dump: gdbarch_fetch_tls_load_module_address_p() = %d\n",
                       gdbarch_fetch_tls_load_module_address_p (gdbarch));
@@ -3026,6 +3038,40 @@ set_gdbarch_set_cap_tag_from_address (struct gdbarch *gdbarch,
   gdbarch->set_cap_tag_from_address = set_cap_tag_from_address;
 }
 
+void
+gdbarch_print_cap (struct gdbarch *gdbarch, const gdb_byte *contents, bool tag, bool compact, struct ui_file *stream)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->print_cap != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_print_cap called\n");
+  gdbarch->print_cap (gdbarch, contents, tag, compact, stream);
+}
+
+void
+set_gdbarch_print_cap (struct gdbarch *gdbarch,
+                       gdbarch_print_cap_ftype print_cap)
+{
+  gdbarch->print_cap = print_cap;
+}
+
+void
+gdbarch_print_cap_attributes (struct gdbarch *gdbarch, const gdb_byte *contents, bool tag, struct ui_file *stream)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->print_cap_attributes != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_print_cap_attributes called\n");
+  gdbarch->print_cap_attributes (gdbarch, contents, tag, stream);
+}
+
+void
+set_gdbarch_print_cap_attributes (struct gdbarch *gdbarch,
+                                  gdbarch_print_cap_attributes_ftype print_cap_attributes)
+{
+  gdbarch->print_cap_attributes = print_cap_attributes;
+}
+
 bool
 gdbarch_fetch_tls_load_module_address_p (struct gdbarch *gdbarch)
 {