]>
Commit | Line | Data |
---|---|---|
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, bool quiet) | |
9 | { | |
10 | kperf_reset(); | |
11 | ||
12 | (void)kperf_action_count_set(1); | |
13 | (void)kperf_timer_count_set(1); | |
14 | ||
15 | if (quiet) { | |
16 | T_QUIET; | |
17 | } | |
18 | T_ASSERT_POSIX_SUCCESS(kperf_action_samplers_set(1, | |
19 | KPERF_SAMPLER_USTACK | KPERF_SAMPLER_KSTACK), NULL); | |
20 | ||
21 | if (pid != -1) { | |
22 | if (quiet) { | |
23 | T_QUIET; | |
24 | } | |
25 | T_ASSERT_POSIX_SUCCESS(kperf_action_filter_set_by_pid(1, pid), NULL); | |
26 | } | |
27 | ||
28 | if (quiet) { | |
29 | T_QUIET; | |
30 | } | |
31 | T_ASSERT_POSIX_SUCCESS(kperf_timer_action_set(0, 1), NULL); | |
32 | if (quiet) { | |
33 | T_QUIET; | |
34 | } | |
35 | T_ASSERT_POSIX_SUCCESS(kperf_timer_period_set(0, | |
36 | kperf_ns_to_ticks(period_ms * NSEC_PER_MSEC)), NULL); | |
37 | } |