aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Washburn <[email protected]>2023-02-28 18:53:35 -0600
committerAndrew Morton <[email protected]>2023-04-18 16:39:35 -0700
commit5a10562bdeb58006de4b1cd5f671b7da26b20bb3 (patch)
tree45e4ad85130c71d59d56bc1af447bdf364252f74
parentf4efbdaf59e959507a1a931ec4afecdfb09db76e (diff)
scripts/gdb: add GDB convenience functions $lx_dentry_name() and $lx_i_dentry()
$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. Link: https://lkml.kernel.org/r/c9a5ad8efbfbd2cc6559e082734eed7628f43a16.1677631565.git.development@efficientek.com Signed-off-by: Glenn Washburn <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Antonio Borneo <[email protected]> Cc: Jan Kiszka <[email protected]> Cc: John Ogness <[email protected]> Cc: Kieran Bingham <[email protected]> Cc: Petr Mladek <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--scripts/gdb/linux/vfs.py37
1 files changed, 37 insertions, 0 deletions
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()