* [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size @ 2023-06-20 9:48 ` Kuan-Ying Lee 2023-06-30 1:01 ` Kuan-Ying Lee (李冠穎) 2023-07-04 12:11 ` Pankaj Raghav 0 siblings, 2 replies; 4+ messages in thread From: Kuan-Ying Lee @ 2023-06-20 9:48 UTC (permalink / raw) To: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Luis Chamberlain, Pankaj Raghav Cc: chinwen.chang, qun-wei.lin, linux-mm, andrew.yang, Kuan-Ying Lee, linux-kernel, linux-arm-kernel, linux-mediatek '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 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> --- scripts/gdb/linux/constants.py.in | 3 +++ scripts/gdb/linux/modules.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in index 50a92c4e9984..fab74ca9df6f 100644 --- a/scripts/gdb/linux/constants.py.in +++ b/scripts/gdb/linux/constants.py.in @@ -64,6 +64,9 @@ LX_GDBPARSED(IRQ_HIDDEN) /* linux/module.h */ LX_GDBPARSED(MOD_TEXT) +LX_GDBPARSED(MOD_DATA) +LX_GDBPARSED(MOD_RODATA) +LX_GDBPARSED(MOD_RO_AFTER_INIT) /* linux/mount.h */ LX_VALUE(MNT_NOSUID) diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 261f28640f4c..84933c4c1083 100644 --- a/scripts/gdb/linux/modules.py +++ b/scripts/gdb/linux/modules.py @@ -73,11 +73,17 @@ class LxLsmod(gdb.Command): " " if utils.get_long_type().sizeof == 8 else "")) for module in module_list(): - layout = module['mem'][constants.LX_MOD_TEXT] + total_size = 0 + for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1): + layout = module['mem'][i] + if i == constants.LX_MOD_TEXT: + text_addr = str(layout['base']).split()[0] + total_size += layout['size'] + gdb.write("{address} {name:<19} {size:>8} {ref}".format( - address=str(layout['base']).split()[0], + address=text_addr, name=module['name'].string(), - size=str(layout['size']), + size=str(total_size), ref=str(module['refcnt']['counter'] - 1))) t = self._module_use_type.get_type().pointer() -- 2.18.0 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size 2023-06-20 9:48 ` [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size Kuan-Ying Lee @ 2023-06-30 1:01 ` Kuan-Ying Lee (李冠穎) 2023-07-04 12:11 ` Pankaj Raghav 1 sibling, 0 replies; 4+ messages in thread From: Kuan-Ying Lee (李冠穎) @ 2023-06-30 1:01 UTC (permalink / raw) To: matthias.bgg, p.raghav, kbingham, angelogioacchino.delregno, jan.kiszka, mcgrof Cc: Andrew Yang (楊智強), linux-kernel, linux-mediatek, Qun-wei Lin (林群崴), linux-modules, linux-mm, Chinwen Chang (張錦文), linux-arm-kernel Kindly ping, any comment? Cc linux-modules. Thanks, Kuan-Ying Lee On Tue, 2023-06-20 at 17:48 +0800, Kuan-Ying Lee wrote: > '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 > > 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> > --- > scripts/gdb/linux/constants.py.in | 3 +++ > scripts/gdb/linux/modules.py | 12 +++++++++--- > 2 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/scripts/gdb/linux/constants.py.in > b/scripts/gdb/linux/constants.py.in > index 50a92c4e9984..fab74ca9df6f 100644 > --- a/scripts/gdb/linux/constants.py.in > +++ b/scripts/gdb/linux/constants.py.in > @@ -64,6 +64,9 @@ LX_GDBPARSED(IRQ_HIDDEN) > > /* linux/module.h */ > LX_GDBPARSED(MOD_TEXT) > +LX_GDBPARSED(MOD_DATA) > +LX_GDBPARSED(MOD_RODATA) > +LX_GDBPARSED(MOD_RO_AFTER_INIT) > > /* linux/mount.h */ > LX_VALUE(MNT_NOSUID) > diff --git a/scripts/gdb/linux/modules.py > b/scripts/gdb/linux/modules.py > index 261f28640f4c..84933c4c1083 100644 > --- a/scripts/gdb/linux/modules.py > +++ b/scripts/gdb/linux/modules.py > @@ -73,11 +73,17 @@ class LxLsmod(gdb.Command): > " " if utils.get_long_type().sizeof == 8 else > "")) > > for module in module_list(): > - layout = module['mem'][constants.LX_MOD_TEXT] > + total_size = 0 > + for i in range(constants.LX_MOD_TEXT, > constants.LX_MOD_RO_AFTER_INIT + 1): > + layout = module['mem'][i] > + if i == constants.LX_MOD_TEXT: > + text_addr = str(layout['base']).split()[0] > + total_size += layout['size'] > + > gdb.write("{address} {name:<19} > {size:>8} {ref}".format( > - address=str(layout['base']).split()[0], > + address=text_addr, > name=module['name'].string(), > - size=str(layout['size']), > + size=str(total_size), > ref=str(module['refcnt']['counter'] - 1))) > > t = self._module_use_type.get_type().pointer() > -- > 2.18.0 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size 2023-06-20 9:48 ` [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size Kuan-Ying Lee 2023-06-30 1:01 ` Kuan-Ying Lee (李冠穎) @ 2023-07-04 12:11 ` Pankaj Raghav 2023-07-10 8:51 ` Kuan-Ying Lee (李冠穎) 1 sibling, 1 reply; 4+ messages in thread From: Pankaj Raghav @ 2023-07-04 12:11 UTC (permalink / raw) To: Kuan-Ying Lee, Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Luis Chamberlain Cc: chinwen.chang, qun-wei.lin, linux-mm, andrew.yang, linux-kernel, linux-arm-kernel, linux-mediatek > '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 > > 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> > --- Just one minor comment, but apart from that, feel free to add: Reviewed-by: Pankaj Raghav <p.raghav@samsung.com> > diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py > index 261f28640f4c..84933c4c1083 100644 > --- a/scripts/gdb/linux/modules.py > +++ b/scripts/gdb/linux/modules.py > @@ -73,11 +73,17 @@ class LxLsmod(gdb.Command): > " " if utils.get_long_type().sizeof == 8 else "")) > > for module in module_list(): > - layout = module['mem'][constants.LX_MOD_TEXT] > + total_size = 0 > + for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1): > + layout = module['mem'][i] > + if i == constants.LX_MOD_TEXT: > + text_addr = str(layout['base']).split()[0] > + total_size += layout['size'] > + > gdb.write("{address} {name:<19} {size:>8} {ref}".format( > - address=str(layout['base']).split()[0], > + address=text_addr, > name=module['name'].string(), > - size=str(layout['size']), > + size=str(total_size), > ref=str(module['refcnt']['counter'] - 1))) > > t = self._module_use_type.get_type().pointer() We could slightly modify the code to remove the special condition with `i == constants.LX_MOD_TEXT`: (I made changes on top of your patch) diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py index 84933c4c1083..f76a43bfa15f 100644 --- a/scripts/gdb/linux/modules.py +++ b/scripts/gdb/linux/modules.py @@ -73,12 +73,12 @@ class LxLsmod(gdb.Command): " " if utils.get_long_type().sizeof == 8 else "")) for module in module_list(): + text = module['mem'][constants.LX_MOD_TEXT] + text_addr = str(text['base']).split()[0] total_size = 0 + for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1): - layout = module['mem'][i] - if i == constants.LX_MOD_TEXT: - text_addr = str(layout['base']).split()[0] - total_size += layout['size'] + total_size += module['mem'][i]['size'] gdb.write("{address} {name:<19} {size:>8} {ref}".format( address=text_addr, ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size 2023-07-04 12:11 ` Pankaj Raghav @ 2023-07-10 8:51 ` Kuan-Ying Lee (李冠穎) 0 siblings, 0 replies; 4+ messages in thread From: Kuan-Ying Lee (李冠穎) @ 2023-07-10 8:51 UTC (permalink / raw) To: matthias.bgg, p.raghav, kbingham, angelogioacchino.delregno, jan.kiszka, mcgrof Cc: linux-arm-kernel, linux-kernel, Qun-wei Lin (林群崴), linux-mm, linux-mediatek, Chinwen Chang (張錦文), Andrew Yang (楊智強) On Tue, 2023-07-04 at 14:11 +0200, Pankaj Raghav wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > '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 > > > > 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> > > --- > > Just one minor comment, but apart from that, feel free to add: > > Reviewed-by: Pankaj Raghav <p.raghav@samsung.com> > > > diff --git a/scripts/gdb/linux/modules.py > b/scripts/gdb/linux/modules.py > > index 261f28640f4c..84933c4c1083 100644 > > --- a/scripts/gdb/linux/modules.py > > +++ b/scripts/gdb/linux/modules.py > > @@ -73,11 +73,17 @@ class LxLsmod(gdb.Command): > > " " if utils.get_long_type().sizeof == 8 > else "")) > > > > for module in module_list(): > > - layout = module['mem'][constants.LX_MOD_TEXT] > > + total_size = 0 > > + for i in range(constants.LX_MOD_TEXT, > constants.LX_MOD_RO_AFTER_INIT + 1): > > + layout = module['mem'][i] > > + if i == constants.LX_MOD_TEXT: > > + text_addr = str(layout['base']).split()[0] > > + total_size += layout['size'] > > + > > gdb.write("{address} {name:<19} > {size:>8} {ref}".format( > > - address=str(layout['base']).split()[0], > > + address=text_addr, > > name=module['name'].string(), > > - size=str(layout['size']), > > + size=str(total_size), > > ref=str(module['refcnt']['counter'] - 1))) > > > > t = self._module_use_type.get_type().pointer() > > We could slightly modify the code to remove the special condition > with `i == constants.LX_MOD_TEXT`: > > (I made changes on top of your patch) Thanks for your suggestion. I will upload v2. > > diff --git a/scripts/gdb/linux/modules.py > b/scripts/gdb/linux/modules.py > index 84933c4c1083..f76a43bfa15f 100644 > --- a/scripts/gdb/linux/modules.py > +++ b/scripts/gdb/linux/modules.py > @@ -73,12 +73,12 @@ class LxLsmod(gdb.Command): > " " if utils.get_long_type().sizeof == 8 else > "")) > > for module in module_list(): > + text = module['mem'][constants.LX_MOD_TEXT] > + text_addr = str(text['base']).split()[0] > total_size = 0 > + > for i in range(constants.LX_MOD_TEXT, > constants.LX_MOD_RO_AFTER_INIT + 1): > - layout = module['mem'][i] > - if i == constants.LX_MOD_TEXT: > - text_addr = str(layout['base']).split()[0] > - total_size += layout['size'] > + total_size += module['mem'][i]['size'] > > gdb.write("{address} {name:<19} > {size:>8} {ref}".format( > address=text_addr, ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-10 9:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20230620094846eucas1p21dfc03b10384449dee5e67837ba3e72d@eucas1p2.samsung.com>
2023-06-20 9:48 ` [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size Kuan-Ying Lee
2023-06-30 1:01 ` Kuan-Ying Lee (李冠穎)
2023-07-04 12:11 ` Pankaj Raghav
2023-07-10 8:51 ` Kuan-Ying Lee (李冠穎)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox