From: Glenn Washburn <development@efficientek.com>
To: Jan Kiszka <jan.kiszka@siemens.com>,
Kieran Bingham <kbingham@kernel.org>
Cc: Glenn Washburn <development@efficientek.com>,
John Ogness <john.ogness@linutronix.de>,
Petr Mladek <pmladek@suse.com>,
Antonio Borneo <antonio.borneo@foss.st.com>,
linux-kernel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
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 [thread overview]
Message-ID: <c9a5ad8efbfbd2cc6559e082734eed7628f43a16.1677631565.git.development@efficientek.com> (raw)
In-Reply-To: <cover.1677631565.git.development@efficientek.com>
$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 <development@efficientek.com>
---
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.
#
+import gdb
+from linux import utils
+
def dentry_name(d):
parent = d['d_parent']
@@ -20,3 +23,37 @@ def dentry_name(d):
return ""
p = 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 = 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 = inode_ptr["i_dentry"]["first"]
+ if d_u == 0:
+ return ""
+ return utils.container_of(d_u, dentry_type.get_type().pointer(), "d_u")
+
+InodeDentry()
--
2.30.2
next prev parent reply other threads:[~2023-03-01 0:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 0:53 [PATCH 0/2] GDB VFS utils Glenn Washburn
2023-03-01 0:53 ` [PATCH 1/2] scripts/gdb: Create linux/vfs.py for VFS related GDB helpers Glenn Washburn
2023-04-12 19:21 ` Andrew Morton
2023-03-01 0:53 ` Glenn Washburn [this message]
2023-04-12 18:02 ` [PATCH 0/2] GDB VFS utils Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9a5ad8efbfbd2cc6559e082734eed7628f43a16.1677631565.git.development@efficientek.com \
--to=development@efficientek.com \
--cc=antonio.borneo@foss.st.com \
--cc=jan.kiszka@siemens.com \
--cc=john.ogness@linutronix.de \
--cc=kbingham@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).