]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kperf/action.h
xnu-3789.1.32.tar.gz
[apple/xnu.git] / osfmk / kperf / action.h
1 /*
2 * Copyright (c) 2016 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef KPERF_ACTION_H
30 #define KPERF_ACTION_H
31
32 #include <mach/kern_return.h>
33
34 /* fwd decl */
35 struct kperf_sample;
36 struct kperf_context;
37
38 /* bits for defining what to do on an action */
39 #define SAMPLER_TH_INFO (1U << 0)
40 #define SAMPLER_TH_SNAPSHOT (1U << 1)
41 #define SAMPLER_KSTACK (1U << 2)
42 #define SAMPLER_USTACK (1U << 3)
43 #define SAMPLER_PMC_THREAD (1U << 4)
44 #define SAMPLER_PMC_CPU (1U << 5)
45 #define SAMPLER_PMC_CONFIG (1U << 6)
46 #define SAMPLER_MEMINFO (1U << 7)
47 #define SAMPLER_TH_SCHEDULING (1U << 8)
48 #define SAMPLER_TH_DISPATCH (1U << 9)
49 #define SAMPLER_TK_SNAPSHOT (1U << 10)
50
51 /* flags for sample calls */
52
53 /* pend certain samplers until AST boundary, instead of sampling them */
54 #define SAMPLE_FLAG_PEND_USER (1U << 0)
55 /* sample idle threads */
56 #define SAMPLE_FLAG_IDLE_THREADS (1U << 1)
57 /* do not sample callstacks */
58 #define SAMPLE_FLAG_EMPTY_CALLSTACK (1U << 2)
59 /* use the continuation as a kernel backtrace */
60 #define SAMPLE_FLAG_CONTINUATION (1U << 3)
61 /* sample is occurring outside of interrupt context */
62 #define SAMPLE_FLAG_NON_INTERRUPT (1U << 4)
63
64 /* Take a sample into "sbuf" using current thread "cur_thread" */
65 kern_return_t kperf_sample(struct kperf_sample *sbuf,
66 struct kperf_context *ctx,
67 unsigned actionid,
68 unsigned sample_flags);
69
70 /* return codes from taking a sample
71 * either keep trigger, or something went wrong (or we're shutting down)
72 * so turn off.
73 */
74 #define SAMPLE_CONTINUE (0)
75 #define SAMPLE_SHUTDOWN (1)
76 #define SAMPLE_OFF (2)
77
78 void kperf_action_reset(void);
79
80 /* Interface functions */
81 unsigned kperf_action_get_count(void);
82 int kperf_action_set_count(unsigned count);
83
84 int kperf_action_set_samplers(unsigned int actionid, uint32_t samplers);
85 int kperf_action_get_samplers(unsigned int actionid, uint32_t *samplers_out);
86
87 int kperf_action_set_userdata(unsigned int actionid, uint32_t userdata);
88 int kperf_action_get_userdata(unsigned int actionid, uint32_t *userdata_out);
89
90 int kperf_action_set_ucallstack_depth(unsigned int actionid, uint32_t depth);
91 int kperf_action_get_ucallstack_depth(unsigned int actionid, uint32_t * depth_out);
92 int kperf_action_set_kcallstack_depth(unsigned int actionid, uint32_t depth);
93 int kperf_action_get_kcallstack_depth(unsigned int actionid, uint32_t * depth_out);
94
95 int kperf_action_set_filter(unsigned int actionid, int pid);
96 int kperf_action_get_filter(unsigned int actionid, int *pid_out);
97
98 #endif /* !defined(KPERF_ACTION_H) */