Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27596260rwd; Tue, 4 Jul 2023 05:20:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzVeGI4KAukkAzyqg+JXMivl9K1qIy6WsG+hRsoz1spXvee6VsFt5kU3tU+Xalpq2GJyJG X-Received: by 2002:a17:90b:3944:b0:262:f5a0:113c with SMTP id oe4-20020a17090b394400b00262f5a0113cmr9522351pjb.40.1688473205035; Tue, 04 Jul 2023 05:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688473205; cv=none; d=google.com; s=arc-20160816; b=w2M5+1eCQJi5dxqM7q3vzgvAuGYmqQw7HVxXSYqC5fix/lpmils/HuDow8d/pdr7Kr znUqp1OgVDY8vWY8nF6YRMg7udt7e1imwH/QaEPYFHkm4EJI8xZ15RFiKSb0uzspp131 OPI1K+uRehgIpIchT2aKPA6RDe2L8u0hM3E+I/K0HXa8LFcTbGGznkkEFctBXygXM7ba Uya5rnjoxiccOWsHx5UVUY6GKk5+Roc2UFYuREE7KkJMITQCFtkT954yuhUUN5TMF3Cw Ucywo61SmDyA83n1CSgHCwaDgYygP0e0q62fCuRTTM1C2nx2hgKekwr2QTJymLkxH4dn p/0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=YyGAJb/q3tqQcZ2W+JulaaKT2SHdQuqBKQ0EoXB4AmA=; fh=r+aIP5uS9484Rpho0ttdmBwfcd0etDfLctnFRbPCrwI=; b=E6EVONRMz4BFhcHizJt0zedPv6BNEB2OSCTSevuCw4RMZ747JuiY5JJf5W9tPeqMh1 ablwv9n4Ix2oFxSm4G6d8NRKxkx0MrEBYu/yxQcS+qTUgIzkdNqKHeC1GrC1jBxx+gqX 4On5GktyDhFOPhE1q/8n36TGuUWWQ4bm+CH7/YPyqkgE3FKRJ2Wx9VFFWLTiDlEtGltc tahft9Nbcn6q8CykNmiDtxvj1MIhIUoLEt7rfKLwXqFhSCTqmWovK9ZwQxwKxykerf1S csttFAm4hOhbHfN4sM0TpKDh0aGODvfFLB4LX8RViYAF7FCQ7xuCPTQsoiI++Z97Sc8y 4hnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PtcpdhsX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc6-20020a17090b3b8600b0025669d0176asi14564484pjb.134.2023.07.04.05.19.50; Tue, 04 Jul 2023 05:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PtcpdhsX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbjGDMLz (ORCPT + 99 others); Tue, 4 Jul 2023 08:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjGDMLx (ORCPT ); Tue, 4 Jul 2023 08:11:53 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16B86F3 for ; Tue, 4 Jul 2023 05:11:52 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230704121150euoutp020097b8e11ea2a80eb6e530ecba1e4267~uqPv3cvie1315213152euoutp02i for ; Tue, 4 Jul 2023 12:11:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230704121150euoutp020097b8e11ea2a80eb6e530ecba1e4267~uqPv3cvie1315213152euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1688472710; bh=YyGAJb/q3tqQcZ2W+JulaaKT2SHdQuqBKQ0EoXB4AmA=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=PtcpdhsXECSpduj+sDH/Y0PDgMNF3m5YTxy720Ydpvo+A/7iFVHyPJOzqwK2kGUgv rVZy9Qmt7OyQEIe3O0DAPLM6WV4BP6rD991HmHYFc+LJshR3nGxV6w9znvFPW2e7K3 AcjycivlgFyULqtXeRDHCpV8TotYJh7yty2/7hdI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230704121148eucas1p12ce4e9a088be6fb90957fa50a8e0c5b5~uqPuNE0ss1616416164eucas1p1P; Tue, 4 Jul 2023 12:11:48 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 3C.17.11320.48C04A46; Tue, 4 Jul 2023 13:11:48 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230704121148eucas1p1a346072c4ff918f9b7c90f1901b8bfb4~uqPtzEgxI2899828998eucas1p1x; Tue, 4 Jul 2023 12:11:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230704121148eusmtrp142c1a17af1c6741bcbec18e351c54494~uqPtyXSHi1847518475eusmtrp1L; Tue, 4 Jul 2023 12:11:48 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-02-64a40c84cca2 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 09.3A.10549.48C04A46; Tue, 4 Jul 2023 13:11:48 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230704121148eusmtip1874992cdee4d805e50891d8da75794c5~uqPtmq8SG2020220202eusmtip1k; Tue, 4 Jul 2023 12:11:48 +0000 (GMT) Received: from [192.168.8.209] (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 4 Jul 2023 13:11:47 +0100 Message-ID: Date: Tue, 4 Jul 2023 14:11:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size Content-Language: en-US To: Kuan-Ying Lee , Jan Kiszka , Kieran Bingham , Matthias Brugger , AngeloGioacchino Del Regno , Luis Chamberlain CC: , , , , , , From: Pankaj Raghav In-Reply-To: <20230620094834.14688-1-Kuan-Ying.Lee@mediatek.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJKsWRmVeSWpSXmKPExsWy7djP87otPEtSDA7eUbQ4em4Zk8WllRIW bzdfZLe4d/Mms8Wp7s1MFo/39rFbbHp8jdXi8q45bBaXmy8yWtxb85/VoqnF2OLGhKeMFqtP WTjweuy4u4TR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fA2+IvHu4LMnt1Y8JJ5+t6s9hD+zjUWIpzkg01GIuKk4EABPW55uQAwAA X-CMS-MailID: 20230704121148eucas1p1a346072c4ff918f9b7c90f1901b8bfb4 X-Msg-Generator: CA X-RootMTR: 20230620094846eucas1p21dfc03b10384449dee5e67837ba3e72d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230620094846eucas1p21dfc03b10384449dee5e67837ba3e72d References: <20230620094834.14688-1-Kuan-Ying.Lee@mediatek.com> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > '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 > --- Just one minor comment, but apart from that, feel free to add: Reviewed-by: Pankaj Raghav > 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,