2 # gdb helper commands and functions for Linux kernel debugging
6 # Copyright (c) 2023 Glenn Washburn
7 # Copyright (c) 2016 Linaro Ltd
10 # Glenn Washburn <development@efficientek.com>
11 # Kieran Bingham <kieran.bingham@linaro.org>
13 # This work is licensed under the terms of the GNU GPL version 2.
17 from linux import utils
21 parent = d['d_parent']
22 if parent == d or parent == 0:
24 p = dentry_name(d['d_parent']) + "/"
25 return p + d['d_iname'].string()
27 class DentryName(gdb.Function):
28 """Return string of the full path of a dentry.
30 $lx_dentry_name(PTR): Given PTR to a dentry struct, return a string
31 of the full path of the dentry."""
34 super(DentryName, self).__init__("lx_dentry_name")
36 def invoke(self, dentry_ptr):
37 return dentry_name(dentry_ptr)
42 dentry_type = utils.CachedType("struct dentry")
44 class InodeDentry(gdb.Function):
45 """Return dentry pointer for inode.
47 $lx_i_dentry(PTR): Given PTR to an inode struct, return a pointer to
48 the associated dentry struct, if there is one."""
51 super(InodeDentry, self).__init__("lx_i_dentry")
53 def invoke(self, inode_ptr):
54 d_u = inode_ptr["i_dentry"]["first"]
57 return utils.container_of(d_u, dentry_type.get_type().pointer(), "d_u")