2009-09-17 04:28:30

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH 1/3] [PATCH 1/3] vsprintf: add %ps that is the same as %pS but is like %pf

From: Steven Rostedt <[email protected]>

On PowerPC64 function pointers do not point directly at the functions,
but instead point to pointers to the functions. The output of %pF expects
to point to a pointer to the function, whereas %pS will show the function
itself.

mcount returns the direct pointer to the function and not the pointer to
the pointer. Thus %pS must be used to show this. The function tracer
requires printing of the functions without offsets and uses the %pf
instead.

%pF produces run_local_timers+0x4/0x1f
%pf produces just run_local_timers

For PowerPC64, we need to use the direct pointer, and we only have
%pS which will produce .run_local_timers+0x4/0x1f

This patch creates a %ps that matches the %pf as %pS matches %pF.

Cc: Linus Torvalds <[email protected]>
Cc: Zhao Lei <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
lib/vsprintf.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 756ccaf..c265e75 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -580,7 +580,7 @@ static char *symbol_string(char *buf, char *end, void *ptr,
unsigned long value = (unsigned long) ptr;
#ifdef CONFIG_KALLSYMS
char sym[KSYM_SYMBOL_LEN];
- if (ext != 'f')
+ if (ext != 'f' && ext != 's')
sprint_symbol(sym, value);
else
kallsyms_lookup(value, NULL, NULL, NULL, sym);
@@ -721,6 +721,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
case 'F':
case 'f':
ptr = dereference_function_descriptor(ptr);
+ case 's':
/* Fallthrough */
case 'S':
return symbol_string(buf, end, ptr, spec, *fmt);
@@ -958,7 +959,8 @@ qualifier:
* @args: Arguments for the format string
*
* This function follows C99 vsnprintf, but has some extensions:
- * %pS output the name of a text symbol
+ * %pS output the name of a text symbol with offset
+ * %ps output the name of a text symbol without offset
* %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
--
1.6.3.3


2009-09-17 05:41:24

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 1/3] [PATCH 1/3] vsprintf: add %ps that is the same as %pS but is like %pf

On Thu, 2009-09-17 at 00:27 -0400, Steven Rostedt wrote:
> plain text document attachment
> (0001-vsprintf-add-ps-that-is-the-same-as-pS-but-is-like-p.patch)
> From: Steven Rostedt <[email protected]>
>
> On PowerPC64 function pointers do not point directly at the functions,
> but instead point to pointers to the functions. The output of %pF expects
> to point to a pointer to the function, whereas %pS will show the function
> itself.
>
> mcount returns the direct pointer to the function and not the pointer to
> the pointer. Thus %pS must be used to show this. The function tracer
> requires printing of the functions without offsets and uses the %pf
> instead.
>
> %pF produces run_local_timers+0x4/0x1f
> %pf produces just run_local_timers
>
> For PowerPC64, we need to use the direct pointer, and we only have
> %pS which will produce .run_local_timers+0x4/0x1f
>
> This patch creates a %ps that matches the %pf as %pS matches %pF.
>
> Cc: Linus Torvalds <[email protected]>
> Cc: Zhao Lei <[email protected]>

Acked-by: Benjamin Herrenschmidt <[email protected]>

> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> lib/vsprintf.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 756ccaf..c265e75 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -580,7 +580,7 @@ static char *symbol_string(char *buf, char *end, void *ptr,
> unsigned long value = (unsigned long) ptr;
> #ifdef CONFIG_KALLSYMS
> char sym[KSYM_SYMBOL_LEN];
> - if (ext != 'f')
> + if (ext != 'f' && ext != 's')
> sprint_symbol(sym, value);
> else
> kallsyms_lookup(value, NULL, NULL, NULL, sym);
> @@ -721,6 +721,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
> case 'F':
> case 'f':
> ptr = dereference_function_descriptor(ptr);
> + case 's':
> /* Fallthrough */
> case 'S':
> return symbol_string(buf, end, ptr, spec, *fmt);
> @@ -958,7 +959,8 @@ qualifier:
> * @args: Arguments for the format string
> *
> * This function follows C99 vsnprintf, but has some extensions:
> - * %pS output the name of a text symbol
> + * %pS output the name of a text symbol with offset
> + * %ps output the name of a text symbol without offset
> * %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

2009-09-17 06:04:47

by Zhao Lei

[permalink] [raw]
Subject: Re: [PATCH 1/3] [PATCH 1/3] vsprintf: add %ps that is the same as %pS but is like %pf

Steven Rostedt wrote:
> From: Steven Rostedt <[email protected]>
>
> On PowerPC64 function pointers do not point directly at the functions,
> but instead point to pointers to the functions. The output of %pF expects
> to point to a pointer to the function, whereas %pS will show the function
> itself.
>
> mcount returns the direct pointer to the function and not the pointer to
> the pointer. Thus %pS must be used to show this. The function tracer
> requires printing of the functions without offsets and uses the %pf
> instead.
>
> %pF produces run_local_timers+0x4/0x1f
> %pf produces just run_local_timers
>
> For PowerPC64, we need to use the direct pointer, and we only have
> %pS which will produce .run_local_timers+0x4/0x1f
>
> This patch creates a %ps that matches the %pf as %pS matches %pF.
>
> Cc: Linus Torvalds <[email protected]>
> Cc: Zhao Lei <[email protected]>
> Cc: Benjamin Herrenschmidt <[email protected]>
> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> lib/vsprintf.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 756ccaf..c265e75 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -580,7 +580,7 @@ static char *symbol_string(char *buf, char *end, void *ptr,
> unsigned long value = (unsigned long) ptr;
> #ifdef CONFIG_KALLSYMS
> char sym[KSYM_SYMBOL_LEN];
> - if (ext != 'f')
> + if (ext != 'f' && ext != 's')
> sprint_symbol(sym, value);
> else
> kallsyms_lookup(value, NULL, NULL, NULL, sym);
> @@ -721,6 +721,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
> case 'F':
> case 'f':
> ptr = dereference_function_descriptor(ptr);
> + case 's':
> /* Fallthrough */
> case 'S':
> return symbol_string(buf, end, ptr, spec, *fmt);
> @@ -958,7 +959,8 @@ qualifier:
> * @args: Arguments for the format string
> *
> * This function follows C99 vsnprintf, but has some extensions:
> - * %pS output the name of a text symbol
> + * %pS output the name of a text symbol with offset
> + * %ps output the name of a text symbol without offset

Comments of bstr_printf() also need to be updated.
or remove duplation and just say "refer to vsnprintf()" in bstr_printf()'s
comment.

Thanks
Zhaolei