summaryrefslogtreecommitdiff
path: root/tools/perf/tests/perf-hooks.c
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2016-11-26 07:03:29 +0000
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-12-05 15:51:42 -0300
commit8ad85e9e6fdaf996bf3ff60303ea00e696bcdd36 (patch)
treedb08e2b766f375c3037d8dcc39d730c3b58b1dec /tools/perf/tests/perf-hooks.c
parentbaa1973ebcf6a7bd15522a5b6a35a8fefd6cb232 (diff)
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/perf-hooks.c')
-rw-r--r--tools/perf/tests/perf-hooks.c14
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"))