diff options
author | Joe Perches <joe@perches.com> | 2012-12-12 18:18:50 (GMT) |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-04-30 20:31:16 (GMT) |
commit | b0d33c2bd77bcf2d7c9427d2361ac57fe5b33aa1 (patch) | |
tree | 2acb72d0e39aee019cf8aecc917685b120e506a3 | |
parent | 071361d3473ebb8142907470ff12d59c59f6be72 (diff) | |
download | linux-fsl-qoriq-b0d33c2bd77bcf2d7c9427d2361ac57fe5b33aa1.tar.xz |
vsprintf: Add extension %pSR - print_symbol replacement
print_symbol takes a long and converts it to a function
name and offset. %pS does something similar, but doesn't
translate the address via __builtin_extract_return_addr.
%pSR does the translation.
This will enable replacing multiple calls like
printk(...);
printk_symbol(addr);
printk("\n");
with a single non-interleavable in dmesg
printk("... %pSR\n", (void *)addr);
Update documentation too.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | Documentation/printk-formats.txt | 2 | ||||
-rw-r--r-- | lib/vsprintf.c | 18 |
2 files changed, 15 insertions, 5 deletions
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt index e8a6aa4..e3d0215 100644 --- a/Documentation/printk-formats.txt +++ b/Documentation/printk-formats.txt @@ -17,6 +17,8 @@ Symbols/Function Pointers: %pF versatile_init+0x0/0x110 %pf versatile_init %pS versatile_init+0x0/0x110 + %pSR versatile_init+0x9/0x110 + (with __builtin_extract_return_addr() translation) %ps versatile_init %pB prev_fn_of_versatile_init+0x88/0x88 diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 0d62fd7..e149c64 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -534,14 +534,21 @@ char *string(char *buf, char *end, const char *s, struct printf_spec spec) static noinline_for_stack char *symbol_string(char *buf, char *end, void *ptr, - struct printf_spec spec, char ext) + struct printf_spec spec, const char *fmt) { - unsigned long value = (unsigned long) ptr; + unsigned long value; #ifdef CONFIG_KALLSYMS char sym[KSYM_SYMBOL_LEN]; - if (ext == 'B') +#endif + + if (fmt[1] == 'R') + ptr = __builtin_extract_return_addr(ptr); + value = (unsigned long)ptr; + +#ifdef CONFIG_KALLSYMS + if (*fmt == 'B') sprint_backtrace(sym, value); - else if (ext != 'f' && ext != 's') + else if (*fmt != 'f' && *fmt != 's') sprint_symbol(sym, value); else sprint_symbol_no_offset(sym, value); @@ -987,6 +994,7 @@ int kptr_restrict __read_mostly; * - 'f' For simple symbolic function names without offset * - 'S' For symbolic direct pointers with offset * - 's' For symbolic direct pointers without offset + * - '[FfSs]R' as above with __builtin_extract_return_addr() translation * - 'B' For backtraced symbolic direct pointers with offset * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref] * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201] @@ -1060,7 +1068,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, case 'S': case 's': case 'B': - return symbol_string(buf, end, ptr, spec, *fmt); + return symbol_string(buf, end, ptr, spec, fmt); case 'R': case 'r': return resource_string(buf, end, ptr, spec, fmt); |