• A
    perf symbols: Add support for 'variable' symtabs · f1dfa0b1
    Arnaldo Carvalho de Melo 提交于
    Example:
    
    {
    	u64 addr = strtoull(sym_filter, NULL, 16);
    	struct map *map = map_groups__find(kmaps, MAP__VARIABLE, addr);
    
    	if (map == NULL)
    		pr_err("couldn't find map!\n");
    	else {
    		struct symbol *sym = map__find_symbol(map, addr, NULL);
    		if (sym == NULL)
    			pr_err("couldn't find addr!\n");
    		else
    			pr_info("addr %#Lx is in %s global var\n", addr, sym->name);
    	}
    	exit(0);
    }
    
    Added just after symbol__init() call in 'perf top', then:
    
    {
            u64 addr = strtoull(sym_filter, NULL, 16);
            struct map *map = map_groups__find(kmaps, MAP__VARIABLE, addr);
    
            if (map == NULL)
                    pr_err("couldn't find map!\n");
            else {
                    struct symbol *sym = map__find_symbol(map, addr, NULL);
                    if (sym == NULL)
                            pr_err("couldn't find addr!\n");
                    else
                            pr_info("addr %#Lx is in %s global var\n", addr, sym->name);
            }
            exit(0);
    }
    
    [root@doppio linux-2.6-tip]# grep ' [dD] ' /proc/kallsyms | grep ' sched'
    ffffffff817827d8 d sched_nr_latency
    ffffffff81782ce0 d sched_domains_mutex
    ffffffff8178c070 d schedstr.22423
    ffffffff817909a0 d sched_register_mutex
    ffffffff81823490 d sched_feat_names
    ffffffff81823558 d scheduler_running
    ffffffff818235b8 d sched_clock_running
    ffffffff818235bc D sched_clock_stable
    ffffffff81824f00 d sched_switch_trace
    [root@doppio linux-2.6-tip]# perf top -s 0xffffffff817827d9
    addr 0xffffffff817827d9 is in sched_nr_latency global var
    [root@doppio linux-2.6-tip]# perf top -s ffffffff81782ce0
    addr 0xffffffff81782ce0 is in sched_domains_mutex global var
    [root@doppio linux-2.6-tip]#
    [root@doppio linux-2.6-tip]# perf top -s ffffffff81782ce0 --vmlinux OFF
    The file OFF cannot be used, trying to use /proc/kallsyms...addr 0xffffffff81782ce0 is in sched_domains_mutex global var
    [root@doppio linux-2.6-tip]# perf top -s ffffffff818235bc --vmlinux OFF
    The file OFF cannot be used, trying to use /proc/kallsyms...addr 0xffffffff818235bc is in sched_clock_stable global var
    [root@doppio linux-2.6-tip]#
    
    So it works with both /proc/kallsyms and with ELF symtabs, either
    the one on the vmlinux explicitely passed via --vmlinux or in one
    in the vmlinux_path that matches the buildid for the running kernel
    or the one found in the buildid header section in a perf.data file.
    Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Frédéric Weisbecker <fweisbec@gmail.com>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Paul Mackerras <paulus@samba.org>
    LKML-Reference: <1260550239-5372-4-git-send-email-acme@infradead.org>
    Signed-off-by: NIngo Molnar <mingo@elte.hu>
    f1dfa0b1
event.h 3.5 KB