]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Mark some gdbarch components as "unused"
authorTom Tromey <tom@tromey.com>
Wed, 21 Jan 2026 19:27:44 +0000 (12:27 -0700)
committerTom Tromey <tom@tromey.com>
Sat, 7 Feb 2026 14:56:29 +0000 (07:56 -0700)
This adds a new "unused" attribute to gdbarch components, and marks a
few this way.  The only goal of this patch is to make it so that
check-gdbarch.py gives an empty report by default.

gdb/check-gdbarch.py
gdb/gdbarch_components.py
gdb/gdbarch_types.py

index 3c68fd9cdef9df0e78c80aa435715b619a5ed86d..3d6f3deca570abae9f50874e556344e83b55be1b 100755 (executable)
@@ -50,6 +50,8 @@ called_names = set()
 for c in filter(not_info, components):
     if c.implement:
         defined_names.add(c.name)
+    if c.unused:
+        set_names.add(c.name)
     if c.predicate:
         # Predicates are always "set".
         pname = c.name + "_p"
@@ -91,7 +93,13 @@ for filename in tqdm.tqdm(files, desc="Scanning", leave=False):
                     called_names.add(m[2])
 
 
+printed = False
 for elt in sorted(defined_names - set_names):
+    printed = True
     print(f"never set: {elt}")
 for elt in sorted(defined_names - called_names):
+    printed = True
     print(f"never called: {elt}")
+
+if not printed:
+    print("Everything ok!")
index 6e765e9315514d47a1bc6348adb700a535b21bfc..46283c1bd7d436cf82bcde4a22073234e46a9a2e 100644 (file)
 # *'.  This is used for dumping.  The string must live long enough to
 # be passed to printf.
 #
+# * "unused" - a boolean.  If true, the hook is known to be unused, we
+# but agreed to keep it around nevertheless.  check-gdbarch.py uses
+# this.  This should be used sparingly, if at all.
+#
 # Value, Function, and Method share some more parameters.  Some of
 # these work in conjunction in a somewhat complicated way, so they are
 # described in a separate sub-section below.
@@ -195,6 +199,8 @@ useful).
     name="bfloat16_bit",
     predefault="2*TARGET_CHAR_BIT",
     invalid=False,
+    # Currently unused but we wanted to keep this hook around.
+    unused=True,
 )
 
 Value(
@@ -210,6 +216,8 @@ Value(
     name="half_bit",
     predefault="2*TARGET_CHAR_BIT",
     invalid=False,
+    # Currently unused but we wanted to keep this hook around.
+    unused=True,
 )
 
 Value(
@@ -2122,6 +2130,8 @@ on the architecture's assembly.
     name="stap_integer_suffixes",
     invalid=False,
     printer="pstring_list (gdbarch->stap_integer_suffixes)",
+    # Currently unused but we wanted to keep this hook around.
+    unused=True,
 )
 
 Value(
@@ -2149,6 +2159,8 @@ the architecture's assembly.
     name="stap_register_suffixes",
     invalid=False,
     printer="pstring_list (gdbarch->stap_register_suffixes)",
+    # Currently unused but we wanted to keep this hook around.
+    unused=True,
 )
 
 Value(
@@ -2202,6 +2214,8 @@ register would be represented as `r10' internally.
     name="stap_gdb_register_prefix",
     invalid=False,
     printer="pstring (gdbarch->stap_gdb_register_prefix)",
+    # Currently unused but we wanted to keep this hook around.
+    unused=True,
 )
 
 Value(
@@ -2212,6 +2226,8 @@ Suffix used to name a register using GDB's nomenclature.
     name="stap_gdb_register_suffix",
     invalid=False,
     printer="pstring (gdbarch->stap_gdb_register_suffix)",
+    # Currently unused but we wanted to keep this hook around.
+    unused=True,
 )
 
 Method(
@@ -2640,6 +2656,8 @@ each address in memory.
     params=[],
     predefault="default_addressable_memory_unit_size",
     invalid=False,
+    # Currently unused but we wanted to keep this hook around.
+    unused=True,
 )
 
 Value(
index 02c81c5ddb9a15a804414bd547eea5251e54af2e..f2a40e1444cb82b5a2a813be4771353adcf20bdd 100644 (file)
@@ -51,6 +51,7 @@ class Component:
         param_checks: Optional[List[str]] = None,
         result_checks: Optional[List[str]] = None,
         implement: bool = True,
+        unused: bool = False,
     ):
         self.name = name
         self.type = type
@@ -64,6 +65,7 @@ class Component:
         self.param_checks = param_checks
         self.result_checks = result_checks
         self.implement = implement
+        self.unused = unused
 
         components.append(self)
 
@@ -99,6 +101,7 @@ class Value(Component):
         postdefault: Optional[str] = None,
         invalid: Union[bool, str] = True,
         printer: Optional[str] = None,
+        unused: bool = False,
     ):
         super().__init__(
             comment=comment,
@@ -109,6 +112,7 @@ class Value(Component):
             postdefault=postdefault,
             invalid=invalid,
             printer=printer,
+            unused=unused,
         )
 
 
@@ -130,6 +134,7 @@ class Function(Component):
         param_checks: Optional[List[str]] = None,
         result_checks: Optional[List[str]] = None,
         implement: bool = True,
+        unused: bool = False,
     ):
         super().__init__(
             comment=comment,
@@ -144,6 +149,7 @@ class Function(Component):
             param_checks=param_checks,
             result_checks=result_checks,
             implement=implement,
+            unused=unused,
         )
 
     def ftype(self):