From patchwork Tue Oct 31 20:22:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Wolsieffer X-Patchwork-Id: 160324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:d23:b0:164:83eb:24d7 with SMTP id gp35csp588522rwb; Tue, 31 Oct 2023 13:24:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBGqSFa9fVmDfsuHeBtsFRmTKDyYAu0SzypcCmdWRlLeMxL/V2vieM9TRWpY9+fN2TwbDs X-Received: by 2002:a05:6870:1306:b0:1e9:e02e:f4c8 with SMTP id 6-20020a056870130600b001e9e02ef4c8mr13595551oab.54.1698783846509; Tue, 31 Oct 2023 13:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698783846; cv=none; d=google.com; s=arc-20160816; b=gUTJ57tTKtRrYDqdUQNmnWu22zkGJfLqmmNItmKMtexAgqqoimbfBLN7vSnPPmWPCt JI2b0644Qr9UG6ZrIeuW672Xnk5QdQ3hAIGOZreizfMOpnUTyIzEK7x5Buye3oJKfs43 HpV8RbeQu6gTo9gLfjdB3rqwn92MicRnNo9rRBAtWJp2fQ7Gyg0Q5saESJJ0HKH7QLDg 4glHRuDVdhZR+cfYkeulgIwGi4HWpoRoPMPCsRR005cRU3y7ZGZWX69N7xR0IHNHuqfV lbp4FcdQU9GXMDhVZxPaF3Gxi/RJXKy9o2gABHyqc82a/Itq9H5NHBt3c3ajv+3YyIbK j/Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=cAl1Hg4JRuGCSI5hrrAD0peIOWwe7ctUsvKwLVEKWuM=; fh=XrFOforFvyGwW5sKtKQFbiZypPHQvtcZxCCD7uJjh5c=; b=NTYKb/6I9NGT3HDOcYWUMOLI6IYng7ZqGwn85JP93qHW3V0OrONCXJrD8f1QuqIzHJ CdxL/0/baYLK5CIuKTpCE2usLVNlaXdCdxMvFT0Qc6qVLDqavXtGr+QO4GQTAYbO1rVS hwkYi+sr8+guDQKTlG+qLzjY1jZFgHNP8HSCVzuj1q2Vvd3j/fg4ConqUjxa1RkbMOK7 cbjrsoYeDxst7/v5xpjyCDHIIe7Avj1eztX/sNE2kTuu5Vg7eK2umP9OdScT96qRNZm0 xjKvcJIZxx7SpaO6OYmGz9rTzUhb4q15SM6yRsBqWAQfm3n6hSLFVk3E6vsP/F/72qWb sx4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hefring-com.20230601.gappssmtp.com header.s=20230601 header.b=Ww5RToF8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id y2-20020a655b02000000b005b92db1e113si1515796pgq.702.2023.10.31.13.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 13:24:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@hefring-com.20230601.gappssmtp.com header.s=20230601 header.b=Ww5RToF8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 433EF80EA789; Tue, 31 Oct 2023 13:24:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbjJaUXq (ORCPT + 33 others); Tue, 31 Oct 2023 16:23:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbjJaUXp (ORCPT ); Tue, 31 Oct 2023 16:23:45 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75629E4 for ; Tue, 31 Oct 2023 13:23:41 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b2f5aed39cso3682975b6e.1 for ; Tue, 31 Oct 2023 13:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hefring-com.20230601.gappssmtp.com; s=20230601; t=1698783820; x=1699388620; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cAl1Hg4JRuGCSI5hrrAD0peIOWwe7ctUsvKwLVEKWuM=; b=Ww5RToF8tPdI/7bdA8sT3SxBJVtExcczZ1YfrahMteF7mwBKNU1wN2YMGCt/uBLGqv PC6cs+e5aXLLOlKt+jMHrWl7u07bqW5f/6lPWnkw+gYbO5/hkradHBtSB4qmgYDqg5tl sVgcPEdaIz/kGPJHEoqD0Cv+Dpnq+FmD+F0I6uA2PRLtFP7PxQrAsgpEWDJZU4Ylp0xT m0TuSwy3D2q/w8X+oei6d4UqCAgR7tussYn6sjrXlik27O4MeJsZkaDWiKBobhnK2tuz BKd401R8i50AP8LGHVYGPSHef6/p9evuZtobljnWS4uX3A8gGJBrfT2RQmVlDXxm0Gad AkVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698783820; x=1699388620; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cAl1Hg4JRuGCSI5hrrAD0peIOWwe7ctUsvKwLVEKWuM=; b=h3qPo9ynDdoSzs8wbCRMV4TintVC2ZiwRGyaeTw29DImdOIIDClFsQIiRxkiR6iwI1 V9F6lPWVMp3GWXlPQPIHIVt8Veg6FCXlUvSmMvMBWhXFGrecWwaEbbhy9mA4nOrv7IyZ ucVQDceuTUHDP4//8qyBujqoXVuAytepTFsJQAI+XKTzX3GjpwJnnXhu3zIPWkQcILUA /9OfZzb5IGybWh7lVZN0oPbjI7OvUB5OFn6YU1M3314EdpI+oq0AZRzceMLTKraltoco W/z9jsOvhanIOA+Rzp9KhRPLRRamdid/l808s68uQMf3dyfZn9uzsJ4GVcNmRFj2pDUG 0a+A== X-Gm-Message-State: AOJu0YyA8KebjVlWOr+xY+IV0N/Ze2U7IST8+At5hnacRlkD+QP5K1fZ YTxnilQT40ngQJ1Hng2OyVSRutZ6NfgsFzOElNk= X-Received: by 2002:a05:6808:22a3:b0:3b5:6467:8cf5 with SMTP id bo35-20020a05680822a300b003b564678cf5mr2916382oib.54.1698783819996; Tue, 31 Oct 2023 13:23:39 -0700 (PDT) Received: from localhost.localdomain ([50.212.55.89]) by smtp.gmail.com with ESMTPSA id qr7-20020a05620a390700b007788bb0ab8esm806628qkn.19.2023.10.31.13.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 13:23:39 -0700 (PDT) From: Ben Wolsieffer To: linux-kernel@vger.kernel.org Cc: Jan Kiszka , Kieran Bingham , Kuan-Ying Lee , Andrew Morton , Ben Wolsieffer Subject: [PATCH] scripts/gdb/vmalloc: disable on no-MMU Date: Tue, 31 Oct 2023 16:22:36 -0400 Message-ID: <20231031202235.2655333-2-ben.wolsieffer@hefring.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 31 Oct 2023 13:24:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781303971043516682 X-GMAIL-MSGID: 1781303971043516682 vmap_area does not exist on no-MMU, therefore the GDB scripts fail to load: Traceback (most recent call last): File "<...>/vmlinux-gdb.py", line 51, in import linux.vmalloc File "<...>/scripts/gdb/linux/vmalloc.py", line 14, in vmap_area_ptr_type = vmap_area_type.get_type().pointer() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "<...>/scripts/gdb/linux/utils.py", line 28, in get_type self._type = gdb.lookup_type(self._name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ gdb.error: No struct type named vmap_area. To fix this, disable the command and add an informative error message if CONFIG_MMU is not defined, following the example of lx-slabinfo. Fixes: 852622bf3616 ("scripts/gdb/vmalloc: add vmallocinfo support") Signed-off-by: Ben Wolsieffer --- scripts/gdb/linux/constants.py.in | 1 + scripts/gdb/linux/vmalloc.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in index e3517d4ab8ec..b5ba9682fc6b 100644 --- a/scripts/gdb/linux/constants.py.in +++ b/scripts/gdb/linux/constants.py.in @@ -157,3 +157,4 @@ LX_CONFIG(CONFIG_STACKDEPOT) LX_CONFIG(CONFIG_PAGE_OWNER) LX_CONFIG(CONFIG_SLUB_DEBUG) LX_CONFIG(CONFIG_SLAB_FREELIST_HARDENED) +LX_CONFIG(CONFIG_MMU) diff --git a/scripts/gdb/linux/vmalloc.py b/scripts/gdb/linux/vmalloc.py index 48e4a4fae7bb..d3c8a0274d1e 100644 --- a/scripts/gdb/linux/vmalloc.py +++ b/scripts/gdb/linux/vmalloc.py @@ -10,8 +10,9 @@ import gdb import re from linux import lists, utils, stackdepot, constants, mm -vmap_area_type = utils.CachedType('struct vmap_area') -vmap_area_ptr_type = vmap_area_type.get_type().pointer() +if constants.LX_CONFIG_MMU: + vmap_area_type = utils.CachedType('struct vmap_area') + vmap_area_ptr_type = vmap_area_type.get_type().pointer() def is_vmalloc_addr(x): pg_ops = mm.page_ops().ops @@ -25,6 +26,9 @@ class LxVmallocInfo(gdb.Command): super(LxVmallocInfo, self).__init__("lx-vmallocinfo", gdb.COMMAND_DATA) def invoke(self, arg, from_tty): + if not constants.LX_CONFIG_MMU: + raise gdb.GdbError("Requires MMU support") + vmap_area_list = gdb.parse_and_eval('vmap_area_list') for vmap_area in lists.list_for_each_entry(vmap_area_list, vmap_area_ptr_type, "list"): if not vmap_area['vm']: