The patch titled Subject: scripts/gdb: add GDB convenience functions $lx_dentry_name() and $lx_i_dentry() has been added to the -mm mm-nonmm-unstable branch. Its filename is scripts-gdb-add-gdb-convenience-functions-lx_dentry_name-and-lx_i_dentry.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/scripts-gdb-add-gdb-convenience-functions-lx_dentry_name-and-lx_i_dentry.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Glenn Washburn <development@xxxxxxxxxxxxxxx> Subject: scripts/gdb: add GDB convenience functions $lx_dentry_name() and $lx_i_dentry() Date: Tue, 28 Feb 2023 18:53:35 -0600 $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@xxxxxxxxxxxxxxx Signed-off-by: Glenn Washburn <development@xxxxxxxxxxxxxxx> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Antonio Borneo <antonio.borneo@xxxxxxxxxxx> Cc: Jan Kiszka <jan.kiszka@xxxxxxxxxxx> Cc: John Ogness <john.ogness@xxxxxxxxxxxxx> Cc: Kieran Bingham <kbingham@xxxxxxxxxx> Cc: Petr Mladek <pmladek@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- scripts/gdb/linux/vfs.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) --- a/scripts/gdb/linux/vfs.py~scripts-gdb-add-gdb-convenience-functions-lx_dentry_name-and-lx_i_dentry +++ a/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() _ Patches currently in -mm which might be from development@xxxxxxxxxxxxxxx are scripts-gdb-create-linux-vfspy-for-vfs-related-gdb-helpers.patch scripts-gdb-add-gdb-convenience-functions-lx_dentry_name-and-lx_i_dentry.patch