tools/docs/get_abi.py
Source file repositories/reference/linux-study-clean/tools/docs/get_abi.py
File Facts
- System
- Linux kernel
- Corpus path
tools/docs/get_abi.py- Extension
.py- Size
- 7346 bytes
- Lines
- 215
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# pylint: disable=R0903
# Copyright(c) 2025: Mauro Carvalho Chehab <mchehab@kernel.org>.
# SPDX-License-Identifier: GPL-2.0
"""
Parse ABI documentation and produce results from it.
"""
import argparse
import logging
import os
import sys
# Import Python modules
LIB_DIR = "../lib/python"
SRC_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
from abi.abi_parser import AbiParser # pylint: disable=C0413
from abi.abi_regex import AbiRegex # pylint: disable=C0413
from abi.helpers import ABI_DIR, DEBUG_HELP # pylint: disable=C0413
from abi.system_symbols import SystemSymbols # pylint: disable=C0413
# Command line classes
REST_DESC = """
Produce output in ReST format.
The output is done on two sections:
- Symbols: show all parsed symbols in alphabetic order;
- Files: cross reference the content of each file with the symbols on it.
"""
class AbiRest:
"""Initialize an argparse subparser for rest output"""
def __init__(self, subparsers):
"""Initialize argparse subparsers"""
parser = subparsers.add_parser("rest",
formatter_class=argparse.RawTextHelpFormatter,
description=REST_DESC)
parser.add_argument("--enable-lineno", action="store_true",
help="enable lineno")
parser.add_argument("--raw", action="store_true",
help="output text as contained in the ABI files. "
"It not used, output will contain dynamically"
" generated cross references when possible.")
parser.add_argument("--no-file", action="store_true",
help="Don't the files section")
parser.add_argument("--show-hints", help="Show-hints")
parser.set_defaults(func=self.run)
def run(self, args):
"""Run subparser"""
parser = AbiParser(args.dir, debug=args.debug)
parser.parse_abi()
parser.check_issues()
for t in parser.doc(args.raw, not args.no_file):
if args.enable_lineno:
print (f".. LINENO {t[1]}#{t[2]}\n\n")
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.