1 # 1 # 2 # gdb helper commands and functions for Linux 2 # gdb helper commands and functions for Linux kernel debugging 3 # 3 # 4 # VFS tools 4 # VFS tools 5 # 5 # 6 # Copyright (c) 2023 Glenn Washburn 6 # Copyright (c) 2023 Glenn Washburn 7 # Copyright (c) 2016 Linaro Ltd 7 # Copyright (c) 2016 Linaro Ltd 8 # 8 # 9 # Authors: 9 # Authors: 10 # Glenn Washburn <development@efficientek.com> 10 # Glenn Washburn <development@efficientek.com> 11 # Kieran Bingham <kieran.bingham@linaro.org> 11 # Kieran Bingham <kieran.bingham@linaro.org> 12 # 12 # 13 # This work is licensed under the terms of the 13 # This work is licensed under the terms of the GNU GPL version 2. 14 # 14 # 15 15 16 import gdb 16 import gdb 17 from linux import utils 17 from linux import utils 18 18 19 19 20 def dentry_name(d): 20 def dentry_name(d): 21 parent = d['d_parent'] 21 parent = d['d_parent'] 22 if parent == d or parent == 0: 22 if parent == d or parent == 0: 23 return "" 23 return "" 24 p = dentry_name(d['d_parent']) + "/" 24 p = dentry_name(d['d_parent']) + "/" 25 return p + d['d_iname'].string() 25 return p + d['d_iname'].string() 26 26 27 class DentryName(gdb.Function): 27 class DentryName(gdb.Function): 28 """Return string of the full path of a den 28 """Return string of the full path of a dentry. 29 29 30 $lx_dentry_name(PTR): Given PTR to a dentry st 30 $lx_dentry_name(PTR): Given PTR to a dentry struct, return a string 31 of the full path of the dentry.""" 31 of the full path of the dentry.""" 32 32 33 def __init__(self): 33 def __init__(self): 34 super(DentryName, self).__init__("lx_d 34 super(DentryName, self).__init__("lx_dentry_name") 35 35 36 def invoke(self, dentry_ptr): 36 def invoke(self, dentry_ptr): 37 return dentry_name(dentry_ptr) 37 return dentry_name(dentry_ptr) 38 38 39 DentryName() 39 DentryName() 40 40 41 41 42 dentry_type = utils.CachedType("struct dentry" 42 dentry_type = utils.CachedType("struct dentry") 43 43 44 class InodeDentry(gdb.Function): 44 class InodeDentry(gdb.Function): 45 """Return dentry pointer for inode. 45 """Return dentry pointer for inode. 46 46 47 $lx_i_dentry(PTR): Given PTR to an inode struc 47 $lx_i_dentry(PTR): Given PTR to an inode struct, return a pointer to 48 the associated dentry struct, if there is one. 48 the associated dentry struct, if there is one.""" 49 49 50 def __init__(self): 50 def __init__(self): 51 super(InodeDentry, self).__init__("lx_ 51 super(InodeDentry, self).__init__("lx_i_dentry") 52 52 53 def invoke(self, inode_ptr): 53 def invoke(self, inode_ptr): 54 d_u = inode_ptr["i_dentry"]["first"] 54 d_u = inode_ptr["i_dentry"]["first"] 55 if d_u == 0: 55 if d_u == 0: 56 return "" 56 return "" 57 return utils.container_of(d_u, dentry_ 57 return utils.container_of(d_u, dentry_type.get_type().pointer(), "d_u") 58 58 59 InodeDentry() 59 InodeDentry()
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.