]>
Commit | Line | Data |
---|---|---|
39037602 A |
1 | #include "kperf_helpers.h" |
2 | ||
3 | #include <darwintest.h> | |
4 | #include <kperf/kperf.h> | |
5 | #include <unistd.h> | |
6 | ||
7 | void | |
8 | configure_kperf_stacks_timer(pid_t pid, unsigned int period_ms) | |
9 | { | |
10 | kperf_reset(); | |
11 | ||
12 | (void)kperf_action_count_set(1); | |
13 | (void)kperf_timer_count_set(1); | |
14 | ||
15 | T_ASSERT_POSIX_SUCCESS(kperf_action_samplers_set(1, | |
16 | KPERF_SAMPLER_USTACK | KPERF_SAMPLER_KSTACK), NULL); | |
17 | ||
18 | if (pid != -1) { | |
19 | T_ASSERT_POSIX_SUCCESS(kperf_action_filter_set_by_pid(1, pid), NULL); | |
20 | } | |
21 | ||
22 | T_ASSERT_POSIX_SUCCESS(kperf_timer_action_set(0, 1), NULL); | |
23 | T_ASSERT_POSIX_SUCCESS(kperf_timer_period_set(0, | |
24 | kperf_ns_to_ticks(period_ms * NSEC_PER_MSEC)), NULL); | |
25 | } |