Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4236788rwo; Tue, 25 Jul 2023 02:59:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlF4Ftxays2GY/U0WDIAYzpCli5s4bCG0qz2rx5OKxwd8jepoVUAdlamU2EvjpypxGY8ZR8w X-Received: by 2002:a17:906:518e:b0:98e:419b:4cbc with SMTP id y14-20020a170906518e00b0098e419b4cbcmr12666376ejk.12.1690279152694; Tue, 25 Jul 2023 02:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690279152; cv=none; d=google.com; s=arc-20160816; b=0Dd1rXdr64TEFRHq+/mt6QuQRc44wlk4O/43IxLNkraRkKB9NAKMATtg+7YCMLLrUK VX0U50qg/LB2y8HWP06YgMnqnA5fw064zig66nwEbHI+xI86v72bSqCtEWcCVtEKMTWd HU7tEZfEvOltJGnqBpmRB6bNoxRJyhO1R4xohHt5ZOdiItg1a4a9EkabNf7h7v+pIh/X pHFNQ9UGbX8Yxc8x4yrC6pSw20imC57tMLSyW07YI3LR/TZdq6ADRDYvc4cUp0vj7DDi 6oOE4JGchd8a+wNyVKsBafn9AM0zBZMdKqRb/+Rs0QGsnoGN+iI03aEdg+drug/NHAoq qWpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=CCTXtSXii4WjoQb/QME4Zdq2bfBGafme2o0RO1nxKt8=; fh=6k0khTxGVH1+z7/UroFbx6JqzCpFP1yEYFy+y/7Bd9E=; b=ld8uUn8T/bRjq/MmOWveyqujusB4RW4DdI2d4BHGX9CimgdjyfzAlZD75MOeqG3JG7 Czgs/YfNjkyDs7uT5Fpe8m8EuGABAS4zBLb8kZRSnw1wDHrElH5J95SYZzof+0NOVRsd MfBCHIFvYVDkAlipyon+EwUNcCVCEOZnqY9w+/3pCTZ3fNlnE/FZsfBx7p1HITU8LrEL kp+NHa/QlRNELMCjLerUwzT7vGjmc2LhwLANjrqeP5+1kskhGGRxnTEnU5IRMpj1olrl MRlFpLJRZ78O+RCeA58KC9HOGSL7AjxJaiKbTwSOfb110bJDzOFD6zZ/YTOrNXk2tfoU Pb5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=pJM25hOG; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n22-20020a1709065e1600b00992a8a54f2fsi7378928eju.368.2023.07.25.02.58.47; Tue, 25 Jul 2023 02:59:12 -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=@mediatek.com header.s=dk header.b=pJM25hOG; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233266AbjGYJhD (ORCPT + 99 others); Tue, 25 Jul 2023 05:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233234AbjGYJgq (ORCPT ); Tue, 25 Jul 2023 05:36:46 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4242A2707; Tue, 25 Jul 2023 02:35:30 -0700 (PDT) X-UUID: 9594c90a2ace11ee9cb5633481061a41-20230725 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=CCTXtSXii4WjoQb/QME4Zdq2bfBGafme2o0RO1nxKt8=; b=pJM25hOGVrtXDyNIDLycc74vFOas6onEsU0S4A1ivop07H6V4rWXdwuiMvo2wOIfW9THQXYjlQ0yRFjPeJcJVDWkt7qwcmbpO2nkQ3BFDozOLVk9Huq9R8j/VEvsyhIaTXlY9W6VuDvNzslvIkKvX++erd21tW01f2M81pJ5uo8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.29,REQID:f8d75b8d-11b2-4524-b50c-34ff117bc1c0,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:e7562a7,CLOUDID:eba081a0-0933-4333-8d4f-6c3c53ebd55b,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,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_ULN,TF_CID_SPAM_SNR X-UUID: 9594c90a2ace11ee9cb5633481061a41-20230725 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1876787150; Tue, 25 Jul 2023 17:35:25 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 25 Jul 2023 17:35:24 +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, 25 Jul 2023 17:35:24 +0800 From: Kuan-Ying Lee To: Jan Kiszka , Kieran Bingham , Matthias Brugger , AngeloGioacchino Del Regno CC: , , , , , , , Kuan-Ying Lee , , Subject: [PATCH 1/8] scripts/gdb/symbols: add specific ko module load command Date: Tue, 25 Jul 2023 17:34:51 +0800 Message-ID: <20230725093458.30064-2-Kuan-Ying.Lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230725093458.30064-1-Kuan-Ying.Lee@mediatek.com> References: <20230725093458.30064-1-Kuan-Ying.Lee@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY,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 Add lx-symbols command to support add specific ko module. Example output like below: (gdb) lx-symbols mm/kasan/kasan_test.ko loading @0xffff800002d30000: mm/kasan/kasan_test.ko Signed-off-by: Kuan-Ying Lee --- scripts/gdb/linux/symbols.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py index fdad3f32c747..b21ae62fdd7d 100644 --- a/scripts/gdb/linux/symbols.py +++ b/scripts/gdb/linux/symbols.py @@ -107,11 +107,12 @@ lx-symbols command.""" name=section_name, addr=str(address))) return "".join(args) - def load_module_symbols(self, module): + def load_module_symbols(self, module, module_file=None): module_name = module['name'].string() module_addr = str(module['mem'][constants.LX_MOD_TEXT]['base']).split()[0] - module_file = self._get_module_file(module_name) + if not module_file: + module_file = self._get_module_file(module_name) if not module_file and not self.module_files_updated: self._update_module_files() module_file = self._get_module_file(module_name) @@ -135,6 +136,19 @@ lx-symbols command.""" else: gdb.write("no module object found for '{0}'\n".format(module_name)) + def load_ko_symbols(self, mod_path): + self.loaded_modules = [] + module_list = modules.module_list() + + for module in module_list: + module_name = module['name'].string() + module_pattern = ".*/{0}\.ko(?:.debug)?$".format( + module_name.replace("_", r"[_\-]")) + if re.match(module_pattern, mod_path) and os.path.exists(mod_path): + self.load_module_symbols(module, mod_path) + return + raise gdb.GdbError("%s is not a valid .ko\n" % mod_path) + def load_all_symbols(self): gdb.write("loading vmlinux\n") @@ -173,6 +187,11 @@ lx-symbols command.""" self.module_files = [] self.module_files_updated = False + argv = gdb.string_to_argv(arg) + if len(argv) == 1: + self.load_ko_symbols(argv[0]) + return + self.load_all_symbols() if hasattr(gdb, 'Breakpoint'): -- 2.18.0