Skip to content

perf: Add a libdw addr2line implementation

Ian Rogers linux-perf-users lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest7 patches 7 repliesIn review
  2. v26 patches 0 repliesSuperseded
  3. v11 patch 15 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7perf unwind-libdw: Fix invalid reference countstools/perf/util/unwind-libdw.c+5 -20 replies
2/7perf addr2line: Add a libdw implementationtools/perf/util/Build tools/perf/util/dso.c tools/perf/util/dso.h +4 more+252 -02 replies
3/7perf addr2line.c: Rename a2l_style to cmd_a2l_styletools/perf/util/addr2line.c+10 -100 replies
4/7perf srcline: Add configuration support for the addr2line styletools/perf/builtin-report.c tools/perf/util/config.c tools/perf/util/srcline.c +2 more+113 -110 replies
5/7perf callchain: Fix srcline printing with inlinestools/perf/util/evsel_fprintf.c+6 -20 replies
6/7perf test workload: Add inlineloop test workloadtools/perf/tests/builtin-test.c tools/perf/tests/tests.h tools/perf/tests/workloads/Build +1 more+56 -00 replies
7/7perf test: Test addr2line unwinding works with inline functionstools/perf/tests/shell/addr2line_inlines.sh+47 -00 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJames Clark
SeriesR-b
1/7
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/7] perf: Add a libdw addr2line implementation

addr2line is a performance bottleneck in perf, add a libdw based implementation that avoids forking addr2line and caches the decoded debug information.

Allow the addr2line implementation to be picked via the configuration file or --addr2line-style with perf report.

Test/fix that inline callchains are properly displayed by perf script.

An example:

```
$ perf record --call-graph dwarf -e cycles:u -- perf test -w inlineloop 1
[ perf record: Woken up 132 times to write data ]
[ perf record: Captured and wrote 32.814 MB perf.data (4074 samples) ]
$ perf script --fields +srcline
...
perf-inlineloop 1814670 293100.228871:     640004 cpu_core/cycles/u: 
            55a11d6e61ee leaf+0x2e
  inlineloop.c:21 (inlined)
            55a11d6e61ee middle+0x2e
  inlineloop.c:27 (inlined)
            55a11d6e61ee parent+0x2e (perf)
  inlineloop.c:32
            55a11d6e629b inlineloop+0x8b (perf)
  inlineloop.c:47
            55a11d69a3bc run_workload+0x5a (perf)
  builtin-test.c:715
            55a11d69aa9f cmd_test+0x417 (perf)
  builtin-test.c:825
            55a11d6155f5 run_builtin+0xd4 (perf)
  perf.c:349
            55a11d61588d handle_internal_command+0xdd (perf)
  perf.c:401
            55a11d6159e6 run_argv+0x35 (perf)
  perf.c:445
            55a11d615d2f main+0x2cb (perf)
  perf.c:553
            7fae3d233ca7 __libc_start_call_main+0x77 (libc.so.6)
  libc_start_call_main.h:58
            7fae3d233d64 __libc_start_main_impl+0x84
  libc-start.c:360 (inlined)
            55a11d565f80 _start+0x20 (perf)
  ??:0
...
```

v3: Make the caller inline file and line number accurate in the libdw
addr2line, rather than using the function's declared location. Fix reference counts in unwind-libdw. Add fixes tag for srcline inline printing.

v2: Fix bias issue with libdwfl functions. Use cu_walk_functions_at
from perf's dwarf-aux to fully walk inline functions. Add testing that inlined functions are shown in the perf script srcline callchain information. Add configurability as to which addr2line style to use.
https://lore.kernel.org/lkml/[email protected]/

v1: https://lore.kernel.org/lkml/[email protected]/

Ian Rogers (7):
perf unwind-libdw: Fix invalid reference counts
perf addr2line: Add a libdw implementation
perf addr2line.c: Rename a2l_style to cmd_a2l_style perf srcline: Add configuration support for the addr2line style perf callchain: Fix srcline printing with inlines perf test workload: Add inlineloop test workload
perf test: Test addr2line unwinding works with inline functions

 tools/perf/builtin-report.c                 |  10 ++
 tools/perf/tests/builtin-test.c             |   1 +
 tools/perf/tests/shell/addr2line_inlines.sh |  47 ++++++
 tools/perf/tests/tests.h                    |   1 +
 tools/perf/tests/workloads/Build            |   2 +
 tools/perf/tests/workloads/inlineloop.c     |  52 +++++++
 tools/perf/util/Build                       |   1 +
 tools/perf/util/addr2line.c                 |  20 +--
 tools/perf/util/config.c                    |   4 +
 tools/perf/util/dso.c                       |   2 +
 tools/perf/util/dso.h                       |  11 ++
 tools/perf/util/evsel_fprintf.c             |   8 +-
 tools/perf/util/libdw.c                     | 153 ++++++++++++++++++++
 tools/perf/util/libdw.h                     |  60 ++++++++
 tools/perf/util/srcline.c                   | 116 ++++++++++++++-
 tools/perf/util/srcline.h                   |   3 +
 tools/perf/util/symbol_conf.h               |  10 ++
 tools/perf/util/unwind-libdw.c              |   7 +-
 18 files changed, 486 insertions(+), 22 deletions(-)
 create mode 100755 tools/perf/tests/shell/addr2line_inlines.sh
 create mode 100644 tools/perf/tests/workloads/inlineloop.c
 create mode 100644 tools/perf/util/libdw.c
 create mode 100644 tools/perf/util/libdw.h
Signature · 1 line
2.52.0.457.g6b5491de43-goog