summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Washburn <development@efficientek.com>2023-03-01 03:53:34 +0300
committerAndrew Morton <akpm@linux-foundation.org>2023-04-19 02:39:34 +0300
commitf4efbdaf59e959507a1a931ec4afecdfb09db76e (patch)
tree732a0a10444b728e819b39a8e0fc2f923dcb7d18
parent31088f6f7906253ef4577f6a9b84e2d42447dba0 (diff)
downloadlinux-f4efbdaf59e959507a1a931ec4afecdfb09db76e.tar.xz
scripts/gdb: create linux/vfs.py for VFS related GDB helpers
Patch series "GDB VFS utils". I've created a couple GDB convenience functions that I found useful when debugging some VFS issues and figure others might find them useful. For instance, they are useful in setting conditional breakpoints on VFS functions where you only care if the dentry path is a certain value. I took the opportunity to create a new "vfs" python module to give VFS related utilities a home. This patch (of 2): This will allow for more VFS specific GDB helpers to be collected in one place. Move utils.dentry_name into the vfs modules. Also a local variable in proc.py was changed from vfs to mnt to prevent a naming collision with the new vfs module. [akpm@linux-foundation.org: add SPDX-License-Identifier] Link: https://lkml.kernel.org/r/cover.1677631565.git.development@efficientek.com Link: https://lkml.kernel.org/r/7bba4c065a8c2c47f1fc5b03a7278005b04db251.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>
-rw-r--r--scripts/gdb/linux/proc.py16
-rw-r--r--scripts/gdb/linux/utils.py8
-rw-r--r--scripts/gdb/linux/vfs.py22
-rw-r--r--scripts/gdb/vmlinux-gdb.py1
4 files changed, 32 insertions, 15 deletions
diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py
index 09cd871925a5..43c687e7a69d 100644
--- a/scripts/gdb/linux/proc.py
+++ b/scripts/gdb/linux/proc.py
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
#
# gdb helper commands and functions for Linux kernel debugging
#
@@ -16,6 +17,7 @@ from linux import constants
from linux import utils
from linux import tasks
from linux import lists
+from linux import vfs
from struct import *
@@ -170,16 +172,16 @@ values of that process namespace"""
gdb.write("{:^18} {:^15} {:>9} {} {} options\n".format(
"mount", "super_block", "devname", "pathname", "fstype"))
- for vfs in lists.list_for_each_entry(namespace['list'],
+ for mnt in lists.list_for_each_entry(namespace['list'],
mount_ptr_type, "mnt_list"):
- devname = vfs['mnt_devname'].string()
+ devname = mnt['mnt_devname'].string()
devname = devname if devname else "none"
pathname = ""
- parent = vfs
+ parent = mnt
while True:
mntpoint = parent['mnt_mountpoint']
- pathname = utils.dentry_name(mntpoint) + pathname
+ pathname = vfs.dentry_name(mntpoint) + pathname
if (parent == parent['mnt_parent']):
break
parent = parent['mnt_parent']
@@ -187,14 +189,14 @@ values of that process namespace"""
if (pathname == ""):
pathname = "/"
- superblock = vfs['mnt']['mnt_sb']
+ superblock = mnt['mnt']['mnt_sb']
fstype = superblock['s_type']['name'].string()
s_flags = int(superblock['s_flags'])
- m_flags = int(vfs['mnt']['mnt_flags'])
+ m_flags = int(mnt['mnt']['mnt_flags'])
rd = "ro" if (s_flags & constants.LX_SB_RDONLY) else "rw"
gdb.write("{} {} {} {} {} {}{}{} 0 0\n".format(
- vfs.format_string(), superblock.format_string(), devname,
+ mnt.format_string(), superblock.format_string(), devname,
pathname, fstype, rd, info_opts(FS_INFO, s_flags),
info_opts(MNT_INFO, m_flags)))
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py
index 7f36aee32ac6..9f44df13761e 100644
--- a/scripts/gdb/linux/utils.py
+++ b/scripts/gdb/linux/utils.py
@@ -196,11 +196,3 @@ def gdb_eval_or_none(expresssion):
return gdb.parse_and_eval(expresssion)
except gdb.error:
return None
-
-
-def dentry_name(d):
- parent = d['d_parent']
- if parent == d or parent == 0:
- return ""
- p = dentry_name(d['d_parent']) + "/"
- return p + d['d_iname'].string()
diff --git a/scripts/gdb/linux/vfs.py b/scripts/gdb/linux/vfs.py
new file mode 100644
index 000000000000..62d4f9ad7d79
--- /dev/null
+++ b/scripts/gdb/linux/vfs.py
@@ -0,0 +1,22 @@
+#
+# gdb helper commands and functions for Linux kernel debugging
+#
+# VFS tools
+#
+# Copyright (c) 2023 Glenn Washburn
+# Copyright (c) 2016 Linaro Ltd
+#
+# Authors:
+# Glenn Washburn <development@efficientek.com>
+# Kieran Bingham <kieran.bingham@linaro.org>
+#
+# This work is licensed under the terms of the GNU GPL version 2.
+#
+
+
+def dentry_name(d):
+ parent = d['d_parent']
+ if parent == d or parent == 0:
+ return ""
+ p = dentry_name(d['d_parent']) + "/"
+ return p + d['d_iname'].string()
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index 2a72f91059b5..2d32308c3f7a 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -40,6 +40,7 @@ else:
import linux.clk
import linux.genpd
import linux.device
+ import linux.vfs
import linux.mm
import linux.radixtree
import linux.interrupts