Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

From: Arnaldo Carvalho de Melo
Date: Thu Jan 28 2010 - 13:30:43 EST


Em Thu, Jan 28, 2010 at 11:28:29AM -0500, Masami Hiramatsu escreveu:

> Yeah, and if you can separate an interface only for handling symbols
> from debug/elf binaries, it will be helpful for me too.

It was done on this same series, now you can do as the patch at the end
of this message, that will be on my next series, does.

Testing with this patch:

[root@doppio ~]# perf probe --list
[root@doppio ~]# perf probe schedule
Added new event:
probe:schedule (on schedule+0)

You can now use it on all perf tools, such as:

perf record -e probe:schedule -a sleep 1

[root@doppio ~]# perf record -e probe:schedule -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.158 MB perf.data (~6923 samples) ]
[root@doppio ~]# perf report | head -9
# Samples: 4
#
# Overhead Command Shared Object Symbol
# ........ ............... ..................... ......
#
25.00% perf libc-2.10.2.so [.] __GI___libc_read
25.00% kondemand/1 [kernel.kallsyms] [k] kernel_thread_helper
25.00% kondemand/0 [kernel.kallsyms] [k] kernel_thread_helper
[root@doppio ~]#

And what about support for modules? You have everything you need there
as well :-)

If you do:

struct map *mod;
struct symbol *sym;

mod = map_groups__find_by_name(&session.kmap_groups,
MAP__FUNCTION, "[ipv6]");

sym = map__find_symbol_by_name(module, "ip6_xmit");

you'll get ipv6.ko located and loaded, mod->dso->long_name thus will
have the file to use with libdwarf and sym->start will have the
unrelocated address, and mod->start will have where ipv6 is loaded in
kernel space.

Also you should be able to find variables by name or address too, just
use MAP__VARIABLE where above you see MAP__FUNCTION.

- Arnaldo