Skip to content

Commit 5a10562

Browse files
crassakpm00
authored andcommitted
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 <development@efficientek.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Antonio Borneo <antonio.borneo@foss.st.com> Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: John Ogness <john.ogness@linutronix.de> Cc: Kieran Bingham <kbingham@kernel.org> Cc: Petr Mladek <pmladek@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent f4efbda commit 5a10562

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

scripts/gdb/linux/vfs.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,47 @@
1313
# This work is licensed under the terms of the GNU GPL version 2.
1414
#
1515

16+
import gdb
17+
from linux import utils
18+
1619

1720
def dentry_name(d):
1821
parent = d['d_parent']
1922
if parent == d or parent == 0:
2023
return ""
2124
p = dentry_name(d['d_parent']) + "/"
2225
return p + d['d_iname'].string()
26+
27+
class DentryName(gdb.Function):
28+
"""Return string of the full path of a dentry.
29+
30+
$lx_dentry_name(PTR): Given PTR to a dentry struct, return a string
31+
of the full path of the dentry."""
32+
33+
def __init__(self):
34+
super(DentryName, self).__init__("lx_dentry_name")
35+
36+
def invoke(self, dentry_ptr):
37+
return dentry_name(dentry_ptr)
38+
39+
DentryName()
40+
41+
42+
dentry_type = utils.CachedType("struct dentry")
43+
44+
class InodeDentry(gdb.Function):
45+
"""Return dentry pointer for inode.
46+
47+
$lx_i_dentry(PTR): Given PTR to an inode struct, return a pointer to
48+
the associated dentry struct, if there is one."""
49+
50+
def __init__(self):
51+
super(InodeDentry, self).__init__("lx_i_dentry")
52+
53+
def invoke(self, inode_ptr):
54+
d_u = inode_ptr["i_dentry"]["first"]
55+
if d_u == 0:
56+
return ""
57+
return utils.container_of(d_u, dentry_type.get_type().pointer(), "d_u")
58+
59+
InodeDentry()

0 commit comments

Comments
 (0)