• Lai Jiangshan's avatar
    kallsyms, tracing: output more proper symbol name · b478b782
    Lai Jiangshan authored
    Impact: bugfix, output more reliable symbol lookup 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.
     # echo function_graph > current_tracer
     # cat trace
     1)   1.923 us    |    select_nohz_load_balancer();
     1) + 76.692 us   |  }
     1)               |  default_idle() {
     1)   ==========> |    __irqentry_text_start() {
     1)   0.000 us    |      native_apic_mem_write();
     1)               |      irq_enter() {
     1)   0.000 us    |        idle_cpu();
     1)               |        tick_check_idle() {
     1)   0.000 us    |          tick_check_oneshot_broadcast();
     1)               |          tick_nohz_stop_idle() {
    It's very embarrassing, it ouputs "__irqentry_text_start()",
    actually, it should output "smp_apic_timer_interrupt()".
    (these two symbol are the same address, but "__irqentry_text_start"
    is deemed to the first aliased symbol by scripts/kallsyms)
    This patch puts symbols like "__irqentry_text_start" to the second
    aliased symbols. And a more proper symbol name becomes the first.
    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: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
    Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
    Reviewed-by: default avatarPaulo Marques <pmarques@grupopie.com>
    LKML-Reference: <49BA06E2.7080807@cn.fujitsu.com>
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>