From patchwork Tue Jun 20 09:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= X-Patchwork-Id: 13285513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 993B6EB64D7 for ; Tue, 20 Jun 2023 09:49:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B95358D0002; Tue, 20 Jun 2023 05:49:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B448D8D0001; Tue, 20 Jun 2023 05:49:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A59ED8D0002; Tue, 20 Jun 2023 05:49:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 99E498D0001 for ; Tue, 20 Jun 2023 05:49:28 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 28C3BB015C for ; Tue, 20 Jun 2023 09:49:28 +0000 (UTC) X-FDA: 80922653616.16.DBFCBB4 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf02.hostedemail.com (Postfix) with ESMTP id 3E9358001C for ; Tue, 20 Jun 2023 09:49:22 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=QJM8Obn8; dmarc=pass (policy=quarantine) header.from=mediatek.com; spf=pass (imf02.hostedemail.com: domain of kuan-ying.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=kuan-ying.lee@mediatek.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687254564; a=rsa-sha256; cv=none; b=1cFln8ZO1pDcb/G6v8bzJ1HaLmFjr2Hd5N+B/Lcaxd8mS435hKnCvQKoIHQoJo64F606En uCmWg/iRUBFv0wwCK5UBDq3uTe1LKWOMDV+RSyJb7v09Vz4f6ce2lxWph+b12hkzeiE08U qQe0OKyJ7KiQfAJK9hbIWBbFVn62Hus= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=QJM8Obn8; dmarc=pass (policy=quarantine) header.from=mediatek.com; spf=pass (imf02.hostedemail.com: domain of kuan-ying.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=kuan-ying.lee@mediatek.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687254564; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=KX9Gwg7gwsESAK8OAmogwWn5H1GX62YrEpzhQ8fTwcU=; b=k3tVIZj0Zg8JJQpws4sqtOiYnbM1aOY7tpknI2ESQFtXWjnq7J8TIDxfhbVC0LEAK2Q5+Q DIEqZHcvNzW9/YefleqJbseiceFSSurvm5fTNFbRBv+fX2+3KAXa+wwQ5nBwqies1O2X3f vtGa6d9eXgfc5WWPf/93md20+KBmP6Q= X-UUID: b63fb1f00f4f11ee912e1518a6540028-20230620 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=KX9Gwg7gwsESAK8OAmogwWn5H1GX62YrEpzhQ8fTwcU=; b=QJM8Obn8Uqeo5ucpAsLebBl3A1HRDw7nVlIiG+3O7mFfgW/EBBVlFrzgDbHCw7/x7HJ3GGRu6MfEgUp89VKgOe6leau6E3nM8EyhL6tRCjJQcck159bc7aVTW06xabd5NJg3tCdHgmWEuN2J4p6zRjRmDhm5SESbb0Cw/0nmAkg=; X-CID-UNFAMILIAR: 1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.27,REQID:28a92b36-9615-4b54-a00f-65b7eced1580,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:1,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:101 X-CID-INFO: VERSION:1.1.27,REQID:28a92b36-9615-4b54-a00f-65b7eced1580,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:1,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:101 X-CID-META: VersionHash:01c9525,CLOUDID:8a8da86f-2f20-4998-991c-3b78627e4938,B ulkID:23062017484238AIYB81,BulkQuantity:1,Recheck:0,SF:29|28|16|19|48|38,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_SDM,TF_CID_SPAM_ASC,TF_CID_SPAM_USA, TF_CID_SPAM_FSD,TF_CID_SPAM_ULN X-UUID: b63fb1f00f4f11ee912e1518a6540028-20230620 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1515213187; Tue, 20 Jun 2023 02:49:12 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 20 Jun 2023 17:48:38 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 20 Jun 2023 17:48:38 +0800 From: Kuan-Ying Lee To: Jan Kiszka , Kieran Bingham , Matthias Brugger , AngeloGioacchino Del Regno , Luis Chamberlain , Pankaj Raghav CC: , , , , Kuan-Ying Lee , , , Subject: [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size Date: Tue, 20 Jun 2023 17:48:33 +0800 Message-ID: <20230620094834.14688-1-Kuan-Ying.Lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3E9358001C X-Stat-Signature: 6z8xuqm4bnw4k1zgpgb5pig914my6315 X-HE-Tag: 1687254562-347593 X-HE-Meta: U2FsdGVkX184AW7mRKjQIM4+qMU83gD7wrW0RaNwc/JFW+xkFTVtbUn77kHggI2RvpUoDgwr2f33llh1w/l5BE6aSqoAN4P+Y0mrcqUmE/d5DbHZGQC+oCbfQJdKjQZxGuh6QFQr4ehoAQHQw8BNRgEEPMMssRA5XoDHfPgmbOPwSbifARpXcPtt40uvTfzDuJ+gEOsC8zWO+xLf+J+uKaECpJa55xTc1n3Wdth6Jo8mesuUl9fmaaCkMdc1N6EQ4CjKJZPAWHE/JsFqzBVx95re6l3PxPhLoXBsNGci1GNZ7VCnBtkGeyRXoW2JMGNCe+49jB/VwspGgNFgb/eH9UYgWr7FnQJEq/LmZJkqnc/twD6uZjVHcrYjNVX3orTR45x+gXgcGM5ZQP+TE7vX2B+2erlGKbjrPDdwgO6te+X30oPDBT202E2kr0kNIKk1Z3yYXJL7KKTbmTs1rI3CKorOb3wRnredXPETddT+lmkU4aewVywQD714cXuWvO33d3FDLEPsvoQ5Ei3X/kaafSZDLTd4/9leMyyndsC5rZuYTbQ83Omng4sO+DcDLWTUBjwy3e2HzUydQ7lRSoUTqWt7a0beBUeXjJpQFOpY6PuduJsQvnYOE06jkl9FQ7OS8HP8XNCCPJveaumnoRqYu3OVDzTGj1qPhZdQuv5daMUamUPkkpeSgGnFPzO5zx+hRVWGw0LTG3hFcKF/A+PNBbG/od6LB5gZJGxJ3rijPTVzM9Os4hBqzn5UMzoDK4BNlrHsBvACxqjJcu9Qt2smRiUkKo2KJRgRV3PI0PFA7FtqvR4bsnnqEYh8XLsRqUrNdS/06MU4lKAffuEDfEvbHUWAiR4kBsn63/qktG/Ij+e0em6ZZ9NDMbD8V2B21JtgxjNNPMn3YGWp1T9ysGYX0JPf3a+HqI2DRJzUXLZl96JyWbvjHtWMzpDXpJtRZeoYCwZBa6IqqQRTHy9ii5b XoBzJUhi cQiYDrejX0LwwoIB7R980vHMpi9WkQMEbSGVyJpKEgUO4erL7afGvrQdl0mp4Tq2FYixcvIKnZ9p9OnafbDhg7u6zldzrbyPHaSC5ayM0ONpck4yhmu0JUJfgpsHCzzu6EsZLUdzTKFLbQ9OHZovWXseghhSVi7ZhqsmQT6pSVcE2ZbU/4P2QN1mW24eL1obb9AkmxycA0HXfpCnYny4Rk9zOa70Zzl3KGJR9G8bXfU5W2j8QVx4hlPVRIQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: '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 Reviewed-by: Pankaj Raghav --- 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()