From patchwork Mon Jul 10 09:28:46 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: 13306584 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 CAFEEEB64DA for ; Mon, 10 Jul 2023 09:39:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C5BE6B0078; Mon, 10 Jul 2023 05:39:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 675F06B007B; Mon, 10 Jul 2023 05:39:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5658C6B007D; Mon, 10 Jul 2023 05:39:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 442C76B0078 for ; Mon, 10 Jul 2023 05:39:43 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 134BB1A01AA for ; Mon, 10 Jul 2023 09:39:43 +0000 (UTC) X-FDA: 80995205046.13.6DDFA58 Received: from mailgw02.mediatek.com (mailgw02.mediatek.com [216.200.240.185]) by imf09.hostedemail.com (Postfix) with ESMTP id A95CC140013 for ; Mon, 10 Jul 2023 09:39:39 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b="SeEG/ioO"; dmarc=pass (policy=quarantine) header.from=mediatek.com; spf=pass (imf09.hostedemail.com: domain of kuan-ying.lee@mediatek.com designates 216.200.240.185 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=1688981981; 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=nb99lc8Wmse35yybNXCud8AjDzpYa3GbyoDtpeuAjOk=; b=O64BkkKAN/w5iIzXlW6jBfUdFE2Sd2MZ98MDilUrW7a04/PDhGqf7UMY1QiZ6pj+kfcAia SQrUM1M0sKUCjka5C8GcUR8FSiUa5i5ZUhaqTkuJlX0P+z1hFybFLv+E+A7LLmzvWL/ZH+ g1Ajd/5io6fsRZLKOGFrfD3juVR+Nao= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b="SeEG/ioO"; dmarc=pass (policy=quarantine) header.from=mediatek.com; spf=pass (imf09.hostedemail.com: domain of kuan-ying.lee@mediatek.com designates 216.200.240.185 as permitted sender) smtp.mailfrom=kuan-ying.lee@mediatek.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688981981; a=rsa-sha256; cv=none; b=w/19luhLwEKYJfYbYHUE+uRs6nR+YF9O8URiilUDqoitDRpqduD1S6DMw5VALQh260cGpY W3nwH2A2cDhIXmRUmZZafxTkcXPGgAnkiYVUlDofv4dCnUqqQeast2IC1VR0fG6RJ84uHl g1xSNYDmICCFZynHgrTDGbd11J6d7h4= X-UUID: aa1c54bc1f0511ee83ed1395ce914268-20230710 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=nb99lc8Wmse35yybNXCud8AjDzpYa3GbyoDtpeuAjOk=; b=SeEG/ioOymc16mHFXLdb9p1jG8VP+wACBtfVuE6iLSwL+9UV6Rn5fxzRrIiXl0oN3iAGnZtjHqyqy/48Fe6wQBlyy602seF/whgm9UJBWa337vEY2nsk7uIiOgZVSilCFbPi1M3fpWUimBYrtE+ZqEYXHEQIRkIFoBWs3GLcF90=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.28,REQID:bec83182-c69d-4c6e-9f52-7cec9adfb8af,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:1,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:1 X-CID-META: VersionHash:176cd25,CLOUDID:0915d3da-b4fa-43c8-9c3e-0d3fabd03ec0,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR: NO,DKR:0,DKP:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: aa1c54bc1f0511ee83ed1395ce914268-20230710 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1049895643; Mon, 10 Jul 2023 02:39:28 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) 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; Mon, 10 Jul 2023 17:29:25 +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; Mon, 10 Jul 2023 17:29:25 +0800 From: Kuan-Ying Lee To: Jan Kiszka , Kieran Bingham , Matthias Brugger , AngeloGioacchino Del Regno , Pankaj Raghav , Luis Chamberlain CC: , , , , , Kuan-Ying Lee , , , Subject: [PATCH v2] scripts/gdb: fix 'lx-lsmod' show the wrong size Date: Mon, 10 Jul 2023 17:28:46 +0800 Message-ID: <20230710092852.31049-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-Stat-Signature: njgsy6f9xqhroh9yfq3ef88w9g4qrnhs X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A95CC140013 X-HE-Tag: 1688981979-552951 X-HE-Meta: U2FsdGVkX19ppfdUfhzG7w3WIoof653JacnpNR5YnJ/sVdU0iyLyJlb3alfPkjQY5QoWk9jiWhfxidEKjADn66rJCdR8bdrkHZe03MOOBwAx7e7vsTtbedilxLkjAsruR/GKIK7CwGVeyX+A0S2jDDvc537kshgULCxdZFrPUsEonQB3gIstg2EpnhG6swBd6dOVGPN5yyf88fcjt/feHhnIGDqX5uKnAcWDkXn9JKPLeOh66WEWfm5MZPjmafSc6KBXDgju/dy/8OW+5SlXmCF6pWkZe9nXPjdxwNNDz2CwFGzIb/usKeEvAri362Rdh5JDxbxvVeTR+r5wQkcHEkeUYGTzoIUP8J6ONX/MRA1Wb1zy8eLfH84JTuRUrSLjCMTP52iVd+KpOU1NTdApLXWbyXRYhyLK+JAwbjuP4S/7kaXpMKC79Vt2UBFHTPyVqbI4C8ZCafCYRhACBpsWduSbATRN4tl2vnoo+caY6trt5FmLVSLztVSyJw/WMU46G0mt6BhSfWeeO+kmB9ZW1/nOhcdR4X9t0c8PkHrh/VCcDCn5Hj5q08YHXI2XcGCyR07MWPtID1qF3chITaz/wbRCjRnI7OFzaI9yBMXvLQywwQP+SbG9EcE+zh04IorltMhdas1+R2mAV131JNHFQ791UvriqnZA1H7MoiUhmVW/PEyxXWvFyt2b3dHzXs+suJZzLHjpais+lI12YoV8NwMsnGFmfD3HMpiBn+Vy2KIT/JnKyd65OAWQEJMOm3PubJALLNAG8CkLwpl/dssI+c3AbdlUbKlwS0S7loUTZ+LcvNYa95ALkaw2R7+UJF8WNPkUgD9LoY/fB/pDmSFkXbYLMm9boZgvd0uifYS7cWGOL/kucZxCQMX+AqY03HNGLUD67L2KHcH4KsyZWMB1peki0vXYblL9XvirKVP9nVPXgWR2E75xFXPfp+S8NXhhFF6jiZ4Dwsi8koQPi0Z Y8AEE3zt vN8yDA0tYpPGAA153RJpRc3mZ6UB/Omk2/FcN9hS0ELI3gTYSWQsakp6KOZbTiOD/ymMgI+amXAdxJ1eqj+PbdV5ikGuyBqCIy2xME8WfqT+Ul3PNIfEC0PXZQALWAYclgRrnXSV2Ujb+lvN5hauyUTVoA+iOp/tLCconoBZ4K7G8x2BrL+7hH6qw0jxUVv/10PSWeOwq/I9ZbIckyNwVeB0XG6lgRSYHpRuICAafCmyUKvty5yJybC5eGWNs79RIFwgyDEyoTmaBAiY= 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") Reviewed-by: Pankaj Raghav Signed-off-by: Kuan-Ying Lee --- V1->V2: - Remove special condition 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..f76a43bfa15f 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] + 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): + total_size += module['mem'][i]['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()