[PATCH 17/18] dyndbg: rename dynamic_debug to dyndbg

From: Jim Cromie
Date: Thu Dec 05 2019 - 16:52:51 EST


This rename fixes a subtle usage wrinkle; the __setup() names didn't
match the fake "dyndbg" module parameter used to enable dynamic-printk
callsites in modules. See the last change in Docs for the effect.

It also shortens the "__FILE__:__func__" prefix in dyndbg.verbose
messages, effectively s/dynamic_debug/dyndbg/

This is a 99.9% rename; trim_prefix and debugfs_create_dir arg excepted.
Nonetheless, it also changes both /sys appearances:

bash-5.0# ls -R /sys/kernel/debug/dyndbg/ /sys/module/dyndbg/parameters/
/sys/kernel/debug/dyndbg/:
control
/sys/module/dyndbg/parameters/:
verbose

Finally, paths in docs are ~= s|/dynamic_debug/|/dyndbg/|,
plus the kernel cmdline example tweak cited above.

Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
.../admin-guide/dynamic-debug-howto.rst | 50 +++++++++----------
lib/Makefile | 4 +-
lib/{dynamic_debug.c => dyndbg.c} | 4 +-
3 files changed, 29 insertions(+), 29 deletions(-)
rename lib/{dynamic_debug.c => dyndbg.c} (99%)

diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst
index 5c170e49121d..d91dbb52721d 100644
--- a/Documentation/admin-guide/dynamic-debug-howto.rst
+++ b/Documentation/admin-guide/dynamic-debug-howto.rst
@@ -31,7 +31,7 @@ Dynamic debug has even more useful features:
- module name
- format string

- * Provides a debugfs control file: ``<debugfs>/dynamic_debug/control``
+ * Provides a debugfs control file: ``<debugfs>/dyndbg/control``
which can be read to display the complete list of known debug
statements, to help guide you

@@ -42,16 +42,16 @@ The behaviour of ``pr_debug()``/``dev_dbg()`` are controlled via writing to a
control file in the 'debugfs' filesystem. Thus, you must first mount
the debugfs filesystem, in order to make use of this feature.
Subsequently, we refer to the control file as:
-``<debugfs>/dynamic_debug/control``. For example, if you want to enable
+``<debugfs>/dyndbg/control``. For example, if you want to enable
printing from source file ``svcsock.c``, line 1603 you simply do::

nullarbor:~ # echo 'file svcsock.c line 1603 +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

If you make a mistake with the syntax, the write will fail thus::

nullarbor:~ # echo 'file svcsock.c wtf 1 +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control
-bash: echo: write error: Invalid argument

Viewing Dynamic Debug Behaviour
@@ -60,7 +60,7 @@ Viewing Dynamic Debug Behaviour
You can view the currently configured behaviour of all the debug
statements via::

- nullarbor:~ # cat <debugfs>/dynamic_debug/control
+ nullarbor:~ # cat <debugfs>/dyndbg/control
# filename:lineno [module]function flags format
net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012"
net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline : %d\012"
@@ -72,10 +72,10 @@ statements via::
You can also apply standard Unix text manipulation filters to this
data, e.g.::

- nullarbor:~ # grep -i rdma <debugfs>/dynamic_debug/control | wc -l
+ nullarbor:~ # grep -i rdma <debugfs>/dyndbg/control | wc -l
62

- nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l
+ nullarbor:~ # grep -i tcp <debugfs>/dyndbg/control | wc -l
42

The third column shows the currently enabled flags for each debug
@@ -83,7 +83,7 @@ statement callsite (see below for definitions of the flags). The
default value, with no flags enabled, is ``=_``. So you can view all
the debug statement callsites with any non-default flags::

- nullarbor:~ # awk '$3 != "=_"' <debugfs>/dynamic_debug/control
+ nullarbor:~ # awk '$3 != "=_"' <debugfs>/dyndbg/control
# filename:lineno [module]function flags format
net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012"

@@ -94,27 +94,27 @@ At the lexical level, a command comprises a sequence of words separated
by spaces or tabs. So these are all equivalent::

nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control
nullarbor:~ # echo -n ' file svcsock.c line 1603 +p ' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control
nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

Command submissions are bounded by a write() system call.
Multiple commands can be written together, separated by ``;`` or ``\n``::

~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \
- > <debugfs>/dynamic_debug/control
+ > <debugfs>/dyndbg/control

If your query set is big, you can batch them too::

- ~# cat query-batch-file > <debugfs>/dynamic_debug/control
+ ~# cat query-batch-file > <debugfs>/dyndbg/control

