From: Tom Tromey Date: Wed, 21 Jan 2026 19:27:44 +0000 (-0700) Subject: Mark some gdbarch components as "unused" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=614e12ef652d0e05906599dfb519c7171904c481;p=thirdparty%2Fbinutils-gdb.git Mark some gdbarch components as "unused" 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. --- diff --git a/gdb/check-gdbarch.py b/gdb/check-gdbarch.py index 3c68fd9cdef..3d6f3deca57 100755 --- a/gdb/check-gdbarch.py +++ b/gdb/check-gdbarch.py @@ -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!") diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 6e765e93155..46283c1bd7d 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -48,6 +48,10 @@ # *'. 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( diff --git a/gdb/gdbarch_types.py b/gdb/gdbarch_types.py index 02c81c5ddb9..f2a40e1444c 100644 --- a/gdb/gdbarch_types.py +++ b/gdb/gdbarch_types.py @@ -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):