]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/sdt_impl.h
xnu-6153.81.5.tar.gz
[apple/xnu.git] / bsd / sys / sdt_impl.h
CommitLineData
2d21ac55
A
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef _SDT_IMPL_H
0a7de745 28#define _SDT_IMPL_H
2d21ac55 29
0a7de745 30#ifdef __cplusplus
2d21ac55
A
31extern "C" {
32#endif
33
34extern const char *sdt_prefix;
35
36typedef struct sdt_probedesc {
0a7de745
A
37 char *sdpd_name; /* name of this probe */
38 char *sdpd_func; /* APPLE NOTE: function name */
39 unsigned long sdpd_offset; /* offset of call in text */
40 struct sdt_probedesc *sdpd_next; /* next static probe */
2d21ac55
A
41} sdt_probedesc_t;
42
0a7de745 43#ifdef __cplusplus
2d21ac55
A
44}
45#endif
46
0a7de745 47#ifdef __cplusplus
2d21ac55
A
48extern "C" {
49#endif
50
51#include <sys/dtrace.h>
52
2d21ac55
A
53struct module {
54 int sdt_nprobes;
55 sdt_probedesc_t *sdt_probes;
56};
57
58extern int sdt_invop(uintptr_t, uintptr_t *, uintptr_t);
6d2010ae 59extern uint64_t sdt_getarg(void *, dtrace_id_t, void *, int, int);
2d21ac55
A
60
61void sdt_provide_module(void *, struct modctl *);
d9a64523 62void sdt_early_init(void);
2d21ac55
A
63void sdt_init(void);
64
65extern int sdt_probetab_size;
66extern int sdt_probetab_mask;
67#define SDT_ADDR2NDX(addr) ((((uintptr_t)(addr)) >> 4) & sdt_probetab_mask)
68
69
39236c6e 70#if defined(__x86_64__)
2d21ac55 71typedef uint8_t sdt_instr_t;
5ba3f43e
A
72#elif defined(__arm__)
73typedef uint16_t sdt_instr_t;
74#elif defined(__arm64__)
75typedef uint32_t sdt_instr_t;
2d21ac55
A
76#else
77#error Unknown implementation
78#endif
2d21ac55
A
79
80typedef struct sdt_provider {
0a7de745
A
81 const char *sdtp_name; /* name of provider */
82 const char *sdtp_prefix; /* prefix for probe names */
83 dtrace_pattr_t *sdtp_attr; /* stability attributes */
84 dtrace_provider_id_t sdtp_id; /* provider ID */
2d21ac55
A
85} sdt_provider_t;
86
0a7de745 87extern sdt_provider_t sdt_providers[]; /* array of providers */
2d21ac55
A
88
89typedef struct sdt_probe {
0a7de745
A
90 sdt_provider_t *sdp_provider; /* provider */
91 char *sdp_name; /* name of probe */
92 int sdp_namelen; /* length of allocated name */
93 dtrace_id_t sdp_id; /* probe ID */
94 struct modctl *sdp_ctl; /* modctl for module */
95 int sdp_loadcnt; /* load count for module */
96 int sdp_primary; /* non-zero if primary mod */
97 sdt_instr_t *sdp_patchpoint; /* patch point */
98 sdt_instr_t sdp_patchval; /* instruction to patch */
99 sdt_instr_t sdp_savedval; /* saved instruction value */
100 struct sdt_probe *sdp_next; /* next probe */
101 struct sdt_probe *sdp_hashnext; /* next on hash */
2d21ac55
A
102} sdt_probe_t;
103
104typedef struct sdt_argdesc {
0a7de745
A
105 const char *sda_provider; /* provider for arg */
106 const char *sda_name; /* name of probe */
107 const int sda_ndx; /* argument index */
108 const int sda_mapping; /* mapping of argument */
109 const char *sda_native; /* native type of argument */
110 const char *sda_xlate; /* translated type of arg */
2d21ac55
A
111} sdt_argdesc_t;
112
113extern void sdt_getargdesc(void *, dtrace_id_t, void *, dtrace_argdesc_t *);
114
0a7de745 115#ifdef __cplusplus
2d21ac55
A
116}
117#endif
118
0a7de745 119#endif /* _SDT_IMPL_H */