[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-0c8b946e3ebb3846103486420ea7430a4b5e5b1b@git.kernel.org>
Date: Wed, 29 Apr 2009 19:09:32 GMT
From: tip-bot for Frederic Weisbecker <fweisbec@...il.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, hpa@...or.com, mingo@...hat.com,
tzanussi@...il.com, lizf@...fujitsu.com,
torvalds@...ux-foundation.org, zhaolei@...fujitsu.com,
fweisbec@...il.com, rostedt@...dmis.org, akpm@...ux-foundation.org,
vapier@...too.org, tglx@...utronix.de, mingo@...e.hu
Subject: [tip:core/printk] vsprintf: introduce %pf format specifier
Commit-ID: 0c8b946e3ebb3846103486420ea7430a4b5e5b1b
Gitweb: http://git.kernel.org/tip/0c8b946e3ebb3846103486420ea7430a4b5e5b1b
Author: Frederic Weisbecker <fweisbec@...il.com>
AuthorDate: Wed, 15 Apr 2009 17:48:18 +0200
Committer: Ingo Molnar <mingo@...e.hu>
CommitDate: Wed, 29 Apr 2009 20:55:55 +0200
vsprintf: introduce %pf format specifier
A printf format specifier which would allow us to print a pure
function name has been suggested by Andrew Morton a couple of
months ago.
The current %pF is very convenient to print a function symbol,
but often we only want to print the name of the function, without
its asm offset.
That's what %pf does in this patch. The lowecase f has been chosen
for its intuitive meaning of a 'weak kind of %pF'.
The support for this new format would be welcome by the tracing code
where the need to print pure function names is often needed. This is
also true for other parts of the kernel:
$ git-grep -E "kallsyms_lookup\(.+?\)"
arch/blackfin/kernel/traps.c: symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
arch/powerpc/xmon/xmon.c: name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
arch/sh/kernel/cpu/sh5/unwind.c: sym = kallsyms_lookup(pc, NULL, &offset, NULL, namebuf);
arch/x86/kernel/ftrace.c: kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
kernel/kprobes.c: sym = kallsyms_lookup((unsigned long)p->addr, NULL,
kernel/lockdep.c: return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup((unsigned long)rec->ops->func, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
kernel/trace/ftrace.c: kallsyms_lookup(rec->ip, NULL, NULL, &modname, str);
kernel/trace/ftrace.c: kallsyms_lookup(*ptr, NULL, NULL, NULL, str);
kernel/trace/trace_functions.c: kallsyms_lookup(ip, NULL, NULL, NULL, str);
kernel/trace/trace_output.c: kallsyms_lookup(address, NULL, NULL, NULL, str);
Changes in v2:
- Add the explanation of the %pf role for vsnprintf() and bstr_printf()
- Change the comments by dropping the "asm offset" notion and only
define the %pf against the actual function offset notion.
Signed-off-by: Frederic Weisbecker <fweisbec@...il.com>
Acked-by: Mike Frysinger <vapier@...too.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Zhaolei <zhaolei@...fujitsu.com>
Cc: Tom Zanussi <tzanussi@...il.com>
Cc: Li Zefan <lizf@...fujitsu.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Steven Rostedt <rostedt@...dmis.org>
LKML-Reference: <20090415154817.GC5989@...here>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
lib/vsprintf.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index b56f6d0..756ccaf 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -575,12 +575,15 @@ static char *string(char *buf, char *end, char *s, struct printf_spec spec)
}
static char *symbol_string(char *buf, char *end, void *ptr,
- struct printf_spec spec)
+ struct printf_spec spec, char ext)
{
unsigned long value = (unsigned long) ptr;
#ifdef CONFIG_KALLSYMS
char sym[KSYM_SYMBOL_LEN];
- sprint_symbol(sym, value);
+ if (ext != 'f')
+ sprint_symbol(sym, value);
+ else
+ kallsyms_lookup(value, NULL, NULL, NULL, sym);
return string(buf, end, sym, spec);
#else
spec.field_width = 2*sizeof(void *);
@@ -692,7 +695,8 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr,
*
* Right now we handle:
*
- * - 'F' For symbolic function descriptor pointers
+ * - 'F' For symbolic function descriptor pointers with offset
+ * - 'f' For simple symbolic function names without offset
* - 'S' For symbolic direct pointers
* - 'R' For a struct resource pointer, it prints the range of
* addresses (not the name nor the flags)
@@ -715,10 +719,11 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
switch (*fmt) {
case 'F':
+ case 'f':
ptr = dereference_function_descriptor(ptr);
/* Fallthrough */
case 'S':
- return symbol_string(buf, end, ptr, spec);
+ return symbol_string(buf, end, ptr, spec, *fmt);
case 'R':
return resource_string(buf, end, ptr, spec);
case 'm':
@@ -954,7 +959,8 @@ qualifier:
*
* This function follows C99 vsnprintf, but has some extensions:
* %pS output the name of a text symbol
- * %pF output the name of a function pointer
+ * %pF output the name of a function pointer with its offset
+ * %pf output the name of a function pointer without its offset
* %pR output the address range in a struct resource
*
* The return value is the number of characters which would
@@ -1412,7 +1418,8 @@ EXPORT_SYMBOL_GPL(vbin_printf);
*
* The format follows C99 vsnprintf, but has some extensions:
* %pS output the name of a text symbol
- * %pF output the name of a function pointer
+ * %pF output the name of a function pointer with its offset
+ * %pf output the name of a function pointer without its offset
* %pR output the address range in a struct resource
* %n is ignored
*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists