summaryrefslogtreecommitdiff
path: root/scripts/lib/abi/abi_parser.py
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2025-02-10 13:18:00 +0300
committerJonathan Corbet <corbet@lwn.net>2025-02-10 21:19:56 +0300
commit6b48bea16848dd7c771411db3dcc01b3bc4dd4c2 (patch)
treea2a8892dcc26e505286376e91606c39d9705a6e8 /scripts/lib/abi/abi_parser.py
parent484e9aa6efaf96a7a5b5fe3216f24973166fbfe3 (diff)
downloadlinux-6b48bea16848dd7c771411db3dcc01b3bc4dd4c2.tar.xz
scripts/get_abi.py: add support for symbol search
Add support for searching symbols from Documentation/ABI using regular expressions to match the symbols' names. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/21b2c48657dde112d5417dcd7e0aa7cd383b9a0a.1739182025.git.mchehab+huawei@kernel.org
Diffstat (limited to 'scripts/lib/abi/abi_parser.py')
-rw-r--r--scripts/lib/abi/abi_parser.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/lib/abi/abi_parser.py b/scripts/lib/abi/abi_parser.py
index b3fa70eee412..bea7f1a76165 100644
--- a/scripts/lib/abi/abi_parser.py
+++ b/scripts/lib/abi/abi_parser.py
@@ -510,3 +510,55 @@ class AbiParser:
f.append(f"{fname} lines {", ".join(str(x) for x in lines)}")
self.log.warning("%s is defined %d times: %s", what, len(f), "; ".join(f))
+
+ def search_symbols(self, expr):
+ """ Searches for ABI symbols """
+
+ regex = re.compile(expr, re.I)
+
+ found_keys = 0
+ for t in sorted(self.data.items(), key=lambda x: [0]):
+ v = t[1]
+
+ wtype = v.get("type", "")
+ if wtype == "File":
+ continue
+
+ for what in v.get("what", [""]):
+ if regex.search(what):
+ found_keys += 1
+
+ kernelversion = v.get("kernelversion", "").strip(" \t\n")
+ date = v.get("date", "").strip(" \t\n")
+ contact = v.get("contact", "").strip(" \t\n")
+ users = v.get("users", "").strip(" \t\n")
+ desc = v.get("description", "").strip(" \t\n")
+
+ files = []
+ for f in v.get("file", ()):
+ files.append(f[0])
+
+ what = str(found_keys) + ". " + what
+ title_tag = "-" * len(what)
+
+ print(f"\n{what}\n{title_tag}\n")
+
+ if kernelversion:
+ print(f"Kernel version:\t\t{kernelversion}")
+
+ if date:
+ print(f"Date:\t\t\t{date}")
+
+ if contact:
+ print(f"Contact:\t\t{contact}")
+
+ if users:
+ print(f"Users:\t\t\t{users}")
+
+ print(f"Defined on file{'s'[:len(files) ^ 1]}:\t{", ".join(files)}")
+
+ if desc:
+ print(f"\n{desc.strip("\n")}\n")
+
+ if not found_keys:
+ print(f"Regular expression /{expr}/ not found.")