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