From nobody Sat Apr 11 04:17:35 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5982C64EC7 for ; Wed, 1 Mar 2023 00:54:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbjCAAyb (ORCPT ); Tue, 28 Feb 2023 19:54:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbjCAAy1 (ORCPT ); Tue, 28 Feb 2023 19:54:27 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8497738019 for ; Tue, 28 Feb 2023 16:54:22 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id z2so12302208plf.12 for ; Tue, 28 Feb 2023 16:54:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; t=1677632062; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z8QvEJHYhAXcNkgYMIkS1lSU8aRrD4xwhBP8pWQKoEQ=; b=POpWsg0D7RKSBcxfWey09P/uiwmcI7RQXs+IRRVllDsAp8dZ8Uz1pCW2nsB3x2sVDm adz4wQt9hBCZA9Z65RvFgYvAFS6b9nfMOgqn6CxiaUWNZWvZErnz2fDrZSeD0A0sbBqx gouNPyUN/sS22fY9nFZaPnsXvjOn2v/ZoBo7+StxIbqRFCTTvenxy81A4s64ZqtMOWMw DYC7Dr7FrIuwur4+uD6rtjWpr+vmftWcRrwUOO7kpsPwPxEsjrfhJ3WqHDsjDMbNGG9K Hk6hXlRkUcIJMmbV0ZQIUd299cJJkbu3SrYGpWOLfh7nOArneTJF6ojGNk3esqX8Q7u3 L9fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677632062; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z8QvEJHYhAXcNkgYMIkS1lSU8aRrD4xwhBP8pWQKoEQ=; b=IN0ic6XBHB7w3T+orLS2Xg4IA/WXGLrEKGL3exo51ilJK8+55GcFmz1mkAG63916KP +2GJucZP85R3ma3KrBzUptrtzQddlCCB3iMa/3nCUdHtOuIkaMZuke2FXgGy1h7eAyZJ 1FPr+pgUz6COzmaENX7KVEpVPEhpspPe5G7w3mMVd97QGFzSvkBGIJ1ZQdNuoXOg3tag yfs9iP2Ek8dkMNoMOmjpeEzs8uT8RbzWGqAeICRBRdxaRWsqNKDeax8o95mlBSPZc/Hl npV0mIacLRqH2eaGakUvjPmej72K6KIszTjtLNcD9Ukt3qoD54TRuawnE8yTRijyTa5Z Amxw== X-Gm-Message-State: AO0yUKXOys03dnVk5d4KIdQ1dBMHW92Wv0mk/HcoL+/jS0c11nn5jhTl HIDq902TSZ/Tn7J/tE+OrLxQvg== X-Google-Smtp-Source: AK7set+ZIjetJnI/eW38N5gYq4TacNpMbuGunCgeLcexpsYtSVLN8hreE/tlERE7S87p3ZoWWB92Jw== X-Received: by 2002:a05:6a20:748c:b0:bd:17a4:c35f with SMTP id p12-20020a056a20748c00b000bd17a4c35fmr5665085pzd.23.1677632062013; Tue, 28 Feb 2023 16:54:22 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id c5-20020a6566c5000000b00503000f0492sm18606pgw.14.2023.02.28.16.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 16:54:21 -0800 (PST) From: Glenn Washburn To: Jan Kiszka , Kieran Bingham Cc: Glenn Washburn , John Ogness , Petr Mladek , Antonio Borneo , linux-kernel@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] scripts/gdb: Add GDB convenience functions $lx_dentry_name() and $lx_i_dentry() Date: Tue, 28 Feb 2023 18:53:35 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" $lx_dentry_name() generates a full VFS path from a given dentry pointer, and $lx_i_dentry() returns the dentry pointer associated with the given inode pointer, if there is one. Signed-off-by: Glenn Washburn --- scripts/gdb/linux/vfs.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/scripts/gdb/linux/vfs.py b/scripts/gdb/linux/vfs.py index 62d4f9ad7d79..c77b9ce75f6d 100644 --- a/scripts/gdb/linux/vfs.py +++ b/scripts/gdb/linux/vfs.py @@ -13,6 +13,9 @@ # This work is licensed under the terms of the GNU GPL version 2. # =20 +import gdb +from linux import utils + =20 def dentry_name(d): parent =3D d['d_parent'] @@ -20,3 +23,37 @@ def dentry_name(d): return "" p =3D dentry_name(d['d_parent']) + "/" return p + d['d_iname'].string() + +class DentryName(gdb.Function): + """Return string of the full path of a dentry. + +$lx_dentry_name(PTR): Given PTR to a dentry struct, return a string +of the full path of the dentry.""" + + def __init__(self): + super(DentryName, self).__init__("lx_dentry_name") + + def invoke(self, dentry_ptr): + return dentry_name(dentry_ptr) + +DentryName() + + +dentry_type =3D utils.CachedType("struct dentry") + +class InodeDentry(gdb.Function): + """Return dentry pointer for inode. + +$lx_i_dentry(PTR): Given PTR to an inode struct, return a pointer to +the associated dentry struct, if there is one.""" + + def __init__(self): + super(InodeDentry, self).__init__("lx_i_dentry") + + def invoke(self, inode_ptr): + d_u =3D inode_ptr["i_dentry"]["first"] + if d_u =3D=3D 0: + return "" + return utils.container_of(d_u, dentry_type.get_type().pointer(), "= d_u") + +InodeDentry() --=20 2.30.2