linux/tools/perf
Wang Nan 6371ca3b54 bpf tools: Improve libbpf error reporting
In this patch, a series of libbpf specific error numbers and
libbpf_strerror() are introduced to help reporting errors.

Functions are updated to pass correct the error number through the
CHECK_ERR() macro.

All users of bpf_object__open{_buffer}() and bpf_program__title() in
perf are modified accordingly. In addition, due to the error codes
changing, bpf__strerror_load() is also modified to use them.

bpf__strerror_head() is also changed accordingly so it can parse libbpf
errors. bpf_loader_strerror() is introduced for that purpose, and will
be improved by the following patch.

load_program() is improved not to dump log buffer if it is empty. log
buffer is also used to deduce whether the error was caused by an invalid
program or other problem.

v1 -> v2:

 - Using macro for error code.

 - Fetch error message based on array index, eliminate for-loop.

 - Use log buffer to detect the reason of failure. 3 new error code
   are introduced to replace LIBBPF_ERRNO__LOAD.

In v1:

  # perf record -e ./test_ill_program.o ls
  event syntax error: './test_ill_program.o'
                       \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
  SKIP

  # perf record -e ./test_kversion_nomatch_program.o ls
  event syntax error: './test_kversion_nomatch_program.o'
                       \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
  SKIP

  # perf record -e ./test_big_program.o ls
  event syntax error: './test_big_program.o'
                       \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
  SKIP

  In v2:

  # perf record -e ./test_ill_program.o ls
  event syntax error: './test_ill_program.o'
                       \___ Kernel verifier blocks program loading
  SKIP

  # perf record -e ./test_kversion_nomatch_program.o
  event syntax error: './test_kversion_nomatch_program.o'
                       \___ Incorrect kernel version
  SKIP
  (Will be further improved by following patches)

  # perf record -e ./test_big_program.o
  event syntax error: './test_big_program.o'
                       \___ Program too big
  SKIP

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1446817783-86722-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-06 15:52:41 -03:00
..
arch perf tests: Add Intel CQM test 2015-10-05 16:56:07 -03:00
bench perf bench: Use named initializers in the trailer too 2015-10-19 18:17:25 -03:00
config perf tools: Make perf depend on libbpf 2015-10-28 12:48:12 -03:00
Documentation perf trace: Fix documentation for -i 2015-11-05 12:47:51 -03:00
python perf python: Support the PERF_RECORD_SWITCH event 2015-10-07 19:41:50 -03:00
scripts perf tools: Add more documentation to export-to-postgresql.py script 2015-09-28 16:53:07 -03:00
tests bpf tools: Improve libbpf error reporting 2015-11-06 15:52:41 -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: Don't die() when finding an invalid config option 2015-10-22 18:10:52 -03:00
util bpf tools: Improve libbpf error reporting 2015-11-06 15:52:41 -03:00
.gitignore perf tools: Add Intel PT instruction decoder 2015-08-17 11:11:36 -03:00
Build perf trace: Support 'strace' syscall event groups 2015-07-20 15:16:32 -03:00
builtin-annotate.c perf env: Rename some leftovers from rename to perf_env 2015-09-14 12:50:20 -03:00
builtin-bench.c perf bench: Run benchmarks, don't test them 2015-10-19 16:10:25 -03:00
builtin-buildid-cache.c perf buildid: Introduce sysfs/filename__sprintf_build_id 2015-08-28 14:53:50 -03:00
builtin-buildid-list.c perf buildid: Introduce sysfs/filename__sprintf_build_id 2015-08-28 14:53:50 -03:00
builtin-data.c perf data: Support using -f to override perf.data file ownership for 'convert' 2015-04-02 13:18:52 -03:00
builtin-diff.c perf callchain: Allow disabling call graphs per event 2015-08-12 13:20:28 -03:00
builtin-evlist.c perf tools: Introduce usage_with_options_msg() 2015-10-27 09:28:44 -03:00
builtin-help.c perf help: Change 'usage' to 'Usage' for consistency 2015-10-19 16:51:44 -03:00
builtin-inject.c perf inject: Add --strip option to strip out non-synthesized events 2015-09-28 17:19:51 -03:00
builtin-kmem.c perf machine: Add method for common kernel_map(FUNCTION) operation 2015-09-30 18:34:29 -03:00
builtin-kvm.c tools lib api fs: Replace debugfs/tracefs objects interface with fs.c 2015-09-14 12:50:15 -03:00
builtin-list.c perf list: Do event name substring search as last resort when no events found 2015-10-01 12:12:22 -03:00
builtin-lock.c perf machine: Protect the machine->threads with a rwlock 2015-05-08 16:19:27 -03:00
builtin-mem.c perf mem: Fill in the missing session freeing after an error occurs 2015-07-01 17:53:49 -03:00
builtin-probe.c perf tools: Introduce usage_with_options_msg() 2015-10-27 09:28:44 -03:00
builtin-record.c perf record: Add clang options for compiling BPF scripts 2015-10-29 17:16:22 -03:00
builtin-report.c perf report: Rename to --show-cpu-utilization 2015-10-26 14:06:04 -03:00
builtin-sched.c perf sched latency: Fix thread pid reuse issue 2015-11-05 12:51:00 -03:00
builtin-script.c perf script: Enable printing of branch stack 2015-10-29 17:16:20 -03:00
builtin-stat.c perf stat: Make stat options global 2015-11-05 17:54:34 -03:00
builtin-timechart.c perf tools: Elliminate alignment holes 2015-05-18 10:17:33 -03:00
builtin-top.c perf tools: Improve call graph documents and help messages 2015-10-22 16:23:19 -03:00
builtin-trace.c perf trace: Add cmd string table to decode sys_bpf first arg 2015-10-29 11:48:18 -03:00
builtin.h perf tools: Add new 'perf data' command 2015-02-25 12:42:25 -03:00
command-list.txt perf tools: Add new 'perf data' command 2015-02-25 12:42:25 -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 tools: Make sure fixdep is built before libbpf 2015-10-29 17:16:21 -03:00
MANIFEST perf tools: Make perf depend on libbpf 2015-10-28 12:48:12 -03:00
perf-archive.sh
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 tools: Enable passing bpf object file to --event 2015-10-28 12:48:12 -03:00
perf.h perf record: Add ability to name registers to record 2015-08-31 18:01:33 -03:00