diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-11-26 08:03:29 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-12-05 19:51:42 +0100 |
commit | 8ad85e9e6fdaf996bf3ff60303ea00e696bcdd36 (patch) | |
tree | db08e2b766f375c3037d8dcc39d730c3b58b1dec /tools/perf/tests | |
parent | tools build: Fix objtool build with clang (diff) | |
download | linux-8ad85e9e6fdaf996bf3ff60303ea00e696bcdd36.tar.xz linux-8ad85e9e6fdaf996bf3ff60303ea00e696bcdd36.zip |
perf tools: Pass context to perf hook functions
Pass a pointer to perf hook functions so they receive context
information during setup.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Stringer <joe@ovn.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/20161126070354.141764-6-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests')
-rw-r--r-- | tools/perf/tests/perf-hooks.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c index 9338cb2c25ab..665ecc19671c 100644 --- a/tools/perf/tests/perf-hooks.c +++ b/tools/perf/tests/perf-hooks.c @@ -15,13 +15,13 @@ static void sigsegv_handler(int sig __maybe_unused) exit(-1); } -static int hook_flags; -static void the_hook(void) +static void the_hook(void *_hook_flags) { + int *hook_flags = _hook_flags; int *p = NULL; - hook_flags = 1234; + *hook_flags = 1234; /* Generate a segfault, test perf_hooks__recover */ *p = 0; @@ -29,13 +29,17 @@ static void the_hook(void) int test__perf_hooks(int subtest __maybe_unused) { + int hook_flags = 0; + signal(SIGSEGV, sigsegv_handler); - perf_hooks__set_hook("test", the_hook); + perf_hooks__set_hook("test", the_hook, &hook_flags); perf_hooks__invoke_test(); /* hook is triggered? */ - if (hook_flags != 1234) + if (hook_flags != 1234) { + pr_debug("Setting failed: %d (%p)\n", hook_flags, &hook_flags); return TEST_FAIL; + } /* the buggy hook is removed? */ if (perf_hooks__get_hook("test")) |