[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0990cccb0d6361c2d824e4efdefa98a1980cf6b8.camel@mediatek.com>
Date: Mon, 10 Jul 2023 08:51:50 +0000
From: Kuan-Ying Lee (李冠穎)
<Kuan-Ying.Lee@...iatek.com>
To: "matthias.bgg@...il.com" <matthias.bgg@...il.com>,
"p.raghav@...sung.com" <p.raghav@...sung.com>,
"kbingham@...nel.org" <kbingham@...nel.org>,
"angelogioacchino.delregno@...labora.com"
<angelogioacchino.delregno@...labora.com>,
"jan.kiszka@...mens.com" <jan.kiszka@...mens.com>,
"mcgrof@...nel.org" <mcgrof@...nel.org>
CC: "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Qun-wei Lin (林群崴)
<Qun-wei.Lin@...iatek.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-mediatek@...ts.infradead.org"
<linux-mediatek@...ts.infradead.org>,
Chinwen Chang (張錦文)
<chinwen.chang@...iatek.com>,
Andrew Yang (楊智強)
<Andrew.Yang@...iatek.com>
Subject: Re: [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size
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@...iatek.com>
> > ---
>
> Just one minor comment, but apart from that, feel free to add:
>
> Reviewed-by: Pankaj Raghav <p.raghav@...sung.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,
Powered by blists - more mailing lists