aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb/linux/modules.py
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2015-02-17 16:47:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 17:34:54 -0500
commit5403727f985ba39967c899a56fff5bbd2c9a9f36 (patch)
tree01baa4cd5fd18c4b544c881e1a744cc8103ddf7d /scripts/gdb/linux/modules.py
parent3d4cd9c94191f60cbb741cfbaa770d442c4680aa (diff)
scripts/gdb: add lx-lsmod command
This adds a lsmod-like command to list all currently loaded modules of the target. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Ben Widawsky <ben@bwidawsk.net> Cc: Borislav Petkov <bp@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/gdb/linux/modules.py')
-rw-r--r--scripts/gdb/linux/modules.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index 531f7632d03f..e7c99e9c9620 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -13,7 +13,7 @@
13 13
14import gdb 14import gdb
15 15
16from linux import utils 16from linux import cpus, utils
17 17
18 18
19module_type = utils.CachedType("struct module") 19module_type = utils.CachedType("struct module")
@@ -65,3 +65,47 @@ of the target and return that module variable which MODULE matches."""
65 65
66 66
67LxModule() 67LxModule()
68
69
70class LxLsmod(gdb.Command):
71 """List currently loaded modules."""
72
73 _module_use_type = utils.CachedType("struct module_use")
74
75 def __init__(self):
76 super(LxLsmod, self).__init__("lx-lsmod", gdb.COMMAND_DATA)
77
78 def invoke(self, arg, from_tty):
79 gdb.write(
80 "Address{0} Module Size Used by\n".format(
81 " " if utils.get_long_type().sizeof == 8 else ""))
82
83 for module in ModuleList():
84 ref = 0
85 module_refptr = module['refptr']
86 for cpu in cpus.CpuList("cpu_possible_mask"):
87 refptr = cpus.per_cpu(module_refptr, cpu)
88 ref += refptr['incs']
89 ref -= refptr['decs']
90
91 gdb.write("{address} {name:<19} {size:>8} {ref}".format(
92 address=str(module['module_core']).split()[0],
93 name=module['name'].string(),
94 size=module['core_size'],
95 ref=ref))
96
97 source_list = module['source_list']
98 t = self._module_use_type.get_type().pointer()
99 entry = source_list['next']
100 first = True
101 while entry != source_list.address:
102 use = utils.container_of(entry, t, "source_list")
103 gdb.write("{separator}{name}".format(
104 separator=" " if first else ",",
105 name=use['source']['name'].string()))
106 first = False
107 entry = entry['next']
108 gdb.write("\n")
109
110
111LxLsmod()