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 28 #define _SDT_IMPL_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 extern const char *sdt_prefix; 35 36 typedef struct sdt_probedesc { 37 char *sdpd_name; /* name of this probe */ 38 int sdpd_namelen; 39 char *sdpd_func; /* APPLE NOTE: function name */ 40 const char *sdpd_prov; /* APPLE NOTE: provider name */ 41 unsigned long sdpd_offset; /* offset of call in text */ 42 struct sdt_probedesc *sdpd_next; /* next static probe */ 43 } sdt_probedesc_t; 44 45 #ifdef __cplusplus 46 } 47 #endif 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 #include <sys/dtrace.h> 54 55 struct module { 56 int sdt_nprobes; 57 sdt_probedesc_t *sdt_probes; 58 }; 59 60 extern int sdt_invop(uintptr_t, uintptr_t *, uintptr_t); 61 extern uint64_t sdt_getarg(void *, dtrace_id_t, void *, int, int); 62 63 void sdt_provide_module(void *, struct modctl *); 64 void sdt_early_init(void); 65 void sdt_load_machsect(struct modctl *ctl); 66 void sdt_init(void); 67 68 extern int sdt_probetab_size; 69 extern int sdt_probetab_mask; 70 #define SDT_ADDR2NDX(addr) ((((uintptr_t)(addr)) >> 4) & sdt_probetab_mask) 71 72 73 #if defined(__x86_64__) 74 typedef uint8_t sdt_instr_t; 75 #elif defined(__arm__) 76 typedef uint16_t sdt_instr_t; 77 #elif defined(__arm64__) 78 typedef uint32_t sdt_instr_t; 79 #else 80 #error Unknown implementation 81 #endif 82 83 typedef struct sdt_provider { 84 const char *sdtp_name; /* name of provider */ 85 const char *sdtp_prefix; /* prefix for probe names */ 86 dtrace_pattr_t *sdtp_attr; /* stability attributes */ 87 dtrace_provider_id_t sdtp_id; /* provider ID */ 88 } sdt_provider_t; 89 90 extern sdt_provider_t sdt_providers[]; /* array of providers */ 91 92 typedef struct sdt_probe { 93 sdt_provider_t *sdp_provider; /* provider */ 94 char *sdp_name; /* name of probe */ 95 int sdp_namelen; /* length of allocated name */ 96 dtrace_id_t sdp_id; /* probe ID */ 97 struct modctl *sdp_ctl; /* modctl for module */ 98 int sdp_loadcnt; /* load count for module */ 99 int sdp_primary; /* non-zero if primary mod */ 100 sdt_instr_t *sdp_patchpoint; /* patch point */ 101 sdt_instr_t sdp_patchval; /* instruction to patch */ 102 sdt_instr_t sdp_savedval; /* saved instruction value */ 103 struct sdt_probe *sdp_next; /* next probe */ 104 struct sdt_probe *sdp_hashnext; /* next on hash */ 105 } sdt_probe_t; 106 107 typedef struct sdt_argdesc { 108 const char *sda_provider; /* provider for arg */ 109 const char *sda_name; /* name of probe */ 110 const int sda_ndx; /* argument index */ 111 const int sda_mapping; /* mapping of argument */ 112 const char *sda_native; /* native type of argument */ 113 const char *sda_xlate; /* translated type of arg */ 114 } sdt_argdesc_t; 115 116 extern void sdt_getargdesc(void *, dtrace_id_t, void *, dtrace_argdesc_t *); 117 118 #ifdef __cplusplus 119 } 120 #endif 121 122 #endif /* _SDT_IMPL_H */ 123