Another way is to use wildcards. The match rule supports ``*`` (matches
zero or more characters) and ``?`` (matches exactly one character). For
example, you can match all usb drivers::

- ~# echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control
+ ~# echo "file drivers/usb/* +p" > <debugfs>/dyndbg/control

At the syntactical level, a command comprises a sequence of match
specifications, followed by a flags change specification::
@@ -338,7 +338,7 @@ For ``CONFIG_DYNAMIC_DEBUG`` kernels, any settings given at boot-time (or
enabled by ``-DDEBUG`` flag during compilation) can be disabled later via
the debugfs interface if the debug messages are no longer needed::

- echo "module module_name -p" > <debugfs>/dynamic_debug/control
+ echo "module module_name -p" > <debugfs>/dyndbg/control

Examples
========
@@ -347,41 +347,41 @@ Examples

// enable the message at line 1603 of file svcsock.c
nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

// enable all the messages in file svcsock.c
nullarbor:~ # echo -n 'file svcsock.c +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

// enable all the messages in the NFS server module
nullarbor:~ # echo -n 'module nfsd +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

// enable all 12 messages in the function svc_process()
nullarbor:~ # echo -n 'func svc_process +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

// disable all 12 messages in the function svc_process()
nullarbor:~ # echo -n 'func svc_process -p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

// enable messages for NFS calls READ, READLINK, READDIR and READDIR+.
nullarbor:~ # echo -n 'format "nfsd: READ" +p' >
- <debugfs>/dynamic_debug/control
+ <debugfs>/dyndbg/control

// enable messages in files of which the paths include string "usb"
- nullarbor:~ # echo -n '*usb* +p' > <debugfs>/dynamic_debug/control
+ nullarbor:~ # echo -n '*usb* +p' > <debugfs>/dyndbg/control

// enable all messages
- nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control
+ nullarbor:~ # echo -n '+p' > <debugfs>/dyndbg/control

// add module, function to all enabled messages
- nullarbor:~ # echo -n '+mf' > <debugfs>/dynamic_debug/control
+ nullarbor:~ # echo -n '+mf' > <debugfs>/dyndbg/control

// boot-args example, with newlines and comments for readability
Kernel command line: ...
// see whats going on in dyndbg=value processing
- dynamic_debug.verbose=1
+ dyndbg.verbose=1
// enable pr_debugs in 2 builtins, #cmt is stripped
dyndbg="module params +p #cmt ; module sys +p"
// enable pr_debugs in 2 functions in a module loaded later
diff --git a/lib/Makefile b/lib/Makefile
index c5892807e06f..ea4028aa7852 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -15,7 +15,7 @@ KCOV_INSTRUMENT_string.o := n
KCOV_INSTRUMENT_rbtree.o := n
KCOV_INSTRUMENT_list_debug.o := n
KCOV_INSTRUMENT_debugobjects.o := n
-KCOV_INSTRUMENT_dynamic_debug.o := n
+KCOV_INSTRUMENT_dyndbg.o := n

# Early boot use of cmdline, don't instrument it
ifdef CONFIG_AMD_MEM_ENCRYPT
@@ -180,7 +180,7 @@ lib-$(CONFIG_GENERIC_BUG) += bug.o

obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o

-obj-$(CONFIG_DYNAMIC_DEBUG) += dynamic_debug.o
+obj-$(CONFIG_DYNAMIC_DEBUG) += dyndbg.o

obj-$(CONFIG_NLATTR) += nlattr.o

diff --git a/lib/dynamic_debug.c b/lib/dyndbg.c
similarity index 99%
rename from lib/dynamic_debug.c
rename to lib/dyndbg.c
index d056fca96b9d..f410d341841a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dyndbg.c
@@ -77,7 +77,7 @@ module_param(verbose, int, 0644);
/* Return the path relative to source root */
static inline const char *trim_prefix(const char *path)
{
- int skip = strlen(__FILE__) - strlen("lib/dynamic_debug.c");
+ int skip = strlen(__FILE__) - strlen("lib/dyndbg.c");

if (strncmp(path, __FILE__, skip))
skip = 0; /* prefix mismatch, don't skip */
@@ -1055,7 +1055,7 @@ static int __init dynamic_debug_init_debugfs(void)
if (!ddebug_init_success)
return -ENODEV;

- dir = debugfs_create_dir("dynamic_debug", NULL);
+ dir = debugfs_create_dir("dyndbg", NULL);
debugfs_create_file("control", 0644, dir, NULL, &ddebug_proc_fops);

return 0;
--
2.23.0