linux/tools/perf/util
Kirill Smelkov 7a2b620986 perf annotate: Fix it for non-prelinked *.so
The problem was we were incorrectly calculating objdump
addresses for sym->start and sym->end, look:

For simple ET_DYN type DSO (*.so) with one function, objdump -dS
output is something like this:

    000004ac <my_strlen>:
    int my_strlen(const char *s)
     4ac:   55                      push   %ebp
     4ad:   89 e5                   mov    %esp,%ebp
     4af:   83 ec 10                sub    $0x10,%esp
    {

i.e. we have relative-to-dso-mapping IPs (=RIP) there.

For ET_EXEC type and probably for prelinked libs as well (sorry
can't test - I don't use prelink) objdump outputs absolute IPs,
e.g.

    08048604 <zz_strlen>:
    extern "C"
    int zz_strlen(const char *s)
     8048604:       55                      push   %ebp
     8048605:       89 e5                   mov    %esp,%ebp
     8048607:       83 ec 10                sub    $0x10,%esp
    {

So, if sym->start is always relative to dso mapping(*), we'll
have to unmap it for ET_EXEC like cases, and leave as is for
ET_DYN cases.

(*) and it is - we've explicitely made it relative. Look for
    adjust_symbols handling in dso__load_sym()

Previously we were always unmapping sym->start and for ET_DYN
dsos resulting addresses were wrong, and so objdump output was
empty.

The end result was that perf annotate output for symbols from
non-prelinked *.so had always 0.00% percents only, which is
wrong.

To fix it, let's introduce a helper for converting rip to
objdump address, and also let's document what map_ip() and
unmap_ip() do -- I had to study sources for several hours to
understand it.

Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265223128-11786-8-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-04 09:33:27 +01:00
..
include perf tools: Adjust some verbosity levels 2010-02-04 09:33:27 +01:00
abspath.c
alias.c
build-id.c perf build-id: Move the routine to find DSOs with hits to the lib 2010-02-04 09:33:26 +01:00
build-id.h perf build-id: Move the routine to find DSOs with hits to the lib 2010-02-04 09:33:26 +01:00
cache.h
callchain.c
callchain.h
color.c
color.h
config.c
ctype.c perf tools: Move graph_line and graph_dotted_line from top 2009-11-23 21:55:20 +01:00
debug.c perf tools: Move the map class definition to a separate header 2009-12-28 09:03:33 +01:00
debug.h
debugfs.c perf trace: Clean up find_debugfs() 2009-12-28 10:36:36 +01:00
debugfs.h perf tools: Mount debugfs automatically 2009-12-28 10:36:36 +01:00
environment.c
event.c perf symbols: Remove perf_session usage in symbols layer 2010-02-04 09:33:24 +01:00
event.h perf tools: Encode kernel module mappings in perf.data 2010-01-13 17:39:43 +01:00
exec_cmd.c
exec_cmd.h
generate-cmdlist.sh
header.c perf record: Stop intercepting events, use postprocessing to get build-ids 2010-02-04 09:33:27 +01:00
header.h perf buildid-cache: Add new command to manage build-id cache 2010-01-21 08:31:29 +01:00
help.c
help.h
hist.c perf diff: Percent calcs should use double values 2009-12-16 18:29:10 +01:00
hist.h perf diff: Use perf_session__fprintf_hists just like 'perf record' 2009-12-16 16:53:37 +01:00
levenshtein.c
levenshtein.h
map.c perf annotate: Fix it for non-prelinked *.so 2010-02-04 09:33:27 +01:00
map.h perf annotate: Fix it for non-prelinked *.so 2010-02-04 09:33:27 +01:00
pager.c
parse-events.c perf tools: Support tracepoint glob matching 2010-01-13 10:09:13 +01:00
parse-events.h
parse-options.c perf tools: Align long options which have no short forms 2009-12-10 08:30:28 +01:00
parse-options.h
path.c
PERF-VERSION-GEN
probe-event.c perf probe: Support --line option to show probable source-code lines 2010-01-13 10:09:14 +01:00
probe-event.h perf probe: Support --line option to show probable source-code lines 2010-01-13 10:09:14 +01:00
probe-finder.c perf probe: Support --line option to show probable source-code lines 2010-01-13 10:09:14 +01:00
probe-finder.h perf probe: Support --line option to show probable source-code lines 2010-01-13 10:09:14 +01:00
quote.c
quote.h
run-command.c
run-command.h
session.c perf record: Stop intercepting events, use postprocessing to get build-ids 2010-02-04 09:33:27 +01:00
session.h perf record: Stop intercepting events, use postprocessing to get build-ids 2010-02-04 09:33:27 +01:00
sigchain.c
sigchain.h
sort.c perf diff: Use perf_session__fprintf_hists just like 'perf record' 2009-12-16 16:53:37 +01:00
sort.h perf diff: Use perf_session__fprintf_hists just like 'perf record' 2009-12-16 16:53:37 +01:00
strbuf.c
strbuf.h
string.c perf tools: Enhance glob string matching 2010-01-13 10:09:14 +01:00
string.h perf probe: Add glob matching support on --del 2009-12-15 20:22:03 +01:00
strlist.c perf probe: Fix --del to update current event list 2009-12-15 20:22:01 +01:00
strlist.h perf tools: Add for_each macros for strlist 2009-12-15 20:22:02 +01:00
svghelper.c
svghelper.h
symbol.c perf tools: Adjust some verbosity levels 2010-02-04 09:33:27 +01:00
symbol.h perf record: Stop intercepting events, use postprocessing to get build-ids 2010-02-04 09:33:27 +01:00
thread.c perf symbols: Remove perf_session usage in symbols layer 2010-02-04 09:33:24 +01:00
thread.h perf symbols: Remove perf_session usage in symbols layer 2010-02-04 09:33:24 +01:00
trace-event-info.c perf tools: Convert getpagesize() uses to sysconf(_SC_GETPAGESIZE) 2010-01-16 10:58:46 +01:00
trace-event-parse.c perf tools: Add __data_loc support 2010-01-31 08:27:52 +01:00
trace-event-perl.c perf trace/scripting: Check return val of perl_run() 2009-12-15 10:31:32 +01:00
trace-event-perl.h perf trace/scripting: Fix compile error when libperl not installed 2009-12-07 06:31:37 +01:00
trace-event-read.c perf tools: Use O_LARGEFILE to open perf data file 2010-02-03 09:03:59 +01:00
trace-event.h perf trace/scripting: Add support for script args 2009-12-15 10:31:31 +01:00
types.h
usage.c
util.c perf: Fix implicit declaration of getline in util.c 2010-01-17 07:53:09 +01:00
util.h perf record: Introduce a symtab cache 2009-12-28 09:03:36 +01:00
values.c perf: Fix memory leak: counterwidth 2010-01-13 10:09:15 +01:00
values.h
wrapper.c perf tools: Remove unused wrapper routines 2009-11-24 16:37:03 +01:00