lkml.org 
[lkml]   [2009]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V3] kallsyms, tracing: output more proper symbol name
Lai Jiangshan wrote:
> [...]
> [resend, previous v3 has some mistakes]
>
> Subject: kallsyms, tracing: output more proper symbol name
>
> Impact: bugfix, output reliable result
>
> Debug tools(dump_stack(), ftrace...) are like to print out symbols.
> But it is always print out the first aliased symbol.(Aliased symbols
> are symbols with the same address), and the first aliased symbol is
> sometime not proper.
> [...]
> Aliased symbols mostly come from linker script. The solution is
> guessing "is this symbol defined in linker script", the symbols
> defined in linker script will not become the first aliased symbol.
>
> And if symbols are found to be equal in this "linker script provided"
> criteria, symbols are sorted by the number of prefix underscores.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> ---
> [...]
> +static int prefix_underscores_count(const char *str)
> +{
> + const char *tail = str;
> +
> + while (*tail == '_')
> + tail++;
> +
> + return tail - str;
> +}
> +
> static int compare_symbols(const void *a, const void *b)
> {
> const struct sym_entry *sa;
> @@ -521,6 +566,18 @@ static int compare_symbols(const void *a, const void *b)
> if (wa != wb)
> return wa - wb;
>
> + /* sort by "linker script provide" type */
> + wa = may_be_linker_script_provide_symbol(sa);
> + wb = may_be_linker_script_provide_symbol(sb);
> + if (wa != wb)
> + return wa - wb;
> +
> + /* sort by the number of prefix underscores */
> + wa = prefix_underscores_count((const char *)sa->sym + 1);
> + wb = prefix_underscores_count((const char *)sb->sym + 1);
> + if (wa != wb)
> + return wa - wb;
> +
> /* sort by initial order, so that other symbols are left undisturbed */
> return sa->start_pos - sb->start_pos;
> }

The code seems fine. I have no time to compile and test it right now,
but there are no obvious problems as far as I can see.

Reviewed-by: Paulo Marques <pmarques@grupopie.com>

--
Paulo Marques - www.grupopie.com

"Measure with laser, mark with chalk, cut with chainsaw."


\
 
 \ /
  Last update: 2009-03-13 20:29    [W:0.100 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site