This adds the printk.caller=[0|1] boot parameter, default setting
controlled by CONFIG_PRINTK_CALLER. (This is modelled on printk.time
and CONFIG_PRINTK_TIME.)
When this is set, each printk line is automagically prefixed with
"{0x123abc} " giving the PC address of that printk call (actually
the PC address just after the call).
As a kernel hacker, I always hate having to grep for some fragment
of a message to find the code that generated it. But I always have
my -g vmlinux handy, so:
(gdb) info line *(0x123abc - 1)
is real handy (it pops the source up in an Emacs buffer).
Signed-off-by: Roland McGrath <roland@redhat.com>
---
Documentation/kernel-parameters.txt | 3 ++
include/linux/kernel.h | 4 ++-
kernel/printk.c | 38 +++++++++++++++++++++++++++++-----
lib/Kconfig.debug | 9 ++++++++
4 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 1150444..9f1e1b9 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1689,6 +1689,9 @@ and is between 256 and 4096 characters. It is defined in the file
printk.time= Show timing data prefixed to each printk message line
Format: <bool> (1/Y/y=enable, 0/N/n=disable)
+ printk.caller= Show caller PC prefixed to each printk message line
+ Format: <bool> (1/Y/y=enable, 0/N/n=disable)
+
profile= [KNL] Enable kernel profiling via /proc/profile
Format: [schedule,]<number>
Param: "schedule" - profile schedule points.
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2651f80..e03b475 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -191,7 +191,9 @@ struct pid;
extern struct pid *session_of_pgrp(struct pid *pgrp);
#ifdef CONFIG_PRINTK
-asmlinkage int vprintk(const char *fmt, va_list args)
+# define vprintk(fmt, args) \
+ vprintk_caller(fmt, args, ...