linux/tools/perf/tests
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
..
attr perf tests: Fix attr tests 2015-04-08 10:49:53 -03:00
attr.c perf test: Keep test result clean if '-v' not set 2015-11-03 11:45:40 -03:00
attr.py perf tools: Remove EOL whitespaces 2015-01-21 13:24:31 -03:00
bp_signal_overflow.c perf tools: Enable close-on-exec flag on perf file descriptor 2014-07-18 09:09:34 +02:00
bp_signal.c perf tools: Enable close-on-exec flag on perf file descriptor 2014-07-18 09:09:34 +02:00
bpf-script-example.c perf tools: Compile scriptlets to BPF objects when passing '.c' to --event 2015-10-29 17:16:23 -03:00
Build perf tests: Move x86 tests into arch directory 2015-10-05 16:55:43 -03:00
builtin-test.c perf tests: Move x86 tests into arch directory 2015-10-05 16:55:43 -03:00
code-reading.c perf test: Keep test result clean if '-v' not set 2015-11-03 11:45:40 -03:00
dso-data.c perf tools: Reference count struct dso 2015-06-08 10:31:40 -03:00
dwarf-unwind.c perf tests: Move x86 tests into arch directory 2015-10-05 16:55:43 -03:00
evsel-roundtrip-name.c perf tools: Add parse_events_error interface 2015-04-29 10:37:58 -03:00
evsel-tp-sched.c perf evsel: Propagate error info from tp_format 2015-09-15 09:48:33 -03:00
fdarray.c tools lib fd array: Allow associating an integer cookie with each entry 2014-09-25 16:46:55 -03:00
hists_common.c perf tools: Reference count struct dso 2015-06-08 10:31:40 -03:00
hists_common.h perf tests: Define and use symbolic names for fake symbols 2014-06-01 14:35:11 +02:00
hists_cumulate.c perf callchain: Allow disabling call graphs per event 2015-08-12 13:20:28 -03:00
hists_filter.c perf test: Add entry for hists socket filter 2015-09-14 13:04:10 -03:00
hists_link.c perf machine: Protect the machine->threads with a rwlock 2015-05-08 16:19:27 -03:00
hists_output.c perf hists: Reducing arguments of hist_entry_iter__add() 2015-05-27 12:21:43 -03:00
keep-tracking.c perf test: Keep test result clean if '-v' not set 2015-11-03 11:45:40 -03:00
kmod-path.c perf tools: Deal with kernel module names in '[]' correctly 2015-06-03 10:02:38 -03:00
llvm.c bpf tools: Improve libbpf error reporting 2015-11-06 15:52:41 -03:00
make perf tools: Allow shuffling the build tests 2015-11-05 11:39:54 -03:00
mmap-basic.c perf evsel: Propagate error info from tp_format 2015-09-15 09:48:33 -03:00
mmap-thread-lookup.c perf tools: Add reference counting for thread_map object 2015-06-25 15:15:50 -03:00
openat-syscall-all-cpus.c perf test: Silence tracepoint event failures 2015-10-19 14:57:49 -03:00
openat-syscall-tp-fields.c perf test: Silence tracepoint event failures 2015-10-19 14:57:49 -03:00
openat-syscall.c perf test: Silence tracepoint event failures 2015-10-19 14:57:49 -03:00
parse-events.c perf test: Suppress libtraceevent warnings 2015-10-19 14:58:10 -03:00
parse-no-sample-id-all.c perf tools: Move pr_* debug macros into debug object 2014-07-17 12:58:39 -03:00
perf-record.c perf evlist: Introduce poll method for common code idiom 2014-09-25 16:46:55 -03:00
perf-targz-src-pkg perf tools: Add test for building detached source tarballs 2014-01-13 10:06:26 -03:00
pmu.c perf tools: Add term support for parse_events_error 2015-04-29 10:38:01 -03:00
python-use.c perf tests: Check python path on attr and binding test 2013-01-24 16:40:10 -03:00
sample-parsing.c perf tests: Fix typo in sample-parsing.c 2015-01-22 17:03:01 -03:00
sw-clock.c perf tests: Fix software clock events test setting maps 2015-09-15 11:04:49 -03:00
switch-tracking.c perf test: Keep test result clean if '-v' not set 2015-11-03 11:45:40 -03:00
task-exit.c perf tests: Fix task exit test setting maps 2015-09-15 11:03:58 -03:00
tests.h perf tests: Move x86 tests into arch directory 2015-10-05 16:55:43 -03:00
thread-map.c perf test: Check for refcnt in thread_map test 2015-07-21 14:20:32 -03:00
thread-mg-share.c perf tools: Use atomic.h for the map_groups refcount 2015-05-15 15:20:44 -03:00
topology.c perf cpu_map: Add data arg to cpu_map__build_map callback 2015-10-19 18:04:01 -03:00
vmlinux-kallsyms.c perf machine: Add method for common kernel_map(FUNCTION) operation 2015-09-30 18:34:29 -03:00