linux-stable/tools/perf/util
Kirill Smelkov ee11b90b12 perf top: Fix annotate for userspace
First, for programs and prelinked libraries, annotate code was
fooled by objdump output IPs (src->eip in the code) being
wrongly converted to absolute IPs. In such case there were no
conversion needed, but in

   src->eip = strtoull(src->line, NULL, 16);
   src->eip = map->unmap_ip(map, src->eip); // = eip + map->start - map->pgoff

we were reading absolute address from objdump (e.g. 8048604) and
then almost doubling it, because eip & map->start are
approximately close for small programs.

Needless to say, that later, in record_precise_ip() there was no
matching with real runtime IPs.

And second, like with `perf annotate` the problem with
non-prelinked *.so was that we were doing rip -> objdump address
conversion wrong.

Also, because unlike `perf annotate`, `perf top` code does
annotation based on absolute IPs for performance reasons(*), new
helper for mapping objdump addresse to IP is introduced.

(*) we get samples info in absolute IPs, and since we do lots of
    hit-testing on absolute IPs at runtime in record_precise_ip(), it's
    better to convert objdump addresses to IPs once and do no conversion
    at runtime.

I also had to fix how objdump output is parsed (with hardcoded
8/16 characters format, which was inappropriate for ET_DYN dsos
with small addresses like '4ac')

Also note, that not all objdump output lines has associtated
IPs, e.g. look at source lines here:

    000004ac <my_strlen>:
    extern "C"
    int my_strlen(const char *s)
     4ac:   55                      push   %ebp
     4ad:   89 e5                   mov    %esp,%ebp
     4af:   83 ec 10                sub    $0x10,%esp
    {
        int len = 0;
     4b2:   c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%ebp)
     4b9:   eb 08                   jmp    4c3 <my_strlen+0x17>

        while (*s) {
            ++len;
     4bb:   83 45 fc 01             addl   $0x1,-0x4(%ebp)
            ++s;
     4bf:   83 45 08 01             addl   $0x1,0x8(%ebp)

So we mark them with eip=0, and ignore such lines in annotate
lookup code.

Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
[ Note: one hunk of this patch was applied by Mike in 57d8188 ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1265550376-12665-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-02-07 17:30:20 +01:00
..
include perf tools: Adjust some verbosity levels 2010-02-04 09:33:27 +01:00
abspath.c perf: Enable more compiler warnings 2009-08-16 10:47:47 +02:00
alias.c perf_counter tools: Add more warnings and fix/annotate them 2009-07-01 12:49:48 +02:00
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 perf tools: Do not manually count string lengths 2009-10-13 11:55:31 +02:00
callchain.c perf tools: Unify debug messages mechanisms 2009-10-23 08:22:47 +02:00
callchain.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
color.c perf tools: Librarize trace_event() helper 2009-08-16 23:06:45 +02:00
color.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
config.c perf: Enable more compiler warnings 2009-08-16 10:47:47 +02:00
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 perf tools: Debug.h needs to include event.h for event_t 2009-11-16 22:05:50 +01:00
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 perf: Enable more compiler warnings 2009-08-16 10:47:47 +02:00
exec_cmd.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
generate-cmdlist.sh
header.c perf tools: Clean up O_LARGEFILE et al usage 2010-02-04 10:03:03 +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 perf_counter tools: Add more warnings and fix/annotate them 2009-07-01 12:49:48 +02:00
help.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
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 perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
map.c perf top: Fix annotate for userspace 2010-02-07 17:30:20 +01:00
map.h perf top: Fix annotate for userspace 2010-02-07 17:30:20 +01:00
pager.c perf_counter tools: Remove dead code 2009-06-27 06:06:39 +02:00
parse-events.c perf tools: Support tracepoint glob matching 2010-01-13 10:09:13 +01:00
parse-events.h perf trace: Add filter Suppport 2009-10-15 11:35:23 +02:00
parse-options.c perf tools: Align long options which have no short forms 2009-12-10 08:30:28 +01:00
parse-options.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
path.c perf: Enable more compiler warnings 2009-08-16 10:47:47 +02:00
PERF-VERSION-GEN perf tools: Bump version to 0.0.2 2009-10-16 10:34:28 +02:00
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 perf: Fix read buffer overflow 2009-08-04 11:09:56 +02:00
quote.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
run-command.c perf: Enable more compiler warnings 2009-08-16 10:47:47 +02:00
run-command.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
session.c perf tools: Clean up O_LARGEFILE et al usage 2010-02-04 10:03:03 +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 perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
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 perf_counter tools: Add more warnings and fix/annotate them 2009-07-01 12:49:48 +02:00
strbuf.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
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 perf timechart: Improve the visual appearance of scheduler delays 2009-10-20 03:39:21 +02:00
svghelper.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
symbol.c perf tools: Fix session init on non-modular kernels 2010-02-04 10:22:01 +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: Clean up O_LARGEFILE et al usage 2010-02-04 10:03:03 +01:00
trace-event.h perf trace/scripting: Add support for script args 2009-12-15 10:31:31 +01:00
types.h perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
usage.c perf top: Fall back to cpu-clock-tick hrtimer sampling if no cycle counter available 2009-06-07 17:31:52 +02:00
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 perf tools: Protect header files with a consistent style 2009-09-24 21:27:51 +02:00
wrapper.c perf tools: Remove unused wrapper routines 2009-11-24 16:37:03 +01:00