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