Atlas - find_symbol.py
Home / ext / kconfiglib / examples Lines: 6 | Size: 3437 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1# Prints all menu nodes that reference a given symbol any of their properties 2# or property conditions, along with their parent menu nodes. 3# 4# Usage: 5# 6# $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/find_symbol.py SCRIPT_ARG=<name> 7# 8# Example output for SCRIPT_ARG=X86: 9# 10# Found 470 locations that reference X86: 11# 12# ========== Location 1 (init/Kconfig:1108) ========== 13# 14# config SGETMASK_SYSCALL 15# bool 16# prompt "sgetmask/ssetmask syscalls support" if EXPERT 17# default PARISC || M68K || PPC || MIPS || X86 || SPARC || MICROBLAZE || SUPERH 18# help 19# sys_sgetmask and sys_ssetmask are obsolete system calls 20# no longer supported in libc but still enabled by default in some 21# architectures. 22# 23# If unsure, leave the default option here. 24# 25# ---------- Parent 1 (init/Kconfig:1077) ---------- 26# 27# menuconfig EXPERT 28# bool 29# prompt "Configure standard kernel features (expert users)" 30# select DEBUG_KERNEL 31# help 32# This option allows certain base kernel options and settings 33# to be disabled or tweaked. This is for specialized 34# environments which can tolerate a "non-standard" kernel. 35# Only use this if you really know what you are doing. 36# 37# ---------- Parent 2 (init/Kconfig:39) ---------- 38# 39# menu "General setup" 40# 41# ========== Location 2 (arch/Kconfig:29) ========== 42# 43# config OPROFILE_EVENT_MULTIPLEX 44# bool 45# prompt "OProfile multiplexing support (EXPERIMENTAL)" 46# default "n" 47# depends on OPROFILE && X86 48# help 49# The number of hardware counters is limited. The multiplexing 50# feature enables OProfile to gather more events than counters 51# are provided by the hardware. This is realized by switching 52# between events at a user specified time interval. 53# 54# If unsure, say N. 55# 56# ---------- Parent 1 (arch/Kconfig:16) ---------- 57# 58# config OPROFILE 59# tristate 60# prompt "OProfile system profiling" 61# select RING_BUFFER 62# select RING_BUFFER_ALLOW_SWAP 63# depends on PROFILING && HAVE_OPROFILE 64# help 65# OProfile is a profiling system capable of profiling the 66# whole system, include the kernel, kernel modules, libraries, 67# and applications. 68# 69# If unsure, say N. 70# 71# ---------- Parent 2 (init/Kconfig:39) ---------- 72# 73# menu "General setup" 74# 75# ... (tons more) 76 77import sys 78 79import kconfiglib 80 81 82if len(sys.argv) < 3: 83 sys.exit('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=<name>') 84 85kconf = kconfiglib.Kconfig(sys.argv[1]) 86sym_name = sys.argv[2] 87if sym_name not in kconf.syms: 88 print("No symbol {} exists in the configuration".format(sym_name)) 89 sys.exit(0) 90 91referencing = [node for node in kconf.node_iter() 92 if kconf.syms[sym_name] in node.referenced] 93if not referencing: 94 print("No references to {} found".format(sym_name)) 95 sys.exit(0) 96 97print("Found {} locations that reference {}:\n" 98 .format(len(referencing), sym_name)) 99 100for i, node in enumerate(referencing, 1): 101 print("========== Location {} ({}:{}) ==========\n\n{}" 102 .format(i, node.filename, node.linenr, node)) 103 104 # Print the parents of the menu node too 105 106 node = node.parent 107 parent_i = 1 108 while node is not kconf.top_node: 109 print("---------- Parent {} ({}:{}) ----------\n\n{}" 110 .format(parent_i, node.filename, node.linenr, node)) 111 node = node.parent 112 parent_i += 1 113[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.