perf annotate browser: Initial loop detection
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 24 Apr 2012 17:24:28 +0000 (14:24 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 24 Apr 2012 17:24:28 +0000 (14:24 -0300)
commita3f895be1f1ed17f66e6e71adeef0cc7f937512c
tree167a39caa601782726a483d977e9e4150d5fb3a7
parent59d038d591f7f00e6752cbfadbbc1c0ca318c5c0
perf annotate browser: Initial loop detection

Simple algorithm, just look for the next backward jump that points to
before the cursor.

Then draw an arrow connecting the jump to its target.

Do this as you move the cursor, entering/exiting possible loops.

Ex (graph chars replaced to avoid mail encoding woes):

avc_has_perm_flags
    0.00 |         nopl   0x0(%rax)
    5.36 |+-> 68:  mov    (%rax),%rax
    5.15 ||        test   %rax,%rax
    0.00 ||      v je     130
    2.96 ||   74:  cmp    -0x20(%rax),%ebx
   47.38 ||        lea    -0x20(%rax),%rcx
    0.28 ||      ^ jne    68
    3.16 ||        cmp    -0x18(%rax),%dx
    0.00 |+------^ jne    68
    4.92 |         cmp    0x4(%rcx),%r13d
    0.00 |       v jne    68
    1.15 |         test   %rcx,%rcx
    0.00 |       v je     130

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-5gairf6or7dazlx3ocxwvftm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browser.c
tools/perf/ui/browser.h
tools/perf/ui/browsers/annotate.c