Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/gdb: fix 'lx-lsmod' show the wrong size

'lsmod' shows total core layout size, so we need to sum up all the
sections in core layout in gdb scripts.

/ # lsmod
kasan_test 200704 0 - Live 0xffff80007f640000

Before patch:
(gdb) lx-lsmod
Address Module Size Used by
0xffff80007f640000 kasan_test 36864 0

After patch:
(gdb) lx-lsmod
Address Module Size Used by
0xffff80007f640000 kasan_test 200704 0

Link: https://lkml.kernel.org/r/20230710092852.31049-1-Kuan-Ying.Lee@mediatek.com
Fixes: b4aff7513df3 ("scripts/gdb: use mem instead of core_layout to get the module address")
Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kuan-Ying Lee and committed by
Andrew Morton
fb40b053 02d7f74a

+12 -3
+3
scripts/gdb/linux/constants.py.in
··· 64 64 65 65 /* linux/module.h */ 66 66 LX_GDBPARSED(MOD_TEXT) 67 + LX_GDBPARSED(MOD_DATA) 68 + LX_GDBPARSED(MOD_RODATA) 69 + LX_GDBPARSED(MOD_RO_AFTER_INIT) 67 70 68 71 /* linux/mount.h */ 69 72 LX_VALUE(MNT_NOSUID)
+9 -3
scripts/gdb/linux/modules.py
··· 73 73 " " if utils.get_long_type().sizeof == 8 else "")) 74 74 75 75 for module in module_list(): 76 - layout = module['mem'][constants.LX_MOD_TEXT] 76 + text = module['mem'][constants.LX_MOD_TEXT] 77 + text_addr = str(text['base']).split()[0] 78 + total_size = 0 79 + 80 + for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1): 81 + total_size += module['mem'][i]['size'] 82 + 77 83 gdb.write("{address} {name:<19} {size:>8} {ref}".format( 78 - address=str(layout['base']).split()[0], 84 + address=text_addr, 79 85 name=module['name'].string(), 80 - size=str(layout['size']), 86 + size=str(total_size), 81 87 ref=str(module['refcnt']['counter'] - 1))) 82 88 83 89 t = self._module_use_type.get_type().pointer()