Allow emitting kbasename(file) in the dynamic debug prefix content before each pr_debug output using flag 'F'.
Update the docs too. Signed-off-by: Joe Perches <[email protected]> --- fs/ceph uses this, so might as well allow it in dynamic_debug. Seems harmless enough. Documentation/admin-guide/dynamic-debug-howto.rst | 13 +++++++++---- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index e5a8def45f3f..31bf6b6a03ca 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -229,20 +229,25 @@ of the characters:: The flags are:: p enables the pr_debug() callsite. + t Include thread ID in messages not generated from interrupt context + m Include module name in the printed message + F Include kbasename(file) (file path after the last forward slash) + in the printed message f Include the function name in the printed message l Include line number in the printed message - m Include module name in the printed message - t Include thread ID in messages not generated from interrupt context _ No flags are set. (Or'd with others on input) For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` flag have meaning, other flags ignored. +A maximum of 64 characters of the above selected content is output. +If enabled, these are output in the order listed above. + For display, the flags are preceded by ``=`` (mnemonic: what the flags are currently equal to). -Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification. -To clear all flags at once, use ``=_`` or ``-flmpt``. +Note the regexp ``^[-+=][Fflmpt_]+$`` matches a flags specification. +To clear all flags at once, use ``=_`` or ``-Fflmpt``. Debug messages during Boot Process diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index aa9ff9e1c0b3..f1d9209c2adc 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,6 +32,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) +#define _DPRINTK_FLAGS_INCL_FILENAME (1<<5) #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT #else diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 1d012e597cc3..5c4b3d0a4c6f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -86,6 +86,7 @@ static inline const char *trim_prefix(const char *path) static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_PRINT, 'p' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, + { _DPRINTK_FLAGS_INCL_FILENAME, 'F' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, { _DPRINTK_FLAGS_INCL_TID, 't' }, @@ -586,6 +587,9 @@ static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf) if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", desc->modname); + if (desc->flags & _DPRINTK_FLAGS_INCL_FILENAME) + pos += snprintf(buf + pos, remaining(pos), "%s:", + kbasename(desc->filename)); if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", desc->function);

