alistair23-linux/tools/perf
Hemant Kumar 270bde1e76 perf probe: Search both .eh_frame and .debug_frame sections for probe location
'perf probe' through debuginfo__find_probes() in util/probe-finder.c
checks for the functions' frame descriptions in either .eh_frame section
of an ELF or the .debug_frame.

The check is based on whether either one of these sections is present.
Depending on distro, toolchain defaults, architetcutre, build flags,
etc., CFI might be found in either .eh_frame and/or .debug_frame.
Sometimes, it may happen that, .eh_frame, even if present, may not be
complete and may miss some descriptions.

Therefore, to be sure, to find the CFI covering an address we will
always have to investigate both if available.

For e.g., in powerpc, this may happen:
  $ gcc -g bin.c -o bin

  $ objdump --dwarf ./bin
  <1><145>: Abbrev Number: 7 (DW_TAG_subprogram)
     <146> DW_AT_external   : 1
     <146> DW_AT_name       : (indirect string, offset: 0x9e): main
     <14a> DW_AT_decl_file  : 1
     <14b> DW_AT_decl_line  : 39
     <14c> DW_AT_prototyped : 1
     <14c> DW_AT_type       : <0x57>
     <150> DW_AT_low_pc     : 0x100007b8

If the .eh_frame and .debug_frame are checked for the same binary, we
will find that, .eh_frame (although present) doesn't contain a
description for "main" function.

But, .debug_frame has a description:

  000000d8 00000024 00000000 FDE cie=00000000 pc=100007b8..10000838
    DW_CFA_advance_loc: 16 to 100007c8
    DW_CFA_def_cfa_offset: 144
    DW_CFA_offset_extended_sf: r65 at cfa+16
  ...

Due to this (since, perf checks whether .eh_frame is present and goes on
searching for that address inside that frame), perf is unable to process
the probes:

  # perf probe -x ./bin main
    Failed to get call frame on 0x100007b8
    Error: Failed to add events.

To avoid this issue, we need to check both the sections (.eh_frame and
.debug_frame), which is done in this patch.

Note that, we can always force everything into both .eh_frame and
.debug_frame by:

  $ gcc bin.c -fasynchronous-unwind-tables  -fno-dwarf2-cfi-asm -g -o bin

Signed-off-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Mark Wielaard <mjw@redhat.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1454426806-13974-1-git-send-email-hemant@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-02 13:30:16 -03:00
..
arch perf tests: Remove wrong semicolon in while loop in CQM test 2016-01-26 11:14:06 -03:00
bench perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
config perf build: Introduce FEATURES_DUMP make variable 2016-01-15 16:32:00 -03:00
Documentation perf tools: Add more usage tips 2016-01-12 12:42:07 -03:00
python perf python: Support the PERF_RECORD_SWITCH event 2015-10-07 19:41:50 -03:00
scripts perf script: Add stat-cpi.py script 2016-01-06 20:11:16 -03:00
tests perf build: Pass O option to kernel makefile in build-test 2016-01-15 16:32:00 -03:00
trace/strace/groups perf trace: Add read/write to the file group 2015-09-04 13:22:06 -03:00
ui perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed 2016-01-26 11:14:25 -03:00
util perf probe: Search both .eh_frame and .debug_frame sections for probe location 2016-02-02 13:30:16 -03:00
.gitignore perf tools: Add Intel PT instruction decoder 2015-08-17 11:11:36 -03:00
Build perf tools: Set and pass DOCDIR to builtin-report.c 2016-01-12 12:42:07 -03:00
builtin-annotate.c perf tools: Pass evlist to setup_sorting() 2016-01-06 20:11:11 -03:00
builtin-bench.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-buildid-cache.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-buildid-list.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-config.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-data.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-diff.c perf diff: Use perf_hpp__register_sort_field interface 2016-01-08 12:59:30 -03:00
builtin-evlist.c perf evlist: Add --trace-fields option to show trace fields 2016-01-08 14:23:02 -03:00
builtin-help.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-inject.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-kmem.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-kvm.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-list.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-lock.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-mem.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-probe.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-record.c perf record: Add --buildid-all option 2016-01-12 12:42:07 -03:00
builtin-report.c perf tools: Fallback to srcdir/Documentation/tips.txt 2016-01-12 12:42:08 -03:00
builtin-sched.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-script.c perf script: Align event name properly 2016-01-08 12:57:26 -03:00
builtin-stat.c perf stat: Fix recort_usage typo 2016-01-12 11:13:52 -03:00
builtin-timechart.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-top.c perf report/top: Add --raw-trace option 2016-01-06 20:11:12 -03:00
builtin-trace.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-version.c perf tools: Move cmd_version() to builtin-version.c 2015-12-09 13:42:03 -03:00
builtin.h perf tools: Add 'perf config' command 2015-11-23 18:31:24 -03:00
command-list.txt perf tools: Do not show trace command if it's not compiled in 2016-01-08 12:46:17 -03:00
CREDITS
design.txt perf tools: Update some code references in design.txt 2014-03-18 18:17:06 -03:00
Makefile perf tools: Allow shuffling the build tests 2015-11-05 11:39:54 -03:00
Makefile.perf perf build: Introduce FEATURES_DUMP make variable 2016-01-15 16:32:00 -03:00
MANIFEST perf tools: Add missing sources to perf's MANIFEST 2016-01-11 12:09:25 -03:00
perf-archive.sh perf archive: Make 'f' the last parameter for tar 2012-09-17 13:10:42 -03:00
perf-completion.sh perf tools: Avoid confusion with preloaded bash function for perf bash completion 2015-03-19 13:53:27 -03:00
perf-read-vdso.c perf tools: Build programs to copy 32-bit compatibility 2014-10-29 10:32:48 -02:00
perf-sys.h perf tools: Move generic barriers out of perf-sys.h 2015-05-08 16:05:08 -03:00
perf-with-kcore.sh perf tools: Fix perf-with-kcore handling of arguments containing spaces 2015-08-06 16:48:27 -03:00
perf.c perf report: Show random usage tip on the help line 2016-01-08 13:15:46 -03:00
perf.h perf record: Add ability to name registers to record 2015-08-31 18:01:33 -03:00