Skip to contentSkip to conversation

scripts/gdb: fix lx-lsmod refcnt

PATCH In review Adrien Schildknecht 2 participants 2 messages May 20, 2015 – May 22, 2015 GDB kernel debugging helper scripts

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/gdb: fix lx-lsmod refcnt

Commit 2f35c41f58a9 ("module: Replace module_ref with atomic_t refcnt") changes the way refcnt is handled but did not update the gdb script to use the new variable.

Since refcnt is not per-cpu anymore, we can directly read its value.

---
 scripts/gdb/linux/modules.py | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
scripts/gdb/linux/modules.py +1 -8
index a1504c4..25db8cf 100644
@@ -73,18 +73,11 @@ class LxLsmod(gdb.Command):
                 "        " if utils.get_long_type().sizeof == 8 else ""))
 
         for module in module_list():
-            ref = 0
-            module_refptr = module['refptr']
-            for cpu in cpus.cpu_list("cpu_possible_mask"):
-                refptr = cpus.per_cpu(module_refptr, cpu)
-                ref += refptr['incs']
-                ref -= refptr['decs']
-
             gdb.write("{address} {name:<19} {size:>8}  {ref}".format(
                 address=str(module['module_core']).split()[0],
                 name=module['name'].string(),
                 size=str(module['core_size']),
-                ref=str(ref)))
+                ref=str(module['refcnt']['counter'])))
 
             source_list = module['source_list']
             t = self._module_use_type.get_type().pointer()
Signature · 1 line
2.4.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Adrien Schildknecht

Commit 2f35c41f58a9 ("module: Replace module_ref with atomic_t refcnt") changes the way refcnt is handled but did not update the gdb script to use the new variable.

Since refcnt is not per-cpu anymore, we can directly read its value.

---
 scripts/gdb/linux/modules.py | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
scripts/gdb/linux/modules.py +0 -6
index a1504c4..25db8cf 100644
@@ -73,18 +73,11 @@ class LxLsmod(gdb.Command):
                 "        " if utils.get_long_type().sizeof == 8 else ""))
 
         for module in module_list():
-            ref = 0
-            module_refptr = module['refptr']
-            for cpu in cpus.cpu_list("cpu_possible_mask"):
-                refptr = cpus.per_cpu(module_refptr, cpu)
-                ref += refptr['incs']
-                ref -= refptr['decs']

scripts/gdb/linux/modules.py class LxLsmod(gdb.Command): · line 83

Quoted 10 lines
scripts/gdb/linux/modules.py +1 -2
-
             gdb.write("{address} {name:<19} {size:>8}  {ref}".format(
                 address=str(module['module_core']).split()[0],
                 name=module['name'].string(),
                 size=str(module['core_size']),
-                ref=str(ref)))
+                ref=str(module['refcnt']['counter'])))
 
             source_list = module['source_list']
             t = self._module_use_type.get_type().pointer()

Thanks for fixing!

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux