linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Jason Baron <jbaron@akamai.com>
Cc: Jim Cromie <jim.cromie@gmail.com>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] dynamic_debug: Allow kbasename(file) to be output using 'F'
Date: Sun, 16 Aug 2020 14:58:57 -0700	[thread overview]
Message-ID: <3e4a895e7c25e37c0f4727b960b7abdcf0752cbb.camel@perches.com> (raw)

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 <joe@perches.com>
---

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);


                 reply	other threads:[~2020-08-16 21:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e4a895e7c25e37c0f4727b960b7abdcf0752cbb.camel@perches.com \
    --to=joe@perches.com \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).