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