···11-/*
22- * CDDL HEADER START
33- *
44- * The contents of this file are subject to the terms of the
55- * Common Development and Distribution License (the "License").
66- * You may not use this file except in compliance with the License.
77- *
88- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99- * or http://www.opensolaris.org/os/licensing.
1010- * See the License for the specific language governing permissions
1111- * and limitations under the License.
1212- *
1313- * When distributing Covered Code, include this CDDL HEADER in each
1414- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1515- * If applicable, add the following below this CDDL HEADER, with the
1616- * fields enclosed by brackets "[]" replaced with your own identifying
1717- * information: Portions Copyright [yyyy] [name of copyright owner]
1818- *
1919- * CDDL HEADER END
2020- */
2121-2222-/*
2323- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2424- * Use is subject to license terms.
2525- */
2626-2727-#ifndef _SYS_DTRACE_H
2828-#define _SYS_DTRACE_H
2929-3030-/* #pragma ident "@(#)dtrace.h 1.37 07/06/05 SMI" */
3131-3232-#ifdef __cplusplus
3333-extern "C" {
3434-#endif
3535-3636-/*
3737- * DTrace Dynamic Tracing Software: Kernel Interfaces
3838- *
3939- * Note: The contents of this file are private to the implementation of the
4040- * Solaris system and DTrace subsystem and are subject to change at any time
4141- * without notice. Applications and drivers using these interfaces will fail
4242- * to run on future releases. These interfaces should not be used for any
4343- * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
4444- * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
4545- */
4646-4747-#ifndef _ASM
4848-4949-#if !defined(__APPLE__)
5050-#include <sys/types.h>
5151-#include <sys/modctl.h>
5252-#include <sys/processor.h>
5353-#include <sys/systm.h>
5454-#include <sys/ctf_api.h>
5555-#include <sys/cyclic.h>
5656-#include <sys/int_limits.h>
5757-#else /* is Apple Mac OS X */
5858-5959-#if defined(__LP64__)
6060-#if !defined(_LP64)
6161-#define _LP64 /* Solaris vs. Darwin */
6262-#endif
6363-#else
6464-#if !defined(_ILP32)
6565-#define _ILP32 /* Solaris vs. Darwin */
6666-#endif
6767-#endif
6868-6969-#ifdef KERNEL
7070-#ifndef _KERNEL
7171-#define _KERNEL /* Solaris vs. Darwin */
7272-#endif
7373-#endif
7474-7575-#if defined(__BIG_ENDIAN__)
7676-#if !defined(_BIG_ENDIAN)
7777-#define _BIG_ENDIAN /* Solaris vs. Darwin */
7878-#endif
7979-#elif defined(__LITTLE_ENDIAN__)
8080-#if !defined(_LITTLE_ENDIAN)
8181-#define _LITTLE_ENDIAN /* Solaris vs. Darwin */
8282-#endif
8383-#else
8484-#error Unknown endian-ness
8585-#endif
8686-8787-#include <sys/types.h>
8888-#include <stdint.h>
8989-9090-#ifndef NULL
9191-#define NULL ((void *)0) /* quiets many warnings */
9292-#endif
9393-9494-#define SEC 1
9595-#define MILLISEC 1000
9696-#define MICROSEC 1000000
9797-#define NANOSEC 1000000000
9898-9999-#define S_ROUND(x, a) ((x) + (((a) ? (a) : 1) - 1) & ~(((a) ? (a) : 1) - 1))
100100-#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
101101-102102-#define CTF_MODEL_ILP32 1 /* object data model is ILP32 */
103103-#define CTF_MODEL_LP64 2 /* object data model is LP64 */
104104-#ifdef __LP64__
105105-#define CTF_MODEL_NATIVE CTF_MODEL_LP64
106106-#else
107107-#define CTF_MODEL_NATIVE CTF_MODEL_ILP32
108108-#endif
109109-110110-typedef uint8_t uchar_t;
111111-typedef uint16_t ushort_t;
112112-typedef uint32_t uint_t;
113113-typedef unsigned long ulong_t;
114114-typedef uint64_t u_longlong_t;
115115-typedef int64_t longlong_t;
116116-typedef int64_t off64_t;
117117-typedef int processorid_t;
118118-typedef int64_t hrtime_t;
119119-120120-typedef enum { B_FALSE = 0, B_TRUE = 1 } _dtrace_boolean;
121121-122122-typedef uint8_t UUID[16]; /* For modctl use in dtrace.h */
123123-124124-struct modctl; /* In lieu of Solaris <sys/modctl.h> */
125125-/* NOTHING */ /* In lieu of Solaris <sys/processor.h> */
126126-#include <sys/ioctl.h> /* In lieu of Solaris <sys/systm.h> */
127127-#ifdef KERNEL
128128-/* NOTHING */ /* In lieu of Solaris <sys/ctf_api.h> */
129129-#else
130130-/* In lieu of Solaris <sys/ctf_api.h> */
131131-typedef struct ctf_file ctf_file_t;
132132-typedef long ctf_id_t;
133133-#endif
134134-/* NOTHING */ /* In lieu of Solaris <sys/cyclic.h> */
135135-/* NOTHING */ /* In lieu of Solaris <sys/int_limits.h> */
136136-137137-typedef uint32_t zoneid_t;
138138-139139-#include <sys/dtrace_glue.h>
140140-141141-#include <stdarg.h>
142142-typedef va_list __va_list;
143143-144144-/* Solaris proc_t is the struct. Darwin's proc_t is a pointer to it. */
145145-#define proc_t struct proc /* Steer clear of the Darwin typedef for proc_t */
146146-#endif /* __APPLE__ */
147147-148148-/*
149149- * DTrace Universal Constants and Typedefs
150150- */
151151-#define DTRACE_CPUALL -1 /* all CPUs */
152152-#define DTRACE_IDNONE 0 /* invalid probe identifier */
153153-#define DTRACE_EPIDNONE 0 /* invalid enabled probe identifier */
154154-#define DTRACE_AGGIDNONE 0 /* invalid aggregation identifier */
155155-#define DTRACE_AGGVARIDNONE 0 /* invalid aggregation variable ID */
156156-#define DTRACE_CACHEIDNONE 0 /* invalid predicate cache */
157157-#define DTRACE_PROVNONE 0 /* invalid provider identifier */
158158-#define DTRACE_METAPROVNONE 0 /* invalid meta-provider identifier */
159159-#define DTRACE_ARGNONE -1 /* invalid argument index */
160160-161161-#define DTRACE_PROVNAMELEN 64
162162-#define DTRACE_MODNAMELEN 64
163163-#define DTRACE_FUNCNAMELEN 128
164164-#define DTRACE_NAMELEN 64
165165-#define DTRACE_FULLNAMELEN (DTRACE_PROVNAMELEN + DTRACE_MODNAMELEN + \
166166- DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 4)
167167-#define DTRACE_ARGTYPELEN 128
168168-169169-typedef uint32_t dtrace_id_t; /* probe identifier */
170170-typedef uint32_t dtrace_epid_t; /* enabled probe identifier */
171171-typedef uint32_t dtrace_aggid_t; /* aggregation identifier */
172172-typedef int64_t dtrace_aggvarid_t; /* aggregation variable identifier */
173173-typedef uint16_t dtrace_actkind_t; /* action kind */
174174-typedef int64_t dtrace_optval_t; /* option value */
175175-typedef uint32_t dtrace_cacheid_t; /* predicate cache identifier */
176176-177177-typedef enum dtrace_probespec {
178178- DTRACE_PROBESPEC_NONE = -1,
179179- DTRACE_PROBESPEC_PROVIDER = 0,
180180- DTRACE_PROBESPEC_MOD,
181181- DTRACE_PROBESPEC_FUNC,
182182- DTRACE_PROBESPEC_NAME
183183-} dtrace_probespec_t;
184184-185185-/*
186186- * DTrace Intermediate Format (DIF)
187187- *
188188- * The following definitions describe the DTrace Intermediate Format (DIF), a
189189- * a RISC-like instruction set and program encoding used to represent
190190- * predicates and actions that can be bound to DTrace probes. The constants
191191- * below defining the number of available registers are suggested minimums; the
192192- * compiler should use DTRACEIOC_CONF to dynamically obtain the number of
193193- * registers provided by the current DTrace implementation.
194194- */
195195-#define DIF_VERSION_1 1 /* DIF version 1: Solaris 10 Beta */
196196-#define DIF_VERSION_2 2 /* DIF version 2: Solaris 10 FCS */
197197-#define DIF_VERSION DIF_VERSION_2 /* latest DIF instruction set version */
198198-#define DIF_DIR_NREGS 8 /* number of DIF integer registers */
199199-#define DIF_DTR_NREGS 8 /* number of DIF tuple registers */
200200-201201-#define DIF_OP_OR 1 /* or r1, r2, rd */
202202-#define DIF_OP_XOR 2 /* xor r1, r2, rd */
203203-#define DIF_OP_AND 3 /* and r1, r2, rd */
204204-#define DIF_OP_SLL 4 /* sll r1, r2, rd */
205205-#define DIF_OP_SRL 5 /* srl r1, r2, rd */
206206-#define DIF_OP_SUB 6 /* sub r1, r2, rd */
207207-#define DIF_OP_ADD 7 /* add r1, r2, rd */
208208-#define DIF_OP_MUL 8 /* mul r1, r2, rd */
209209-#define DIF_OP_SDIV 9 /* sdiv r1, r2, rd */
210210-#define DIF_OP_UDIV 10 /* udiv r1, r2, rd */
211211-#define DIF_OP_SREM 11 /* srem r1, r2, rd */
212212-#define DIF_OP_UREM 12 /* urem r1, r2, rd */
213213-#define DIF_OP_NOT 13 /* not r1, rd */
214214-#define DIF_OP_MOV 14 /* mov r1, rd */
215215-#define DIF_OP_CMP 15 /* cmp r1, r2 */
216216-#define DIF_OP_TST 16 /* tst r1 */
217217-#define DIF_OP_BA 17 /* ba label */
218218-#define DIF_OP_BE 18 /* be label */
219219-#define DIF_OP_BNE 19 /* bne label */
220220-#define DIF_OP_BG 20 /* bg label */
221221-#define DIF_OP_BGU 21 /* bgu label */
222222-#define DIF_OP_BGE 22 /* bge label */
223223-#define DIF_OP_BGEU 23 /* bgeu label */
224224-#define DIF_OP_BL 24 /* bl label */
225225-#define DIF_OP_BLU 25 /* blu label */
226226-#define DIF_OP_BLE 26 /* ble label */
227227-#define DIF_OP_BLEU 27 /* bleu label */
228228-#define DIF_OP_LDSB 28 /* ldsb [r1], rd */
229229-#define DIF_OP_LDSH 29 /* ldsh [r1], rd */
230230-#define DIF_OP_LDSW 30 /* ldsw [r1], rd */
231231-#define DIF_OP_LDUB 31 /* ldub [r1], rd */
232232-#define DIF_OP_LDUH 32 /* lduh [r1], rd */
233233-#define DIF_OP_LDUW 33 /* lduw [r1], rd */
234234-#define DIF_OP_LDX 34 /* ldx [r1], rd */
235235-#define DIF_OP_RET 35 /* ret rd */
236236-#define DIF_OP_NOP 36 /* nop */
237237-#define DIF_OP_SETX 37 /* setx intindex, rd */
238238-#define DIF_OP_SETS 38 /* sets strindex, rd */
239239-#define DIF_OP_SCMP 39 /* scmp r1, r2 */
240240-#define DIF_OP_LDGA 40 /* ldga var, ri, rd */
241241-#define DIF_OP_LDGS 41 /* ldgs var, rd */
242242-#define DIF_OP_STGS 42 /* stgs var, rs */
243243-#define DIF_OP_LDTA 43 /* ldta var, ri, rd */
244244-#define DIF_OP_LDTS 44 /* ldts var, rd */
245245-#define DIF_OP_STTS 45 /* stts var, rs */
246246-#define DIF_OP_SRA 46 /* sra r1, r2, rd */
247247-#define DIF_OP_CALL 47 /* call subr, rd */
248248-#define DIF_OP_PUSHTR 48 /* pushtr type, rs, rr */
249249-#define DIF_OP_PUSHTV 49 /* pushtv type, rs, rv */
250250-#define DIF_OP_POPTS 50 /* popts */
251251-#define DIF_OP_FLUSHTS 51 /* flushts */
252252-#define DIF_OP_LDGAA 52 /* ldgaa var, rd */
253253-#define DIF_OP_LDTAA 53 /* ldtaa var, rd */
254254-#define DIF_OP_STGAA 54 /* stgaa var, rs */
255255-#define DIF_OP_STTAA 55 /* sttaa var, rs */
256256-#define DIF_OP_LDLS 56 /* ldls var, rd */
257257-#define DIF_OP_STLS 57 /* stls var, rs */
258258-#define DIF_OP_ALLOCS 58 /* allocs r1, rd */
259259-#define DIF_OP_COPYS 59 /* copys r1, r2, rd */
260260-#define DIF_OP_STB 60 /* stb r1, [rd] */
261261-#define DIF_OP_STH 61 /* sth r1, [rd] */
262262-#define DIF_OP_STW 62 /* stw r1, [rd] */
263263-#define DIF_OP_STX 63 /* stx r1, [rd] */
264264-#define DIF_OP_ULDSB 64 /* uldsb [r1], rd */
265265-#define DIF_OP_ULDSH 65 /* uldsh [r1], rd */
266266-#define DIF_OP_ULDSW 66 /* uldsw [r1], rd */
267267-#define DIF_OP_ULDUB 67 /* uldub [r1], rd */
268268-#define DIF_OP_ULDUH 68 /* ulduh [r1], rd */
269269-#define DIF_OP_ULDUW 69 /* ulduw [r1], rd */
270270-#define DIF_OP_ULDX 70 /* uldx [r1], rd */
271271-#define DIF_OP_RLDSB 71 /* rldsb [r1], rd */
272272-#define DIF_OP_RLDSH 72 /* rldsh [r1], rd */
273273-#define DIF_OP_RLDSW 73 /* rldsw [r1], rd */
274274-#define DIF_OP_RLDUB 74 /* rldub [r1], rd */
275275-#define DIF_OP_RLDUH 75 /* rlduh [r1], rd */
276276-#define DIF_OP_RLDUW 76 /* rlduw [r1], rd */
277277-#define DIF_OP_RLDX 77 /* rldx [r1], rd */
278278-#define DIF_OP_XLATE 78 /* xlate xlrindex, rd */
279279-#define DIF_OP_XLARG 79 /* xlarg xlrindex, rd */
280280-281281-#define DIF_INTOFF_MAX 0xffff /* highest integer table offset */
282282-#define DIF_STROFF_MAX 0xffff /* highest string table offset */
283283-#define DIF_REGISTER_MAX 0xff /* highest register number */
284284-#define DIF_VARIABLE_MAX 0xffff /* highest variable identifier */
285285-#define DIF_SUBROUTINE_MAX 0xffff /* highest subroutine code */
286286-287287-#define DIF_VAR_ARRAY_MIN 0x0000 /* lowest numbered array variable */
288288-#define DIF_VAR_ARRAY_UBASE 0x0080 /* lowest user-defined array */
289289-#define DIF_VAR_ARRAY_MAX 0x00ff /* highest numbered array variable */
290290-291291-#define DIF_VAR_OTHER_MIN 0x0100 /* lowest numbered scalar or assc */
292292-#define DIF_VAR_OTHER_UBASE 0x0500 /* lowest user-defined scalar or assc */
293293-#define DIF_VAR_OTHER_MAX 0xffff /* highest numbered scalar or assc */
294294-295295-#define DIF_VAR_ARGS 0x0000 /* arguments array */
296296-#define DIF_VAR_REGS 0x0001 /* registers array */
297297-#define DIF_VAR_UREGS 0x0002 /* user registers array */
298298-#define DIF_VAR_CURTHREAD 0x0100 /* thread pointer */
299299-#define DIF_VAR_TIMESTAMP 0x0101 /* timestamp */
300300-#define DIF_VAR_VTIMESTAMP 0x0102 /* virtual timestamp */
301301-#define DIF_VAR_IPL 0x0103 /* interrupt priority level */
302302-#define DIF_VAR_EPID 0x0104 /* enabled probe ID */
303303-#define DIF_VAR_ID 0x0105 /* probe ID */
304304-#define DIF_VAR_ARG0 0x0106 /* first argument */
305305-#define DIF_VAR_ARG1 0x0107 /* second argument */
306306-#define DIF_VAR_ARG2 0x0108 /* third argument */
307307-#define DIF_VAR_ARG3 0x0109 /* fourth argument */
308308-#define DIF_VAR_ARG4 0x010a /* fifth argument */
309309-#define DIF_VAR_ARG5 0x010b /* sixth argument */
310310-#define DIF_VAR_ARG6 0x010c /* seventh argument */
311311-#define DIF_VAR_ARG7 0x010d /* eighth argument */
312312-#define DIF_VAR_ARG8 0x010e /* ninth argument */
313313-#define DIF_VAR_ARG9 0x010f /* tenth argument */
314314-#define DIF_VAR_STACKDEPTH 0x0110 /* stack depth */
315315-#define DIF_VAR_CALLER 0x0111 /* caller */
316316-#define DIF_VAR_PROBEPROV 0x0112 /* probe provider */
317317-#define DIF_VAR_PROBEMOD 0x0113 /* probe module */
318318-#define DIF_VAR_PROBEFUNC 0x0114 /* probe function */
319319-#define DIF_VAR_PROBENAME 0x0115 /* probe name */
320320-#define DIF_VAR_PID 0x0116 /* process ID */
321321-#define DIF_VAR_TID 0x0117 /* (per-process) thread ID */
322322-#define DIF_VAR_EXECNAME 0x0118 /* name of executable */
323323-#define DIF_VAR_ZONENAME 0x0119 /* zone name associated with process */
324324-#define DIF_VAR_WALLTIMESTAMP 0x011a /* wall-clock timestamp */
325325-#define DIF_VAR_USTACKDEPTH 0x011b /* user-land stack depth */
326326-#define DIF_VAR_UCALLER 0x011c /* user-level caller */
327327-#define DIF_VAR_PPID 0x011d /* parent process ID */
328328-#define DIF_VAR_UID 0x011e /* process user ID */
329329-#define DIF_VAR_GID 0x011f /* process group ID */
330330-#define DIF_VAR_ERRNO 0x0120 /* thread errno */
331331-#if defined(__APPLE__)
332332-#define DIF_VAR_PTHREAD_SELF 0x0200 /* Apple specific PTHREAD_SELF (Not currently supported!) */
333333-#define DIF_VAR_DISPATCHQADDR 0x0201 /* Apple specific dispatch queue addr */
334334-#endif /* __APPLE __ */
335335-336336-#define DIF_SUBR_RAND 0
337337-#define DIF_SUBR_MUTEX_OWNED 1
338338-#define DIF_SUBR_MUTEX_OWNER 2
339339-#define DIF_SUBR_MUTEX_TYPE_ADAPTIVE 3
340340-#define DIF_SUBR_MUTEX_TYPE_SPIN 4
341341-#define DIF_SUBR_RW_READ_HELD 5
342342-#define DIF_SUBR_RW_WRITE_HELD 6
343343-#define DIF_SUBR_RW_ISWRITER 7
344344-#define DIF_SUBR_COPYIN 8
345345-#define DIF_SUBR_COPYINSTR 9
346346-#define DIF_SUBR_SPECULATION 10
347347-#define DIF_SUBR_PROGENYOF 11
348348-#define DIF_SUBR_STRLEN 12
349349-#define DIF_SUBR_COPYOUT 13
350350-#define DIF_SUBR_COPYOUTSTR 14
351351-#define DIF_SUBR_ALLOCA 15
352352-#define DIF_SUBR_BCOPY 16
353353-#define DIF_SUBR_COPYINTO 17
354354-#define DIF_SUBR_MSGDSIZE 18
355355-#define DIF_SUBR_MSGSIZE 19
356356-#define DIF_SUBR_GETMAJOR 20
357357-#define DIF_SUBR_GETMINOR 21
358358-#define DIF_SUBR_DDI_PATHNAME 22
359359-#define DIF_SUBR_STRJOIN 23
360360-#define DIF_SUBR_LLTOSTR 24
361361-#define DIF_SUBR_BASENAME 25
362362-#define DIF_SUBR_DIRNAME 26
363363-#define DIF_SUBR_CLEANPATH 27
364364-#define DIF_SUBR_STRCHR 28
365365-#define DIF_SUBR_STRRCHR 29
366366-#define DIF_SUBR_STRSTR 30
367367-#define DIF_SUBR_STRTOK 31
368368-#define DIF_SUBR_SUBSTR 32
369369-#define DIF_SUBR_INDEX 33
370370-#define DIF_SUBR_RINDEX 34
371371-#define DIF_SUBR_HTONS 35
372372-#define DIF_SUBR_HTONL 36
373373-#define DIF_SUBR_HTONLL 37
374374-#define DIF_SUBR_NTOHS 38
375375-#define DIF_SUBR_NTOHL 39
376376-#define DIF_SUBR_NTOHLL 40
377377-#define DIF_SUBR_INET_NTOP 41
378378-#define DIF_SUBR_INET_NTOA 42
379379-#define DIF_SUBR_INET_NTOA6 43
380380-#if !defined(__APPLE__)
381381-382382-#define DIF_SUBR_MAX 43 /* max subroutine value */
383383-#else
384384-#define DIF_SUBR_COREPROFILE 44
385385-386386-#define DIF_SUBR_MAX 44 /* max subroutine value */
387387-#endif /* __APPLE__ */
388388-389389-typedef uint32_t dif_instr_t;
390390-391391-#define DIF_INSTR_OP(i) (((i) >> 24) & 0xff)
392392-#define DIF_INSTR_R1(i) (((i) >> 16) & 0xff)
393393-#define DIF_INSTR_R2(i) (((i) >> 8) & 0xff)
394394-#define DIF_INSTR_RD(i) ((i) & 0xff)
395395-#define DIF_INSTR_RS(i) ((i) & 0xff)
396396-#define DIF_INSTR_LABEL(i) ((i) & 0xffffff)
397397-#define DIF_INSTR_VAR(i) (((i) >> 8) & 0xffff)
398398-#define DIF_INSTR_INTEGER(i) (((i) >> 8) & 0xffff)
399399-#define DIF_INSTR_STRING(i) (((i) >> 8) & 0xffff)
400400-#define DIF_INSTR_SUBR(i) (((i) >> 8) & 0xffff)
401401-#define DIF_INSTR_TYPE(i) (((i) >> 16) & 0xff)
402402-#define DIF_INSTR_XLREF(i) (((i) >> 8) & 0xffff)
403403-404404-#define DIF_INSTR_FMT(op, r1, r2, d) \
405405- (((op) << 24) | ((r1) << 16) | ((r2) << 8) | (d))
406406-407407-#define DIF_INSTR_NOT(r1, d) (DIF_INSTR_FMT(DIF_OP_NOT, r1, 0, d))
408408-#define DIF_INSTR_MOV(r1, d) (DIF_INSTR_FMT(DIF_OP_MOV, r1, 0, d))
409409-#define DIF_INSTR_CMP(op, r1, r2) (DIF_INSTR_FMT(op, r1, r2, 0))
410410-#define DIF_INSTR_TST(r1) (DIF_INSTR_FMT(DIF_OP_TST, r1, 0, 0))
411411-#define DIF_INSTR_BRANCH(op, label) (((op) << 24) | (label))
412412-#define DIF_INSTR_LOAD(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d))
413413-#define DIF_INSTR_STORE(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d))
414414-#define DIF_INSTR_SETX(i, d) ((DIF_OP_SETX << 24) | ((i) << 8) | (d))
415415-#define DIF_INSTR_SETS(s, d) ((DIF_OP_SETS << 24) | ((s) << 8) | (d))
416416-#define DIF_INSTR_RET(d) (DIF_INSTR_FMT(DIF_OP_RET, 0, 0, d))
417417-#define DIF_INSTR_NOP (DIF_OP_NOP << 24)
418418-#define DIF_INSTR_LDA(op, v, r, d) (DIF_INSTR_FMT(op, v, r, d))
419419-#define DIF_INSTR_LDV(op, v, d) (((op) << 24) | ((v) << 8) | (d))
420420-#define DIF_INSTR_STV(op, v, rs) (((op) << 24) | ((v) << 8) | (rs))
421421-#define DIF_INSTR_CALL(s, d) ((DIF_OP_CALL << 24) | ((s) << 8) | (d))
422422-#define DIF_INSTR_PUSHTS(op, t, r2, rs) (DIF_INSTR_FMT(op, t, r2, rs))
423423-#define DIF_INSTR_POPTS (DIF_OP_POPTS << 24)
424424-#define DIF_INSTR_FLUSHTS (DIF_OP_FLUSHTS << 24)
425425-#define DIF_INSTR_ALLOCS(r1, d) (DIF_INSTR_FMT(DIF_OP_ALLOCS, r1, 0, d))
426426-#define DIF_INSTR_COPYS(r1, r2, d) (DIF_INSTR_FMT(DIF_OP_COPYS, r1, r2, d))
427427-#define DIF_INSTR_XLATE(op, r, d) (((op) << 24) | ((r) << 8) | (d))
428428-429429-#define DIF_REG_R0 0 /* %r0 is always set to zero */
430430-431431-/*
432432- * A DTrace Intermediate Format Type (DIF Type) is used to represent the types
433433- * of variables, function and associative array arguments, and the return type
434434- * for each DIF object (shown below). It contains a description of the type,
435435- * its size in bytes, and a module identifier.
436436- */
437437-typedef struct dtrace_diftype {
438438- uint8_t dtdt_kind; /* type kind (see below) */
439439- uint8_t dtdt_ckind; /* type kind in CTF */
440440- uint8_t dtdt_flags; /* type flags (see below) */
441441- uint8_t dtdt_pad; /* reserved for future use */
442442- uint32_t dtdt_size; /* type size in bytes (unless string) */
443443-} dtrace_diftype_t;
444444-445445-#define DIF_TYPE_CTF 0 /* type is a CTF type */
446446-#define DIF_TYPE_STRING 1 /* type is a D string */
447447-448448-#define DIF_TF_BYREF 0x1 /* type is passed by reference */
449449-450450-/*
451451- * A DTrace Intermediate Format variable record is used to describe each of the
452452- * variables referenced by a given DIF object. It contains an integer variable
453453- * identifier along with variable scope and properties, as shown below. The
454454- * size of this structure must be sizeof (int) aligned.
455455- */
456456-typedef struct dtrace_difv {
457457- uint32_t dtdv_name; /* variable name index in dtdo_strtab */
458458- uint32_t dtdv_id; /* variable reference identifier */
459459- uint8_t dtdv_kind; /* variable kind (see below) */
460460- uint8_t dtdv_scope; /* variable scope (see below) */
461461- uint16_t dtdv_flags; /* variable flags (see below) */
462462- dtrace_diftype_t dtdv_type; /* variable type (see above) */
463463-} dtrace_difv_t;
464464-465465-#define DIFV_KIND_ARRAY 0 /* variable is an array of quantities */
466466-#define DIFV_KIND_SCALAR 1 /* variable is a scalar quantity */
467467-468468-#define DIFV_SCOPE_GLOBAL 0 /* variable has global scope */
469469-#define DIFV_SCOPE_THREAD 1 /* variable has thread scope */
470470-#define DIFV_SCOPE_LOCAL 2 /* variable has local scope */
471471-472472-#define DIFV_F_REF 0x1 /* variable is referenced by DIFO */
473473-#define DIFV_F_MOD 0x2 /* variable is written by DIFO */
474474-475475-/*
476476- * DTrace Actions
477477- *
478478- * The upper byte determines the class of the action; the low bytes determines
479479- * the specific action within that class. The classes of actions are as
480480- * follows:
481481- *
482482- * [ no class ] <= May record process- or kernel-related data
483483- * DTRACEACT_PROC <= Only records process-related data
484484- * DTRACEACT_PROC_DESTRUCTIVE <= Potentially destructive to processes
485485- * DTRACEACT_KERNEL <= Only records kernel-related data
486486- * DTRACEACT_KERNEL_DESTRUCTIVE <= Potentially destructive to the kernel
487487- * DTRACEACT_SPECULATIVE <= Speculation-related action
488488- * DTRACEACT_AGGREGATION <= Aggregating action
489489- */
490490-#define DTRACEACT_NONE 0 /* no action */
491491-#define DTRACEACT_DIFEXPR 1 /* action is DIF expression */
492492-#define DTRACEACT_EXIT 2 /* exit() action */
493493-#define DTRACEACT_PRINTF 3 /* printf() action */
494494-#define DTRACEACT_PRINTA 4 /* printa() action */
495495-#define DTRACEACT_LIBACT 5 /* library-controlled action */
496496-497497-#if defined(__APPLE__)
498498-#define DTRACEACT_APPLEBINARY 50 /* Apple DT perf. tool action */
499499-#endif /* __APPLE__ */
500500-501501-#define DTRACEACT_PROC 0x0100
502502-#define DTRACEACT_USTACK (DTRACEACT_PROC + 1)
503503-#define DTRACEACT_JSTACK (DTRACEACT_PROC + 2)
504504-#define DTRACEACT_USYM (DTRACEACT_PROC + 3)
505505-#define DTRACEACT_UMOD (DTRACEACT_PROC + 4)
506506-#define DTRACEACT_UADDR (DTRACEACT_PROC + 5)
507507-508508-#define DTRACEACT_PROC_DESTRUCTIVE 0x0200
509509-#define DTRACEACT_STOP (DTRACEACT_PROC_DESTRUCTIVE + 1)
510510-#define DTRACEACT_RAISE (DTRACEACT_PROC_DESTRUCTIVE + 2)
511511-#define DTRACEACT_SYSTEM (DTRACEACT_PROC_DESTRUCTIVE + 3)
512512-#define DTRACEACT_FREOPEN (DTRACEACT_PROC_DESTRUCTIVE + 4)
513513-514514-#if defined(__APPLE__)
515515-/*
516516- * Dtrace stop() will task_suspend the currently running process.
517517- * Dtrace pidresume(pid) will task_resume it.
518518- */
519519-520520-#define DTRACEACT_PIDRESUME (DTRACEACT_PROC_DESTRUCTIVE + 50)
521521-#endif /* __APPLE__ */
522522-523523-#define DTRACEACT_PROC_CONTROL 0x0300
524524-525525-#define DTRACEACT_KERNEL 0x0400
526526-#define DTRACEACT_STACK (DTRACEACT_KERNEL + 1)
527527-#define DTRACEACT_SYM (DTRACEACT_KERNEL + 2)
528528-#define DTRACEACT_MOD (DTRACEACT_KERNEL + 3)
529529-530530-#define DTRACEACT_KERNEL_DESTRUCTIVE 0x0500
531531-#define DTRACEACT_BREAKPOINT (DTRACEACT_KERNEL_DESTRUCTIVE + 1)
532532-#define DTRACEACT_PANIC (DTRACEACT_KERNEL_DESTRUCTIVE + 2)
533533-#define DTRACEACT_CHILL (DTRACEACT_KERNEL_DESTRUCTIVE + 3)
534534-535535-#define DTRACEACT_SPECULATIVE 0x0600
536536-#define DTRACEACT_SPECULATE (DTRACEACT_SPECULATIVE + 1)
537537-#define DTRACEACT_COMMIT (DTRACEACT_SPECULATIVE + 2)
538538-#define DTRACEACT_DISCARD (DTRACEACT_SPECULATIVE + 3)
539539-540540-#define DTRACEACT_CLASS(x) ((x) & 0xff00)
541541-542542-#define DTRACEACT_ISDESTRUCTIVE(x) \
543543- (DTRACEACT_CLASS(x) == DTRACEACT_PROC_DESTRUCTIVE || \
544544- DTRACEACT_CLASS(x) == DTRACEACT_KERNEL_DESTRUCTIVE)
545545-546546-#define DTRACEACT_ISSPECULATIVE(x) \
547547- (DTRACEACT_CLASS(x) == DTRACEACT_SPECULATIVE)
548548-549549-#define DTRACEACT_ISPRINTFLIKE(x) \
550550- ((x) == DTRACEACT_PRINTF || (x) == DTRACEACT_PRINTA || \
551551- (x) == DTRACEACT_SYSTEM || (x) == DTRACEACT_FREOPEN)
552552-553553-/*
554554- * DTrace Aggregating Actions
555555- *
556556- * These are functions f(x) for which the following is true:
557557- *
558558- * f(f(x_0) U f(x_1) U ... U f(x_n)) = f(x_0 U x_1 U ... U x_n)
559559- *
560560- * where x_n is a set of arbitrary data. Aggregating actions are in their own
561561- * DTrace action class, DTTRACEACT_AGGREGATION. The macros provided here allow
562562- * for easier processing of the aggregation argument and data payload for a few
563563- * aggregating actions (notably: quantize(), lquantize(), and ustack()).
564564- */
565565-#define DTRACEACT_AGGREGATION 0x0700
566566-#define DTRACEAGG_COUNT (DTRACEACT_AGGREGATION + 1)
567567-#define DTRACEAGG_MIN (DTRACEACT_AGGREGATION + 2)
568568-#define DTRACEAGG_MAX (DTRACEACT_AGGREGATION + 3)
569569-#define DTRACEAGG_AVG (DTRACEACT_AGGREGATION + 4)
570570-#define DTRACEAGG_SUM (DTRACEACT_AGGREGATION + 5)
571571-#define DTRACEAGG_STDDEV (DTRACEACT_AGGREGATION + 6)
572572-#define DTRACEAGG_QUANTIZE (DTRACEACT_AGGREGATION + 7)
573573-#define DTRACEAGG_LQUANTIZE (DTRACEACT_AGGREGATION + 8)
574574-575575-#define DTRACEACT_ISAGG(x) \
576576- (DTRACEACT_CLASS(x) == DTRACEACT_AGGREGATION)
577577-578578-#if !defined(__APPLE__) /* Quiet compiler warning. */
579579-#define DTRACE_QUANTIZE_NBUCKETS \
580580- (((sizeof (uint64_t) * NBBY) - 1) * 2 + 1)
581581-582582-#define DTRACE_QUANTIZE_ZEROBUCKET ((sizeof (uint64_t) * NBBY) - 1)
583583-#else
584584-#define DTRACE_QUANTIZE_NBUCKETS \
585585- (int)(((sizeof (uint64_t) * NBBY) - 1) * 2 + 1)
586586-587587-#define DTRACE_QUANTIZE_ZEROBUCKET (int64_t)((sizeof (uint64_t) * NBBY) - 1)
588588-#endif /* __APPLE __*/
589589-590590-#define DTRACE_QUANTIZE_BUCKETVAL(buck) \
591591- (int64_t)((buck) < DTRACE_QUANTIZE_ZEROBUCKET ? \
592592- -(1LL << (DTRACE_QUANTIZE_ZEROBUCKET - 1 - (buck))) : \
593593- (buck) == DTRACE_QUANTIZE_ZEROBUCKET ? 0 : \
594594- 1LL << ((buck) - DTRACE_QUANTIZE_ZEROBUCKET - 1))
595595-596596-#define DTRACE_LQUANTIZE_STEPSHIFT 48
597597-#define DTRACE_LQUANTIZE_STEPMASK ((uint64_t)UINT16_MAX << 48)
598598-#define DTRACE_LQUANTIZE_LEVELSHIFT 32
599599-#define DTRACE_LQUANTIZE_LEVELMASK ((uint64_t)UINT16_MAX << 32)
600600-#define DTRACE_LQUANTIZE_BASESHIFT 0
601601-#define DTRACE_LQUANTIZE_BASEMASK UINT32_MAX
602602-603603-#define DTRACE_LQUANTIZE_STEP(x) \
604604- (uint16_t)(((x) & DTRACE_LQUANTIZE_STEPMASK) >> \
605605- DTRACE_LQUANTIZE_STEPSHIFT)
606606-607607-#define DTRACE_LQUANTIZE_LEVELS(x) \
608608- (uint16_t)(((x) & DTRACE_LQUANTIZE_LEVELMASK) >> \
609609- DTRACE_LQUANTIZE_LEVELSHIFT)
610610-611611-#define DTRACE_LQUANTIZE_BASE(x) \
612612- (int32_t)(((x) & DTRACE_LQUANTIZE_BASEMASK) >> \
613613- DTRACE_LQUANTIZE_BASESHIFT)
614614-615615-#define DTRACE_USTACK_NFRAMES(x) (uint32_t)((x) & UINT32_MAX)
616616-#define DTRACE_USTACK_STRSIZE(x) (uint32_t)((x) >> 32)
617617-#define DTRACE_USTACK_ARG(x, y) \
618618- ((((uint64_t)(y)) << 32) | ((x) & UINT32_MAX))
619619-620620-#if !defined(__APPLE__)
621621-622622-#ifndef _LP64
623623-#ifndef _LITTLE_ENDIAN
624624-#define DTRACE_PTR(type, name) uint32_t name##pad; type *name
625625-#else
626626-#define DTRACE_PTR(type, name) type *name; uint32_t name##pad
627627-#endif
628628-#else
629629-#define DTRACE_PTR(type, name) type *name
630630-#endif
631631-632632-#else
633633-634634-#ifndef _LP64
635635-#define DTRACE_PTR(type, name) user_addr_t name
636636-#else
637637-#define DTRACE_PTR(type, name) type *name
638638-#endif
639639-640640-#endif /* __APPLE__ */
641641-642642-/*
643643- * DTrace Object Format (DOF)
644644- *
645645- * DTrace programs can be persistently encoded in the DOF format so that they
646646- * may be embedded in other programs (for example, in an ELF file) or in the
647647- * dtrace driver configuration file for use in anonymous tracing. The DOF
648648- * format is versioned and extensible so that it can be revised and so that
649649- * internal data structures can be modified or extended compatibly. All DOF
650650- * structures use fixed-size types, so the 32-bit and 64-bit representations
651651- * are identical and consumers can use either data model transparently.
652652- *
653653- * The file layout is structured as follows:
654654- *
655655- * +---------------+-------------------+----- ... ----+---- ... ------+
656656- * | dof_hdr_t | dof_sec_t[ ... ] | loadable | non-loadable |
657657- * | (file header) | (section headers) | section data | section data |
658658- * +---------------+-------------------+----- ... ----+---- ... ------+
659659- * |<------------ dof_hdr.dofh_loadsz --------------->| |
660660- * |<------------ dof_hdr.dofh_filesz ------------------------------->|
661661- *
662662- * The file header stores meta-data including a magic number, data model for
663663- * the instrumentation, data encoding, and properties of the DIF code within.
664664- * The header describes its own size and the size of the section headers. By
665665- * convention, an array of section headers follows the file header, and then
666666- * the data for all loadable sections and unloadable sections. This permits
667667- * consumer code to easily download the headers and all loadable data into the
668668- * DTrace driver in one contiguous chunk, omitting other extraneous sections.
669669- *
670670- * The section headers describe the size, offset, alignment, and section type
671671- * for each section. Sections are described using a set of #defines that tell
672672- * the consumer what kind of data is expected. Sections can contain links to
673673- * other sections by storing a dof_secidx_t, an index into the section header
674674- * array, inside of the section data structures. The section header includes
675675- * an entry size so that sections with data arrays can grow their structures.
676676- *
677677- * The DOF data itself can contain many snippets of DIF (i.e. >1 DIFOs), which
678678- * are represented themselves as a collection of related DOF sections. This
679679- * permits us to change the set of sections associated with a DIFO over time,
680680- * and also permits us to encode DIFOs that contain different sets of sections.
681681- * When a DOF section wants to refer to a DIFO, it stores the dof_secidx_t of a
682682- * section of type DOF_SECT_DIFOHDR. This section's data is then an array of
683683- * dof_secidx_t's which in turn denote the sections associated with this DIFO.
684684- *
685685- * This loose coupling of the file structure (header and sections) to the
686686- * structure of the DTrace program itself (ECB descriptions, action
687687- * descriptions, and DIFOs) permits activities such as relocation processing
688688- * to occur in a single pass without having to understand D program structure.
689689- *
690690- * Finally, strings are always stored in ELF-style string tables along with a
691691- * string table section index and string table offset. Therefore strings in
692692- * DOF are always arbitrary-length and not bound to the current implementation.
693693- */
694694-695695-#define DOF_ID_SIZE 16 /* total size of dofh_ident[] in bytes */
696696-697697-typedef struct dof_hdr {
698698- uint8_t dofh_ident[DOF_ID_SIZE]; /* identification bytes (see below) */
699699- uint32_t dofh_flags; /* file attribute flags (if any) */
700700- uint32_t dofh_hdrsize; /* size of file header in bytes */
701701- uint32_t dofh_secsize; /* size of section header in bytes */
702702- uint32_t dofh_secnum; /* number of section headers */
703703- uint64_t dofh_secoff; /* file offset of section headers */
704704- uint64_t dofh_loadsz; /* file size of loadable portion */
705705- uint64_t dofh_filesz; /* file size of entire DOF file */
706706- uint64_t dofh_pad; /* reserved for future use */
707707-} dof_hdr_t;
708708-709709-#define DOF_ID_MAG0 0 /* first byte of magic number */
710710-#define DOF_ID_MAG1 1 /* second byte of magic number */
711711-#define DOF_ID_MAG2 2 /* third byte of magic number */
712712-#define DOF_ID_MAG3 3 /* fourth byte of magic number */
713713-#define DOF_ID_MODEL 4 /* DOF data model (see below) */
714714-#define DOF_ID_ENCODING 5 /* DOF data encoding (see below) */
715715-#define DOF_ID_VERSION 6 /* DOF file format major version (see below) */
716716-#define DOF_ID_DIFVERS 7 /* DIF instruction set version */
717717-#define DOF_ID_DIFIREG 8 /* DIF integer registers used by compiler */
718718-#define DOF_ID_DIFTREG 9 /* DIF tuple registers used by compiler */
719719-#define DOF_ID_PAD 10 /* start of padding bytes (all zeroes) */
720720-721721-#define DOF_MAG_MAG0 0x7F /* DOF_ID_MAG[0-3] */
722722-#define DOF_MAG_MAG1 'D'
723723-#define DOF_MAG_MAG2 'O'
724724-#define DOF_MAG_MAG3 'F'
725725-726726-#define DOF_MAG_STRING "\177DOF"
727727-#define DOF_MAG_STRLEN 4
728728-729729-#define DOF_MODEL_NONE 0 /* DOF_ID_MODEL */
730730-#define DOF_MODEL_ILP32 1
731731-#define DOF_MODEL_LP64 2
732732-733733-#ifdef _LP64
734734-#define DOF_MODEL_NATIVE DOF_MODEL_LP64
735735-#else
736736-#define DOF_MODEL_NATIVE DOF_MODEL_ILP32
737737-#endif
738738-739739-#define DOF_ENCODE_NONE 0 /* DOF_ID_ENCODING */
740740-#define DOF_ENCODE_LSB 1
741741-#define DOF_ENCODE_MSB 2
742742-743743-#ifdef _BIG_ENDIAN
744744-#define DOF_ENCODE_NATIVE DOF_ENCODE_MSB
745745-#else
746746-#define DOF_ENCODE_NATIVE DOF_ENCODE_LSB
747747-#endif
748748-749749-#define DOF_VERSION_1 1 /* DOF version 1: Solaris 10 FCS */
750750-#define DOF_VERSION_2 2 /* DOF version 2: Solaris Express 6/06 */
751751-#if !defined(__APPLE__)
752752-#define DOF_VERSION DOF_VERSION_2 /* Latest DOF version */
753753-#else
754754-#define DOF_VERSION_3 3 /* DOF version 3: Minimum version for Leopard */
755755-#define DOF_VERSION DOF_VERSION_3 /* Latest DOF version */
756756-#endif /* __APPLE__ */
757757-758758-#define DOF_FL_VALID 0 /* mask of all valid dofh_flags bits */
759759-760760-typedef uint32_t dof_secidx_t; /* section header table index type */
761761-typedef uint32_t dof_stridx_t; /* string table index type */
762762-763763-#define DOF_SECIDX_NONE (-1U) /* null value for section indices */
764764-#define DOF_STRIDX_NONE (-1U) /* null value for string indices */
765765-766766-typedef struct dof_sec {
767767- uint32_t dofs_type; /* section type (see below) */
768768- uint32_t dofs_align; /* section data memory alignment */
769769- uint32_t dofs_flags; /* section flags (if any) */
770770- uint32_t dofs_entsize; /* size of section entry (if table) */
771771- uint64_t dofs_offset; /* offset of section data within file */
772772- uint64_t dofs_size; /* size of section data in bytes */
773773-} dof_sec_t;
774774-775775-#define DOF_SECT_NONE 0 /* null section */
776776-#define DOF_SECT_COMMENTS 1 /* compiler comments */
777777-#define DOF_SECT_SOURCE 2 /* D program source code */
778778-#define DOF_SECT_ECBDESC 3 /* dof_ecbdesc_t */
779779-#define DOF_SECT_PROBEDESC 4 /* dof_probedesc_t */
780780-#define DOF_SECT_ACTDESC 5 /* dof_actdesc_t array */
781781-#define DOF_SECT_DIFOHDR 6 /* dof_difohdr_t (variable length) */
782782-#define DOF_SECT_DIF 7 /* uint32_t array of byte code */
783783-#define DOF_SECT_STRTAB 8 /* string table */
784784-#define DOF_SECT_VARTAB 9 /* dtrace_difv_t array */
785785-#define DOF_SECT_RELTAB 10 /* dof_relodesc_t array */
786786-#define DOF_SECT_TYPTAB 11 /* dtrace_diftype_t array */
787787-#define DOF_SECT_URELHDR 12 /* dof_relohdr_t (user relocations) */
788788-#define DOF_SECT_KRELHDR 13 /* dof_relohdr_t (kernel relocations) */
789789-#define DOF_SECT_OPTDESC 14 /* dof_optdesc_t array */
790790-#define DOF_SECT_PROVIDER 15 /* dof_provider_t */
791791-#define DOF_SECT_PROBES 16 /* dof_probe_t array */
792792-#define DOF_SECT_PRARGS 17 /* uint8_t array (probe arg mappings) */
793793-#define DOF_SECT_PROFFS 18 /* uint32_t array (probe arg offsets) */
794794-#define DOF_SECT_INTTAB 19 /* uint64_t array */
795795-#define DOF_SECT_UTSNAME 20 /* struct utsname */
796796-#define DOF_SECT_XLTAB 21 /* dof_xlref_t array */
797797-#define DOF_SECT_XLMEMBERS 22 /* dof_xlmember_t array */
798798-#define DOF_SECT_XLIMPORT 23 /* dof_xlator_t */
799799-#define DOF_SECT_XLEXPORT 24 /* dof_xlator_t */
800800-#define DOF_SECT_PREXPORT 25 /* dof_secidx_t array (exported objs) */
801801-#define DOF_SECT_PRENOFFS 26 /* uint32_t array (enabled offsets) */
802802-803803-#define DOF_SECF_LOAD 1 /* section should be loaded */
804804-805805-typedef struct dof_ecbdesc {
806806- dof_secidx_t dofe_probes; /* link to DOF_SECT_PROBEDESC */
807807- dof_secidx_t dofe_pred; /* link to DOF_SECT_DIFOHDR */
808808- dof_secidx_t dofe_actions; /* link to DOF_SECT_ACTDESC */
809809- uint32_t dofe_pad; /* reserved for future use */
810810- uint64_t dofe_uarg; /* user-supplied library argument */
811811-} dof_ecbdesc_t;
812812-813813-typedef struct dof_probedesc {
814814- dof_secidx_t dofp_strtab; /* link to DOF_SECT_STRTAB section */
815815- dof_stridx_t dofp_provider; /* provider string */
816816- dof_stridx_t dofp_mod; /* module string */
817817- dof_stridx_t dofp_func; /* function string */
818818- dof_stridx_t dofp_name; /* name string */
819819- uint32_t dofp_id; /* probe identifier (or zero) */
820820-} dof_probedesc_t;
821821-822822-typedef struct dof_actdesc {
823823- dof_secidx_t dofa_difo; /* link to DOF_SECT_DIFOHDR */
824824- dof_secidx_t dofa_strtab; /* link to DOF_SECT_STRTAB section */
825825- uint32_t dofa_kind; /* action kind (DTRACEACT_* constant) */
826826- uint32_t dofa_ntuple; /* number of subsequent tuple actions */
827827- uint64_t dofa_arg; /* kind-specific argument */
828828- uint64_t dofa_uarg; /* user-supplied argument */
829829-} dof_actdesc_t;
830830-831831-typedef struct dof_difohdr {
832832- dtrace_diftype_t dofd_rtype; /* return type for this fragment */
833833- dof_secidx_t dofd_links[1]; /* variable length array of indices */
834834-} dof_difohdr_t;
835835-836836-typedef struct dof_relohdr {
837837- dof_secidx_t dofr_strtab; /* link to DOF_SECT_STRTAB for names */
838838- dof_secidx_t dofr_relsec; /* link to DOF_SECT_RELTAB for relos */
839839- dof_secidx_t dofr_tgtsec; /* link to section we are relocating */
840840-} dof_relohdr_t;
841841-842842-typedef struct dof_relodesc {
843843- dof_stridx_t dofr_name; /* string name of relocation symbol */
844844- uint32_t dofr_type; /* relo type (DOF_RELO_* constant) */
845845- uint64_t dofr_offset; /* byte offset for relocation */
846846- uint64_t dofr_data; /* additional type-specific data */
847847-} dof_relodesc_t;
848848-849849-#define DOF_RELO_NONE 0 /* empty relocation entry */
850850-#define DOF_RELO_SETX 1 /* relocate setx value */
851851-852852-typedef struct dof_optdesc {
853853- uint32_t dofo_option; /* option identifier */
854854- dof_secidx_t dofo_strtab; /* string table, if string option */
855855- uint64_t dofo_value; /* option value or string index */
856856-} dof_optdesc_t;
857857-858858-typedef uint32_t dof_attr_t; /* encoded stability attributes */
859859-860860-#define DOF_ATTR(n, d, c) (((n) << 24) | ((d) << 16) | ((c) << 8))
861861-#define DOF_ATTR_NAME(a) (((a) >> 24) & 0xff)
862862-#define DOF_ATTR_DATA(a) (((a) >> 16) & 0xff)
863863-#define DOF_ATTR_CLASS(a) (((a) >> 8) & 0xff)
864864-865865-typedef struct dof_provider {
866866- dof_secidx_t dofpv_strtab; /* link to DOF_SECT_STRTAB section */
867867- dof_secidx_t dofpv_probes; /* link to DOF_SECT_PROBES section */
868868- dof_secidx_t dofpv_prargs; /* link to DOF_SECT_PRARGS section */
869869- dof_secidx_t dofpv_proffs; /* link to DOF_SECT_PROFFS section */
870870- dof_stridx_t dofpv_name; /* provider name string */
871871- dof_attr_t dofpv_provattr; /* provider attributes */
872872- dof_attr_t dofpv_modattr; /* module attributes */
873873- dof_attr_t dofpv_funcattr; /* function attributes */
874874- dof_attr_t dofpv_nameattr; /* name attributes */
875875- dof_attr_t dofpv_argsattr; /* args attributes */
876876- dof_secidx_t dofpv_prenoffs; /* link to DOF_SECT_PRENOFFS section */
877877-} dof_provider_t;
878878-879879-typedef struct dof_probe {
880880- uint64_t dofpr_addr; /* probe base address or offset */
881881- dof_stridx_t dofpr_func; /* probe function string */
882882- dof_stridx_t dofpr_name; /* probe name string */
883883- dof_stridx_t dofpr_nargv; /* native argument type strings */
884884- dof_stridx_t dofpr_xargv; /* translated argument type strings */
885885- uint32_t dofpr_argidx; /* index of first argument mapping */
886886- uint32_t dofpr_offidx; /* index of first offset entry */
887887- uint8_t dofpr_nargc; /* native argument count */
888888- uint8_t dofpr_xargc; /* translated argument count */
889889- uint16_t dofpr_noffs; /* number of offset entries for probe */
890890- uint32_t dofpr_enoffidx; /* index of first is-enabled offset */
891891- uint16_t dofpr_nenoffs; /* number of is-enabled offsets */
892892- uint16_t dofpr_pad1; /* reserved for future use */
893893- uint32_t dofpr_pad2; /* reserved for future use */
894894-} dof_probe_t;
895895-896896-typedef struct dof_xlator {
897897- dof_secidx_t dofxl_members; /* link to DOF_SECT_XLMEMBERS section */
898898- dof_secidx_t dofxl_strtab; /* link to DOF_SECT_STRTAB section */
899899- dof_stridx_t dofxl_argv; /* input parameter type strings */
900900- uint32_t dofxl_argc; /* input parameter list length */
901901- dof_stridx_t dofxl_type; /* output type string name */
902902- dof_attr_t dofxl_attr; /* output stability attributes */
903903-} dof_xlator_t;
904904-905905-typedef struct dof_xlmember {
906906- dof_secidx_t dofxm_difo; /* member link to DOF_SECT_DIFOHDR */
907907- dof_stridx_t dofxm_name; /* member name */
908908- dtrace_diftype_t dofxm_type; /* member type */
909909-} dof_xlmember_t;
910910-911911-typedef struct dof_xlref {
912912- dof_secidx_t dofxr_xlator; /* link to DOF_SECT_XLATORS section */
913913- uint32_t dofxr_member; /* index of referenced dof_xlmember */
914914- uint32_t dofxr_argn; /* index of argument for DIF_OP_XLARG */
915915-} dof_xlref_t;
916916-917917-/*
918918- * DTrace Intermediate Format Object (DIFO)
919919- *
920920- * A DIFO is used to store the compiled DIF for a D expression, its return
921921- * type, and its string and variable tables. The string table is a single
922922- * buffer of character data into which sets instructions and variable
923923- * references can reference strings using a byte offset. The variable table
924924- * is an array of dtrace_difv_t structures that describe the name and type of
925925- * each variable and the id used in the DIF code. This structure is described
926926- * above in the DIF section of this header file. The DIFO is used at both
927927- * user-level (in the library) and in the kernel, but the structure is never
928928- * passed between the two: the DOF structures form the only interface. As a
929929- * result, the definition can change depending on the presence of _KERNEL.
930930- */
931931-typedef struct dtrace_difo {
932932- dif_instr_t *dtdo_buf; /* instruction buffer */
933933- uint64_t *dtdo_inttab; /* integer table (optional) */
934934- char *dtdo_strtab; /* string table (optional) */
935935- dtrace_difv_t *dtdo_vartab; /* variable table (optional) */
936936- uint_t dtdo_len; /* length of instruction buffer */
937937- uint_t dtdo_intlen; /* length of integer table */
938938- uint_t dtdo_strlen; /* length of string table */
939939- uint_t dtdo_varlen; /* length of variable table */
940940- dtrace_diftype_t dtdo_rtype; /* return type */
941941- uint_t dtdo_refcnt; /* owner reference count */
942942- uint_t dtdo_destructive; /* invokes destructive subroutines */
943943-#ifndef _KERNEL
944944- dof_relodesc_t *dtdo_kreltab; /* kernel relocations */
945945- dof_relodesc_t *dtdo_ureltab; /* user relocations */
946946- struct dt_node **dtdo_xlmtab; /* translator references */
947947- uint_t dtdo_krelen; /* length of krelo table */
948948- uint_t dtdo_urelen; /* length of urelo table */
949949- uint_t dtdo_xlmlen; /* length of translator table */
950950-#endif
951951-} dtrace_difo_t;
952952-953953-/*
954954- * DTrace Enabling Description Structures
955955- *
956956- * When DTrace is tracking the description of a DTrace enabling entity (probe,
957957- * predicate, action, ECB, record, etc.), it does so in a description
958958- * structure. These structures all end in "desc", and are used at both
959959- * user-level and in the kernel -- but (with the exception of
960960- * dtrace_probedesc_t) they are never passed between them. Typically,
961961- * user-level will use the description structures when assembling an enabling.
962962- * It will then distill those description structures into a DOF object (see
963963- * above), and send it into the kernel. The kernel will again use the
964964- * description structures to create a description of the enabling as it reads
965965- * the DOF. When the description is complete, the enabling will be actually
966966- * created -- turning it into the structures that represent the enabling
967967- * instead of merely describing it. Not surprisingly, the description
968968- * structures bear a strong resemblance to the DOF structures that act as their
969969- * conduit.
970970- */
971971-struct dtrace_predicate;
972972-973973-typedef struct dtrace_probedesc {
974974- dtrace_id_t dtpd_id; /* probe identifier */
975975- char dtpd_provider[DTRACE_PROVNAMELEN]; /* probe provider name */
976976- char dtpd_mod[DTRACE_MODNAMELEN]; /* probe module name */
977977- char dtpd_func[DTRACE_FUNCNAMELEN]; /* probe function name */
978978- char dtpd_name[DTRACE_NAMELEN]; /* probe name */
979979-} dtrace_probedesc_t;
980980-981981-typedef struct dtrace_repldesc {
982982- dtrace_probedesc_t dtrpd_match; /* probe descr. to match */
983983- dtrace_probedesc_t dtrpd_create; /* probe descr. to create */
984984-} dtrace_repldesc_t;
985985-986986-typedef struct dtrace_preddesc {
987987- dtrace_difo_t *dtpdd_difo; /* pointer to DIF object */
988988- struct dtrace_predicate *dtpdd_predicate; /* pointer to predicate */
989989-} dtrace_preddesc_t;
990990-991991-typedef struct dtrace_actdesc {
992992- dtrace_difo_t *dtad_difo; /* pointer to DIF object */
993993- struct dtrace_actdesc *dtad_next; /* next action */
994994- dtrace_actkind_t dtad_kind; /* kind of action */
995995- uint32_t dtad_ntuple; /* number in tuple */
996996- uint64_t dtad_arg; /* action argument */
997997- uint64_t dtad_uarg; /* user argument */
998998- int dtad_refcnt; /* reference count */
999999-} dtrace_actdesc_t;
10001000-10011001-typedef struct dtrace_ecbdesc {
10021002- dtrace_actdesc_t *dted_action; /* action description(s) */
10031003- dtrace_preddesc_t dted_pred; /* predicate description */
10041004- dtrace_probedesc_t dted_probe; /* probe description */
10051005- uint64_t dted_uarg; /* library argument */
10061006- int dted_refcnt; /* reference count */
10071007-} dtrace_ecbdesc_t;
10081008-10091009-/*
10101010- * DTrace Metadata Description Structures
10111011- *
10121012- * DTrace separates the trace data stream from the metadata stream. The only
10131013- * metadata tokens placed in the data stream are enabled probe identifiers
10141014- * (EPIDs) or (in the case of aggregations) aggregation identifiers. In order
10151015- * to determine the structure of the data, DTrace consumers pass the token to
10161016- * the kernel, and receive in return a corresponding description of the enabled
10171017- * probe (via the dtrace_eprobedesc structure) or the aggregation (via the
10181018- * dtrace_aggdesc structure). Both of these structures are expressed in terms
10191019- * of record descriptions (via the dtrace_recdesc structure) that describe the
10201020- * exact structure of the data. Some record descriptions may also contain a
10211021- * format identifier; this additional bit of metadata can be retrieved from the
10221022- * kernel, for which a format description is returned via the dtrace_fmtdesc
10231023- * structure. Note that all four of these structures must be bitness-neutral
10241024- * to allow for a 32-bit DTrace consumer on a 64-bit kernel.
10251025- */
10261026-typedef struct dtrace_recdesc {
10271027- dtrace_actkind_t dtrd_action; /* kind of action */
10281028- uint32_t dtrd_size; /* size of record */
10291029- uint32_t dtrd_offset; /* offset in ECB's data */
10301030- uint16_t dtrd_alignment; /* required alignment */
10311031- uint16_t dtrd_format; /* format, if any */
10321032- uint64_t dtrd_arg; /* action argument */
10331033- uint64_t dtrd_uarg; /* user argument */
10341034-} dtrace_recdesc_t;
10351035-10361036-typedef struct dtrace_eprobedesc {
10371037- dtrace_epid_t dtepd_epid; /* enabled probe ID */
10381038- dtrace_id_t dtepd_probeid; /* probe ID */
10391039- uint64_t dtepd_uarg; /* library argument */
10401040- uint32_t dtepd_size; /* total size */
10411041- int dtepd_nrecs; /* number of records */
10421042- dtrace_recdesc_t dtepd_rec[1]; /* records themselves */
10431043-} dtrace_eprobedesc_t;
10441044-10451045-typedef struct dtrace_aggdesc {
10461046- DTRACE_PTR(char, dtagd_name); /* not filled in by kernel */
10471047- dtrace_aggvarid_t dtagd_varid; /* not filled in by kernel */
10481048- int dtagd_flags; /* not filled in by kernel */
10491049- dtrace_aggid_t dtagd_id; /* aggregation ID */
10501050- dtrace_epid_t dtagd_epid; /* enabled probe ID */
10511051- uint32_t dtagd_size; /* size in bytes */
10521052- int dtagd_nrecs; /* number of records */
10531053- uint32_t dtagd_pad; /* explicit padding */
10541054- dtrace_recdesc_t dtagd_rec[1]; /* record descriptions */
10551055-} dtrace_aggdesc_t;
10561056-10571057-typedef struct dtrace_fmtdesc {
10581058- DTRACE_PTR(char, dtfd_string); /* format string */
10591059- int dtfd_length; /* length of format string */
10601060- uint16_t dtfd_format; /* format identifier */
10611061-} dtrace_fmtdesc_t;
10621062-10631063-#define DTRACE_SIZEOF_EPROBEDESC(desc) \
10641064- (sizeof (dtrace_eprobedesc_t) + ((desc)->dtepd_nrecs ? \
10651065- (((desc)->dtepd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
10661066-10671067-#define DTRACE_SIZEOF_AGGDESC(desc) \
10681068- (sizeof (dtrace_aggdesc_t) + ((desc)->dtagd_nrecs ? \
10691069- (((desc)->dtagd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
10701070-10711071-/*
10721072- * DTrace Option Interface
10731073- *
10741074- * Run-time DTrace options are set and retrieved via DOF_SECT_OPTDESC sections
10751075- * in a DOF image. The dof_optdesc structure contains an option identifier and
10761076- * an option value. The valid option identifiers are found below; the mapping
10771077- * between option identifiers and option identifying strings is maintained at
10781078- * user-level. Note that the value of DTRACEOPT_UNSET is such that all of the
10791079- * following are potentially valid option values: all positive integers, zero
10801080- * and negative one. Some options (notably "bufpolicy" and "bufresize") take
10811081- * predefined tokens as their values; these are defined with
10821082- * DTRACEOPT_{option}_{token}.
10831083- */
10841084-#define DTRACEOPT_BUFSIZE 0 /* buffer size */
10851085-#define DTRACEOPT_BUFPOLICY 1 /* buffer policy */
10861086-#define DTRACEOPT_DYNVARSIZE 2 /* dynamic variable size */
10871087-#define DTRACEOPT_AGGSIZE 3 /* aggregation size */
10881088-#define DTRACEOPT_SPECSIZE 4 /* speculation size */
10891089-#define DTRACEOPT_NSPEC 5 /* number of speculations */
10901090-#define DTRACEOPT_STRSIZE 6 /* string size */
10911091-#define DTRACEOPT_CLEANRATE 7 /* dynvar cleaning rate */
10921092-#define DTRACEOPT_CPU 8 /* CPU to trace */
10931093-#define DTRACEOPT_BUFRESIZE 9 /* buffer resizing policy */
10941094-#define DTRACEOPT_GRABANON 10 /* grab anonymous state, if any */
10951095-#define DTRACEOPT_FLOWINDENT 11 /* indent function entry/return */
10961096-#define DTRACEOPT_QUIET 12 /* only output explicitly traced data */
10971097-#define DTRACEOPT_STACKFRAMES 13 /* number of stack frames */
10981098-#define DTRACEOPT_USTACKFRAMES 14 /* number of user stack frames */
10991099-#define DTRACEOPT_AGGRATE 15 /* aggregation snapshot rate */
11001100-#define DTRACEOPT_SWITCHRATE 16 /* buffer switching rate */
11011101-#define DTRACEOPT_STATUSRATE 17 /* status rate */
11021102-#define DTRACEOPT_DESTRUCTIVE 18 /* destructive actions allowed */
11031103-#define DTRACEOPT_STACKINDENT 19 /* output indent for stack traces */
11041104-#define DTRACEOPT_RAWBYTES 20 /* always print bytes in raw form */
11051105-#define DTRACEOPT_JSTACKFRAMES 21 /* number of jstack() frames */
11061106-#define DTRACEOPT_JSTACKSTRSIZE 22 /* size of jstack() string table */
11071107-#define DTRACEOPT_AGGSORTKEY 23 /* sort aggregations by key */
11081108-#define DTRACEOPT_AGGSORTREV 24 /* reverse-sort aggregations */
11091109-#define DTRACEOPT_AGGSORTPOS 25 /* agg. position to sort on */
11101110-#define DTRACEOPT_AGGSORTKEYPOS 26 /* agg. key position to sort on */
11111111-#if !defined(__APPLE__)
11121112-#define DTRACEOPT_MAX 27 /* number of options */
11131113-#else
11141114-#define DTRACEOPT_STACKSYMBOLS 27 /* clear to prevent stack symbolication */
11151115-#define DTRACEOPT_MAX 28 /* number of options */
11161116-#endif /* __APPLE__ */
11171117-11181118-#define DTRACEOPT_UNSET (dtrace_optval_t)-2 /* unset option */
11191119-11201120-#define DTRACEOPT_BUFPOLICY_RING 0 /* ring buffer */
11211121-#define DTRACEOPT_BUFPOLICY_FILL 1 /* fill buffer, then stop */
11221122-#define DTRACEOPT_BUFPOLICY_SWITCH 2 /* switch buffers */
11231123-11241124-#define DTRACEOPT_BUFRESIZE_AUTO 0 /* automatic resizing */
11251125-#define DTRACEOPT_BUFRESIZE_MANUAL 1 /* manual resizing */
11261126-11271127-/*
11281128- * DTrace Buffer Interface
11291129- *
11301130- * In order to get a snapshot of the principal or aggregation buffer,
11311131- * user-level passes a buffer description to the kernel with the dtrace_bufdesc
11321132- * structure. This describes which CPU user-level is interested in, and
11331133- * where user-level wishes the kernel to snapshot the buffer to (the
11341134- * dtbd_data field). The kernel uses the same structure to pass back some
11351135- * information regarding the buffer: the size of data actually copied out, the
11361136- * number of drops, the number of errors, and the offset of the oldest record.
11371137- * If the buffer policy is a "switch" policy, taking a snapshot of the
11381138- * principal buffer has the additional effect of switching the active and
11391139- * inactive buffers. Taking a snapshot of the aggregation buffer _always_ has
11401140- * the additional effect of switching the active and inactive buffers.
11411141- */
11421142-typedef struct dtrace_bufdesc {
11431143- uint64_t dtbd_size; /* size of buffer */
11441144- uint32_t dtbd_cpu; /* CPU or DTRACE_CPUALL */
11451145- uint32_t dtbd_errors; /* number of errors */
11461146- uint64_t dtbd_drops; /* number of drops */
11471147- DTRACE_PTR(char, dtbd_data); /* data */
11481148- uint64_t dtbd_oldest; /* offset of oldest record */
11491149-} dtrace_bufdesc_t;
11501150-11511151-/*
11521152- * DTrace Status
11531153- *
11541154- * The status of DTrace is relayed via the dtrace_status structure. This
11551155- * structure contains members to count drops other than the capacity drops
11561156- * available via the buffer interface (see above). This consists of dynamic
11571157- * drops (including capacity dynamic drops, rinsing drops and dirty drops), and
11581158- * speculative drops (including capacity speculative drops, drops due to busy
11591159- * speculative buffers and drops due to unavailable speculative buffers).
11601160- * Additionally, the status structure contains a field to indicate the number
11611161- * of "fill"-policy buffers have been filled and a boolean field to indicate
11621162- * that exit() has been called. If the dtst_exiting field is non-zero, no
11631163- * further data will be generated until tracing is stopped (at which time any
11641164- * enablings of the END action will be processed); if user-level sees that
11651165- * this field is non-zero, tracing should be stopped as soon as possible.
11661166- */
11671167-typedef struct dtrace_status {
11681168- uint64_t dtst_dyndrops; /* dynamic drops */
11691169- uint64_t dtst_dyndrops_rinsing; /* dyn drops due to rinsing */
11701170- uint64_t dtst_dyndrops_dirty; /* dyn drops due to dirty */
11711171- uint64_t dtst_specdrops; /* speculative drops */
11721172- uint64_t dtst_specdrops_busy; /* spec drops due to busy */
11731173- uint64_t dtst_specdrops_unavail; /* spec drops due to unavail */
11741174- uint64_t dtst_errors; /* total errors */
11751175- uint64_t dtst_filled; /* number of filled bufs */
11761176- uint64_t dtst_stkstroverflows; /* stack string tab overflows */
11771177- uint64_t dtst_dblerrors; /* errors in ERROR probes */
11781178- char dtst_killed; /* non-zero if killed */
11791179- char dtst_exiting; /* non-zero if exit() called */
11801180- char dtst_pad[6]; /* pad out to 64-bit align */
11811181-} dtrace_status_t;
11821182-11831183-/*
11841184- * DTrace Configuration
11851185- *
11861186- * User-level may need to understand some elements of the kernel DTrace
11871187- * configuration in order to generate correct DIF. This information is
11881188- * conveyed via the dtrace_conf structure.
11891189- */
11901190-typedef struct dtrace_conf {
11911191- uint_t dtc_difversion; /* supported DIF version */
11921192- uint_t dtc_difintregs; /* # of DIF integer registers */
11931193- uint_t dtc_diftupregs; /* # of DIF tuple registers */
11941194- uint_t dtc_ctfmodel; /* CTF data model */
11951195- uint_t dtc_pad[8]; /* reserved for future use */
11961196-} dtrace_conf_t;
11971197-11981198-/*
11991199- * DTrace Faults
12001200- *
12011201- * The constants below DTRACEFLT_LIBRARY indicate probe processing faults;
12021202- * constants at or above DTRACEFLT_LIBRARY indicate faults in probe
12031203- * postprocessing at user-level. Probe processing faults induce an ERROR
12041204- * probe and are replicated in unistd.d to allow users' ERROR probes to decode
12051205- * the error condition using thse symbolic labels.
12061206- */
12071207-#define DTRACEFLT_UNKNOWN 0 /* Unknown fault */
12081208-#define DTRACEFLT_BADADDR 1 /* Bad address */
12091209-#define DTRACEFLT_BADALIGN 2 /* Bad alignment */
12101210-#define DTRACEFLT_ILLOP 3 /* Illegal operation */
12111211-#define DTRACEFLT_DIVZERO 4 /* Divide-by-zero */
12121212-#define DTRACEFLT_NOSCRATCH 5 /* Out of scratch space */
12131213-#define DTRACEFLT_KPRIV 6 /* Illegal kernel access */
12141214-#define DTRACEFLT_UPRIV 7 /* Illegal user access */
12151215-#define DTRACEFLT_TUPOFLOW 8 /* Tuple stack overflow */
12161216-#define DTRACEFLT_BADSTACK 9 /* Bad stack */
12171217-12181218-#define DTRACEFLT_LIBRARY 1000 /* Library-level fault */
12191219-12201220-/*
12211221- * DTrace Argument Types
12221222- *
12231223- * Because it would waste both space and time, argument types do not reside
12241224- * with the probe. In order to determine argument types for args[X]
12251225- * variables, the D compiler queries for argument types on a probe-by-probe
12261226- * basis. (This optimizes for the common case that arguments are either not
12271227- * used or used in an untyped fashion.) Typed arguments are specified with a
12281228- * string of the type name in the dtragd_native member of the argument
12291229- * description structure. Typed arguments may be further translated to types
12301230- * of greater stability; the provider indicates such a translated argument by
12311231- * filling in the dtargd_xlate member with the string of the translated type.
12321232- * Finally, the provider may indicate which argument value a given argument
12331233- * maps to by setting the dtargd_mapping member -- allowing a single argument
12341234- * to map to multiple args[X] variables.
12351235- */
12361236-typedef struct dtrace_argdesc {
12371237- dtrace_id_t dtargd_id; /* probe identifier */
12381238- int dtargd_ndx; /* arg number (-1 iff none) */
12391239- int dtargd_mapping; /* value mapping */
12401240- char dtargd_native[DTRACE_ARGTYPELEN]; /* native type name */
12411241- char dtargd_xlate[DTRACE_ARGTYPELEN]; /* translated type name */
12421242-} dtrace_argdesc_t;
12431243-12441244-/*
12451245- * DTrace Stability Attributes
12461246- *
12471247- * Each DTrace provider advertises the name and data stability of each of its
12481248- * probe description components, as well as its architectural dependencies.
12491249- * The D compiler can query the provider attributes (dtrace_pattr_t below) in
12501250- * order to compute the properties of an input program and report them.
12511251- */
12521252-typedef uint8_t dtrace_stability_t; /* stability code (see attributes(5)) */
12531253-typedef uint8_t dtrace_class_t; /* architectural dependency class */
12541254-12551255-#define DTRACE_STABILITY_INTERNAL 0 /* private to DTrace itself */
12561256-#define DTRACE_STABILITY_PRIVATE 1 /* private to Sun (see docs) */
12571257-#define DTRACE_STABILITY_OBSOLETE 2 /* scheduled for removal */
12581258-#define DTRACE_STABILITY_EXTERNAL 3 /* not controlled by Sun */
12591259-#define DTRACE_STABILITY_UNSTABLE 4 /* new or rapidly changing */
12601260-#define DTRACE_STABILITY_EVOLVING 5 /* less rapidly changing */
12611261-#define DTRACE_STABILITY_STABLE 6 /* mature interface from Sun */
12621262-#define DTRACE_STABILITY_STANDARD 7 /* industry standard */
12631263-#define DTRACE_STABILITY_MAX 7 /* maximum valid stability */
12641264-12651265-#define DTRACE_CLASS_UNKNOWN 0 /* unknown architectural dependency */
12661266-#define DTRACE_CLASS_CPU 1 /* CPU-module-specific */
12671267-#define DTRACE_CLASS_PLATFORM 2 /* platform-specific (uname -i) */
12681268-#define DTRACE_CLASS_GROUP 3 /* hardware-group-specific (uname -m) */
12691269-#define DTRACE_CLASS_ISA 4 /* ISA-specific (uname -p) */
12701270-#define DTRACE_CLASS_COMMON 5 /* common to all systems */
12711271-#define DTRACE_CLASS_MAX 5 /* maximum valid class */
12721272-12731273-#define DTRACE_PRIV_NONE 0x0000
12741274-#define DTRACE_PRIV_KERNEL 0x0001
12751275-#define DTRACE_PRIV_USER 0x0002
12761276-#define DTRACE_PRIV_PROC 0x0004
12771277-#define DTRACE_PRIV_OWNER 0x0008
12781278-#define DTRACE_PRIV_ZONEOWNER 0x0010
12791279-12801280-#define DTRACE_PRIV_ALL \
12811281- (DTRACE_PRIV_KERNEL | DTRACE_PRIV_USER | \
12821282- DTRACE_PRIV_PROC | DTRACE_PRIV_OWNER | DTRACE_PRIV_ZONEOWNER)
12831283-12841284-typedef struct dtrace_ppriv {
12851285- uint32_t dtpp_flags; /* privilege flags */
12861286- uid_t dtpp_uid; /* user ID */
12871287- zoneid_t dtpp_zoneid; /* zone ID */
12881288-} dtrace_ppriv_t;
12891289-12901290-typedef struct dtrace_attribute {
12911291- dtrace_stability_t dtat_name; /* entity name stability */
12921292- dtrace_stability_t dtat_data; /* entity data stability */
12931293- dtrace_class_t dtat_class; /* entity data dependency */
12941294-} dtrace_attribute_t;
12951295-12961296-typedef struct dtrace_pattr {
12971297- dtrace_attribute_t dtpa_provider; /* provider attributes */
12981298- dtrace_attribute_t dtpa_mod; /* module attributes */
12991299- dtrace_attribute_t dtpa_func; /* function attributes */
13001300- dtrace_attribute_t dtpa_name; /* name attributes */
13011301- dtrace_attribute_t dtpa_args; /* args[] attributes */
13021302-} dtrace_pattr_t;
13031303-13041304-typedef struct dtrace_providerdesc {
13051305- char dtvd_name[DTRACE_PROVNAMELEN]; /* provider name */
13061306- dtrace_pattr_t dtvd_attr; /* stability attributes */
13071307- dtrace_ppriv_t dtvd_priv; /* privileges required */
13081308-} dtrace_providerdesc_t;
13091309-13101310-/*
13111311- * DTrace Pseudodevice Interface
13121312- *
13131313- * DTrace is controlled through ioctl(2)'s to the in-kernel dtrace:dtrace
13141314- * pseudodevice driver. These ioctls comprise the user-kernel interface to
13151315- * DTrace.
13161316- */
13171317-#if !defined(__APPLE__)
13181318-#define DTRACEIOC (('d' << 24) | ('t' << 16) | ('r' << 8))
13191319-#define DTRACEIOC_PROVIDER (DTRACEIOC | 1) /* provider query */
13201320-#define DTRACEIOC_PROBES (DTRACEIOC | 2) /* probe query */
13211321-#define DTRACEIOC_BUFSNAP (DTRACEIOC | 4) /* snapshot buffer */
13221322-#define DTRACEIOC_PROBEMATCH (DTRACEIOC | 5) /* match probes */
13231323-#define DTRACEIOC_ENABLE (DTRACEIOC | 6) /* enable probes */
13241324-#define DTRACEIOC_AGGSNAP (DTRACEIOC | 7) /* snapshot agg. */
13251325-#define DTRACEIOC_EPROBE (DTRACEIOC | 8) /* get eprobe desc. */
13261326-#define DTRACEIOC_PROBEARG (DTRACEIOC | 9) /* get probe arg */
13271327-#define DTRACEIOC_CONF (DTRACEIOC | 10) /* get config. */
13281328-#define DTRACEIOC_STATUS (DTRACEIOC | 11) /* get status */
13291329-#define DTRACEIOC_GO (DTRACEIOC | 12) /* start tracing */
13301330-#define DTRACEIOC_STOP (DTRACEIOC | 13) /* stop tracing */
13311331-#define DTRACEIOC_AGGDESC (DTRACEIOC | 15) /* get agg. desc. */
13321332-#define DTRACEIOC_FORMAT (DTRACEIOC | 16) /* get format str */
13331333-#define DTRACEIOC_DOFGET (DTRACEIOC | 17) /* get DOF */
13341334-#define DTRACEIOC_REPLICATE (DTRACEIOC | 18) /* replicate enab */
13351335-#else
13361336-/* coding this as IOC_VOID allows this driver to handle its own copyin/copuout */
13371337-#define DTRACEIOC _IO('d',0)
13381338-#define DTRACEIOC_PROVIDER (DTRACEIOC | 1) /* provider query */
13391339-#define DTRACEIOC_PROBES (DTRACEIOC | 2) /* probe query */
13401340-#define DTRACEIOC_BUFSNAP (DTRACEIOC | 4) /* snapshot buffer */
13411341-#define DTRACEIOC_PROBEMATCH (DTRACEIOC | 5) /* match probes */
13421342-#define DTRACEIOC_ENABLE (DTRACEIOC | 6) /* enable probes */
13431343-#define DTRACEIOC_AGGSNAP (DTRACEIOC | 7) /* snapshot agg. */
13441344-#define DTRACEIOC_EPROBE (DTRACEIOC | 8) /* get eprobe desc. */
13451345-#define DTRACEIOC_PROBEARG (DTRACEIOC | 9) /* get probe arg */
13461346-#define DTRACEIOC_CONF (DTRACEIOC | 10) /* get config. */
13471347-#define DTRACEIOC_STATUS (DTRACEIOC | 11) /* get status */
13481348-#define DTRACEIOC_GO (DTRACEIOC | 12) /* start tracing */
13491349-#define DTRACEIOC_STOP (DTRACEIOC | 13) /* stop tracing */
13501350-#define DTRACEIOC_AGGDESC (DTRACEIOC | 15) /* get agg. desc. */
13511351-#define DTRACEIOC_FORMAT (DTRACEIOC | 16) /* get format str */
13521352-#define DTRACEIOC_DOFGET (DTRACEIOC | 17) /* get DOF */
13531353-#define DTRACEIOC_REPLICATE (DTRACEIOC | 18) /* replicate enab */
13541354-#define DTRACEIOC_MODUUIDSLIST (DTRACEIOC | 30) /* APPLE ONLY, query for modules with missing symbols */
13551355-#define DTRACEIOC_PROVMODSYMS (DTRACEIOC | 31) /* APPLE ONLY, provide missing symbols for a given module */
13561356-13571357-/*
13581358- * The following structs are used to provide symbol information to the kernel from userspace.
13591359- */
13601360-13611361-typedef struct dtrace_symbol {
13621362- uint64_t dtsym_addr; /* address of the symbol */
13631363- uint64_t dtsym_size; /* size of the symbol, must be uint64_t to maintain alignment when called by 64b uproc in i386 kernel */
13641364- char dtsym_name[DTRACE_FUNCNAMELEN]; /* symbol name */
13651365-} dtrace_symbol_t;
13661366-13671367-typedef struct dtrace_module_symbols {
13681368- UUID dtmodsyms_uuid;
13691369- uint64_t dtmodsyms_count;
13701370- dtrace_symbol_t dtmodsyms_symbols[1];
13711371-} dtrace_module_symbols_t;
13721372-13731373-#define DTRACE_MODULE_SYMBOLS_SIZE(count) (sizeof(dtrace_module_symbols_t) + ((count - 1) * sizeof(dtrace_symbol_t)))
13741374-13751375-typedef struct dtrace_module_uuids_list {
13761376- uint64_t dtmul_count;
13771377- UUID dtmul_uuid[1];
13781378-} dtrace_module_uuids_list_t;
13791379-13801380-#define DTRACE_MODULE_UUIDS_LIST_SIZE(count) (sizeof(dtrace_module_uuids_list_t) + ((count - 1) * sizeof(UUID)))
13811381-13821382-#endif /* __APPLE__ */
13831383-13841384-/*
13851385- * DTrace Helpers
13861386- *
13871387- * In general, DTrace establishes probes in processes and takes actions on
13881388- * processes without knowing their specific user-level structures. Instead of
13891389- * existing in the framework, process-specific knowledge is contained by the
13901390- * enabling D program -- which can apply process-specific knowledge by making
13911391- * appropriate use of DTrace primitives like copyin() and copyinstr() to
13921392- * operate on user-level data. However, there may exist some specific probes
13931393- * of particular semantic relevance that the application developer may wish to
13941394- * explicitly export. For example, an application may wish to export a probe
13951395- * at the point that it begins and ends certain well-defined transactions. In
13961396- * addition to providing probes, programs may wish to offer assistance for
13971397- * certain actions. For example, in highly dynamic environments (e.g., Java),
13981398- * it may be difficult to obtain a stack trace in terms of meaningful symbol
13991399- * names (the translation from instruction addresses to corresponding symbol
14001400- * names may only be possible in situ); these environments may wish to define
14011401- * a series of actions to be applied in situ to obtain a meaningful stack
14021402- * trace.
14031403- *
14041404- * These two mechanisms -- user-level statically defined tracing and assisting
14051405- * DTrace actions -- are provided via DTrace _helpers_. Helpers are specified
14061406- * via DOF, but unlike enabling DOF, helper DOF may contain definitions of
14071407- * providers, probes and their arguments. If a helper wishes to provide
14081408- * action assistance, probe descriptions and corresponding DIF actions may be
14091409- * specified in the helper DOF. For such helper actions, however, the probe
14101410- * description describes the specific helper: all DTrace helpers have the
14111411- * provider name "dtrace" and the module name "helper", and the name of the
14121412- * helper is contained in the function name (for example, the ustack() helper
14131413- * is named "ustack"). Any helper-specific name may be contained in the name
14141414- * (for example, if a helper were to have a constructor, it might be named
14151415- * "dtrace:helper:<helper>:init"). Helper actions are only called when the
14161416- * action that they are helping is taken. Helper actions may only return DIF
14171417- * expressions, and may only call the following subroutines:
14181418- *
14191419- * alloca() <= Allocates memory out of the consumer's scratch space
14201420- * bcopy() <= Copies memory to scratch space
14211421- * copyin() <= Copies memory from user-level into consumer's scratch
14221422- * copyinto() <= Copies memory into a specific location in scratch
14231423- * copyinstr() <= Copies a string into a specific location in scratch
14241424- *
14251425- * Helper actions may only access the following built-in variables:
14261426- *
14271427- * curthread <= Current kthread_t pointer
14281428- * tid <= Current thread identifier
14291429- * pid <= Current process identifier
14301430- * ppid <= Parent process identifier
14311431- * uid <= Current user ID
14321432- * gid <= Current group ID
14331433- * execname <= Current executable name
14341434- * zonename <= Current zone name
14351435- *
14361436- * Helper actions may not manipulate or allocate dynamic variables, but they
14371437- * may have clause-local and statically-allocated global variables. The
14381438- * helper action variable state is specific to the helper action -- variables
14391439- * used by the helper action may not be accessed outside of the helper
14401440- * action, and the helper action may not access variables that like outside
14411441- * of it. Helper actions may not load from kernel memory at-large; they are
14421442- * restricting to loading current user state (via copyin() and variants) and
14431443- * scratch space. As with probe enablings, helper actions are executed in
14441444- * program order. The result of the helper action is the result of the last
14451445- * executing helper expression.
14461446- *
14471447- * Helpers -- composed of either providers/probes or probes/actions (or both)
14481448- * -- are added by opening the "helper" minor node, and issuing an ioctl(2)
14491449- * (DTRACEHIOC_ADDDOF) that specifies the dof_helper_t structure. This
14501450- * encapsulates the name and base address of the user-level library or
14511451- * executable publishing the helpers and probes as well as the DOF that
14521452- * contains the definitions of those helpers and probes.
14531453- *
14541454- * The DTRACEHIOC_ADD and DTRACEHIOC_REMOVE are left in place for legacy
14551455- * helpers and should no longer be used. No other ioctls are valid on the
14561456- * helper minor node.
14571457- */
14581458-#if !defined(__APPLE__)
14591459-#define DTRACEHIOC (('d' << 24) | ('t' << 16) | ('h' << 8))
14601460-#define DTRACEHIOC_ADD (DTRACEHIOC | 1) /* add helper */
14611461-#define DTRACEHIOC_REMOVE (DTRACEHIOC | 2) /* remove helper */
14621462-#define DTRACEHIOC_ADDDOF (DTRACEHIOC | 3) /* add helper DOF */
14631463-#else
14641464-#define DTRACEHIOC_REMOVE _IO('h', 2) /* remove helper */
14651465-#define DTRACEHIOC_ADDDOF _IOW('h', 4, user_addr_t) /* add helper DOF */
14661466-#endif /* __APPLE__ */
14671467-14681468-typedef struct dof_helper {
14691469- char dofhp_mod[DTRACE_MODNAMELEN]; /* executable or library name */
14701470- uint64_t dofhp_addr; /* base address of object */
14711471- uint64_t dofhp_dof; /* address of helper DOF */
14721472-} dof_helper_t;
14731473-14741474-#if defined(__APPLE__)
14751475-/*
14761476- * This structure is used to register one or more dof_helper_t(s).
14771477- * For counts greater than one, malloc the structure as if the
14781478- * dofiod_helpers field was "count" sized. The kernel will copyin
14791479- * data of size:
14801480- *
14811481- * sizeof(dof_ioctl_data_t) + ((count - 1) * sizeof(dof_helper_t))
14821482- */
14831483-typedef struct dof_ioctl_data {
14841484- /*
14851485- * This field must be 64 bits to keep the alignment the same
14861486- * when 64 bit user procs are sending data to 32 bit xnu
14871487- */
14881488- uint64_t dofiod_count;
14891489- dof_helper_t dofiod_helpers[1];
14901490-} dof_ioctl_data_t;
14911491-14921492-#define DOF_IOCTL_DATA_T_SIZE(count) (sizeof(dof_ioctl_data_t) + ((count - 1) * sizeof(dof_helper_t)))
14931493-14941494-#endif
14951495-14961496-#define DTRACEMNR_DTRACE "dtrace" /* node for DTrace ops */
14971497-#if !defined(__APPLE__)
14981498-#define DTRACEMNR_HELPER "helper" /* node for helpers */
14991499-#else
15001500-#define DTRACEMNR_HELPER "dtracehelper" /* node for helpers */
15011501-#endif /* __APPLE__ */
15021502-#define DTRACEMNRN_DTRACE 0 /* minor for DTrace ops */
15031503-#define DTRACEMNRN_HELPER 1 /* minor for helpers */
15041504-#define DTRACEMNRN_CLONE 2 /* first clone minor */
15051505-15061506-#ifdef _KERNEL
15071507-15081508-/*
15091509- * DTrace Provider API
15101510- *
15111511- * The following functions are implemented by the DTrace framework and are
15121512- * used to implement separate in-kernel DTrace providers. Common functions
15131513- * are provided in uts/common/os/dtrace.c. ISA-dependent subroutines are
15141514- * defined in uts/<isa>/dtrace/dtrace_asm.s or uts/<isa>/dtrace/dtrace_isa.c.
15151515- *
15161516- * The provider API has two halves: the API that the providers consume from
15171517- * DTrace, and the API that providers make available to DTrace.
15181518- *
15191519- * 1 Framework-to-Provider API
15201520- *
15211521- * 1.1 Overview
15221522- *
15231523- * The Framework-to-Provider API is represented by the dtrace_pops structure
15241524- * that the provider passes to the framework when registering itself. This
15251525- * structure consists of the following members:
15261526- *
15271527- * dtps_provide() <-- Provide all probes, all modules
15281528- * dtps_provide_module() <-- Provide all probes in specified module
15291529- * dtps_enable() <-- Enable specified probe
15301530- * dtps_disable() <-- Disable specified probe
15311531- * dtps_suspend() <-- Suspend specified probe
15321532- * dtps_resume() <-- Resume specified probe
15331533- * dtps_getargdesc() <-- Get the argument description for args[X]
15341534- * dtps_getargval() <-- Get the value for an argX or args[X] variable
15351535- * dtps_usermode() <-- Find out if the probe was fired in user mode
15361536- * dtps_destroy() <-- Destroy all state associated with this probe
15371537- *
15381538- * 1.2 void dtps_provide(void *arg, const dtrace_probedesc_t *spec)
15391539- *
15401540- * 1.2.1 Overview
15411541- *
15421542- * Called to indicate that the provider should provide all probes. If the
15431543- * specified description is non-NULL, dtps_provide() is being called because
15441544- * no probe matched a specified probe -- if the provider has the ability to
15451545- * create custom probes, it may wish to create a probe that matches the
15461546- * specified description.
15471547- *
15481548- * 1.2.2 Arguments and notes
15491549- *
15501550- * The first argument is the cookie as passed to dtrace_register(). The
15511551- * second argument is a pointer to a probe description that the provider may
15521552- * wish to consider when creating custom probes. The provider is expected to
15531553- * call back into the DTrace framework via dtrace_probe_create() to create
15541554- * any necessary probes. dtps_provide() may be called even if the provider
15551555- * has made available all probes; the provider should check the return value
15561556- * of dtrace_probe_create() to handle this case. Note that the provider need
15571557- * not implement both dtps_provide() and dtps_provide_module(); see
15581558- * "Arguments and Notes" for dtrace_register(), below.
15591559- *
15601560- * 1.2.3 Return value
15611561- *
15621562- * None.
15631563- *
15641564- * 1.2.4 Caller's context
15651565- *
15661566- * dtps_provide() is typically called from open() or ioctl() context, but may
15671567- * be called from other contexts as well. The DTrace framework is locked in
15681568- * such a way that providers may not register or unregister. This means that
15691569- * the provider may not call any DTrace API that affects its registration with
15701570- * the framework, including dtrace_register(), dtrace_unregister(),
15711571- * dtrace_invalidate(), and dtrace_condense(). However, the context is such
15721572- * that the provider may (and indeed, is expected to) call probe-related
15731573- * DTrace routines, including dtrace_probe_create(), dtrace_probe_lookup(),
15741574- * and dtrace_probe_arg().
15751575- *
15761576- * 1.3 void dtps_provide_module(void *arg, struct modctl *mp)
15771577- *
15781578- * 1.3.1 Overview
15791579- *
15801580- * Called to indicate that the provider should provide all probes in the
15811581- * specified module.
15821582- *
15831583- * 1.3.2 Arguments and notes
15841584- *
15851585- * The first argument is the cookie as passed to dtrace_register(). The
15861586- * second argument is a pointer to a modctl structure that indicates the
15871587- * module for which probes should be created.
15881588- *
15891589- * 1.3.3 Return value
15901590- *
15911591- * None.
15921592- *
15931593- * 1.3.4 Caller's context
15941594- *
15951595- * dtps_provide_module() may be called from open() or ioctl() context, but
15961596- * may also be called from a module loading context. mod_lock is held, and
15971597- * the DTrace framework is locked in such a way that providers may not
15981598- * register or unregister. This means that the provider may not call any
15991599- * DTrace API that affects its registration with the framework, including
16001600- * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and
16011601- * dtrace_condense(). However, the context is such that the provider may (and
16021602- * indeed, is expected to) call probe-related DTrace routines, including
16031603- * dtrace_probe_create(), dtrace_probe_lookup(), and dtrace_probe_arg(). Note
16041604- * that the provider need not implement both dtps_provide() and
16051605- * dtps_provide_module(); see "Arguments and Notes" for dtrace_register(),
16061606- * below.
16071607- *
16081608- * 1.4 int dtps_enable(void *arg, dtrace_id_t id, void *parg)
16091609- *
16101610- * 1.4.1 Overview
16111611- *
16121612- * Called to enable the specified probe.
16131613- *
16141614- * 1.4.2 Arguments and notes
16151615- *
16161616- * The first argument is the cookie as passed to dtrace_register(). The
16171617- * second argument is the identifier of the probe to be enabled. The third
16181618- * argument is the probe argument as passed to dtrace_probe_create().
16191619- * dtps_enable() will be called when a probe transitions from not being
16201620- * enabled at all to having one or more ECB. The number of ECBs associated
16211621- * with the probe may change without subsequent calls into the provider.
16221622- * When the number of ECBs drops to zero, the provider will be explicitly
16231623- * told to disable the probe via dtps_disable(). dtrace_probe() should never
16241624- * be called for a probe identifier that hasn't been explicitly enabled via
16251625- * dtps_enable().
16261626- *
16271627- * 1.4.3 Return value
16281628- *
16291629- * On success, dtps_enable() should return 0. On failure, -1 should be
16301630- * returned.
16311631- *
16321632- * 1.4.4 Caller's context
16331633- *
16341634- * The DTrace framework is locked in such a way that it may not be called
16351635- * back into at all. cpu_lock is held. mod_lock is not held and may not
16361636- * be acquired.
16371637- *
16381638- * 1.5 void dtps_disable(void *arg, dtrace_id_t id, void *parg)
16391639- *
16401640- * 1.5.1 Overview
16411641- *
16421642- * Called to disable the specified probe.
16431643- *
16441644- * 1.5.2 Arguments and notes
16451645- *
16461646- * The first argument is the cookie as passed to dtrace_register(). The
16471647- * second argument is the identifier of the probe to be disabled. The third
16481648- * argument is the probe argument as passed to dtrace_probe_create().
16491649- * dtps_disable() will be called when a probe transitions from being enabled
16501650- * to having zero ECBs. dtrace_probe() should never be called for a probe
16511651- * identifier that has been explicitly enabled via dtps_disable().
16521652- *
16531653- * 1.5.3 Return value
16541654- *
16551655- * None.
16561656- *
16571657- * 1.5.4 Caller's context
16581658- *
16591659- * The DTrace framework is locked in such a way that it may not be called
16601660- * back into at all. cpu_lock is held. mod_lock is not held and may not
16611661- * be acquired.
16621662- *
16631663- * 1.6 void dtps_suspend(void *arg, dtrace_id_t id, void *parg)
16641664- *
16651665- * 1.6.1 Overview
16661666- *
16671667- * Called to suspend the specified enabled probe. This entry point is for
16681668- * providers that may need to suspend some or all of their probes when CPUs
16691669- * are being powered on or when the boot monitor is being entered for a
16701670- * prolonged period of time.
16711671- *
16721672- * 1.6.2 Arguments and notes
16731673- *
16741674- * The first argument is the cookie as passed to dtrace_register(). The
16751675- * second argument is the identifier of the probe to be suspended. The
16761676- * third argument is the probe argument as passed to dtrace_probe_create().
16771677- * dtps_suspend will only be called on an enabled probe. Providers that
16781678- * provide a dtps_suspend entry point will want to take roughly the action
16791679- * that it takes for dtps_disable.
16801680- *
16811681- * 1.6.3 Return value
16821682- *
16831683- * None.
16841684- *
16851685- * 1.6.4 Caller's context
16861686- *
16871687- * Interrupts are disabled. The DTrace framework is in a state such that the
16881688- * specified probe cannot be disabled or destroyed for the duration of
16891689- * dtps_suspend(). As interrupts are disabled, the provider is afforded
16901690- * little latitude; the provider is expected to do no more than a store to
16911691- * memory.
16921692- *
16931693- * 1.7 void dtps_resume(void *arg, dtrace_id_t id, void *parg)
16941694- *
16951695- * 1.7.1 Overview
16961696- *
16971697- * Called to resume the specified enabled probe. This entry point is for
16981698- * providers that may need to resume some or all of their probes after the
16991699- * completion of an event that induced a call to dtps_suspend().
17001700- *
17011701- * 1.7.2 Arguments and notes
17021702- *
17031703- * The first argument is the cookie as passed to dtrace_register(). The
17041704- * second argument is the identifier of the probe to be resumed. The
17051705- * third argument is the probe argument as passed to dtrace_probe_create().
17061706- * dtps_resume will only be called on an enabled probe. Providers that
17071707- * provide a dtps_resume entry point will want to take roughly the action
17081708- * that it takes for dtps_enable.
17091709- *
17101710- * 1.7.3 Return value
17111711- *
17121712- * None.
17131713- *
17141714- * 1.7.4 Caller's context
17151715- *
17161716- * Interrupts are disabled. The DTrace framework is in a state such that the
17171717- * specified probe cannot be disabled or destroyed for the duration of
17181718- * dtps_resume(). As interrupts are disabled, the provider is afforded
17191719- * little latitude; the provider is expected to do no more than a store to
17201720- * memory.
17211721- *
17221722- * 1.8 void dtps_getargdesc(void *arg, dtrace_id_t id, void *parg,
17231723- * dtrace_argdesc_t *desc)
17241724- *
17251725- * 1.8.1 Overview
17261726- *
17271727- * Called to retrieve the argument description for an args[X] variable.
17281728- *
17291729- * 1.8.2 Arguments and notes
17301730- *
17311731- * The first argument is the cookie as passed to dtrace_register(). The
17321732- * second argument is the identifier of the current probe. The third
17331733- * argument is the probe argument as passed to dtrace_probe_create(). The
17341734- * fourth argument is a pointer to the argument description. This
17351735- * description is both an input and output parameter: it contains the
17361736- * index of the desired argument in the dtargd_ndx field, and expects
17371737- * the other fields to be filled in upon return. If there is no argument
17381738- * corresponding to the specified index, the dtargd_ndx field should be set
17391739- * to DTRACE_ARGNONE.
17401740- *
17411741- * 1.8.3 Return value
17421742- *
17431743- * None. The dtargd_ndx, dtargd_native, dtargd_xlate and dtargd_mapping
17441744- * members of the dtrace_argdesc_t structure are all output values.
17451745- *
17461746- * 1.8.4 Caller's context
17471747- *
17481748- * dtps_getargdesc() is called from ioctl() context. mod_lock is held, and
17491749- * the DTrace framework is locked in such a way that providers may not
17501750- * register or unregister. This means that the provider may not call any
17511751- * DTrace API that affects its registration with the framework, including
17521752- * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and
17531753- * dtrace_condense().
17541754- *
17551755- * 1.9 uint64_t dtps_getargval(void *arg, dtrace_id_t id, void *parg,
17561756- * int argno, int aframes)
17571757- *
17581758- * 1.9.1 Overview
17591759- *
17601760- * Called to retrieve a value for an argX or args[X] variable.
17611761- *
17621762- * 1.9.2 Arguments and notes
17631763- *
17641764- * The first argument is the cookie as passed to dtrace_register(). The
17651765- * second argument is the identifier of the current probe. The third
17661766- * argument is the probe argument as passed to dtrace_probe_create(). The
17671767- * fourth argument is the number of the argument (the X in the example in
17681768- * 1.9.1). The fifth argument is the number of stack frames that were used
17691769- * to get from the actual place in the code that fired the probe to
17701770- * dtrace_probe() itself, the so-called artificial frames. This argument may
17711771- * be used to descend an appropriate number of frames to find the correct
17721772- * values. If this entry point is left NULL, the dtrace_getarg() built-in
17731773- * function is used.
17741774- *
17751775- * 1.9.3 Return value
17761776- *
17771777- * The value of the argument.
17781778- *
17791779- * 1.9.4 Caller's context
17801780- *
17811781- * This is called from within dtrace_probe() meaning that interrupts
17821782- * are disabled. No locks should be taken within this entry point.
17831783- *
17841784- * 1.10 int dtps_usermode(void *arg, dtrace_id_t id, void *parg)
17851785- *
17861786- * 1.10.1 Overview
17871787- *
17881788- * Called to determine if the probe was fired in a user context.
17891789- *
17901790- * 1.10.2 Arguments and notes
17911791- *
17921792- * The first argument is the cookie as passed to dtrace_register(). The
17931793- * second argument is the identifier of the current probe. The third
17941794- * argument is the probe argument as passed to dtrace_probe_create(). This
17951795- * entry point must not be left NULL for providers whose probes allow for
17961796- * mixed mode tracing, that is to say those probes that can fire during
17971797- * kernel- _or_ user-mode execution
17981798- *
17991799- * 1.10.3 Return value
18001800- *
18011801- * A boolean value.
18021802- *
18031803- * 1.10.4 Caller's context
18041804- *
18051805- * This is called from within dtrace_probe() meaning that interrupts
18061806- * are disabled. No locks should be taken within this entry point.
18071807- *
18081808- * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg)
18091809- *
18101810- * 1.11.1 Overview
18111811- *
18121812- * Called to destroy the specified probe.
18131813- *
18141814- * 1.11.2 Arguments and notes
18151815- *
18161816- * The first argument is the cookie as passed to dtrace_register(). The
18171817- * second argument is the identifier of the probe to be destroyed. The third
18181818- * argument is the probe argument as passed to dtrace_probe_create(). The
18191819- * provider should free all state associated with the probe. The framework
18201820- * guarantees that dtps_destroy() is only called for probes that have either
18211821- * been disabled via dtps_disable() or were never enabled via dtps_enable().
18221822- * Once dtps_disable() has been called for a probe, no further call will be
18231823- * made specifying the probe.
18241824- *
18251825- * 1.11.3 Return value
18261826- *
18271827- * None.
18281828- *
18291829- * 1.11.4 Caller's context
18301830- *
18311831- * The DTrace framework is locked in such a way that it may not be called
18321832- * back into at all. mod_lock is held. cpu_lock is not held, and may not be
18331833- * acquired.
18341834- *
18351835- *
18361836- * 2 Provider-to-Framework API
18371837- *
18381838- * 2.1 Overview
18391839- *
18401840- * The Provider-to-Framework API provides the mechanism for the provider to
18411841- * register itself with the DTrace framework, to create probes, to lookup
18421842- * probes and (most importantly) to fire probes. The Provider-to-Framework
18431843- * consists of:
18441844- *
18451845- * dtrace_register() <-- Register a provider with the DTrace framework
18461846- * dtrace_unregister() <-- Remove a provider's DTrace registration
18471847- * dtrace_invalidate() <-- Invalidate the specified provider
18481848- * dtrace_condense() <-- Remove a provider's unenabled probes
18491849- * dtrace_attached() <-- Indicates whether or not DTrace has attached
18501850- * dtrace_probe_create() <-- Create a DTrace probe
18511851- * dtrace_probe_lookup() <-- Lookup a DTrace probe based on its name
18521852- * dtrace_probe_arg() <-- Return the probe argument for a specific probe
18531853- * dtrace_probe() <-- Fire the specified probe
18541854- *
18551855- * 2.2 int dtrace_register(const char *name, const dtrace_pattr_t *pap,
18561856- * uint32_t priv, cred_t *cr, const dtrace_pops_t *pops, void *arg,
18571857- * dtrace_provider_id_t *idp)
18581858- *
18591859- * 2.2.1 Overview
18601860- *
18611861- * dtrace_register() registers the calling provider with the DTrace
18621862- * framework. It should generally be called by DTrace providers in their
18631863- * attach(9E) entry point.
18641864- *
18651865- * 2.2.2 Arguments and Notes
18661866- *
18671867- * The first argument is the name of the provider. The second argument is a
18681868- * pointer to the stability attributes for the provider. The third argument
18691869- * is the privilege flags for the provider, and must be some combination of:
18701870- *
18711871- * DTRACE_PRIV_NONE <= All users may enable probes from this provider
18721872- *
18731873- * DTRACE_PRIV_PROC <= Any user with privilege of PRIV_DTRACE_PROC may
18741874- * enable probes from this provider
18751875- *
18761876- * DTRACE_PRIV_USER <= Any user with privilege of PRIV_DTRACE_USER may
18771877- * enable probes from this provider
18781878- *
18791879- * DTRACE_PRIV_KERNEL <= Any user with privilege of PRIV_DTRACE_KERNEL
18801880- * may enable probes from this provider
18811881- *
18821882- * DTRACE_PRIV_OWNER <= This flag places an additional constraint on
18831883- * the privilege requirements above. These probes
18841884- * require either (a) a user ID matching the user
18851885- * ID of the cred passed in the fourth argument
18861886- * or (b) the PRIV_PROC_OWNER privilege.
18871887- *
18881888- * DTRACE_PRIV_ZONEOWNER<= This flag places an additional constraint on
18891889- * the privilege requirements above. These probes
18901890- * require either (a) a zone ID matching the zone
18911891- * ID of the cred passed in the fourth argument
18921892- * or (b) the PRIV_PROC_ZONE privilege.
18931893- *
18941894- * Note that these flags designate the _visibility_ of the probes, not
18951895- * the conditions under which they may or may not fire.
18961896- *
18971897- * The fourth argument is the credential that is associated with the
18981898- * provider. This argument should be NULL if the privilege flags don't
18991899- * include DTRACE_PRIV_OWNER or DTRACE_PRIV_ZONEOWNER. If non-NULL, the
19001900- * framework stashes the uid and zoneid represented by this credential
19011901- * for use at probe-time, in implicit predicates. These limit visibility
19021902- * of the probes to users and/or zones which have sufficient privilege to
19031903- * access them.
19041904- *
19051905- * The fifth argument is a DTrace provider operations vector, which provides
19061906- * the implementation for the Framework-to-Provider API. (See Section 1,
19071907- * above.) This must be non-NULL, and each member must be non-NULL. The
19081908- * exceptions to this are (1) the dtps_provide() and dtps_provide_module()
19091909- * members (if the provider so desires, _one_ of these members may be left
19101910- * NULL -- denoting that the provider only implements the other) and (2)
19111911- * the dtps_suspend() and dtps_resume() members, which must either both be
19121912- * NULL or both be non-NULL.
19131913- *
19141914- * The sixth argument is a cookie to be specified as the first argument for
19151915- * each function in the Framework-to-Provider API. This argument may have
19161916- * any value.
19171917- *
19181918- * The final argument is a pointer to dtrace_provider_id_t. If
19191919- * dtrace_register() successfully completes, the provider identifier will be
19201920- * stored in the memory pointed to be this argument. This argument must be
19211921- * non-NULL.
19221922- *
19231923- * 2.2.3 Return value
19241924- *
19251925- * On success, dtrace_register() returns 0 and stores the new provider's
19261926- * identifier into the memory pointed to by the idp argument. On failure,
19271927- * dtrace_register() returns an errno:
19281928- *
19291929- * EINVAL The arguments passed to dtrace_register() were somehow invalid.
19301930- * This may because a parameter that must be non-NULL was NULL,
19311931- * because the name was invalid (either empty or an illegal
19321932- * provider name) or because the attributes were invalid.
19331933- *
19341934- * No other failure code is returned.
19351935- *
19361936- * 2.2.4 Caller's context
19371937- *
19381938- * dtrace_register() may induce calls to dtrace_provide(); the provider must
19391939- * hold no locks across dtrace_register() that may also be acquired by
19401940- * dtrace_provide(). cpu_lock and mod_lock must not be held.
19411941- *
19421942- * 2.3 int dtrace_unregister(dtrace_provider_t id)
19431943- *
19441944- * 2.3.1 Overview
19451945- *
19461946- * Unregisters the specified provider from the DTrace framework. It should
19471947- * generally be called by DTrace providers in their detach(9E) entry point.
19481948- *
19491949- * 2.3.2 Arguments and Notes
19501950- *
19511951- * The only argument is the provider identifier, as returned from a
19521952- * successful call to dtrace_register(). As a result of calling
19531953- * dtrace_unregister(), the DTrace framework will call back into the provider
19541954- * via the dtps_destroy() entry point. Once dtrace_unregister() successfully
19551955- * completes, however, the DTrace framework will no longer make calls through
19561956- * the Framework-to-Provider API.
19571957- *
19581958- * 2.3.3 Return value
19591959- *
19601960- * On success, dtrace_unregister returns 0. On failure, dtrace_unregister()
19611961- * returns an errno:
19621962- *
19631963- * EBUSY There are currently processes that have the DTrace pseudodevice
19641964- * open, or there exists an anonymous enabling that hasn't yet
19651965- * been claimed.
19661966- *
19671967- * No other failure code is returned.
19681968- *
19691969- * 2.3.4 Caller's context
19701970- *
19711971- * Because a call to dtrace_unregister() may induce calls through the
19721972- * Framework-to-Provider API, the caller may not hold any lock across
19731973- * dtrace_register() that is also acquired in any of the Framework-to-
19741974- * Provider API functions. Additionally, mod_lock may not be held.
19751975- *
19761976- * 2.4 void dtrace_invalidate(dtrace_provider_id_t id)
19771977- *
19781978- * 2.4.1 Overview
19791979- *
19801980- * Invalidates the specified provider. All subsequent probe lookups for the
19811981- * specified provider will fail, but its probes will not be removed.
19821982- *
19831983- * 2.4.2 Arguments and note
19841984- *
19851985- * The only argument is the provider identifier, as returned from a
19861986- * successful call to dtrace_register(). In general, a provider's probes
19871987- * always remain valid; dtrace_invalidate() is a mechanism for invalidating
19881988- * an entire provider, regardless of whether or not probes are enabled or
19891989- * not. Note that dtrace_invalidate() will _not_ prevent already enabled
19901990- * probes from firing -- it will merely prevent any new enablings of the
19911991- * provider's probes.
19921992- *
19931993- * 2.5 int dtrace_condense(dtrace_provider_id_t id)
19941994- *
19951995- * 2.5.1 Overview
19961996- *
19971997- * Removes all the unenabled probes for the given provider. This function is
19981998- * not unlike dtrace_unregister(), except that it doesn't remove the
19991999- * provider just as many of its associated probes as it can.
20002000- *
20012001- * 2.5.2 Arguments and Notes
20022002- *
20032003- * As with dtrace_unregister(), the sole argument is the provider identifier
20042004- * as returned from a successful call to dtrace_register(). As a result of
20052005- * calling dtrace_condense(), the DTrace framework will call back into the
20062006- * given provider's dtps_destroy() entry point for each of the provider's
20072007- * unenabled probes.
20082008- *
20092009- * 2.5.3 Return value
20102010- *
20112011- * Currently, dtrace_condense() always returns 0. However, consumers of this
20122012- * function should check the return value as appropriate; its behavior may
20132013- * change in the future.
20142014- *
20152015- * 2.5.4 Caller's context
20162016- *
20172017- * As with dtrace_unregister(), the caller may not hold any lock across
20182018- * dtrace_condense() that is also acquired in the provider's entry points.
20192019- * Also, mod_lock may not be held.
20202020- *
20212021- * 2.6 int dtrace_attached()
20222022- *
20232023- * 2.6.1 Overview
20242024- *
20252025- * Indicates whether or not DTrace has attached.
20262026- *
20272027- * 2.6.2 Arguments and Notes
20282028- *
20292029- * For most providers, DTrace makes initial contact beyond registration.
20302030- * That is, once a provider has registered with DTrace, it waits to hear
20312031- * from DTrace to create probes. However, some providers may wish to
20322032- * proactively create probes without first being told by DTrace to do so.
20332033- * If providers wish to do this, they must first call dtrace_attached() to
20342034- * determine if DTrace itself has attached. If dtrace_attached() returns 0,
20352035- * the provider must not make any other Provider-to-Framework API call.
20362036- *
20372037- * 2.6.3 Return value
20382038- *
20392039- * dtrace_attached() returns 1 if DTrace has attached, 0 otherwise.
20402040- *
20412041- * 2.7 int dtrace_probe_create(dtrace_provider_t id, const char *mod,
20422042- * const char *func, const char *name, int aframes, void *arg)
20432043- *
20442044- * 2.7.1 Overview
20452045- *
20462046- * Creates a probe with specified module name, function name, and name.
20472047- *
20482048- * 2.7.2 Arguments and Notes
20492049- *
20502050- * The first argument is the provider identifier, as returned from a
20512051- * successful call to dtrace_register(). The second, third, and fourth
20522052- * arguments are the module name, function name, and probe name,
20532053- * respectively. Of these, module name and function name may both be NULL
20542054- * (in which case the probe is considered to be unanchored), or they may both
20552055- * be non-NULL. The name must be non-NULL, and must point to a non-empty
20562056- * string.
20572057- *
20582058- * The fifth argument is the number of artificial stack frames that will be
20592059- * found on the stack when dtrace_probe() is called for the new probe. These
20602060- * artificial frames will be automatically be pruned should the stack() or
20612061- * stackdepth() functions be called as part of one of the probe's ECBs. If
20622062- * the parameter doesn't add an artificial frame, this parameter should be
20632063- * zero.
20642064- *
20652065- * The final argument is a probe argument that will be passed back to the
20662066- * provider when a probe-specific operation is called. (e.g., via
20672067- * dtps_enable(), dtps_disable(), etc.)
20682068- *
20692069- * Note that it is up to the provider to be sure that the probe that it
20702070- * creates does not already exist -- if the provider is unsure of the probe's
20712071- * existence, it should assure its absence with dtrace_probe_lookup() before
20722072- * calling dtrace_probe_create().
20732073- *
20742074- * 2.7.3 Return value
20752075- *
20762076- * dtrace_probe_create() always succeeds, and always returns the identifier
20772077- * of the newly-created probe.
20782078- *
20792079- * 2.7.4 Caller's context
20802080- *
20812081- * While dtrace_probe_create() is generally expected to be called from
20822082- * dtps_provide() and/or dtps_provide_module(), it may be called from other
20832083- * non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
20842084- *
20852085- * 2.8 dtrace_id_t dtrace_probe_lookup(dtrace_provider_t id, const char *mod,
20862086- * const char *func, const char *name)
20872087- *
20882088- * 2.8.1 Overview
20892089- *
20902090- * Looks up a probe based on provdider and one or more of module name,
20912091- * function name and probe name.
20922092- *
20932093- * 2.8.2 Arguments and Notes
20942094- *
20952095- * The first argument is the provider identifier, as returned from a
20962096- * successful call to dtrace_register(). The second, third, and fourth
20972097- * arguments are the module name, function name, and probe name,
20982098- * respectively. Any of these may be NULL; dtrace_probe_lookup() will return
20992099- * the identifier of the first probe that is provided by the specified
21002100- * provider and matches all of the non-NULL matching criteria.
21012101- * dtrace_probe_lookup() is generally used by a provider to be check the
21022102- * existence of a probe before creating it with dtrace_probe_create().
21032103- *
21042104- * 2.8.3 Return value
21052105- *
21062106- * If the probe exists, returns its identifier. If the probe does not exist,
21072107- * return DTRACE_IDNONE.
21082108- *
21092109- * 2.8.4 Caller's context
21102110- *
21112111- * While dtrace_probe_lookup() is generally expected to be called from
21122112- * dtps_provide() and/or dtps_provide_module(), it may also be called from
21132113- * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
21142114- *
21152115- * 2.9 void *dtrace_probe_arg(dtrace_provider_t id, dtrace_id_t probe)
21162116- *
21172117- * 2.9.1 Overview
21182118- *
21192119- * Returns the probe argument associated with the specified probe.
21202120- *
21212121- * 2.9.2 Arguments and Notes
21222122- *
21232123- * The first argument is the provider identifier, as returned from a
21242124- * successful call to dtrace_register(). The second argument is a probe
21252125- * identifier, as returned from dtrace_probe_lookup() or
21262126- * dtrace_probe_create(). This is useful if a probe has multiple
21272127- * provider-specific components to it: the provider can create the probe
21282128- * once with provider-specific state, and then add to the state by looking
21292129- * up the probe based on probe identifier.
21302130- *
21312131- * 2.9.3 Return value
21322132- *
21332133- * Returns the argument associated with the specified probe. If the
21342134- * specified probe does not exist, or if the specified probe is not provided
21352135- * by the specified provider, NULL is returned.
21362136- *
21372137- * 2.9.4 Caller's context
21382138- *
21392139- * While dtrace_probe_arg() is generally expected to be called from
21402140- * dtps_provide() and/or dtps_provide_module(), it may also be called from
21412141- * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
21422142- *
21432143- * 2.10 void dtrace_probe(dtrace_id_t probe, uintptr_t arg0, uintptr_t arg1,
21442144- * uintptr_t arg2, uintptr_t arg3, uintptr_t arg4)
21452145- *
21462146- * 2.10.1 Overview
21472147- *
21482148- * The epicenter of DTrace: fires the specified probes with the specified
21492149- * arguments.
21502150- *
21512151- * 2.10.2 Arguments and Notes
21522152- *
21532153- * The first argument is a probe identifier as returned by
21542154- * dtrace_probe_create() or dtrace_probe_lookup(). The second through sixth
21552155- * arguments are the values to which the D variables "arg0" through "arg4"
21562156- * will be mapped.
21572157- *
21582158- * dtrace_probe() should be called whenever the specified probe has fired --
21592159- * however the provider defines it.
21602160- *
21612161- * 2.10.3 Return value
21622162- *
21632163- * None.
21642164- *
21652165- * 2.10.4 Caller's context
21662166- *
21672167- * dtrace_probe() may be called in virtually any context: kernel, user,
21682168- * interrupt, high-level interrupt, with arbitrary adaptive locks held, with
21692169- * dispatcher locks held, with interrupts disabled, etc. The only latitude
21702170- * that must be afforded to DTrace is the ability to make calls within
21712171- * itself (and to its in-kernel subroutines) and the ability to access
21722172- * arbitrary (but mapped) memory. On some platforms, this constrains
21732173- * context. For example, on UltraSPARC, dtrace_probe() cannot be called
21742174- * from any context in which TL is greater than zero. dtrace_probe() may
21752175- * also not be called from any routine which may be called by dtrace_probe()
21762176- * -- which includes functions in the DTrace framework and some in-kernel
21772177- * DTrace subroutines. All such functions "dtrace_"; providers that
21782178- * instrument the kernel arbitrarily should be sure to not instrument these
21792179- * routines.
21802180- */
21812181-typedef struct dtrace_pops {
21822182- void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec);
21832183- void (*dtps_provide_module)(void *arg, struct modctl *mp);
21842184- int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
21852185- void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
21862186- void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
21872187- void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg);
21882188- void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg,
21892189- dtrace_argdesc_t *desc);
21902190- uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg,
21912191- int argno, int aframes);
21922192- int (*dtps_usermode)(void *arg, dtrace_id_t id, void *parg);
21932193- void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg);
21942194-} dtrace_pops_t;
21952195-21962196-typedef uintptr_t dtrace_provider_id_t;
21972197-21982198-extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t,
21992199- cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *);
22002200-extern int dtrace_unregister(dtrace_provider_id_t);
22012201-extern int dtrace_condense(dtrace_provider_id_t);
22022202-extern void dtrace_invalidate(dtrace_provider_id_t);
22032203-extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *,
22042204- const char *, const char *);
22052205-extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *,
22062206- const char *, const char *, int, void *);
22072207-extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t);
22082208-#if !defined(__APPLE__)
22092209-extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
22102210- uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
22112211-#else
22122212-extern void dtrace_probe(dtrace_id_t, uint64_t arg0, uint64_t arg1,
22132213- uint64_t arg2, uint64_t arg3, uint64_t arg4);
22142214-#endif /* __APPLE__ */
22152215-22162216-/*
22172217- * DTrace Meta Provider API
22182218- *
22192219- * The following functions are implemented by the DTrace framework and are
22202220- * used to implement meta providers. Meta providers plug into the DTrace
22212221- * framework and are used to instantiate new providers on the fly. At
22222222- * present, there is only one type of meta provider and only one meta
22232223- * provider may be registered with the DTrace framework at a time. The
22242224- * sole meta provider type provides user-land static tracing facilities
22252225- * by taking meta probe descriptions and adding a corresponding provider
22262226- * into the DTrace framework.
22272227- *
22282228- * 1 Framework-to-Provider
22292229- *
22302230- * 1.1 Overview
22312231- *
22322232- * The Framework-to-Provider API is represented by the dtrace_mops structure
22332233- * that the meta provider passes to the framework when registering itself as
22342234- * a meta provider. This structure consists of the following members:
22352235- *
22362236- * dtms_create_probe() <-- Add a new probe to a created provider
22372237- * dtms_provide_pid() <-- Create a new provider for a given process
22382238- * dtms_remove_pid() <-- Remove a previously created provider
22392239- *
22402240- * 1.2 void dtms_create_probe(void *arg, void *parg,
22412241- * dtrace_helper_probedesc_t *probedesc);
22422242- *
22432243- * 1.2.1 Overview
22442244- *
22452245- * Called by the DTrace framework to create a new probe in a provider
22462246- * created by this meta provider.
22472247- *
22482248- * 1.2.2 Arguments and notes
22492249- *
22502250- * The first argument is the cookie as passed to dtrace_meta_register().
22512251- * The second argument is the provider cookie for the associated provider;
22522252- * this is obtained from the return value of dtms_provide_pid(). The third
22532253- * argument is the helper probe description.
22542254- *
22552255- * 1.2.3 Return value
22562256- *
22572257- * None
22582258- *
22592259- * 1.2.4 Caller's context
22602260- *
22612261- * dtms_create_probe() is called from either ioctl() or module load context.
22622262- * The DTrace framework is locked in such a way that meta providers may not
22632263- * register or unregister. This means that the meta provider cannot call
22642264- * dtrace_meta_register() or dtrace_meta_unregister(). However, the context is
22652265- * such that the provider may (and is expected to) call provider-related
22662266- * DTrace provider APIs including dtrace_probe_create().
22672267- *
22682268- * 1.3 void *dtms_provide_pid(void *arg, dtrace_meta_provider_t *mprov,
22692269- * pid_t pid)
22702270- *
22712271- * 1.3.1 Overview
22722272- *
22732273- * Called by the DTrace framework to instantiate a new provider given the
22742274- * description of the provider and probes in the mprov argument. The
22752275- * meta provider should call dtrace_register() to insert the new provider
22762276- * into the DTrace framework.
22772277- *
22782278- * 1.3.2 Arguments and notes
22792279- *
22802280- * The first argument is the cookie as passed to dtrace_meta_register().
22812281- * The second argument is a pointer to a structure describing the new
22822282- * helper provider. The third argument is the process identifier for
22832283- * process associated with this new provider. Note that the name of the
22842284- * provider as passed to dtrace_register() should be the contatenation of
22852285- * the dtmpb_provname member of the mprov argument and the processs
22862286- * identifier as a string.
22872287- *
22882288- * 1.3.3 Return value
22892289- *
22902290- * The cookie for the provider that the meta provider creates. This is
22912291- * the same value that it passed to dtrace_register().
22922292- *
22932293- * 1.3.4 Caller's context
22942294- *
22952295- * dtms_provide_pid() is called from either ioctl() or module load context.
22962296- * The DTrace framework is locked in such a way that meta providers may not
22972297- * register or unregister. This means that the meta provider cannot call
22982298- * dtrace_meta_register() or dtrace_meta_unregister(). However, the context
22992299- * is such that the provider may -- and is expected to -- call
23002300- * provider-related DTrace provider APIs including dtrace_register().
23012301- *
23022302- * 1.4 void dtms_remove_pid(void *arg, dtrace_meta_provider_t *mprov,
23032303- * pid_t pid)
23042304- *
23052305- * 1.4.1 Overview
23062306- *
23072307- * Called by the DTrace framework to remove a provider that had previously
23082308- * been instantiated via the dtms_provide_pid() entry point. The meta
23092309- * provider need not remove the provider immediately, but this entry
23102310- * point indicates that the provider should be removed as soon as possible
23112311- * using the dtrace_unregister() API.
23122312- *
23132313- * 1.4.2 Arguments and notes
23142314- *
23152315- * The first argument is the cookie as passed to dtrace_meta_register().
23162316- * The second argument is a pointer to a structure describing the helper
23172317- * provider. The third argument is the process identifier for process
23182318- * associated with this new provider.
23192319- *
23202320- * 1.4.3 Return value
23212321- *
23222322- * None
23232323- *
23242324- * 1.4.4 Caller's context
23252325- *
23262326- * dtms_remove_pid() is called from either ioctl() or exit() context.
23272327- * The DTrace framework is locked in such a way that meta providers may not
23282328- * register or unregister. This means that the meta provider cannot call
23292329- * dtrace_meta_register() or dtrace_meta_unregister(). However, the context
23302330- * is such that the provider may -- and is expected to -- call
23312331- * provider-related DTrace provider APIs including dtrace_unregister().
23322332- */
23332333-typedef struct dtrace_helper_probedesc {
23342334- char *dthpb_mod; /* probe module */
23352335- char *dthpb_func; /* probe function */
23362336- char *dthpb_name; /* probe name */
23372337- uint64_t dthpb_base; /* base address */
23382338-#if !defined(__APPLE__)
23392339- uint32_t *dthpb_offs; /* offsets array */
23402340- uint32_t *dthpb_enoffs; /* is-enabled offsets array */
23412341-#else
23422342- int32_t *dthpb_offs; /* (signed) offsets array */
23432343- int32_t *dthpb_enoffs; /* (signed) is-enabled offsets array */
23442344-#endif
23452345- uint32_t dthpb_noffs; /* offsets count */
23462346- uint32_t dthpb_nenoffs; /* is-enabled offsets count */
23472347- uint8_t *dthpb_args; /* argument mapping array */
23482348- uint8_t dthpb_xargc; /* translated argument count */
23492349- uint8_t dthpb_nargc; /* native argument count */
23502350- char *dthpb_xtypes; /* translated types strings */
23512351- char *dthpb_ntypes; /* native types strings */
23522352-} dtrace_helper_probedesc_t;
23532353-23542354-typedef struct dtrace_helper_provdesc {
23552355- char *dthpv_provname; /* provider name */
23562356- dtrace_pattr_t dthpv_pattr; /* stability attributes */
23572357-} dtrace_helper_provdesc_t;
23582358-23592359-typedef struct dtrace_mops {
23602360- void (*dtms_create_probe)(void *, void *, dtrace_helper_probedesc_t *);
23612361- void *(*dtms_provide_pid)(void *, dtrace_helper_provdesc_t *, pid_t);
23622362- void (*dtms_remove_pid)(void *, dtrace_helper_provdesc_t *, pid_t);
23632363-} dtrace_mops_t;
23642364-23652365-typedef uintptr_t dtrace_meta_provider_id_t;
23662366-23672367-extern int dtrace_meta_register(const char *, const dtrace_mops_t *, void *,
23682368- dtrace_meta_provider_id_t *);
23692369-extern int dtrace_meta_unregister(dtrace_meta_provider_id_t);
23702370-23712371-/*
23722372- * DTrace Kernel Hooks
23732373- *
23742374- * The following functions are implemented by the base kernel and form a set of
23752375- * hooks used by the DTrace framework. DTrace hooks are implemented in either
23762376- * uts/common/os/dtrace_subr.c, an ISA-specific assembly file, or in a
23772377- * uts/<platform>/os/dtrace_subr.c corresponding to each hardware platform.
23782378- */
23792379-23802380-typedef enum dtrace_vtime_state {
23812381- DTRACE_VTIME_INACTIVE = 0, /* No DTrace, no TNF */
23822382- DTRACE_VTIME_ACTIVE, /* DTrace virtual time, no TNF */
23832383- DTRACE_VTIME_INACTIVE_TNF, /* No DTrace, TNF active */
23842384- DTRACE_VTIME_ACTIVE_TNF /* DTrace virtual time _and_ TNF */
23852385-} dtrace_vtime_state_t;
23862386-23872387-extern dtrace_vtime_state_t dtrace_vtime_active;
23882388-extern void dtrace_vtime_switch(kthread_t *next);
23892389-extern void dtrace_vtime_enable_tnf(void);
23902390-extern void dtrace_vtime_disable_tnf(void);
23912391-extern void dtrace_vtime_enable(void);
23922392-extern void dtrace_vtime_disable(void);
23932393-23942394-#if !defined(__APPLE__)
23952395-struct regs;
23962396-23972397-extern int (*dtrace_pid_probe_ptr)(struct regs *);
23982398-extern int (*dtrace_return_probe_ptr)(struct regs *);
23992399-#else
24002400-#if defined (__i386__) || defined(__x86_64__)
24012401-extern int (*dtrace_pid_probe_ptr)(x86_saved_state_t *regs);
24022402-extern int (*dtrace_return_probe_ptr)(x86_saved_state_t* regs);
24032403-#else
24042404-#error architecture not supported
24052405-#endif
24062406-#endif /* __APPLE__ */
24072407-extern void (*dtrace_fasttrap_fork_ptr)(proc_t *, proc_t *);
24082408-extern void (*dtrace_fasttrap_exec_ptr)(proc_t *);
24092409-extern void (*dtrace_fasttrap_exit_ptr)(proc_t *);
24102410-extern void dtrace_fasttrap_fork(proc_t *, proc_t *);
24112411-24122412-typedef uintptr_t dtrace_icookie_t;
24132413-typedef void (*dtrace_xcall_t)(void *);
24142414-24152415-extern dtrace_icookie_t dtrace_interrupt_disable(void);
24162416-extern void dtrace_interrupt_enable(dtrace_icookie_t);
24172417-24182418-extern void dtrace_membar_producer(void);
24192419-extern void dtrace_membar_consumer(void);
24202420-24212421-extern void (*dtrace_cpu_init)(processorid_t);
24222422-#if !defined(__APPLE__)
24232423-extern void (*dtrace_modload)(struct modctl *);
24242424-extern void (*dtrace_modunload)(struct modctl *);
24252425-#else
24262426-extern int (*dtrace_modload)(struct kmod_info *, uint32_t);
24272427-extern int (*dtrace_modunload)(struct kmod_info *);
24282428-#endif /* __APPLE__ */
24292429-extern void (*dtrace_helpers_cleanup)(proc_t*);
24302430-extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child);
24312431-extern void (*dtrace_cpustart_init)(void);
24322432-extern void (*dtrace_cpustart_fini)(void);
24332433-24342434-extern void (*dtrace_kreloc_init)(void);
24352435-extern void (*dtrace_kreloc_fini)(void);
24362436-24372437-extern void (*dtrace_debugger_init)(void);
24382438-extern void (*dtrace_debugger_fini)(void);
24392439-extern dtrace_cacheid_t dtrace_predcache_id;
24402440-24412441-extern hrtime_t dtrace_gethrtime(void);
24422442-extern void dtrace_sync(void);
24432443-extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
24442444-extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
24452445-24462446-extern int dtrace_safe_defer_signal(void);
24472447-extern void dtrace_safe_synchronous_signal(void);
24482448-24492449-extern int dtrace_mach_aframes(void);
24502450-24512451-#if !defined(__APPLE__)
24522452-#if defined(__i386) || defined(__amd64)
24532453-extern int dtrace_instr_size(uchar_t *instr);
24542454-extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
24552455-extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t));
24562456-extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t));
24572457-extern void dtrace_invop_callsite(void);
24582458-#endif
24592459-24602460-#ifdef __sparc
24612461-extern int dtrace_blksuword32(uintptr_t, uint32_t *, int);
24622462-extern void dtrace_getfsr(uint64_t *);
24632463-#endif
24642464-#else
24652465-#if defined(__i386__) || defined(__x86_64__)
24662466-extern int dtrace_instr_size(uchar_t *instr);
24672467-extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
24682468-extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t));
24692469-extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t));
24702470-extern void *dtrace_invop_callsite_pre;
24712471-extern void *dtrace_invop_callsite_post;
24722472-#endif
24732473-24742474-24752475-#undef proc_t
24762476-#endif /* __APPLE__ */
24772477-24782478-#define DTRACE_CPUFLAG_ISSET(flag) \
24792479- (cpu_core[CPU->cpu_id].cpuc_dtrace_flags & (flag))
24802480-24812481-#define DTRACE_CPUFLAG_SET(flag) \
24822482- (cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= (flag))
24832483-24842484-#define DTRACE_CPUFLAG_CLEAR(flag) \
24852485- (cpu_core[CPU->cpu_id].cpuc_dtrace_flags &= ~(flag))
24862486-24872487-#endif /* _KERNEL */
24882488-24892489-#endif /* _ASM */
24902490-24912491-#if !defined(__APPLE__)
24922492-#if defined(__i386) || defined(__amd64)
24932493-24942494-#define DTRACE_INVOP_PUSHL_EBP 1
24952495-#define DTRACE_INVOP_POPL_EBP 2
24962496-#define DTRACE_INVOP_LEAVE 3
24972497-#define DTRACE_INVOP_NOP 4
24982498-#define DTRACE_INVOP_RET 5
24992499-25002500-#endif
25012501-#else
25022502-#if defined(__i386__) || defined(__x86_64__)
25032503-25042504-#define DTRACE_INVOP_PUSHL_EBP 1
25052505-#define DTRACE_INVOP_POPL_EBP 2
25062506-#define DTRACE_INVOP_LEAVE 3
25072507-#define DTRACE_INVOP_NOP 4
25082508-#define DTRACE_INVOP_RET 5
25092509-25102510-#endif
25112511-25122512-25132513-#endif /* __APPLE__ */
25142514-25152515-#ifdef __cplusplus
25162516-}
25172517-#endif
25182518-25192519-#endif /* _SYS_DTRACE_H */
-2555
platform-include/sys/dtrace.h
···11-/*
22- * CDDL HEADER START
33- *
44- * The contents of this file are subject to the terms of the
55- * Common Development and Distribution License (the "License").
66- * You may not use this file except in compliance with the License.
77- *
88- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99- * or http://www.opensolaris.org/os/licensing.
1010- * See the License for the specific language governing permissions
1111- * and limitations under the License.
1212- *
1313- * When distributing Covered Code, include this CDDL HEADER in each
1414- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1515- * If applicable, add the following below this CDDL HEADER, with the
1616- * fields enclosed by brackets "[]" replaced with your own identifying
1717- * information: Portions Copyright [yyyy] [name of copyright owner]
1818- *
1919- * CDDL HEADER END
2020- */
2121-2222-/*
2323- * Portions copyright (c) 2011, Joyent, Inc. All rights reserved.
2424- */
2525-2626-/*
2727- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2828- * Use is subject to license terms.
2929- */
3030-3131-#ifndef _SYS_DTRACE_H
3232-#define _SYS_DTRACE_H
3333-3434-/* #pragma ident "@(#)dtrace.h 1.37 07/06/05 SMI" */
3535-3636-#ifdef __cplusplus
3737-extern "C" {
3838-#endif
3939-4040-/*
4141- * DTrace Dynamic Tracing Software: Kernel Interfaces
4242- *
4343- * Note: The contents of this file are private to the implementation of the
4444- * Solaris system and DTrace subsystem and are subject to change at any time
4545- * without notice. Applications and drivers using these interfaces will fail
4646- * to run on future releases. These interfaces should not be used for any
4747- * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
4848- * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
4949- */
5050-5151-#ifndef _ASM
5252-5353-#if !defined(__APPLE__)
5454-#include <sys/types.h>
5555-#include <sys/modctl.h>
5656-#include <sys/processor.h>
5757-#include <sys/systm.h>
5858-#include <sys/ctf_api.h>
5959-#include <sys/cyclic.h>
6060-#include <sys/int_limits.h>
6161-#else /* is Apple Mac OS X */
6262-6363-#if defined(__LP64__)
6464-#if !defined(_LP64)
6565-#define _LP64 /* Solaris vs. Darwin */
6666-#endif
6767-#else
6868-#if !defined(_ILP32)
6969-#define _ILP32 /* Solaris vs. Darwin */
7070-#endif
7171-#endif
7272-7373-7474-#if defined(__BIG_ENDIAN__)
7575-#if !defined(_BIG_ENDIAN)
7676-#define _BIG_ENDIAN /* Solaris vs. Darwin */
7777-#endif
7878-#elif defined(__LITTLE_ENDIAN__)
7979-#if !defined(_LITTLE_ENDIAN)
8080-#define _LITTLE_ENDIAN /* Solaris vs. Darwin */
8181-#endif
8282-#else
8383-#error Unknown endian-ness
8484-#endif
8585-8686-#include <sys/types.h>
8787-#include <sys/param.h>
8888-#include <stdint.h>
8989-9090-#ifndef NULL
9191-#define NULL ((void *)0) /* quiets many warnings */
9292-#endif
9393-9494-#define SEC 1
9595-#define MILLISEC 1000
9696-#define MICROSEC 1000000
9797-#define NANOSEC 1000000000
9898-9999-#define S_ROUND(x, a) ((x) + (((a) ? (a) : 1) - 1) & ~(((a) ? (a) : 1) - 1))
100100-#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
101101-102102-#define CTF_MODEL_ILP32 1 /* object data model is ILP32 */
103103-#define CTF_MODEL_LP64 2 /* object data model is LP64 */
104104-#ifdef __LP64__
105105-#define CTF_MODEL_NATIVE CTF_MODEL_LP64
106106-#else
107107-#define CTF_MODEL_NATIVE CTF_MODEL_ILP32
108108-#endif
109109-110110-typedef uint8_t uchar_t;
111111-typedef uint16_t ushort_t;
112112-typedef uint32_t uint_t;
113113-typedef unsigned long ulong_t;
114114-typedef uint64_t u_longlong_t;
115115-typedef int64_t longlong_t;
116116-typedef int64_t off64_t;
117117-typedef int processorid_t;
118118-typedef int64_t hrtime_t;
119119-120120-typedef enum { B_FALSE = 0, B_TRUE = 1 } _dtrace_boolean;
121121-122122-typedef uint8_t UUID[16]; /* For modctl use in dtrace.h */
123123-124124-struct modctl; /* In lieu of Solaris <sys/modctl.h> */
125125-/* NOTHING */ /* In lieu of Solaris <sys/processor.h> */
126126-#include <sys/ioctl.h> /* In lieu of Solaris <sys/systm.h> */
127127-/* In lieu of Solaris <sys/ctf_api.h> */
128128-typedef struct ctf_file ctf_file_t;
129129-typedef long ctf_id_t;
130130-/* NOTHING */ /* In lieu of Solaris <sys/cyclic.h> */
131131-/* NOTHING */ /* In lieu of Solaris <sys/int_limits.h> */
132132-133133-typedef uint32_t zoneid_t;
134134-135135-#include <sys/dtrace_glue.h>
136136-137137-#include <stdarg.h>
138138-typedef va_list __va_list;
139139-140140-/* Solaris proc_t is the struct. Darwin's proc_t is a pointer to it. */
141141-#define proc_t struct proc /* Steer clear of the Darwin typedef for proc_t */
142142-#endif /* __APPLE__ */
143143-144144-/*
145145- * DTrace Universal Constants and Typedefs
146146- */
147147-#define DTRACE_CPUALL -1 /* all CPUs */
148148-#define DTRACE_IDNONE 0 /* invalid probe identifier */
149149-#define DTRACE_EPIDNONE 0 /* invalid enabled probe identifier */
150150-#define DTRACE_AGGIDNONE 0 /* invalid aggregation identifier */
151151-#define DTRACE_AGGVARIDNONE 0 /* invalid aggregation variable ID */
152152-#define DTRACE_CACHEIDNONE 0 /* invalid predicate cache */
153153-#define DTRACE_PROVNONE 0 /* invalid provider identifier */
154154-#define DTRACE_METAPROVNONE 0 /* invalid meta-provider identifier */
155155-#define DTRACE_ARGNONE -1 /* invalid argument index */
156156-157157-#define DTRACE_PROVNAMELEN 64
158158-#define DTRACE_MODNAMELEN 64
159159-#define DTRACE_FUNCNAMELEN 128
160160-#define DTRACE_NAMELEN 64
161161-#define DTRACE_FULLNAMELEN (DTRACE_PROVNAMELEN + DTRACE_MODNAMELEN + \
162162- DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 4)
163163-#define DTRACE_ARGTYPELEN 128
164164-165165-typedef uint32_t dtrace_id_t; /* probe identifier */
166166-typedef uint32_t dtrace_epid_t; /* enabled probe identifier */
167167-typedef uint32_t dtrace_aggid_t; /* aggregation identifier */
168168-typedef int64_t dtrace_aggvarid_t; /* aggregation variable identifier */
169169-typedef uint16_t dtrace_actkind_t; /* action kind */
170170-typedef int64_t dtrace_optval_t; /* option value */
171171-typedef uint32_t dtrace_cacheid_t; /* predicate cache identifier */
172172-173173-typedef enum dtrace_probespec {
174174- DTRACE_PROBESPEC_NONE = -1,
175175- DTRACE_PROBESPEC_PROVIDER = 0,
176176- DTRACE_PROBESPEC_MOD,
177177- DTRACE_PROBESPEC_FUNC,
178178- DTRACE_PROBESPEC_NAME
179179-} dtrace_probespec_t;
180180-181181-/*
182182- * DTrace Intermediate Format (DIF)
183183- *
184184- * The following definitions describe the DTrace Intermediate Format (DIF), a
185185- * a RISC-like instruction set and program encoding used to represent
186186- * predicates and actions that can be bound to DTrace probes. The constants
187187- * below defining the number of available registers are suggested minimums; the
188188- * compiler should use DTRACEIOC_CONF to dynamically obtain the number of
189189- * registers provided by the current DTrace implementation.
190190- */
191191-#define DIF_VERSION_1 1 /* DIF version 1: Solaris 10 Beta */
192192-#define DIF_VERSION_2 2 /* DIF version 2: Solaris 10 FCS */
193193-#define DIF_VERSION DIF_VERSION_2 /* latest DIF instruction set version */
194194-#define DIF_DIR_NREGS 8 /* number of DIF integer registers */
195195-#define DIF_DTR_NREGS 8 /* number of DIF tuple registers */
196196-197197-#define DIF_OP_OR 1 /* or r1, r2, rd */
198198-#define DIF_OP_XOR 2 /* xor r1, r2, rd */
199199-#define DIF_OP_AND 3 /* and r1, r2, rd */
200200-#define DIF_OP_SLL 4 /* sll r1, r2, rd */
201201-#define DIF_OP_SRL 5 /* srl r1, r2, rd */
202202-#define DIF_OP_SUB 6 /* sub r1, r2, rd */
203203-#define DIF_OP_ADD 7 /* add r1, r2, rd */
204204-#define DIF_OP_MUL 8 /* mul r1, r2, rd */
205205-#define DIF_OP_SDIV 9 /* sdiv r1, r2, rd */
206206-#define DIF_OP_UDIV 10 /* udiv r1, r2, rd */
207207-#define DIF_OP_SREM 11 /* srem r1, r2, rd */
208208-#define DIF_OP_UREM 12 /* urem r1, r2, rd */
209209-#define DIF_OP_NOT 13 /* not r1, rd */
210210-#define DIF_OP_MOV 14 /* mov r1, rd */
211211-#define DIF_OP_CMP 15 /* cmp r1, r2 */
212212-#define DIF_OP_TST 16 /* tst r1 */
213213-#define DIF_OP_BA 17 /* ba label */
214214-#define DIF_OP_BE 18 /* be label */
215215-#define DIF_OP_BNE 19 /* bne label */
216216-#define DIF_OP_BG 20 /* bg label */
217217-#define DIF_OP_BGU 21 /* bgu label */
218218-#define DIF_OP_BGE 22 /* bge label */
219219-#define DIF_OP_BGEU 23 /* bgeu label */
220220-#define DIF_OP_BL 24 /* bl label */
221221-#define DIF_OP_BLU 25 /* blu label */
222222-#define DIF_OP_BLE 26 /* ble label */
223223-#define DIF_OP_BLEU 27 /* bleu label */
224224-#define DIF_OP_LDSB 28 /* ldsb [r1], rd */
225225-#define DIF_OP_LDSH 29 /* ldsh [r1], rd */
226226-#define DIF_OP_LDSW 30 /* ldsw [r1], rd */
227227-#define DIF_OP_LDUB 31 /* ldub [r1], rd */
228228-#define DIF_OP_LDUH 32 /* lduh [r1], rd */
229229-#define DIF_OP_LDUW 33 /* lduw [r1], rd */
230230-#define DIF_OP_LDX 34 /* ldx [r1], rd */
231231-#define DIF_OP_RET 35 /* ret rd */
232232-#define DIF_OP_NOP 36 /* nop */
233233-#define DIF_OP_SETX 37 /* setx intindex, rd */
234234-#define DIF_OP_SETS 38 /* sets strindex, rd */
235235-#define DIF_OP_SCMP 39 /* scmp r1, r2 */
236236-#define DIF_OP_LDGA 40 /* ldga var, ri, rd */
237237-#define DIF_OP_LDGS 41 /* ldgs var, rd */
238238-#define DIF_OP_STGS 42 /* stgs var, rs */
239239-#define DIF_OP_LDTA 43 /* ldta var, ri, rd */
240240-#define DIF_OP_LDTS 44 /* ldts var, rd */
241241-#define DIF_OP_STTS 45 /* stts var, rs */
242242-#define DIF_OP_SRA 46 /* sra r1, r2, rd */
243243-#define DIF_OP_CALL 47 /* call subr, rd */
244244-#define DIF_OP_PUSHTR 48 /* pushtr type, rs, rr */
245245-#define DIF_OP_PUSHTV 49 /* pushtv type, rs, rv */
246246-#define DIF_OP_POPTS 50 /* popts */
247247-#define DIF_OP_FLUSHTS 51 /* flushts */
248248-#define DIF_OP_LDGAA 52 /* ldgaa var, rd */
249249-#define DIF_OP_LDTAA 53 /* ldtaa var, rd */
250250-#define DIF_OP_STGAA 54 /* stgaa var, rs */
251251-#define DIF_OP_STTAA 55 /* sttaa var, rs */
252252-#define DIF_OP_LDLS 56 /* ldls var, rd */
253253-#define DIF_OP_STLS 57 /* stls var, rs */
254254-#define DIF_OP_ALLOCS 58 /* allocs r1, rd */
255255-#define DIF_OP_COPYS 59 /* copys r1, r2, rd */
256256-#define DIF_OP_STB 60 /* stb r1, [rd] */
257257-#define DIF_OP_STH 61 /* sth r1, [rd] */
258258-#define DIF_OP_STW 62 /* stw r1, [rd] */
259259-#define DIF_OP_STX 63 /* stx r1, [rd] */
260260-#define DIF_OP_ULDSB 64 /* uldsb [r1], rd */
261261-#define DIF_OP_ULDSH 65 /* uldsh [r1], rd */
262262-#define DIF_OP_ULDSW 66 /* uldsw [r1], rd */
263263-#define DIF_OP_ULDUB 67 /* uldub [r1], rd */
264264-#define DIF_OP_ULDUH 68 /* ulduh [r1], rd */
265265-#define DIF_OP_ULDUW 69 /* ulduw [r1], rd */
266266-#define DIF_OP_ULDX 70 /* uldx [r1], rd */
267267-#define DIF_OP_RLDSB 71 /* rldsb [r1], rd */
268268-#define DIF_OP_RLDSH 72 /* rldsh [r1], rd */
269269-#define DIF_OP_RLDSW 73 /* rldsw [r1], rd */
270270-#define DIF_OP_RLDUB 74 /* rldub [r1], rd */
271271-#define DIF_OP_RLDUH 75 /* rlduh [r1], rd */
272272-#define DIF_OP_RLDUW 76 /* rlduw [r1], rd */
273273-#define DIF_OP_RLDX 77 /* rldx [r1], rd */
274274-#define DIF_OP_XLATE 78 /* xlate xlrindex, rd */
275275-#define DIF_OP_XLARG 79 /* xlarg xlrindex, rd */
276276-277277-#define DIF_INTOFF_MAX 0xffff /* highest integer table offset */
278278-#define DIF_STROFF_MAX 0xffff /* highest string table offset */
279279-#define DIF_REGISTER_MAX 0xff /* highest register number */
280280-#define DIF_VARIABLE_MAX 0xffff /* highest variable identifier */
281281-#define DIF_SUBROUTINE_MAX 0xffff /* highest subroutine code */
282282-283283-#define DIF_VAR_ARRAY_MIN 0x0000 /* lowest numbered array variable */
284284-#define DIF_VAR_ARRAY_UBASE 0x0080 /* lowest user-defined array */
285285-#define DIF_VAR_ARRAY_MAX 0x00ff /* highest numbered array variable */
286286-287287-#define DIF_VAR_OTHER_MIN 0x0100 /* lowest numbered scalar or assc */
288288-#define DIF_VAR_OTHER_UBASE 0x0500 /* lowest user-defined scalar or assc */
289289-#define DIF_VAR_OTHER_MAX 0xffff /* highest numbered scalar or assc */
290290-291291-#define DIF_VAR_ARGS 0x0000 /* arguments array */
292292-#define DIF_VAR_REGS 0x0001 /* registers array */
293293-#define DIF_VAR_UREGS 0x0002 /* user registers array */
294294-#define DIF_VAR_CURTHREAD 0x0100 /* thread pointer */
295295-#define DIF_VAR_TIMESTAMP 0x0101 /* timestamp */
296296-#define DIF_VAR_VTIMESTAMP 0x0102 /* virtual timestamp */
297297-#define DIF_VAR_IPL 0x0103 /* interrupt priority level */
298298-#define DIF_VAR_EPID 0x0104 /* enabled probe ID */
299299-#define DIF_VAR_ID 0x0105 /* probe ID */
300300-#define DIF_VAR_ARG0 0x0106 /* first argument */
301301-#define DIF_VAR_ARG1 0x0107 /* second argument */
302302-#define DIF_VAR_ARG2 0x0108 /* third argument */
303303-#define DIF_VAR_ARG3 0x0109 /* fourth argument */
304304-#define DIF_VAR_ARG4 0x010a /* fifth argument */
305305-#define DIF_VAR_ARG5 0x010b /* sixth argument */
306306-#define DIF_VAR_ARG6 0x010c /* seventh argument */
307307-#define DIF_VAR_ARG7 0x010d /* eighth argument */
308308-#define DIF_VAR_ARG8 0x010e /* ninth argument */
309309-#define DIF_VAR_ARG9 0x010f /* tenth argument */
310310-#define DIF_VAR_STACKDEPTH 0x0110 /* stack depth */
311311-#define DIF_VAR_CALLER 0x0111 /* caller */
312312-#define DIF_VAR_PROBEPROV 0x0112 /* probe provider */
313313-#define DIF_VAR_PROBEMOD 0x0113 /* probe module */
314314-#define DIF_VAR_PROBEFUNC 0x0114 /* probe function */
315315-#define DIF_VAR_PROBENAME 0x0115 /* probe name */
316316-#define DIF_VAR_PID 0x0116 /* process ID */
317317-#define DIF_VAR_TID 0x0117 /* (per-process) thread ID */
318318-#define DIF_VAR_EXECNAME 0x0118 /* name of executable */
319319-#define DIF_VAR_ZONENAME 0x0119 /* zone name associated with process */
320320-#define DIF_VAR_WALLTIMESTAMP 0x011a /* wall-clock timestamp */
321321-#define DIF_VAR_USTACKDEPTH 0x011b /* user-land stack depth */
322322-#define DIF_VAR_UCALLER 0x011c /* user-level caller */
323323-#define DIF_VAR_PPID 0x011d /* parent process ID */
324324-#define DIF_VAR_UID 0x011e /* process user ID */
325325-#define DIF_VAR_GID 0x011f /* process group ID */
326326-#define DIF_VAR_ERRNO 0x0120 /* thread errno */
327327-#if defined(__APPLE__)
328328-#define DIF_VAR_PTHREAD_SELF 0x0200 /* Apple specific PTHREAD_SELF (Not currently supported!) */
329329-#define DIF_VAR_DISPATCHQADDR 0x0201 /* Apple specific dispatch queue addr */
330330-#define DIF_VAR_MACHTIMESTAMP 0x0202 /* mach_absolute_timestamp() */
331331-#endif /* __APPLE __ */
332332-333333-#define DIF_SUBR_RAND 0
334334-#define DIF_SUBR_MUTEX_OWNED 1
335335-#define DIF_SUBR_MUTEX_OWNER 2
336336-#define DIF_SUBR_MUTEX_TYPE_ADAPTIVE 3
337337-#define DIF_SUBR_MUTEX_TYPE_SPIN 4
338338-#define DIF_SUBR_RW_READ_HELD 5
339339-#define DIF_SUBR_RW_WRITE_HELD 6
340340-#define DIF_SUBR_RW_ISWRITER 7
341341-#define DIF_SUBR_COPYIN 8
342342-#define DIF_SUBR_COPYINSTR 9
343343-#define DIF_SUBR_SPECULATION 10
344344-#define DIF_SUBR_PROGENYOF 11
345345-#define DIF_SUBR_STRLEN 12
346346-#define DIF_SUBR_COPYOUT 13
347347-#define DIF_SUBR_COPYOUTSTR 14
348348-#define DIF_SUBR_ALLOCA 15
349349-#define DIF_SUBR_BCOPY 16
350350-#define DIF_SUBR_COPYINTO 17
351351-#define DIF_SUBR_MSGDSIZE 18
352352-#define DIF_SUBR_MSGSIZE 19
353353-#define DIF_SUBR_GETMAJOR 20
354354-#define DIF_SUBR_GETMINOR 21
355355-#define DIF_SUBR_DDI_PATHNAME 22
356356-#define DIF_SUBR_STRJOIN 23
357357-#define DIF_SUBR_LLTOSTR 24
358358-#define DIF_SUBR_BASENAME 25
359359-#define DIF_SUBR_DIRNAME 26
360360-#define DIF_SUBR_CLEANPATH 27
361361-#define DIF_SUBR_STRCHR 28
362362-#define DIF_SUBR_STRRCHR 29
363363-#define DIF_SUBR_STRSTR 30
364364-#define DIF_SUBR_STRTOK 31
365365-#define DIF_SUBR_SUBSTR 32
366366-#define DIF_SUBR_INDEX 33
367367-#define DIF_SUBR_RINDEX 34
368368-#define DIF_SUBR_HTONS 35
369369-#define DIF_SUBR_HTONL 36
370370-#define DIF_SUBR_HTONLL 37
371371-#define DIF_SUBR_NTOHS 38
372372-#define DIF_SUBR_NTOHL 39
373373-#define DIF_SUBR_NTOHLL 40
374374-#define DIF_SUBR_INET_NTOP 41
375375-#define DIF_SUBR_INET_NTOA 42
376376-#define DIF_SUBR_INET_NTOA6 43
377377-#define DIF_SUBR_TOUPPER 44
378378-#define DIF_SUBR_TOLOWER 45
379379-#if !defined(__APPLE__)
380380-381381-#define DIF_SUBR_MAX 45 /* max subroutine value */
382382-#else
383383-#define DIF_SUBR_COREPROFILE 46
384384-385385-#define DIF_SUBR_MAX 46 /* max subroutine value */
386386-#endif /* __APPLE__ */
387387-388388-typedef uint32_t dif_instr_t;
389389-390390-#define DIF_INSTR_OP(i) (((i) >> 24) & 0xff)
391391-#define DIF_INSTR_R1(i) (((i) >> 16) & 0xff)
392392-#define DIF_INSTR_R2(i) (((i) >> 8) & 0xff)
393393-#define DIF_INSTR_RD(i) ((i) & 0xff)
394394-#define DIF_INSTR_RS(i) ((i) & 0xff)
395395-#define DIF_INSTR_LABEL(i) ((i) & 0xffffff)
396396-#define DIF_INSTR_VAR(i) (((i) >> 8) & 0xffff)
397397-#define DIF_INSTR_INTEGER(i) (((i) >> 8) & 0xffff)
398398-#define DIF_INSTR_STRING(i) (((i) >> 8) & 0xffff)
399399-#define DIF_INSTR_SUBR(i) (((i) >> 8) & 0xffff)
400400-#define DIF_INSTR_TYPE(i) (((i) >> 16) & 0xff)
401401-#define DIF_INSTR_XLREF(i) (((i) >> 8) & 0xffff)
402402-403403-#define DIF_INSTR_FMT(op, r1, r2, d) \
404404- (((op) << 24) | ((r1) << 16) | ((r2) << 8) | (d))
405405-406406-#define DIF_INSTR_NOT(r1, d) (DIF_INSTR_FMT(DIF_OP_NOT, r1, 0, d))
407407-#define DIF_INSTR_MOV(r1, d) (DIF_INSTR_FMT(DIF_OP_MOV, r1, 0, d))
408408-#define DIF_INSTR_CMP(op, r1, r2) (DIF_INSTR_FMT(op, r1, r2, 0))
409409-#define DIF_INSTR_TST(r1) (DIF_INSTR_FMT(DIF_OP_TST, r1, 0, 0))
410410-#define DIF_INSTR_BRANCH(op, label) (((op) << 24) | (label))
411411-#define DIF_INSTR_LOAD(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d))
412412-#define DIF_INSTR_STORE(op, r1, d) (DIF_INSTR_FMT(op, r1, 0, d))
413413-#define DIF_INSTR_SETX(i, d) ((DIF_OP_SETX << 24) | ((i) << 8) | (d))
414414-#define DIF_INSTR_SETS(s, d) ((DIF_OP_SETS << 24) | ((s) << 8) | (d))
415415-#define DIF_INSTR_RET(d) (DIF_INSTR_FMT(DIF_OP_RET, 0, 0, d))
416416-#define DIF_INSTR_NOP (DIF_OP_NOP << 24)
417417-#define DIF_INSTR_LDA(op, v, r, d) (DIF_INSTR_FMT(op, v, r, d))
418418-#define DIF_INSTR_LDV(op, v, d) (((op) << 24) | ((v) << 8) | (d))
419419-#define DIF_INSTR_STV(op, v, rs) (((op) << 24) | ((v) << 8) | (rs))
420420-#define DIF_INSTR_CALL(s, d) ((DIF_OP_CALL << 24) | ((s) << 8) | (d))
421421-#define DIF_INSTR_PUSHTS(op, t, r2, rs) (DIF_INSTR_FMT(op, t, r2, rs))
422422-#define DIF_INSTR_POPTS (DIF_OP_POPTS << 24)
423423-#define DIF_INSTR_FLUSHTS (DIF_OP_FLUSHTS << 24)
424424-#define DIF_INSTR_ALLOCS(r1, d) (DIF_INSTR_FMT(DIF_OP_ALLOCS, r1, 0, d))
425425-#define DIF_INSTR_COPYS(r1, r2, d) (DIF_INSTR_FMT(DIF_OP_COPYS, r1, r2, d))
426426-#define DIF_INSTR_XLATE(op, r, d) (((op) << 24) | ((r) << 8) | (d))
427427-428428-#define DIF_REG_R0 0 /* %r0 is always set to zero */
429429-430430-/*
431431- * A DTrace Intermediate Format Type (DIF Type) is used to represent the types
432432- * of variables, function and associative array arguments, and the return type
433433- * for each DIF object (shown below). It contains a description of the type,
434434- * its size in bytes, and a module identifier.
435435- */
436436-typedef struct dtrace_diftype {
437437- uint8_t dtdt_kind; /* type kind (see below) */
438438- uint8_t dtdt_ckind; /* type kind in CTF */
439439- uint8_t dtdt_flags; /* type flags (see below) */
440440- uint8_t dtdt_pad; /* reserved for future use */
441441- uint32_t dtdt_size; /* type size in bytes (unless string) */
442442-} dtrace_diftype_t;
443443-444444-#define DIF_TYPE_CTF 0 /* type is a CTF type */
445445-#define DIF_TYPE_STRING 1 /* type is a D string */
446446-447447-#define DIF_TF_BYREF 0x1 /* type is passed by reference */
448448-449449-/*
450450- * A DTrace Intermediate Format variable record is used to describe each of the
451451- * variables referenced by a given DIF object. It contains an integer variable
452452- * identifier along with variable scope and properties, as shown below. The
453453- * size of this structure must be sizeof (int) aligned.
454454- */
455455-typedef struct dtrace_difv {
456456- uint32_t dtdv_name; /* variable name index in dtdo_strtab */
457457- uint32_t dtdv_id; /* variable reference identifier */
458458- uint8_t dtdv_kind; /* variable kind (see below) */
459459- uint8_t dtdv_scope; /* variable scope (see below) */
460460- uint16_t dtdv_flags; /* variable flags (see below) */
461461- dtrace_diftype_t dtdv_type; /* variable type (see above) */
462462-} dtrace_difv_t;
463463-464464-#define DIFV_KIND_ARRAY 0 /* variable is an array of quantities */
465465-#define DIFV_KIND_SCALAR 1 /* variable is a scalar quantity */
466466-467467-#define DIFV_SCOPE_GLOBAL 0 /* variable has global scope */
468468-#define DIFV_SCOPE_THREAD 1 /* variable has thread scope */
469469-#define DIFV_SCOPE_LOCAL 2 /* variable has local scope */
470470-471471-#define DIFV_F_REF 0x1 /* variable is referenced by DIFO */
472472-#define DIFV_F_MOD 0x2 /* variable is written by DIFO */
473473-474474-/*
475475- * DTrace Actions
476476- *
477477- * The upper byte determines the class of the action; the low bytes determines
478478- * the specific action within that class. The classes of actions are as
479479- * follows:
480480- *
481481- * [ no class ] <= May record process- or kernel-related data
482482- * DTRACEACT_PROC <= Only records process-related data
483483- * DTRACEACT_PROC_DESTRUCTIVE <= Potentially destructive to processes
484484- * DTRACEACT_KERNEL <= Only records kernel-related data
485485- * DTRACEACT_KERNEL_DESTRUCTIVE <= Potentially destructive to the kernel
486486- * DTRACEACT_SPECULATIVE <= Speculation-related action
487487- * DTRACEACT_AGGREGATION <= Aggregating action
488488- */
489489-#define DTRACEACT_NONE 0 /* no action */
490490-#define DTRACEACT_DIFEXPR 1 /* action is DIF expression */
491491-#define DTRACEACT_EXIT 2 /* exit() action */
492492-#define DTRACEACT_PRINTF 3 /* printf() action */
493493-#define DTRACEACT_PRINTA 4 /* printa() action */
494494-#define DTRACEACT_LIBACT 5 /* library-controlled action */
495495-#define DTRACEACT_TRACEMEM 6 /* tracemem() action */
496496-#define DTRACEACT_TRACEMEM_DYNSIZE 7 /* dynamic tracemem() size */
497497-498498-#if defined(__APPLE__)
499499-#define DTRACEACT_APPLEBINARY 50 /* Apple DT perf. tool action */
500500-#endif /* __APPLE__ */
501501-502502-#define DTRACEACT_PROC 0x0100
503503-#define DTRACEACT_USTACK (DTRACEACT_PROC + 1)
504504-#define DTRACEACT_JSTACK (DTRACEACT_PROC + 2)
505505-#define DTRACEACT_USYM (DTRACEACT_PROC + 3)
506506-#define DTRACEACT_UMOD (DTRACEACT_PROC + 4)
507507-#define DTRACEACT_UADDR (DTRACEACT_PROC + 5)
508508-509509-#define DTRACEACT_PROC_DESTRUCTIVE 0x0200
510510-#define DTRACEACT_STOP (DTRACEACT_PROC_DESTRUCTIVE + 1)
511511-#define DTRACEACT_RAISE (DTRACEACT_PROC_DESTRUCTIVE + 2)
512512-#define DTRACEACT_SYSTEM (DTRACEACT_PROC_DESTRUCTIVE + 3)
513513-#define DTRACEACT_FREOPEN (DTRACEACT_PROC_DESTRUCTIVE + 4)
514514-515515-#if defined(__APPLE__)
516516-/*
517517- * Dtrace stop() will task_suspend the currently running process.
518518- * Dtrace pidresume(pid) will task_resume it.
519519- */
520520-521521-#define DTRACEACT_PIDRESUME (DTRACEACT_PROC_DESTRUCTIVE + 50)
522522-#endif /* __APPLE__ */
523523-524524-#define DTRACEACT_PROC_CONTROL 0x0300
525525-526526-#define DTRACEACT_KERNEL 0x0400
527527-#define DTRACEACT_STACK (DTRACEACT_KERNEL + 1)
528528-#define DTRACEACT_SYM (DTRACEACT_KERNEL + 2)
529529-#define DTRACEACT_MOD (DTRACEACT_KERNEL + 3)
530530-531531-#define DTRACEACT_KERNEL_DESTRUCTIVE 0x0500
532532-#define DTRACEACT_BREAKPOINT (DTRACEACT_KERNEL_DESTRUCTIVE + 1)
533533-#define DTRACEACT_PANIC (DTRACEACT_KERNEL_DESTRUCTIVE + 2)
534534-#define DTRACEACT_CHILL (DTRACEACT_KERNEL_DESTRUCTIVE + 3)
535535-536536-#define DTRACEACT_SPECULATIVE 0x0600
537537-#define DTRACEACT_SPECULATE (DTRACEACT_SPECULATIVE + 1)
538538-#define DTRACEACT_COMMIT (DTRACEACT_SPECULATIVE + 2)
539539-#define DTRACEACT_DISCARD (DTRACEACT_SPECULATIVE + 3)
540540-541541-#define DTRACEACT_CLASS(x) ((x) & 0xff00)
542542-543543-#define DTRACEACT_ISDESTRUCTIVE(x) \
544544- (DTRACEACT_CLASS(x) == DTRACEACT_PROC_DESTRUCTIVE || \
545545- DTRACEACT_CLASS(x) == DTRACEACT_KERNEL_DESTRUCTIVE)
546546-547547-#define DTRACEACT_ISSPECULATIVE(x) \
548548- (DTRACEACT_CLASS(x) == DTRACEACT_SPECULATIVE)
549549-550550-#define DTRACEACT_ISPRINTFLIKE(x) \
551551- ((x) == DTRACEACT_PRINTF || (x) == DTRACEACT_PRINTA || \
552552- (x) == DTRACEACT_SYSTEM || (x) == DTRACEACT_FREOPEN)
553553-554554-/*
555555- * DTrace Aggregating Actions
556556- *
557557- * These are functions f(x) for which the following is true:
558558- *
559559- * f(f(x_0) U f(x_1) U ... U f(x_n)) = f(x_0 U x_1 U ... U x_n)
560560- *
561561- * where x_n is a set of arbitrary data. Aggregating actions are in their own
562562- * DTrace action class, DTTRACEACT_AGGREGATION. The macros provided here allow
563563- * for easier processing of the aggregation argument and data payload for a few
564564- * aggregating actions (notably: quantize(), lquantize(), and ustack()).
565565- */
566566-#define DTRACEACT_AGGREGATION 0x0700
567567-#define DTRACEAGG_COUNT (DTRACEACT_AGGREGATION + 1)
568568-#define DTRACEAGG_MIN (DTRACEACT_AGGREGATION + 2)
569569-#define DTRACEAGG_MAX (DTRACEACT_AGGREGATION + 3)
570570-#define DTRACEAGG_AVG (DTRACEACT_AGGREGATION + 4)
571571-#define DTRACEAGG_SUM (DTRACEACT_AGGREGATION + 5)
572572-#define DTRACEAGG_STDDEV (DTRACEACT_AGGREGATION + 6)
573573-#define DTRACEAGG_QUANTIZE (DTRACEACT_AGGREGATION + 7)
574574-#define DTRACEAGG_LQUANTIZE (DTRACEACT_AGGREGATION + 8)
575575-#define DTRACEAGG_LLQUANTIZE (DTRACEACT_AGGREGATION + 9)
576576-577577-#define DTRACEACT_ISAGG(x) \
578578- (DTRACEACT_CLASS(x) == DTRACEACT_AGGREGATION)
579579-580580-#if !defined(__APPLE__) /* Quiet compiler warning. */
581581-#define DTRACE_QUANTIZE_NBUCKETS \
582582- (((sizeof (uint64_t) * NBBY) - 1) * 2 + 1)
583583-584584-#define DTRACE_QUANTIZE_ZEROBUCKET ((sizeof (uint64_t) * NBBY) - 1)
585585-#else
586586-#define DTRACE_QUANTIZE_NBUCKETS \
587587- (int)(((sizeof (uint64_t) * NBBY) - 1) * 2 + 1)
588588-589589-#define DTRACE_QUANTIZE_ZEROBUCKET (int64_t)((sizeof (uint64_t) * NBBY) - 1)
590590-#endif /* __APPLE __*/
591591-592592-#define DTRACE_QUANTIZE_BUCKETVAL(buck) \
593593- (int64_t)((buck) < DTRACE_QUANTIZE_ZEROBUCKET ? \
594594- -(1LL << (DTRACE_QUANTIZE_ZEROBUCKET - 1 - (buck))) : \
595595- (buck) == DTRACE_QUANTIZE_ZEROBUCKET ? 0 : \
596596- 1LL << ((buck) - DTRACE_QUANTIZE_ZEROBUCKET - 1))
597597-598598-#define DTRACE_LQUANTIZE_STEPSHIFT 48
599599-#define DTRACE_LQUANTIZE_STEPMASK ((uint64_t)UINT16_MAX << 48)
600600-#define DTRACE_LQUANTIZE_LEVELSHIFT 32
601601-#define DTRACE_LQUANTIZE_LEVELMASK ((uint64_t)UINT16_MAX << 32)
602602-#define DTRACE_LQUANTIZE_BASESHIFT 0
603603-#define DTRACE_LQUANTIZE_BASEMASK UINT32_MAX
604604-605605-#define DTRACE_LQUANTIZE_STEP(x) \
606606- (uint16_t)(((x) & DTRACE_LQUANTIZE_STEPMASK) >> \
607607- DTRACE_LQUANTIZE_STEPSHIFT)
608608-609609-#define DTRACE_LQUANTIZE_LEVELS(x) \
610610- (uint16_t)(((x) & DTRACE_LQUANTIZE_LEVELMASK) >> \
611611- DTRACE_LQUANTIZE_LEVELSHIFT)
612612-613613-#define DTRACE_LQUANTIZE_BASE(x) \
614614- (int32_t)(((x) & DTRACE_LQUANTIZE_BASEMASK) >> \
615615- DTRACE_LQUANTIZE_BASESHIFT)
616616-617617-#define DTRACE_LLQUANTIZE_FACTORSHIFT 48
618618-#define DTRACE_LLQUANTIZE_FACTORMASK ((uint64_t)UINT16_MAX << 48)
619619-#define DTRACE_LLQUANTIZE_LOWSHIFT 32
620620-#define DTRACE_LLQUANTIZE_LOWMASK ((uint64_t)UINT16_MAX << 32)
621621-#define DTRACE_LLQUANTIZE_HIGHSHIFT 16
622622-#define DTRACE_LLQUANTIZE_HIGHMASK ((uint64_t)UINT16_MAX << 16)
623623-#define DTRACE_LLQUANTIZE_NSTEPSHIFT 0
624624-#define DTRACE_LLQUANTIZE_NSTEPMASK UINT16_MAX
625625-626626-#define DTRACE_LLQUANTIZE_FACTOR(x) \
627627- (uint16_t)(((x) & DTRACE_LLQUANTIZE_FACTORMASK) >> \
628628- DTRACE_LLQUANTIZE_FACTORSHIFT)
629629-630630-#define DTRACE_LLQUANTIZE_LOW(x) \
631631- (uint16_t)(((x) & DTRACE_LLQUANTIZE_LOWMASK) >> \
632632- DTRACE_LLQUANTIZE_LOWSHIFT)
633633-634634-#define DTRACE_LLQUANTIZE_HIGH(x) \
635635- (uint16_t)(((x) & DTRACE_LLQUANTIZE_HIGHMASK) >> \
636636- DTRACE_LLQUANTIZE_HIGHSHIFT)
637637-638638-#define DTRACE_LLQUANTIZE_NSTEP(x) \
639639- (uint16_t)(((x) & DTRACE_LLQUANTIZE_NSTEPMASK) >> \
640640- DTRACE_LLQUANTIZE_NSTEPSHIFT)
641641-642642-#define DTRACE_USTACK_NFRAMES(x) (uint32_t)((x) & UINT32_MAX)
643643-#define DTRACE_USTACK_STRSIZE(x) (uint32_t)((x) >> 32)
644644-#define DTRACE_USTACK_ARG(x, y) \
645645- ((((uint64_t)(y)) << 32) | ((x) & UINT32_MAX))
646646-647647-#if !defined(__APPLE__)
648648-649649-#ifndef _LP64
650650-#ifndef _LITTLE_ENDIAN
651651-#define DTRACE_PTR(type, name) uint32_t name##pad; type *name
652652-#else
653653-#define DTRACE_PTR(type, name) type *name; uint32_t name##pad
654654-#endif
655655-#else
656656-#define DTRACE_PTR(type, name) type *name
657657-#endif
658658-659659-#else
660660-661661-#ifndef _LP64
662662-#define DTRACE_PTR(type, name) user_addr_t name
663663-#else
664664-#define DTRACE_PTR(type, name) type *name
665665-#endif
666666-667667-#endif /* __APPLE__ */
668668-669669-/*
670670- * DTrace Object Format (DOF)
671671- *
672672- * DTrace programs can be persistently encoded in the DOF format so that they
673673- * may be embedded in other programs (for example, in an ELF file) or in the
674674- * dtrace driver configuration file for use in anonymous tracing. The DOF
675675- * format is versioned and extensible so that it can be revised and so that
676676- * internal data structures can be modified or extended compatibly. All DOF
677677- * structures use fixed-size types, so the 32-bit and 64-bit representations
678678- * are identical and consumers can use either data model transparently.
679679- *
680680- * The file layout is structured as follows:
681681- *
682682- * +---------------+-------------------+----- ... ----+---- ... ------+
683683- * | dof_hdr_t | dof_sec_t[ ... ] | loadable | non-loadable |
684684- * | (file header) | (section headers) | section data | section data |
685685- * +---------------+-------------------+----- ... ----+---- ... ------+
686686- * |<------------ dof_hdr.dofh_loadsz --------------->| |
687687- * |<------------ dof_hdr.dofh_filesz ------------------------------->|
688688- *
689689- * The file header stores meta-data including a magic number, data model for
690690- * the instrumentation, data encoding, and properties of the DIF code within.
691691- * The header describes its own size and the size of the section headers. By
692692- * convention, an array of section headers follows the file header, and then
693693- * the data for all loadable sections and unloadable sections. This permits
694694- * consumer code to easily download the headers and all loadable data into the
695695- * DTrace driver in one contiguous chunk, omitting other extraneous sections.
696696- *
697697- * The section headers describe the size, offset, alignment, and section type
698698- * for each section. Sections are described using a set of #defines that tell
699699- * the consumer what kind of data is expected. Sections can contain links to
700700- * other sections by storing a dof_secidx_t, an index into the section header
701701- * array, inside of the section data structures. The section header includes
702702- * an entry size so that sections with data arrays can grow their structures.
703703- *
704704- * The DOF data itself can contain many snippets of DIF (i.e. >1 DIFOs), which
705705- * are represented themselves as a collection of related DOF sections. This
706706- * permits us to change the set of sections associated with a DIFO over time,
707707- * and also permits us to encode DIFOs that contain different sets of sections.
708708- * When a DOF section wants to refer to a DIFO, it stores the dof_secidx_t of a
709709- * section of type DOF_SECT_DIFOHDR. This section's data is then an array of
710710- * dof_secidx_t's which in turn denote the sections associated with this DIFO.
711711- *
712712- * This loose coupling of the file structure (header and sections) to the
713713- * structure of the DTrace program itself (ECB descriptions, action
714714- * descriptions, and DIFOs) permits activities such as relocation processing
715715- * to occur in a single pass without having to understand D program structure.
716716- *
717717- * Finally, strings are always stored in ELF-style string tables along with a
718718- * string table section index and string table offset. Therefore strings in
719719- * DOF are always arbitrary-length and not bound to the current implementation.
720720- */
721721-722722-#define DOF_ID_SIZE 16 /* total size of dofh_ident[] in bytes */
723723-724724-typedef struct dof_hdr {
725725- uint8_t dofh_ident[DOF_ID_SIZE]; /* identification bytes (see below) */
726726- uint32_t dofh_flags; /* file attribute flags (if any) */
727727- uint32_t dofh_hdrsize; /* size of file header in bytes */
728728- uint32_t dofh_secsize; /* size of section header in bytes */
729729- uint32_t dofh_secnum; /* number of section headers */
730730- uint64_t dofh_secoff; /* file offset of section headers */
731731- uint64_t dofh_loadsz; /* file size of loadable portion */
732732- uint64_t dofh_filesz; /* file size of entire DOF file */
733733- uint64_t dofh_pad; /* reserved for future use */
734734-} dof_hdr_t;
735735-736736-#define DOF_ID_MAG0 0 /* first byte of magic number */
737737-#define DOF_ID_MAG1 1 /* second byte of magic number */
738738-#define DOF_ID_MAG2 2 /* third byte of magic number */
739739-#define DOF_ID_MAG3 3 /* fourth byte of magic number */
740740-#define DOF_ID_MODEL 4 /* DOF data model (see below) */
741741-#define DOF_ID_ENCODING 5 /* DOF data encoding (see below) */
742742-#define DOF_ID_VERSION 6 /* DOF file format major version (see below) */
743743-#define DOF_ID_DIFVERS 7 /* DIF instruction set version */
744744-#define DOF_ID_DIFIREG 8 /* DIF integer registers used by compiler */
745745-#define DOF_ID_DIFTREG 9 /* DIF tuple registers used by compiler */
746746-#define DOF_ID_PAD 10 /* start of padding bytes (all zeroes) */
747747-748748-#define DOF_MAG_MAG0 0x7F /* DOF_ID_MAG[0-3] */
749749-#define DOF_MAG_MAG1 'D'
750750-#define DOF_MAG_MAG2 'O'
751751-#define DOF_MAG_MAG3 'F'
752752-753753-#define DOF_MAG_STRING "\177DOF"
754754-#define DOF_MAG_STRLEN 4
755755-756756-#define DOF_MODEL_NONE 0 /* DOF_ID_MODEL */
757757-#define DOF_MODEL_ILP32 1
758758-#define DOF_MODEL_LP64 2
759759-760760-#ifdef _LP64
761761-#define DOF_MODEL_NATIVE DOF_MODEL_LP64
762762-#else
763763-#define DOF_MODEL_NATIVE DOF_MODEL_ILP32
764764-#endif
765765-766766-#define DOF_ENCODE_NONE 0 /* DOF_ID_ENCODING */
767767-#define DOF_ENCODE_LSB 1
768768-#define DOF_ENCODE_MSB 2
769769-770770-#ifdef _BIG_ENDIAN
771771-#define DOF_ENCODE_NATIVE DOF_ENCODE_MSB
772772-#else
773773-#define DOF_ENCODE_NATIVE DOF_ENCODE_LSB
774774-#endif
775775-776776-#define DOF_VERSION_1 1 /* DOF version 1: Solaris 10 FCS */
777777-#define DOF_VERSION_2 2 /* DOF version 2: Solaris Express 6/06 */
778778-#if !defined(__APPLE__)
779779-#define DOF_VERSION DOF_VERSION_2 /* Latest DOF version */
780780-#else
781781-#define DOF_VERSION_3 3 /* DOF version 3: Minimum version for Leopard */
782782-#define DOF_VERSION DOF_VERSION_3 /* Latest DOF version */
783783-#endif /* __APPLE__ */
784784-785785-#define DOF_FL_VALID 0 /* mask of all valid dofh_flags bits */
786786-787787-typedef uint32_t dof_secidx_t; /* section header table index type */
788788-typedef uint32_t dof_stridx_t; /* string table index type */
789789-790790-#define DOF_SECIDX_NONE (-1U) /* null value for section indices */
791791-#define DOF_STRIDX_NONE (-1U) /* null value for string indices */
792792-793793-typedef struct dof_sec {
794794- uint32_t dofs_type; /* section type (see below) */
795795- uint32_t dofs_align; /* section data memory alignment */
796796- uint32_t dofs_flags; /* section flags (if any) */
797797- uint32_t dofs_entsize; /* size of section entry (if table) */
798798- uint64_t dofs_offset; /* offset of section data within file */
799799- uint64_t dofs_size; /* size of section data in bytes */
800800-} dof_sec_t;
801801-802802-#define DOF_SECT_NONE 0 /* null section */
803803-#define DOF_SECT_COMMENTS 1 /* compiler comments */
804804-#define DOF_SECT_SOURCE 2 /* D program source code */
805805-#define DOF_SECT_ECBDESC 3 /* dof_ecbdesc_t */
806806-#define DOF_SECT_PROBEDESC 4 /* dof_probedesc_t */
807807-#define DOF_SECT_ACTDESC 5 /* dof_actdesc_t array */
808808-#define DOF_SECT_DIFOHDR 6 /* dof_difohdr_t (variable length) */
809809-#define DOF_SECT_DIF 7 /* uint32_t array of byte code */
810810-#define DOF_SECT_STRTAB 8 /* string table */
811811-#define DOF_SECT_VARTAB 9 /* dtrace_difv_t array */
812812-#define DOF_SECT_RELTAB 10 /* dof_relodesc_t array */
813813-#define DOF_SECT_TYPTAB 11 /* dtrace_diftype_t array */
814814-#define DOF_SECT_URELHDR 12 /* dof_relohdr_t (user relocations) */
815815-#define DOF_SECT_KRELHDR 13 /* dof_relohdr_t (kernel relocations) */
816816-#define DOF_SECT_OPTDESC 14 /* dof_optdesc_t array */
817817-#define DOF_SECT_PROVIDER 15 /* dof_provider_t */
818818-#define DOF_SECT_PROBES 16 /* dof_probe_t array */
819819-#define DOF_SECT_PRARGS 17 /* uint8_t array (probe arg mappings) */
820820-#define DOF_SECT_PROFFS 18 /* uint32_t array (probe arg offsets) */
821821-#define DOF_SECT_INTTAB 19 /* uint64_t array */
822822-#define DOF_SECT_UTSNAME 20 /* struct utsname */
823823-#define DOF_SECT_XLTAB 21 /* dof_xlref_t array */
824824-#define DOF_SECT_XLMEMBERS 22 /* dof_xlmember_t array */
825825-#define DOF_SECT_XLIMPORT 23 /* dof_xlator_t */
826826-#define DOF_SECT_XLEXPORT 24 /* dof_xlator_t */
827827-#define DOF_SECT_PREXPORT 25 /* dof_secidx_t array (exported objs) */
828828-#define DOF_SECT_PRENOFFS 26 /* uint32_t array (enabled offsets) */
829829-830830-#define DOF_SECF_LOAD 1 /* section should be loaded */
831831-832832-typedef struct dof_ecbdesc {
833833- dof_secidx_t dofe_probes; /* link to DOF_SECT_PROBEDESC */
834834- dof_secidx_t dofe_pred; /* link to DOF_SECT_DIFOHDR */
835835- dof_secidx_t dofe_actions; /* link to DOF_SECT_ACTDESC */
836836- uint32_t dofe_pad; /* reserved for future use */
837837- uint64_t dofe_uarg; /* user-supplied library argument */
838838-} dof_ecbdesc_t;
839839-840840-typedef struct dof_probedesc {
841841- dof_secidx_t dofp_strtab; /* link to DOF_SECT_STRTAB section */
842842- dof_stridx_t dofp_provider; /* provider string */
843843- dof_stridx_t dofp_mod; /* module string */
844844- dof_stridx_t dofp_func; /* function string */
845845- dof_stridx_t dofp_name; /* name string */
846846- uint32_t dofp_id; /* probe identifier (or zero) */
847847-} dof_probedesc_t;
848848-849849-typedef struct dof_actdesc {
850850- dof_secidx_t dofa_difo; /* link to DOF_SECT_DIFOHDR */
851851- dof_secidx_t dofa_strtab; /* link to DOF_SECT_STRTAB section */
852852- uint32_t dofa_kind; /* action kind (DTRACEACT_* constant) */
853853- uint32_t dofa_ntuple; /* number of subsequent tuple actions */
854854- uint64_t dofa_arg; /* kind-specific argument */
855855- uint64_t dofa_uarg; /* user-supplied argument */
856856-} dof_actdesc_t;
857857-858858-typedef struct dof_difohdr {
859859- dtrace_diftype_t dofd_rtype; /* return type for this fragment */
860860- dof_secidx_t dofd_links[1]; /* variable length array of indices */
861861-} dof_difohdr_t;
862862-863863-typedef struct dof_relohdr {
864864- dof_secidx_t dofr_strtab; /* link to DOF_SECT_STRTAB for names */
865865- dof_secidx_t dofr_relsec; /* link to DOF_SECT_RELTAB for relos */
866866- dof_secidx_t dofr_tgtsec; /* link to section we are relocating */
867867-} dof_relohdr_t;
868868-869869-typedef struct dof_relodesc {
870870- dof_stridx_t dofr_name; /* string name of relocation symbol */
871871- uint32_t dofr_type; /* relo type (DOF_RELO_* constant) */
872872- uint64_t dofr_offset; /* byte offset for relocation */
873873- uint64_t dofr_data; /* additional type-specific data */
874874-} dof_relodesc_t;
875875-876876-#define DOF_RELO_NONE 0 /* empty relocation entry */
877877-#define DOF_RELO_SETX 1 /* relocate setx value */
878878-879879-typedef struct dof_optdesc {
880880- uint32_t dofo_option; /* option identifier */
881881- dof_secidx_t dofo_strtab; /* string table, if string option */
882882- uint64_t dofo_value; /* option value or string index */
883883-} dof_optdesc_t;
884884-885885-typedef uint32_t dof_attr_t; /* encoded stability attributes */
886886-887887-#define DOF_ATTR(n, d, c) (((n) << 24) | ((d) << 16) | ((c) << 8))
888888-#define DOF_ATTR_NAME(a) (((a) >> 24) & 0xff)
889889-#define DOF_ATTR_DATA(a) (((a) >> 16) & 0xff)
890890-#define DOF_ATTR_CLASS(a) (((a) >> 8) & 0xff)
891891-892892-typedef struct dof_provider {
893893- dof_secidx_t dofpv_strtab; /* link to DOF_SECT_STRTAB section */
894894- dof_secidx_t dofpv_probes; /* link to DOF_SECT_PROBES section */
895895- dof_secidx_t dofpv_prargs; /* link to DOF_SECT_PRARGS section */
896896- dof_secidx_t dofpv_proffs; /* link to DOF_SECT_PROFFS section */
897897- dof_stridx_t dofpv_name; /* provider name string */
898898- dof_attr_t dofpv_provattr; /* provider attributes */
899899- dof_attr_t dofpv_modattr; /* module attributes */
900900- dof_attr_t dofpv_funcattr; /* function attributes */
901901- dof_attr_t dofpv_nameattr; /* name attributes */
902902- dof_attr_t dofpv_argsattr; /* args attributes */
903903- dof_secidx_t dofpv_prenoffs; /* link to DOF_SECT_PRENOFFS section */
904904-} dof_provider_t;
905905-906906-typedef struct dof_probe {
907907- uint64_t dofpr_addr; /* probe base address or offset */
908908- dof_stridx_t dofpr_func; /* probe function string */
909909- dof_stridx_t dofpr_name; /* probe name string */
910910- dof_stridx_t dofpr_nargv; /* native argument type strings */
911911- dof_stridx_t dofpr_xargv; /* translated argument type strings */
912912- uint32_t dofpr_argidx; /* index of first argument mapping */
913913- uint32_t dofpr_offidx; /* index of first offset entry */
914914- uint8_t dofpr_nargc; /* native argument count */
915915- uint8_t dofpr_xargc; /* translated argument count */
916916- uint16_t dofpr_noffs; /* number of offset entries for probe */
917917- uint32_t dofpr_enoffidx; /* index of first is-enabled offset */
918918- uint16_t dofpr_nenoffs; /* number of is-enabled offsets */
919919- uint16_t dofpr_pad1; /* reserved for future use */
920920- uint32_t dofpr_pad2; /* reserved for future use */
921921-} dof_probe_t;
922922-923923-typedef struct dof_xlator {
924924- dof_secidx_t dofxl_members; /* link to DOF_SECT_XLMEMBERS section */
925925- dof_secidx_t dofxl_strtab; /* link to DOF_SECT_STRTAB section */
926926- dof_stridx_t dofxl_argv; /* input parameter type strings */
927927- uint32_t dofxl_argc; /* input parameter list length */
928928- dof_stridx_t dofxl_type; /* output type string name */
929929- dof_attr_t dofxl_attr; /* output stability attributes */
930930-} dof_xlator_t;
931931-932932-typedef struct dof_xlmember {
933933- dof_secidx_t dofxm_difo; /* member link to DOF_SECT_DIFOHDR */
934934- dof_stridx_t dofxm_name; /* member name */
935935- dtrace_diftype_t dofxm_type; /* member type */
936936-} dof_xlmember_t;
937937-938938-typedef struct dof_xlref {
939939- dof_secidx_t dofxr_xlator; /* link to DOF_SECT_XLATORS section */
940940- uint32_t dofxr_member; /* index of referenced dof_xlmember */
941941- uint32_t dofxr_argn; /* index of argument for DIF_OP_XLARG */
942942-} dof_xlref_t;
943943-944944-/*
945945- * DTrace Intermediate Format Object (DIFO)
946946- *
947947- * A DIFO is used to store the compiled DIF for a D expression, its return
948948- * type, and its string and variable tables. The string table is a single
949949- * buffer of character data into which sets instructions and variable
950950- * references can reference strings using a byte offset. The variable table
951951- * is an array of dtrace_difv_t structures that describe the name and type of
952952- * each variable and the id used in the DIF code. This structure is described
953953- * above in the DIF section of this header file. The DIFO is used at both
954954- * user-level (in the library) and in the kernel, but the structure is never
955955- * passed between the two: the DOF structures form the only interface. As a
956956- * result, the definition can change depending on the presence of _KERNEL.
957957- */
958958-typedef struct dtrace_difo {
959959- dif_instr_t *dtdo_buf; /* instruction buffer */
960960- uint64_t *dtdo_inttab; /* integer table (optional) */
961961- char *dtdo_strtab; /* string table (optional) */
962962- dtrace_difv_t *dtdo_vartab; /* variable table (optional) */
963963- uint_t dtdo_len; /* length of instruction buffer */
964964- uint_t dtdo_intlen; /* length of integer table */
965965- uint_t dtdo_strlen; /* length of string table */
966966- uint_t dtdo_varlen; /* length of variable table */
967967- dtrace_diftype_t dtdo_rtype; /* return type */
968968- uint_t dtdo_refcnt; /* owner reference count */
969969- uint_t dtdo_destructive; /* invokes destructive subroutines */
970970-#ifndef _KERNEL
971971- dof_relodesc_t *dtdo_kreltab; /* kernel relocations */
972972- dof_relodesc_t *dtdo_ureltab; /* user relocations */
973973- struct dt_node **dtdo_xlmtab; /* translator references */
974974- uint_t dtdo_krelen; /* length of krelo table */
975975- uint_t dtdo_urelen; /* length of urelo table */
976976- uint_t dtdo_xlmlen; /* length of translator table */
977977-#endif
978978-} dtrace_difo_t;
979979-980980-/*
981981- * DTrace Enabling Description Structures
982982- *
983983- * When DTrace is tracking the description of a DTrace enabling entity (probe,
984984- * predicate, action, ECB, record, etc.), it does so in a description
985985- * structure. These structures all end in "desc", and are used at both
986986- * user-level and in the kernel -- but (with the exception of
987987- * dtrace_probedesc_t) they are never passed between them. Typically,
988988- * user-level will use the description structures when assembling an enabling.
989989- * It will then distill those description structures into a DOF object (see
990990- * above), and send it into the kernel. The kernel will again use the
991991- * description structures to create a description of the enabling as it reads
992992- * the DOF. When the description is complete, the enabling will be actually
993993- * created -- turning it into the structures that represent the enabling
994994- * instead of merely describing it. Not surprisingly, the description
995995- * structures bear a strong resemblance to the DOF structures that act as their
996996- * conduit.
997997- */
998998-struct dtrace_predicate;
999999-10001000-typedef struct dtrace_probedesc {
10011001- dtrace_id_t dtpd_id; /* probe identifier */
10021002- char dtpd_provider[DTRACE_PROVNAMELEN]; /* probe provider name */
10031003- char dtpd_mod[DTRACE_MODNAMELEN]; /* probe module name */
10041004- char dtpd_func[DTRACE_FUNCNAMELEN]; /* probe function name */
10051005- char dtpd_name[DTRACE_NAMELEN]; /* probe name */
10061006-} dtrace_probedesc_t;
10071007-10081008-typedef struct dtrace_repldesc {
10091009- dtrace_probedesc_t dtrpd_match; /* probe descr. to match */
10101010- dtrace_probedesc_t dtrpd_create; /* probe descr. to create */
10111011-} dtrace_repldesc_t;
10121012-10131013-typedef struct dtrace_preddesc {
10141014- dtrace_difo_t *dtpdd_difo; /* pointer to DIF object */
10151015- struct dtrace_predicate *dtpdd_predicate; /* pointer to predicate */
10161016-} dtrace_preddesc_t;
10171017-10181018-typedef struct dtrace_actdesc {
10191019- dtrace_difo_t *dtad_difo; /* pointer to DIF object */
10201020- struct dtrace_actdesc *dtad_next; /* next action */
10211021- dtrace_actkind_t dtad_kind; /* kind of action */
10221022- uint32_t dtad_ntuple; /* number in tuple */
10231023- uint64_t dtad_arg; /* action argument */
10241024- uint64_t dtad_uarg; /* user argument */
10251025- int dtad_refcnt; /* reference count */
10261026-} dtrace_actdesc_t;
10271027-10281028-typedef struct dtrace_ecbdesc {
10291029- dtrace_actdesc_t *dted_action; /* action description(s) */
10301030- dtrace_preddesc_t dted_pred; /* predicate description */
10311031- dtrace_probedesc_t dted_probe; /* probe description */
10321032- uint64_t dted_uarg; /* library argument */
10331033- int dted_refcnt; /* reference count */
10341034-} dtrace_ecbdesc_t;
10351035-10361036-/*
10371037- * DTrace Metadata Description Structures
10381038- *
10391039- * DTrace separates the trace data stream from the metadata stream. The only
10401040- * metadata tokens placed in the data stream are enabled probe identifiers
10411041- * (EPIDs) or (in the case of aggregations) aggregation identifiers. In order
10421042- * to determine the structure of the data, DTrace consumers pass the token to
10431043- * the kernel, and receive in return a corresponding description of the enabled
10441044- * probe (via the dtrace_eprobedesc structure) or the aggregation (via the
10451045- * dtrace_aggdesc structure). Both of these structures are expressed in terms
10461046- * of record descriptions (via the dtrace_recdesc structure) that describe the
10471047- * exact structure of the data. Some record descriptions may also contain a
10481048- * format identifier; this additional bit of metadata can be retrieved from the
10491049- * kernel, for which a format description is returned via the dtrace_fmtdesc
10501050- * structure. Note that all four of these structures must be bitness-neutral
10511051- * to allow for a 32-bit DTrace consumer on a 64-bit kernel.
10521052- */
10531053-typedef struct dtrace_recdesc {
10541054- dtrace_actkind_t dtrd_action; /* kind of action */
10551055- uint32_t dtrd_size; /* size of record */
10561056- uint32_t dtrd_offset; /* offset in ECB's data */
10571057- uint16_t dtrd_alignment; /* required alignment */
10581058- uint16_t dtrd_format; /* format, if any */
10591059- uint64_t dtrd_arg; /* action argument */
10601060- uint64_t dtrd_uarg; /* user argument */
10611061-} dtrace_recdesc_t;
10621062-10631063-typedef struct dtrace_eprobedesc {
10641064- dtrace_epid_t dtepd_epid; /* enabled probe ID */
10651065- dtrace_id_t dtepd_probeid; /* probe ID */
10661066- uint64_t dtepd_uarg; /* library argument */
10671067- uint32_t dtepd_size; /* total size */
10681068- int dtepd_nrecs; /* number of records */
10691069- dtrace_recdesc_t dtepd_rec[1]; /* records themselves */
10701070-} dtrace_eprobedesc_t;
10711071-10721072-typedef struct dtrace_aggdesc {
10731073- DTRACE_PTR(char, dtagd_name); /* not filled in by kernel */
10741074- dtrace_aggvarid_t dtagd_varid; /* not filled in by kernel */
10751075- int dtagd_flags; /* not filled in by kernel */
10761076- dtrace_aggid_t dtagd_id; /* aggregation ID */
10771077- dtrace_epid_t dtagd_epid; /* enabled probe ID */
10781078- uint32_t dtagd_size; /* size in bytes */
10791079- int dtagd_nrecs; /* number of records */
10801080- uint32_t dtagd_pad; /* explicit padding */
10811081- dtrace_recdesc_t dtagd_rec[1]; /* record descriptions */
10821082-} dtrace_aggdesc_t;
10831083-10841084-typedef struct dtrace_fmtdesc {
10851085- DTRACE_PTR(char, dtfd_string); /* format string */
10861086- int dtfd_length; /* length of format string */
10871087- uint16_t dtfd_format; /* format identifier */
10881088-} dtrace_fmtdesc_t;
10891089-10901090-#define DTRACE_SIZEOF_EPROBEDESC(desc) \
10911091- (sizeof (dtrace_eprobedesc_t) + ((desc)->dtepd_nrecs ? \
10921092- (((desc)->dtepd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
10931093-10941094-#define DTRACE_SIZEOF_AGGDESC(desc) \
10951095- (sizeof (dtrace_aggdesc_t) + ((desc)->dtagd_nrecs ? \
10961096- (((desc)->dtagd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
10971097-10981098-/*
10991099- * DTrace Option Interface
11001100- *
11011101- * Run-time DTrace options are set and retrieved via DOF_SECT_OPTDESC sections
11021102- * in a DOF image. The dof_optdesc structure contains an option identifier and
11031103- * an option value. The valid option identifiers are found below; the mapping
11041104- * between option identifiers and option identifying strings is maintained at
11051105- * user-level. Note that the value of DTRACEOPT_UNSET is such that all of the
11061106- * following are potentially valid option values: all positive integers, zero
11071107- * and negative one. Some options (notably "bufpolicy" and "bufresize") take
11081108- * predefined tokens as their values; these are defined with
11091109- * DTRACEOPT_{option}_{token}.
11101110- */
11111111-#define DTRACEOPT_BUFSIZE 0 /* buffer size */
11121112-#define DTRACEOPT_BUFPOLICY 1 /* buffer policy */
11131113-#define DTRACEOPT_DYNVARSIZE 2 /* dynamic variable size */
11141114-#define DTRACEOPT_AGGSIZE 3 /* aggregation size */
11151115-#define DTRACEOPT_SPECSIZE 4 /* speculation size */
11161116-#define DTRACEOPT_NSPEC 5 /* number of speculations */
11171117-#define DTRACEOPT_STRSIZE 6 /* string size */
11181118-#define DTRACEOPT_CLEANRATE 7 /* dynvar cleaning rate */
11191119-#define DTRACEOPT_CPU 8 /* CPU to trace */
11201120-#define DTRACEOPT_BUFRESIZE 9 /* buffer resizing policy */
11211121-#define DTRACEOPT_GRABANON 10 /* grab anonymous state, if any */
11221122-#define DTRACEOPT_FLOWINDENT 11 /* indent function entry/return */
11231123-#define DTRACEOPT_QUIET 12 /* only output explicitly traced data */
11241124-#define DTRACEOPT_STACKFRAMES 13 /* number of stack frames */
11251125-#define DTRACEOPT_USTACKFRAMES 14 /* number of user stack frames */
11261126-#define DTRACEOPT_AGGRATE 15 /* aggregation snapshot rate */
11271127-#define DTRACEOPT_SWITCHRATE 16 /* buffer switching rate */
11281128-#define DTRACEOPT_STATUSRATE 17 /* status rate */
11291129-#define DTRACEOPT_DESTRUCTIVE 18 /* destructive actions allowed */
11301130-#define DTRACEOPT_STACKINDENT 19 /* output indent for stack traces */
11311131-#define DTRACEOPT_RAWBYTES 20 /* always print bytes in raw form */
11321132-#define DTRACEOPT_JSTACKFRAMES 21 /* number of jstack() frames */
11331133-#define DTRACEOPT_JSTACKSTRSIZE 22 /* size of jstack() string table */
11341134-#define DTRACEOPT_AGGSORTKEY 23 /* sort aggregations by key */
11351135-#define DTRACEOPT_AGGSORTREV 24 /* reverse-sort aggregations */
11361136-#define DTRACEOPT_AGGSORTPOS 25 /* agg. position to sort on */
11371137-#define DTRACEOPT_AGGSORTKEYPOS 26 /* agg. key position to sort on */
11381138-#define DTRACEOPT_AGGHIST 27 /* histogram aggregation output */
11391139-#define DTRACEOPT_AGGPACK 28 /* packed aggregation output */
11401140-#define DTRACEOPT_AGGZOOM 29 /* zoomed aggregation scaling */
11411141-#if !defined(__APPLE__)
11421142-#define DTRACEOPT_MAX 30 /* number of options */
11431143-#else
11441144-#define DTRACEOPT_STACKSYMBOLS 30 /* clear to prevent stack symbolication */
11451145-#define DTRACEOPT_MAX 31 /* number of options */
11461146-#endif /* __APPLE__ */
11471147-11481148-#define DTRACEOPT_UNSET (dtrace_optval_t)-2 /* unset option */
11491149-11501150-#define DTRACEOPT_BUFPOLICY_RING 0 /* ring buffer */
11511151-#define DTRACEOPT_BUFPOLICY_FILL 1 /* fill buffer, then stop */
11521152-#define DTRACEOPT_BUFPOLICY_SWITCH 2 /* switch buffers */
11531153-11541154-#define DTRACEOPT_BUFRESIZE_AUTO 0 /* automatic resizing */
11551155-#define DTRACEOPT_BUFRESIZE_MANUAL 1 /* manual resizing */
11561156-11571157-/*
11581158- * DTrace Buffer Interface
11591159- *
11601160- * In order to get a snapshot of the principal or aggregation buffer,
11611161- * user-level passes a buffer description to the kernel with the dtrace_bufdesc
11621162- * structure. This describes which CPU user-level is interested in, and
11631163- * where user-level wishes the kernel to snapshot the buffer to (the
11641164- * dtbd_data field). The kernel uses the same structure to pass back some
11651165- * information regarding the buffer: the size of data actually copied out, the
11661166- * number of drops, the number of errors, and the offset of the oldest record.
11671167- * If the buffer policy is a "switch" policy, taking a snapshot of the
11681168- * principal buffer has the additional effect of switching the active and
11691169- * inactive buffers. Taking a snapshot of the aggregation buffer _always_ has
11701170- * the additional effect of switching the active and inactive buffers.
11711171- */
11721172-typedef struct dtrace_bufdesc {
11731173- uint64_t dtbd_size; /* size of buffer */
11741174- uint32_t dtbd_cpu; /* CPU or DTRACE_CPUALL */
11751175- uint32_t dtbd_errors; /* number of errors */
11761176- uint64_t dtbd_drops; /* number of drops */
11771177- DTRACE_PTR(char, dtbd_data); /* data */
11781178- uint64_t dtbd_oldest; /* offset of oldest record */
11791179-} dtrace_bufdesc_t;
11801180-11811181-/*
11821182- * DTrace Status
11831183- *
11841184- * The status of DTrace is relayed via the dtrace_status structure. This
11851185- * structure contains members to count drops other than the capacity drops
11861186- * available via the buffer interface (see above). This consists of dynamic
11871187- * drops (including capacity dynamic drops, rinsing drops and dirty drops), and
11881188- * speculative drops (including capacity speculative drops, drops due to busy
11891189- * speculative buffers and drops due to unavailable speculative buffers).
11901190- * Additionally, the status structure contains a field to indicate the number
11911191- * of "fill"-policy buffers have been filled and a boolean field to indicate
11921192- * that exit() has been called. If the dtst_exiting field is non-zero, no
11931193- * further data will be generated until tracing is stopped (at which time any
11941194- * enablings of the END action will be processed); if user-level sees that
11951195- * this field is non-zero, tracing should be stopped as soon as possible.
11961196- */
11971197-typedef struct dtrace_status {
11981198- uint64_t dtst_dyndrops; /* dynamic drops */
11991199- uint64_t dtst_dyndrops_rinsing; /* dyn drops due to rinsing */
12001200- uint64_t dtst_dyndrops_dirty; /* dyn drops due to dirty */
12011201- uint64_t dtst_specdrops; /* speculative drops */
12021202- uint64_t dtst_specdrops_busy; /* spec drops due to busy */
12031203- uint64_t dtst_specdrops_unavail; /* spec drops due to unavail */
12041204- uint64_t dtst_errors; /* total errors */
12051205- uint64_t dtst_filled; /* number of filled bufs */
12061206- uint64_t dtst_stkstroverflows; /* stack string tab overflows */
12071207- uint64_t dtst_dblerrors; /* errors in ERROR probes */
12081208- char dtst_killed; /* non-zero if killed */
12091209- char dtst_exiting; /* non-zero if exit() called */
12101210- char dtst_pad[6]; /* pad out to 64-bit align */
12111211-} dtrace_status_t;
12121212-12131213-/*
12141214- * DTrace Configuration
12151215- *
12161216- * User-level may need to understand some elements of the kernel DTrace
12171217- * configuration in order to generate correct DIF. This information is
12181218- * conveyed via the dtrace_conf structure.
12191219- */
12201220-typedef struct dtrace_conf {
12211221- uint_t dtc_difversion; /* supported DIF version */
12221222- uint_t dtc_difintregs; /* # of DIF integer registers */
12231223- uint_t dtc_diftupregs; /* # of DIF tuple registers */
12241224- uint_t dtc_ctfmodel; /* CTF data model */
12251225- uint_t dtc_pad[8]; /* reserved for future use */
12261226-} dtrace_conf_t;
12271227-12281228-/*
12291229- * DTrace Faults
12301230- *
12311231- * The constants below DTRACEFLT_LIBRARY indicate probe processing faults;
12321232- * constants at or above DTRACEFLT_LIBRARY indicate faults in probe
12331233- * postprocessing at user-level. Probe processing faults induce an ERROR
12341234- * probe and are replicated in unistd.d to allow users' ERROR probes to decode
12351235- * the error condition using thse symbolic labels.
12361236- */
12371237-#define DTRACEFLT_UNKNOWN 0 /* Unknown fault */
12381238-#define DTRACEFLT_BADADDR 1 /* Bad address */
12391239-#define DTRACEFLT_BADALIGN 2 /* Bad alignment */
12401240-#define DTRACEFLT_ILLOP 3 /* Illegal operation */
12411241-#define DTRACEFLT_DIVZERO 4 /* Divide-by-zero */
12421242-#define DTRACEFLT_NOSCRATCH 5 /* Out of scratch space */
12431243-#define DTRACEFLT_KPRIV 6 /* Illegal kernel access */
12441244-#define DTRACEFLT_UPRIV 7 /* Illegal user access */
12451245-#define DTRACEFLT_TUPOFLOW 8 /* Tuple stack overflow */
12461246-#define DTRACEFLT_BADSTACK 9 /* Bad stack */
12471247-12481248-#define DTRACEFLT_LIBRARY 1000 /* Library-level fault */
12491249-12501250-/*
12511251- * DTrace Argument Types
12521252- *
12531253- * Because it would waste both space and time, argument types do not reside
12541254- * with the probe. In order to determine argument types for args[X]
12551255- * variables, the D compiler queries for argument types on a probe-by-probe
12561256- * basis. (This optimizes for the common case that arguments are either not
12571257- * used or used in an untyped fashion.) Typed arguments are specified with a
12581258- * string of the type name in the dtragd_native member of the argument
12591259- * description structure. Typed arguments may be further translated to types
12601260- * of greater stability; the provider indicates such a translated argument by
12611261- * filling in the dtargd_xlate member with the string of the translated type.
12621262- * Finally, the provider may indicate which argument value a given argument
12631263- * maps to by setting the dtargd_mapping member -- allowing a single argument
12641264- * to map to multiple args[X] variables.
12651265- */
12661266-typedef struct dtrace_argdesc {
12671267- dtrace_id_t dtargd_id; /* probe identifier */
12681268- int dtargd_ndx; /* arg number (-1 iff none) */
12691269- int dtargd_mapping; /* value mapping */
12701270- char dtargd_native[DTRACE_ARGTYPELEN]; /* native type name */
12711271- char dtargd_xlate[DTRACE_ARGTYPELEN]; /* translated type name */
12721272-} dtrace_argdesc_t;
12731273-12741274-/*
12751275- * DTrace Stability Attributes
12761276- *
12771277- * Each DTrace provider advertises the name and data stability of each of its
12781278- * probe description components, as well as its architectural dependencies.
12791279- * The D compiler can query the provider attributes (dtrace_pattr_t below) in
12801280- * order to compute the properties of an input program and report them.
12811281- */
12821282-typedef uint8_t dtrace_stability_t; /* stability code (see attributes(5)) */
12831283-typedef uint8_t dtrace_class_t; /* architectural dependency class */
12841284-12851285-#define DTRACE_STABILITY_INTERNAL 0 /* private to DTrace itself */
12861286-#define DTRACE_STABILITY_PRIVATE 1 /* private to Sun (see docs) */
12871287-#define DTRACE_STABILITY_OBSOLETE 2 /* scheduled for removal */
12881288-#define DTRACE_STABILITY_EXTERNAL 3 /* not controlled by Sun */
12891289-#define DTRACE_STABILITY_UNSTABLE 4 /* new or rapidly changing */
12901290-#define DTRACE_STABILITY_EVOLVING 5 /* less rapidly changing */
12911291-#define DTRACE_STABILITY_STABLE 6 /* mature interface from Sun */
12921292-#define DTRACE_STABILITY_STANDARD 7 /* industry standard */
12931293-#define DTRACE_STABILITY_MAX 7 /* maximum valid stability */
12941294-12951295-#define DTRACE_CLASS_UNKNOWN 0 /* unknown architectural dependency */
12961296-#define DTRACE_CLASS_CPU 1 /* CPU-module-specific */
12971297-#define DTRACE_CLASS_PLATFORM 2 /* platform-specific (uname -i) */
12981298-#define DTRACE_CLASS_GROUP 3 /* hardware-group-specific (uname -m) */
12991299-#define DTRACE_CLASS_ISA 4 /* ISA-specific (uname -p) */
13001300-#define DTRACE_CLASS_COMMON 5 /* common to all systems */
13011301-#define DTRACE_CLASS_MAX 5 /* maximum valid class */
13021302-13031303-#define DTRACE_PRIV_NONE 0x0000
13041304-#define DTRACE_PRIV_KERNEL 0x0001
13051305-#define DTRACE_PRIV_USER 0x0002
13061306-#define DTRACE_PRIV_PROC 0x0004
13071307-#define DTRACE_PRIV_OWNER 0x0008
13081308-#define DTRACE_PRIV_ZONEOWNER 0x0010
13091309-13101310-#define DTRACE_PRIV_ALL \
13111311- (DTRACE_PRIV_KERNEL | DTRACE_PRIV_USER | \
13121312- DTRACE_PRIV_PROC | DTRACE_PRIV_OWNER | DTRACE_PRIV_ZONEOWNER)
13131313-13141314-typedef struct dtrace_ppriv {
13151315- uint32_t dtpp_flags; /* privilege flags */
13161316- uid_t dtpp_uid; /* user ID */
13171317- zoneid_t dtpp_zoneid; /* zone ID */
13181318-} dtrace_ppriv_t;
13191319-13201320-typedef struct dtrace_attribute {
13211321- dtrace_stability_t dtat_name; /* entity name stability */
13221322- dtrace_stability_t dtat_data; /* entity data stability */
13231323- dtrace_class_t dtat_class; /* entity data dependency */
13241324-} dtrace_attribute_t;
13251325-13261326-typedef struct dtrace_pattr {
13271327- dtrace_attribute_t dtpa_provider; /* provider attributes */
13281328- dtrace_attribute_t dtpa_mod; /* module attributes */
13291329- dtrace_attribute_t dtpa_func; /* function attributes */
13301330- dtrace_attribute_t dtpa_name; /* name attributes */
13311331- dtrace_attribute_t dtpa_args; /* args[] attributes */
13321332-} dtrace_pattr_t;
13331333-13341334-typedef struct dtrace_providerdesc {
13351335- char dtvd_name[DTRACE_PROVNAMELEN]; /* provider name */
13361336- dtrace_pattr_t dtvd_attr; /* stability attributes */
13371337- dtrace_ppriv_t dtvd_priv; /* privileges required */
13381338-} dtrace_providerdesc_t;
13391339-13401340-/*
13411341- * DTrace Pseudodevice Interface
13421342- *
13431343- * DTrace is controlled through ioctl(2)'s to the in-kernel dtrace:dtrace
13441344- * pseudodevice driver. These ioctls comprise the user-kernel interface to
13451345- * DTrace.
13461346- */
13471347-#if !defined(__APPLE__)
13481348-#define DTRACEIOC (('d' << 24) | ('t' << 16) | ('r' << 8))
13491349-#define DTRACEIOC_PROVIDER (DTRACEIOC | 1) /* provider query */
13501350-#define DTRACEIOC_PROBES (DTRACEIOC | 2) /* probe query */
13511351-#define DTRACEIOC_BUFSNAP (DTRACEIOC | 4) /* snapshot buffer */
13521352-#define DTRACEIOC_PROBEMATCH (DTRACEIOC | 5) /* match probes */
13531353-#define DTRACEIOC_ENABLE (DTRACEIOC | 6) /* enable probes */
13541354-#define DTRACEIOC_AGGSNAP (DTRACEIOC | 7) /* snapshot agg. */
13551355-#define DTRACEIOC_EPROBE (DTRACEIOC | 8) /* get eprobe desc. */
13561356-#define DTRACEIOC_PROBEARG (DTRACEIOC | 9) /* get probe arg */
13571357-#define DTRACEIOC_CONF (DTRACEIOC | 10) /* get config. */
13581358-#define DTRACEIOC_STATUS (DTRACEIOC | 11) /* get status */
13591359-#define DTRACEIOC_GO (DTRACEIOC | 12) /* start tracing */
13601360-#define DTRACEIOC_STOP (DTRACEIOC | 13) /* stop tracing */
13611361-#define DTRACEIOC_AGGDESC (DTRACEIOC | 15) /* get agg. desc. */
13621362-#define DTRACEIOC_FORMAT (DTRACEIOC | 16) /* get format str */
13631363-#define DTRACEIOC_DOFGET (DTRACEIOC | 17) /* get DOF */
13641364-#define DTRACEIOC_REPLICATE (DTRACEIOC | 18) /* replicate enab */
13651365-#else
13661366-/* coding this as IOC_VOID allows this driver to handle its own copyin/copuout */
13671367-#define DTRACEIOC _IO('d',0)
13681368-#define DTRACEIOC_PROVIDER (DTRACEIOC | 1) /* provider query */
13691369-#define DTRACEIOC_PROBES (DTRACEIOC | 2) /* probe query */
13701370-#define DTRACEIOC_BUFSNAP (DTRACEIOC | 4) /* snapshot buffer */
13711371-#define DTRACEIOC_PROBEMATCH (DTRACEIOC | 5) /* match probes */
13721372-#define DTRACEIOC_ENABLE (DTRACEIOC | 6) /* enable probes */
13731373-#define DTRACEIOC_AGGSNAP (DTRACEIOC | 7) /* snapshot agg. */
13741374-#define DTRACEIOC_EPROBE (DTRACEIOC | 8) /* get eprobe desc. */
13751375-#define DTRACEIOC_PROBEARG (DTRACEIOC | 9) /* get probe arg */
13761376-#define DTRACEIOC_CONF (DTRACEIOC | 10) /* get config. */
13771377-#define DTRACEIOC_STATUS (DTRACEIOC | 11) /* get status */
13781378-#define DTRACEIOC_GO (DTRACEIOC | 12) /* start tracing */
13791379-#define DTRACEIOC_STOP (DTRACEIOC | 13) /* stop tracing */
13801380-#define DTRACEIOC_AGGDESC (DTRACEIOC | 15) /* get agg. desc. */
13811381-#define DTRACEIOC_FORMAT (DTRACEIOC | 16) /* get format str */
13821382-#define DTRACEIOC_DOFGET (DTRACEIOC | 17) /* get DOF */
13831383-#define DTRACEIOC_REPLICATE (DTRACEIOC | 18) /* replicate enab */
13841384-#define DTRACEIOC_MODUUIDSLIST (DTRACEIOC | 30) /* APPLE ONLY, query for modules with missing symbols */
13851385-#define DTRACEIOC_PROVMODSYMS (DTRACEIOC | 31) /* APPLE ONLY, provide missing symbols for a given module */
13861386-#define DTRACEIOC_PROCWAITFOR (DTRACEIOC | 32) /* APPLE ONLY, wait for process exec */
13871387-13881388-/*
13891389- * The following structs are used to provide symbol information to the kernel from userspace.
13901390- */
13911391-13921392-typedef struct dtrace_symbol {
13931393- uint64_t dtsym_addr; /* address of the symbol */
13941394- uint64_t dtsym_size; /* size of the symbol, must be uint64_t to maintain alignment when called by 64b uproc in i386 kernel */
13951395- char dtsym_name[DTRACE_FUNCNAMELEN]; /* symbol name */
13961396-} dtrace_symbol_t;
13971397-13981398-typedef struct dtrace_module_symbols {
13991399- UUID dtmodsyms_uuid;
14001400- uint64_t dtmodsyms_count;
14011401- dtrace_symbol_t dtmodsyms_symbols[1];
14021402-} dtrace_module_symbols_t;
14031403-14041404-#define DTRACE_MODULE_SYMBOLS_SIZE(count) (sizeof(dtrace_module_symbols_t) + ((count - 1) * sizeof(dtrace_symbol_t)))
14051405-14061406-typedef struct dtrace_module_uuids_list {
14071407- uint64_t dtmul_count;
14081408- UUID dtmul_uuid[1];
14091409-} dtrace_module_uuids_list_t;
14101410-14111411-#define DTRACE_MODULE_UUIDS_LIST_SIZE(count) (sizeof(dtrace_module_uuids_list_t) + ((count - 1) * sizeof(UUID)))
14121412-14131413-typedef struct dtrace_procdesc {
14141414- char p_comm[MAXCOMLEN+1];
14151415- pid_t p_pid;
14161416-} dtrace_procdesc_t;
14171417-14181418-#endif /* __APPLE__ */
14191419-14201420-/*
14211421- * DTrace Helpers
14221422- *
14231423- * In general, DTrace establishes probes in processes and takes actions on
14241424- * processes without knowing their specific user-level structures. Instead of
14251425- * existing in the framework, process-specific knowledge is contained by the
14261426- * enabling D program -- which can apply process-specific knowledge by making
14271427- * appropriate use of DTrace primitives like copyin() and copyinstr() to
14281428- * operate on user-level data. However, there may exist some specific probes
14291429- * of particular semantic relevance that the application developer may wish to
14301430- * explicitly export. For example, an application may wish to export a probe
14311431- * at the point that it begins and ends certain well-defined transactions. In
14321432- * addition to providing probes, programs may wish to offer assistance for
14331433- * certain actions. For example, in highly dynamic environments (e.g., Java),
14341434- * it may be difficult to obtain a stack trace in terms of meaningful symbol
14351435- * names (the translation from instruction addresses to corresponding symbol
14361436- * names may only be possible in situ); these environments may wish to define
14371437- * a series of actions to be applied in situ to obtain a meaningful stack
14381438- * trace.
14391439- *
14401440- * These two mechanisms -- user-level statically defined tracing and assisting
14411441- * DTrace actions -- are provided via DTrace _helpers_. Helpers are specified
14421442- * via DOF, but unlike enabling DOF, helper DOF may contain definitions of
14431443- * providers, probes and their arguments. If a helper wishes to provide
14441444- * action assistance, probe descriptions and corresponding DIF actions may be
14451445- * specified in the helper DOF. For such helper actions, however, the probe
14461446- * description describes the specific helper: all DTrace helpers have the
14471447- * provider name "dtrace" and the module name "helper", and the name of the
14481448- * helper is contained in the function name (for example, the ustack() helper
14491449- * is named "ustack"). Any helper-specific name may be contained in the name
14501450- * (for example, if a helper were to have a constructor, it might be named
14511451- * "dtrace:helper:<helper>:init"). Helper actions are only called when the
14521452- * action that they are helping is taken. Helper actions may only return DIF
14531453- * expressions, and may only call the following subroutines:
14541454- *
14551455- * alloca() <= Allocates memory out of the consumer's scratch space
14561456- * bcopy() <= Copies memory to scratch space
14571457- * copyin() <= Copies memory from user-level into consumer's scratch
14581458- * copyinto() <= Copies memory into a specific location in scratch
14591459- * copyinstr() <= Copies a string into a specific location in scratch
14601460- *
14611461- * Helper actions may only access the following built-in variables:
14621462- *
14631463- * curthread <= Current kthread_t pointer
14641464- * tid <= Current thread identifier
14651465- * pid <= Current process identifier
14661466- * ppid <= Parent process identifier
14671467- * uid <= Current user ID
14681468- * gid <= Current group ID
14691469- * execname <= Current executable name
14701470- * zonename <= Current zone name
14711471- *
14721472- * Helper actions may not manipulate or allocate dynamic variables, but they
14731473- * may have clause-local and statically-allocated global variables. The
14741474- * helper action variable state is specific to the helper action -- variables
14751475- * used by the helper action may not be accessed outside of the helper
14761476- * action, and the helper action may not access variables that like outside
14771477- * of it. Helper actions may not load from kernel memory at-large; they are
14781478- * restricting to loading current user state (via copyin() and variants) and
14791479- * scratch space. As with probe enablings, helper actions are executed in
14801480- * program order. The result of the helper action is the result of the last
14811481- * executing helper expression.
14821482- *
14831483- * Helpers -- composed of either providers/probes or probes/actions (or both)
14841484- * -- are added by opening the "helper" minor node, and issuing an ioctl(2)
14851485- * (DTRACEHIOC_ADDDOF) that specifies the dof_helper_t structure. This
14861486- * encapsulates the name and base address of the user-level library or
14871487- * executable publishing the helpers and probes as well as the DOF that
14881488- * contains the definitions of those helpers and probes.
14891489- *
14901490- * The DTRACEHIOC_ADD and DTRACEHIOC_REMOVE are left in place for legacy
14911491- * helpers and should no longer be used. No other ioctls are valid on the
14921492- * helper minor node.
14931493- */
14941494-#if !defined(__APPLE__)
14951495-#define DTRACEHIOC (('d' << 24) | ('t' << 16) | ('h' << 8))
14961496-#define DTRACEHIOC_ADD (DTRACEHIOC | 1) /* add helper */
14971497-#define DTRACEHIOC_REMOVE (DTRACEHIOC | 2) /* remove helper */
14981498-#define DTRACEHIOC_ADDDOF (DTRACEHIOC | 3) /* add helper DOF */
14991499-#else
15001500-#define DTRACEHIOC_REMOVE _IO('h', 2) /* remove helper */
15011501-#define DTRACEHIOC_ADDDOF _IOW('h', 4, user_addr_t) /* add helper DOF */
15021502-#endif /* __APPLE__ */
15031503-15041504-typedef struct dof_helper {
15051505- char dofhp_mod[DTRACE_MODNAMELEN]; /* executable or library name */
15061506- uint64_t dofhp_addr; /* base address of object */
15071507- uint64_t dofhp_dof; /* address of helper DOF */
15081508-} dof_helper_t;
15091509-15101510-#if defined(__APPLE__)
15111511-/*
15121512- * This structure is used to register one or more dof_helper_t(s).
15131513- * For counts greater than one, malloc the structure as if the
15141514- * dofiod_helpers field was "count" sized. The kernel will copyin
15151515- * data of size:
15161516- *
15171517- * sizeof(dof_ioctl_data_t) + ((count - 1) * sizeof(dof_helper_t))
15181518- */
15191519-typedef struct dof_ioctl_data {
15201520- /*
15211521- * This field must be 64 bits to keep the alignment the same
15221522- * when 64 bit user procs are sending data to 32 bit xnu
15231523- */
15241524- uint64_t dofiod_count;
15251525- dof_helper_t dofiod_helpers[1];
15261526-} dof_ioctl_data_t;
15271527-15281528-#define DOF_IOCTL_DATA_T_SIZE(count) (sizeof(dof_ioctl_data_t) + ((count - 1) * sizeof(dof_helper_t)))
15291529-15301530-#endif
15311531-15321532-#define DTRACEMNR_DTRACE "dtrace" /* node for DTrace ops */
15331533-#if !defined(__APPLE__)
15341534-#define DTRACEMNR_HELPER "helper" /* node for helpers */
15351535-#else
15361536-#define DTRACEMNR_HELPER "dtracehelper" /* node for helpers */
15371537-#endif /* __APPLE__ */
15381538-#define DTRACEMNRN_DTRACE 0 /* minor for DTrace ops */
15391539-#define DTRACEMNRN_HELPER 1 /* minor for helpers */
15401540-#define DTRACEMNRN_CLONE 2 /* first clone minor */
15411541-15421542-#ifdef _KERNEL
15431543-15441544-/*
15451545- * DTrace Provider API
15461546- *
15471547- * The following functions are implemented by the DTrace framework and are
15481548- * used to implement separate in-kernel DTrace providers. Common functions
15491549- * are provided in uts/common/os/dtrace.c. ISA-dependent subroutines are
15501550- * defined in uts/<isa>/dtrace/dtrace_asm.s or uts/<isa>/dtrace/dtrace_isa.c.
15511551- *
15521552- * The provider API has two halves: the API that the providers consume from
15531553- * DTrace, and the API that providers make available to DTrace.
15541554- *
15551555- * 1 Framework-to-Provider API
15561556- *
15571557- * 1.1 Overview
15581558- *
15591559- * The Framework-to-Provider API is represented by the dtrace_pops structure
15601560- * that the provider passes to the framework when registering itself. This
15611561- * structure consists of the following members:
15621562- *
15631563- * dtps_provide() <-- Provide all probes, all modules
15641564- * dtps_provide_module() <-- Provide all probes in specified module
15651565- * dtps_enable() <-- Enable specified probe
15661566- * dtps_disable() <-- Disable specified probe
15671567- * dtps_suspend() <-- Suspend specified probe
15681568- * dtps_resume() <-- Resume specified probe
15691569- * dtps_getargdesc() <-- Get the argument description for args[X]
15701570- * dtps_getargval() <-- Get the value for an argX or args[X] variable
15711571- * dtps_usermode() <-- Find out if the probe was fired in user mode
15721572- * dtps_destroy() <-- Destroy all state associated with this probe
15731573- *
15741574- * 1.2 void dtps_provide(void *arg, const dtrace_probedesc_t *spec)
15751575- *
15761576- * 1.2.1 Overview
15771577- *
15781578- * Called to indicate that the provider should provide all probes. If the
15791579- * specified description is non-NULL, dtps_provide() is being called because
15801580- * no probe matched a specified probe -- if the provider has the ability to
15811581- * create custom probes, it may wish to create a probe that matches the
15821582- * specified description.
15831583- *
15841584- * 1.2.2 Arguments and notes
15851585- *
15861586- * The first argument is the cookie as passed to dtrace_register(). The
15871587- * second argument is a pointer to a probe description that the provider may
15881588- * wish to consider when creating custom probes. The provider is expected to
15891589- * call back into the DTrace framework via dtrace_probe_create() to create
15901590- * any necessary probes. dtps_provide() may be called even if the provider
15911591- * has made available all probes; the provider should check the return value
15921592- * of dtrace_probe_create() to handle this case. Note that the provider need
15931593- * not implement both dtps_provide() and dtps_provide_module(); see
15941594- * "Arguments and Notes" for dtrace_register(), below.
15951595- *
15961596- * 1.2.3 Return value
15971597- *
15981598- * None.
15991599- *
16001600- * 1.2.4 Caller's context
16011601- *
16021602- * dtps_provide() is typically called from open() or ioctl() context, but may
16031603- * be called from other contexts as well. The DTrace framework is locked in
16041604- * such a way that providers may not register or unregister. This means that
16051605- * the provider may not call any DTrace API that affects its registration with
16061606- * the framework, including dtrace_register(), dtrace_unregister(),
16071607- * dtrace_invalidate(), and dtrace_condense(). However, the context is such
16081608- * that the provider may (and indeed, is expected to) call probe-related
16091609- * DTrace routines, including dtrace_probe_create(), dtrace_probe_lookup(),
16101610- * and dtrace_probe_arg().
16111611- *
16121612- * 1.3 void dtps_provide_module(void *arg, struct modctl *mp)
16131613- *
16141614- * 1.3.1 Overview
16151615- *
16161616- * Called to indicate that the provider should provide all probes in the
16171617- * specified module.
16181618- *
16191619- * 1.3.2 Arguments and notes
16201620- *
16211621- * The first argument is the cookie as passed to dtrace_register(). The
16221622- * second argument is a pointer to a modctl structure that indicates the
16231623- * module for which probes should be created.
16241624- *
16251625- * 1.3.3 Return value
16261626- *
16271627- * None.
16281628- *
16291629- * 1.3.4 Caller's context
16301630- *
16311631- * dtps_provide_module() may be called from open() or ioctl() context, but
16321632- * may also be called from a module loading context. mod_lock is held, and
16331633- * the DTrace framework is locked in such a way that providers may not
16341634- * register or unregister. This means that the provider may not call any
16351635- * DTrace API that affects its registration with the framework, including
16361636- * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and
16371637- * dtrace_condense(). However, the context is such that the provider may (and
16381638- * indeed, is expected to) call probe-related DTrace routines, including
16391639- * dtrace_probe_create(), dtrace_probe_lookup(), and dtrace_probe_arg(). Note
16401640- * that the provider need not implement both dtps_provide() and
16411641- * dtps_provide_module(); see "Arguments and Notes" for dtrace_register(),
16421642- * below.
16431643- *
16441644- * 1.4 int dtps_enable(void *arg, dtrace_id_t id, void *parg)
16451645- *
16461646- * 1.4.1 Overview
16471647- *
16481648- * Called to enable the specified probe.
16491649- *
16501650- * 1.4.2 Arguments and notes
16511651- *
16521652- * The first argument is the cookie as passed to dtrace_register(). The
16531653- * second argument is the identifier of the probe to be enabled. The third
16541654- * argument is the probe argument as passed to dtrace_probe_create().
16551655- * dtps_enable() will be called when a probe transitions from not being
16561656- * enabled at all to having one or more ECB. The number of ECBs associated
16571657- * with the probe may change without subsequent calls into the provider.
16581658- * When the number of ECBs drops to zero, the provider will be explicitly
16591659- * told to disable the probe via dtps_disable(). dtrace_probe() should never
16601660- * be called for a probe identifier that hasn't been explicitly enabled via
16611661- * dtps_enable().
16621662- *
16631663- * 1.4.3 Return value
16641664- *
16651665- * On success, dtps_enable() should return 0. On failure, -1 should be
16661666- * returned.
16671667- *
16681668- * 1.4.4 Caller's context
16691669- *
16701670- * The DTrace framework is locked in such a way that it may not be called
16711671- * back into at all. cpu_lock is held. mod_lock is not held and may not
16721672- * be acquired.
16731673- *
16741674- * 1.5 void dtps_disable(void *arg, dtrace_id_t id, void *parg)
16751675- *
16761676- * 1.5.1 Overview
16771677- *
16781678- * Called to disable the specified probe.
16791679- *
16801680- * 1.5.2 Arguments and notes
16811681- *
16821682- * The first argument is the cookie as passed to dtrace_register(). The
16831683- * second argument is the identifier of the probe to be disabled. The third
16841684- * argument is the probe argument as passed to dtrace_probe_create().
16851685- * dtps_disable() will be called when a probe transitions from being enabled
16861686- * to having zero ECBs. dtrace_probe() should never be called for a probe
16871687- * identifier that has been explicitly enabled via dtps_disable().
16881688- *
16891689- * 1.5.3 Return value
16901690- *
16911691- * None.
16921692- *
16931693- * 1.5.4 Caller's context
16941694- *
16951695- * The DTrace framework is locked in such a way that it may not be called
16961696- * back into at all. cpu_lock is held. mod_lock is not held and may not
16971697- * be acquired.
16981698- *
16991699- * 1.6 void dtps_suspend(void *arg, dtrace_id_t id, void *parg)
17001700- *
17011701- * 1.6.1 Overview
17021702- *
17031703- * Called to suspend the specified enabled probe. This entry point is for
17041704- * providers that may need to suspend some or all of their probes when CPUs
17051705- * are being powered on or when the boot monitor is being entered for a
17061706- * prolonged period of time.
17071707- *
17081708- * 1.6.2 Arguments and notes
17091709- *
17101710- * The first argument is the cookie as passed to dtrace_register(). The
17111711- * second argument is the identifier of the probe to be suspended. The
17121712- * third argument is the probe argument as passed to dtrace_probe_create().
17131713- * dtps_suspend will only be called on an enabled probe. Providers that
17141714- * provide a dtps_suspend entry point will want to take roughly the action
17151715- * that it takes for dtps_disable.
17161716- *
17171717- * 1.6.3 Return value
17181718- *
17191719- * None.
17201720- *
17211721- * 1.6.4 Caller's context
17221722- *
17231723- * Interrupts are disabled. The DTrace framework is in a state such that the
17241724- * specified probe cannot be disabled or destroyed for the duration of
17251725- * dtps_suspend(). As interrupts are disabled, the provider is afforded
17261726- * little latitude; the provider is expected to do no more than a store to
17271727- * memory.
17281728- *
17291729- * 1.7 void dtps_resume(void *arg, dtrace_id_t id, void *parg)
17301730- *
17311731- * 1.7.1 Overview
17321732- *
17331733- * Called to resume the specified enabled probe. This entry point is for
17341734- * providers that may need to resume some or all of their probes after the
17351735- * completion of an event that induced a call to dtps_suspend().
17361736- *
17371737- * 1.7.2 Arguments and notes
17381738- *
17391739- * The first argument is the cookie as passed to dtrace_register(). The
17401740- * second argument is the identifier of the probe to be resumed. The
17411741- * third argument is the probe argument as passed to dtrace_probe_create().
17421742- * dtps_resume will only be called on an enabled probe. Providers that
17431743- * provide a dtps_resume entry point will want to take roughly the action
17441744- * that it takes for dtps_enable.
17451745- *
17461746- * 1.7.3 Return value
17471747- *
17481748- * None.
17491749- *
17501750- * 1.7.4 Caller's context
17511751- *
17521752- * Interrupts are disabled. The DTrace framework is in a state such that the
17531753- * specified probe cannot be disabled or destroyed for the duration of
17541754- * dtps_resume(). As interrupts are disabled, the provider is afforded
17551755- * little latitude; the provider is expected to do no more than a store to
17561756- * memory.
17571757- *
17581758- * 1.8 void dtps_getargdesc(void *arg, dtrace_id_t id, void *parg,
17591759- * dtrace_argdesc_t *desc)
17601760- *
17611761- * 1.8.1 Overview
17621762- *
17631763- * Called to retrieve the argument description for an args[X] variable.
17641764- *
17651765- * 1.8.2 Arguments and notes
17661766- *
17671767- * The first argument is the cookie as passed to dtrace_register(). The
17681768- * second argument is the identifier of the current probe. The third
17691769- * argument is the probe argument as passed to dtrace_probe_create(). The
17701770- * fourth argument is a pointer to the argument description. This
17711771- * description is both an input and output parameter: it contains the
17721772- * index of the desired argument in the dtargd_ndx field, and expects
17731773- * the other fields to be filled in upon return. If there is no argument
17741774- * corresponding to the specified index, the dtargd_ndx field should be set
17751775- * to DTRACE_ARGNONE.
17761776- *
17771777- * 1.8.3 Return value
17781778- *
17791779- * None. The dtargd_ndx, dtargd_native, dtargd_xlate and dtargd_mapping
17801780- * members of the dtrace_argdesc_t structure are all output values.
17811781- *
17821782- * 1.8.4 Caller's context
17831783- *
17841784- * dtps_getargdesc() is called from ioctl() context. mod_lock is held, and
17851785- * the DTrace framework is locked in such a way that providers may not
17861786- * register or unregister. This means that the provider may not call any
17871787- * DTrace API that affects its registration with the framework, including
17881788- * dtrace_register(), dtrace_unregister(), dtrace_invalidate(), and
17891789- * dtrace_condense().
17901790- *
17911791- * 1.9 uint64_t dtps_getargval(void *arg, dtrace_id_t id, void *parg,
17921792- * int argno, int aframes)
17931793- *
17941794- * 1.9.1 Overview
17951795- *
17961796- * Called to retrieve a value for an argX or args[X] variable.
17971797- *
17981798- * 1.9.2 Arguments and notes
17991799- *
18001800- * The first argument is the cookie as passed to dtrace_register(). The
18011801- * second argument is the identifier of the current probe. The third
18021802- * argument is the probe argument as passed to dtrace_probe_create(). The
18031803- * fourth argument is the number of the argument (the X in the example in
18041804- * 1.9.1). The fifth argument is the number of stack frames that were used
18051805- * to get from the actual place in the code that fired the probe to
18061806- * dtrace_probe() itself, the so-called artificial frames. This argument may
18071807- * be used to descend an appropriate number of frames to find the correct
18081808- * values. If this entry point is left NULL, the dtrace_getarg() built-in
18091809- * function is used.
18101810- *
18111811- * 1.9.3 Return value
18121812- *
18131813- * The value of the argument.
18141814- *
18151815- * 1.9.4 Caller's context
18161816- *
18171817- * This is called from within dtrace_probe() meaning that interrupts
18181818- * are disabled. No locks should be taken within this entry point.
18191819- *
18201820- * 1.10 int dtps_usermode(void *arg, dtrace_id_t id, void *parg)
18211821- *
18221822- * 1.10.1 Overview
18231823- *
18241824- * Called to determine if the probe was fired in a user context.
18251825- *
18261826- * 1.10.2 Arguments and notes
18271827- *
18281828- * The first argument is the cookie as passed to dtrace_register(). The
18291829- * second argument is the identifier of the current probe. The third
18301830- * argument is the probe argument as passed to dtrace_probe_create(). This
18311831- * entry point must not be left NULL for providers whose probes allow for
18321832- * mixed mode tracing, that is to say those probes that can fire during
18331833- * kernel- _or_ user-mode execution
18341834- *
18351835- * 1.10.3 Return value
18361836- *
18371837- * A boolean value.
18381838- *
18391839- * 1.10.4 Caller's context
18401840- *
18411841- * This is called from within dtrace_probe() meaning that interrupts
18421842- * are disabled. No locks should be taken within this entry point.
18431843- *
18441844- * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg)
18451845- *
18461846- * 1.11.1 Overview
18471847- *
18481848- * Called to destroy the specified probe.
18491849- *
18501850- * 1.11.2 Arguments and notes
18511851- *
18521852- * The first argument is the cookie as passed to dtrace_register(). The
18531853- * second argument is the identifier of the probe to be destroyed. The third
18541854- * argument is the probe argument as passed to dtrace_probe_create(). The
18551855- * provider should free all state associated with the probe. The framework
18561856- * guarantees that dtps_destroy() is only called for probes that have either
18571857- * been disabled via dtps_disable() or were never enabled via dtps_enable().
18581858- * Once dtps_disable() has been called for a probe, no further call will be
18591859- * made specifying the probe.
18601860- *
18611861- * 1.11.3 Return value
18621862- *
18631863- * None.
18641864- *
18651865- * 1.11.4 Caller's context
18661866- *
18671867- * The DTrace framework is locked in such a way that it may not be called
18681868- * back into at all. mod_lock is held. cpu_lock is not held, and may not be
18691869- * acquired.
18701870- *
18711871- *
18721872- * 2 Provider-to-Framework API
18731873- *
18741874- * 2.1 Overview
18751875- *
18761876- * The Provider-to-Framework API provides the mechanism for the provider to
18771877- * register itself with the DTrace framework, to create probes, to lookup
18781878- * probes and (most importantly) to fire probes. The Provider-to-Framework
18791879- * consists of:
18801880- *
18811881- * dtrace_register() <-- Register a provider with the DTrace framework
18821882- * dtrace_unregister() <-- Remove a provider's DTrace registration
18831883- * dtrace_invalidate() <-- Invalidate the specified provider
18841884- * dtrace_condense() <-- Remove a provider's unenabled probes
18851885- * dtrace_attached() <-- Indicates whether or not DTrace has attached
18861886- * dtrace_probe_create() <-- Create a DTrace probe
18871887- * dtrace_probe_lookup() <-- Lookup a DTrace probe based on its name
18881888- * dtrace_probe_arg() <-- Return the probe argument for a specific probe
18891889- * dtrace_probe() <-- Fire the specified probe
18901890- *
18911891- * 2.2 int dtrace_register(const char *name, const dtrace_pattr_t *pap,
18921892- * uint32_t priv, cred_t *cr, const dtrace_pops_t *pops, void *arg,
18931893- * dtrace_provider_id_t *idp)
18941894- *
18951895- * 2.2.1 Overview
18961896- *
18971897- * dtrace_register() registers the calling provider with the DTrace
18981898- * framework. It should generally be called by DTrace providers in their
18991899- * attach(9E) entry point.
19001900- *
19011901- * 2.2.2 Arguments and Notes
19021902- *
19031903- * The first argument is the name of the provider. The second argument is a
19041904- * pointer to the stability attributes for the provider. The third argument
19051905- * is the privilege flags for the provider, and must be some combination of:
19061906- *
19071907- * DTRACE_PRIV_NONE <= All users may enable probes from this provider
19081908- *
19091909- * DTRACE_PRIV_PROC <= Any user with privilege of PRIV_DTRACE_PROC may
19101910- * enable probes from this provider
19111911- *
19121912- * DTRACE_PRIV_USER <= Any user with privilege of PRIV_DTRACE_USER may
19131913- * enable probes from this provider
19141914- *
19151915- * DTRACE_PRIV_KERNEL <= Any user with privilege of PRIV_DTRACE_KERNEL
19161916- * may enable probes from this provider
19171917- *
19181918- * DTRACE_PRIV_OWNER <= This flag places an additional constraint on
19191919- * the privilege requirements above. These probes
19201920- * require either (a) a user ID matching the user
19211921- * ID of the cred passed in the fourth argument
19221922- * or (b) the PRIV_PROC_OWNER privilege.
19231923- *
19241924- * DTRACE_PRIV_ZONEOWNER<= This flag places an additional constraint on
19251925- * the privilege requirements above. These probes
19261926- * require either (a) a zone ID matching the zone
19271927- * ID of the cred passed in the fourth argument
19281928- * or (b) the PRIV_PROC_ZONE privilege.
19291929- *
19301930- * Note that these flags designate the _visibility_ of the probes, not
19311931- * the conditions under which they may or may not fire.
19321932- *
19331933- * The fourth argument is the credential that is associated with the
19341934- * provider. This argument should be NULL if the privilege flags don't
19351935- * include DTRACE_PRIV_OWNER or DTRACE_PRIV_ZONEOWNER. If non-NULL, the
19361936- * framework stashes the uid and zoneid represented by this credential
19371937- * for use at probe-time, in implicit predicates. These limit visibility
19381938- * of the probes to users and/or zones which have sufficient privilege to
19391939- * access them.
19401940- *
19411941- * The fifth argument is a DTrace provider operations vector, which provides
19421942- * the implementation for the Framework-to-Provider API. (See Section 1,
19431943- * above.) This must be non-NULL, and each member must be non-NULL. The
19441944- * exceptions to this are (1) the dtps_provide() and dtps_provide_module()
19451945- * members (if the provider so desires, _one_ of these members may be left
19461946- * NULL -- denoting that the provider only implements the other) and (2)
19471947- * the dtps_suspend() and dtps_resume() members, which must either both be
19481948- * NULL or both be non-NULL.
19491949- *
19501950- * The sixth argument is a cookie to be specified as the first argument for
19511951- * each function in the Framework-to-Provider API. This argument may have
19521952- * any value.
19531953- *
19541954- * The final argument is a pointer to dtrace_provider_id_t. If
19551955- * dtrace_register() successfully completes, the provider identifier will be
19561956- * stored in the memory pointed to be this argument. This argument must be
19571957- * non-NULL.
19581958- *
19591959- * 2.2.3 Return value
19601960- *
19611961- * On success, dtrace_register() returns 0 and stores the new provider's
19621962- * identifier into the memory pointed to by the idp argument. On failure,
19631963- * dtrace_register() returns an errno:
19641964- *
19651965- * EINVAL The arguments passed to dtrace_register() were somehow invalid.
19661966- * This may because a parameter that must be non-NULL was NULL,
19671967- * because the name was invalid (either empty or an illegal
19681968- * provider name) or because the attributes were invalid.
19691969- *
19701970- * No other failure code is returned.
19711971- *
19721972- * 2.2.4 Caller's context
19731973- *
19741974- * dtrace_register() may induce calls to dtrace_provide(); the provider must
19751975- * hold no locks across dtrace_register() that may also be acquired by
19761976- * dtrace_provide(). cpu_lock and mod_lock must not be held.
19771977- *
19781978- * 2.3 int dtrace_unregister(dtrace_provider_t id)
19791979- *
19801980- * 2.3.1 Overview
19811981- *
19821982- * Unregisters the specified provider from the DTrace framework. It should
19831983- * generally be called by DTrace providers in their detach(9E) entry point.
19841984- *
19851985- * 2.3.2 Arguments and Notes
19861986- *
19871987- * The only argument is the provider identifier, as returned from a
19881988- * successful call to dtrace_register(). As a result of calling
19891989- * dtrace_unregister(), the DTrace framework will call back into the provider
19901990- * via the dtps_destroy() entry point. Once dtrace_unregister() successfully
19911991- * completes, however, the DTrace framework will no longer make calls through
19921992- * the Framework-to-Provider API.
19931993- *
19941994- * 2.3.3 Return value
19951995- *
19961996- * On success, dtrace_unregister returns 0. On failure, dtrace_unregister()
19971997- * returns an errno:
19981998- *
19991999- * EBUSY There are currently processes that have the DTrace pseudodevice
20002000- * open, or there exists an anonymous enabling that hasn't yet
20012001- * been claimed.
20022002- *
20032003- * No other failure code is returned.
20042004- *
20052005- * 2.3.4 Caller's context
20062006- *
20072007- * Because a call to dtrace_unregister() may induce calls through the
20082008- * Framework-to-Provider API, the caller may not hold any lock across
20092009- * dtrace_register() that is also acquired in any of the Framework-to-
20102010- * Provider API functions. Additionally, mod_lock may not be held.
20112011- *
20122012- * 2.4 void dtrace_invalidate(dtrace_provider_id_t id)
20132013- *
20142014- * 2.4.1 Overview
20152015- *
20162016- * Invalidates the specified provider. All subsequent probe lookups for the
20172017- * specified provider will fail, but its probes will not be removed.
20182018- *
20192019- * 2.4.2 Arguments and note
20202020- *
20212021- * The only argument is the provider identifier, as returned from a
20222022- * successful call to dtrace_register(). In general, a provider's probes
20232023- * always remain valid; dtrace_invalidate() is a mechanism for invalidating
20242024- * an entire provider, regardless of whether or not probes are enabled or
20252025- * not. Note that dtrace_invalidate() will _not_ prevent already enabled
20262026- * probes from firing -- it will merely prevent any new enablings of the
20272027- * provider's probes.
20282028- *
20292029- * 2.5 int dtrace_condense(dtrace_provider_id_t id)
20302030- *
20312031- * 2.5.1 Overview
20322032- *
20332033- * Removes all the unenabled probes for the given provider. This function is
20342034- * not unlike dtrace_unregister(), except that it doesn't remove the
20352035- * provider just as many of its associated probes as it can.
20362036- *
20372037- * 2.5.2 Arguments and Notes
20382038- *
20392039- * As with dtrace_unregister(), the sole argument is the provider identifier
20402040- * as returned from a successful call to dtrace_register(). As a result of
20412041- * calling dtrace_condense(), the DTrace framework will call back into the
20422042- * given provider's dtps_destroy() entry point for each of the provider's
20432043- * unenabled probes.
20442044- *
20452045- * 2.5.3 Return value
20462046- *
20472047- * Currently, dtrace_condense() always returns 0. However, consumers of this
20482048- * function should check the return value as appropriate; its behavior may
20492049- * change in the future.
20502050- *
20512051- * 2.5.4 Caller's context
20522052- *
20532053- * As with dtrace_unregister(), the caller may not hold any lock across
20542054- * dtrace_condense() that is also acquired in the provider's entry points.
20552055- * Also, mod_lock may not be held.
20562056- *
20572057- * 2.6 int dtrace_attached()
20582058- *
20592059- * 2.6.1 Overview
20602060- *
20612061- * Indicates whether or not DTrace has attached.
20622062- *
20632063- * 2.6.2 Arguments and Notes
20642064- *
20652065- * For most providers, DTrace makes initial contact beyond registration.
20662066- * That is, once a provider has registered with DTrace, it waits to hear
20672067- * from DTrace to create probes. However, some providers may wish to
20682068- * proactively create probes without first being told by DTrace to do so.
20692069- * If providers wish to do this, they must first call dtrace_attached() to
20702070- * determine if DTrace itself has attached. If dtrace_attached() returns 0,
20712071- * the provider must not make any other Provider-to-Framework API call.
20722072- *
20732073- * 2.6.3 Return value
20742074- *
20752075- * dtrace_attached() returns 1 if DTrace has attached, 0 otherwise.
20762076- *
20772077- * 2.7 int dtrace_probe_create(dtrace_provider_t id, const char *mod,
20782078- * const char *func, const char *name, int aframes, void *arg)
20792079- *
20802080- * 2.7.1 Overview
20812081- *
20822082- * Creates a probe with specified module name, function name, and name.
20832083- *
20842084- * 2.7.2 Arguments and Notes
20852085- *
20862086- * The first argument is the provider identifier, as returned from a
20872087- * successful call to dtrace_register(). The second, third, and fourth
20882088- * arguments are the module name, function name, and probe name,
20892089- * respectively. Of these, module name and function name may both be NULL
20902090- * (in which case the probe is considered to be unanchored), or they may both
20912091- * be non-NULL. The name must be non-NULL, and must point to a non-empty
20922092- * string.
20932093- *
20942094- * The fifth argument is the number of artificial stack frames that will be
20952095- * found on the stack when dtrace_probe() is called for the new probe. These
20962096- * artificial frames will be automatically be pruned should the stack() or
20972097- * stackdepth() functions be called as part of one of the probe's ECBs. If
20982098- * the parameter doesn't add an artificial frame, this parameter should be
20992099- * zero.
21002100- *
21012101- * The final argument is a probe argument that will be passed back to the
21022102- * provider when a probe-specific operation is called. (e.g., via
21032103- * dtps_enable(), dtps_disable(), etc.)
21042104- *
21052105- * Note that it is up to the provider to be sure that the probe that it
21062106- * creates does not already exist -- if the provider is unsure of the probe's
21072107- * existence, it should assure its absence with dtrace_probe_lookup() before
21082108- * calling dtrace_probe_create().
21092109- *
21102110- * 2.7.3 Return value
21112111- *
21122112- * dtrace_probe_create() always succeeds, and always returns the identifier
21132113- * of the newly-created probe.
21142114- *
21152115- * 2.7.4 Caller's context
21162116- *
21172117- * While dtrace_probe_create() is generally expected to be called from
21182118- * dtps_provide() and/or dtps_provide_module(), it may be called from other
21192119- * non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
21202120- *
21212121- * 2.8 dtrace_id_t dtrace_probe_lookup(dtrace_provider_t id, const char *mod,
21222122- * const char *func, const char *name)
21232123- *
21242124- * 2.8.1 Overview
21252125- *
21262126- * Looks up a probe based on provdider and one or more of module name,
21272127- * function name and probe name.
21282128- *
21292129- * 2.8.2 Arguments and Notes
21302130- *
21312131- * The first argument is the provider identifier, as returned from a
21322132- * successful call to dtrace_register(). The second, third, and fourth
21332133- * arguments are the module name, function name, and probe name,
21342134- * respectively. Any of these may be NULL; dtrace_probe_lookup() will return
21352135- * the identifier of the first probe that is provided by the specified
21362136- * provider and matches all of the non-NULL matching criteria.
21372137- * dtrace_probe_lookup() is generally used by a provider to be check the
21382138- * existence of a probe before creating it with dtrace_probe_create().
21392139- *
21402140- * 2.8.3 Return value
21412141- *
21422142- * If the probe exists, returns its identifier. If the probe does not exist,
21432143- * return DTRACE_IDNONE.
21442144- *
21452145- * 2.8.4 Caller's context
21462146- *
21472147- * While dtrace_probe_lookup() is generally expected to be called from
21482148- * dtps_provide() and/or dtps_provide_module(), it may also be called from
21492149- * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
21502150- *
21512151- * 2.9 void *dtrace_probe_arg(dtrace_provider_t id, dtrace_id_t probe)
21522152- *
21532153- * 2.9.1 Overview
21542154- *
21552155- * Returns the probe argument associated with the specified probe.
21562156- *
21572157- * 2.9.2 Arguments and Notes
21582158- *
21592159- * The first argument is the provider identifier, as returned from a
21602160- * successful call to dtrace_register(). The second argument is a probe
21612161- * identifier, as returned from dtrace_probe_lookup() or
21622162- * dtrace_probe_create(). This is useful if a probe has multiple
21632163- * provider-specific components to it: the provider can create the probe
21642164- * once with provider-specific state, and then add to the state by looking
21652165- * up the probe based on probe identifier.
21662166- *
21672167- * 2.9.3 Return value
21682168- *
21692169- * Returns the argument associated with the specified probe. If the
21702170- * specified probe does not exist, or if the specified probe is not provided
21712171- * by the specified provider, NULL is returned.
21722172- *
21732173- * 2.9.4 Caller's context
21742174- *
21752175- * While dtrace_probe_arg() is generally expected to be called from
21762176- * dtps_provide() and/or dtps_provide_module(), it may also be called from
21772177- * other non-DTrace contexts. Neither cpu_lock nor mod_lock may be held.
21782178- *
21792179- * 2.10 void dtrace_probe(dtrace_id_t probe, uintptr_t arg0, uintptr_t arg1,
21802180- * uintptr_t arg2, uintptr_t arg3, uintptr_t arg4)
21812181- *
21822182- * 2.10.1 Overview
21832183- *
21842184- * The epicenter of DTrace: fires the specified probes with the specified
21852185- * arguments.
21862186- *
21872187- * 2.10.2 Arguments and Notes
21882188- *
21892189- * The first argument is a probe identifier as returned by
21902190- * dtrace_probe_create() or dtrace_probe_lookup(). The second through sixth
21912191- * arguments are the values to which the D variables "arg0" through "arg4"
21922192- * will be mapped.
21932193- *
21942194- * dtrace_probe() should be called whenever the specified probe has fired --
21952195- * however the provider defines it.
21962196- *
21972197- * 2.10.3 Return value
21982198- *
21992199- * None.
22002200- *
22012201- * 2.10.4 Caller's context
22022202- *
22032203- * dtrace_probe() may be called in virtually any context: kernel, user,
22042204- * interrupt, high-level interrupt, with arbitrary adaptive locks held, with
22052205- * dispatcher locks held, with interrupts disabled, etc. The only latitude
22062206- * that must be afforded to DTrace is the ability to make calls within
22072207- * itself (and to its in-kernel subroutines) and the ability to access
22082208- * arbitrary (but mapped) memory. On some platforms, this constrains
22092209- * context. For example, on UltraSPARC, dtrace_probe() cannot be called
22102210- * from any context in which TL is greater than zero. dtrace_probe() may
22112211- * also not be called from any routine which may be called by dtrace_probe()
22122212- * -- which includes functions in the DTrace framework and some in-kernel
22132213- * DTrace subroutines. All such functions "dtrace_"; providers that
22142214- * instrument the kernel arbitrarily should be sure to not instrument these
22152215- * routines.
22162216- */
22172217-typedef struct dtrace_pops {
22182218- void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec);
22192219- void (*dtps_provide_module)(void *arg, struct modctl *mp);
22202220- int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
22212221- void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
22222222- void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
22232223- void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg);
22242224- void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg,
22252225- dtrace_argdesc_t *desc);
22262226- uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg,
22272227- int argno, int aframes);
22282228- int (*dtps_usermode)(void *arg, dtrace_id_t id, void *parg);
22292229- void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg);
22302230-} dtrace_pops_t;
22312231-22322232-typedef uintptr_t dtrace_provider_id_t;
22332233-22342234-extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t,
22352235- cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *);
22362236-extern int dtrace_unregister(dtrace_provider_id_t);
22372237-extern int dtrace_condense(dtrace_provider_id_t);
22382238-extern void dtrace_invalidate(dtrace_provider_id_t);
22392239-extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *,
22402240- const char *, const char *);
22412241-extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *,
22422242- const char *, const char *, int, void *);
22432243-extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t);
22442244-#if !defined(__APPLE__)
22452245-extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
22462246- uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
22472247-#else
22482248-extern void dtrace_probe(dtrace_id_t, uint64_t arg0, uint64_t arg1,
22492249- uint64_t arg2, uint64_t arg3, uint64_t arg4);
22502250-#endif /* __APPLE__ */
22512251-22522252-/*
22532253- * DTrace Meta Provider API
22542254- *
22552255- * The following functions are implemented by the DTrace framework and are
22562256- * used to implement meta providers. Meta providers plug into the DTrace
22572257- * framework and are used to instantiate new providers on the fly. At
22582258- * present, there is only one type of meta provider and only one meta
22592259- * provider may be registered with the DTrace framework at a time. The
22602260- * sole meta provider type provides user-land static tracing facilities
22612261- * by taking meta probe descriptions and adding a corresponding provider
22622262- * into the DTrace framework.
22632263- *
22642264- * 1 Framework-to-Provider
22652265- *
22662266- * 1.1 Overview
22672267- *
22682268- * The Framework-to-Provider API is represented by the dtrace_mops structure
22692269- * that the meta provider passes to the framework when registering itself as
22702270- * a meta provider. This structure consists of the following members:
22712271- *
22722272- * dtms_create_probe() <-- Add a new probe to a created provider
22732273- * dtms_provide_pid() <-- Create a new provider for a given process
22742274- * dtms_remove_pid() <-- Remove a previously created provider
22752275- *
22762276- * 1.2 void dtms_create_probe(void *arg, void *parg,
22772277- * dtrace_helper_probedesc_t *probedesc);
22782278- *
22792279- * 1.2.1 Overview
22802280- *
22812281- * Called by the DTrace framework to create a new probe in a provider
22822282- * created by this meta provider.
22832283- *
22842284- * 1.2.2 Arguments and notes
22852285- *
22862286- * The first argument is the cookie as passed to dtrace_meta_register().
22872287- * The second argument is the provider cookie for the associated provider;
22882288- * this is obtained from the return value of dtms_provide_pid(). The third
22892289- * argument is the helper probe description.
22902290- *
22912291- * 1.2.3 Return value
22922292- *
22932293- * None
22942294- *
22952295- * 1.2.4 Caller's context
22962296- *
22972297- * dtms_create_probe() is called from either ioctl() or module load context.
22982298- * The DTrace framework is locked in such a way that meta providers may not
22992299- * register or unregister. This means that the meta provider cannot call
23002300- * dtrace_meta_register() or dtrace_meta_unregister(). However, the context is
23012301- * such that the provider may (and is expected to) call provider-related
23022302- * DTrace provider APIs including dtrace_probe_create().
23032303- *
23042304- * 1.3 void *dtms_provide_pid(void *arg, dtrace_meta_provider_t *mprov,
23052305- * pid_t pid)
23062306- *
23072307- * 1.3.1 Overview
23082308- *
23092309- * Called by the DTrace framework to instantiate a new provider given the
23102310- * description of the provider and probes in the mprov argument. The
23112311- * meta provider should call dtrace_register() to insert the new provider
23122312- * into the DTrace framework.
23132313- *
23142314- * 1.3.2 Arguments and notes
23152315- *
23162316- * The first argument is the cookie as passed to dtrace_meta_register().
23172317- * The second argument is a pointer to a structure describing the new
23182318- * helper provider. The third argument is the process identifier for
23192319- * process associated with this new provider. Note that the name of the
23202320- * provider as passed to dtrace_register() should be the contatenation of
23212321- * the dtmpb_provname member of the mprov argument and the processs
23222322- * identifier as a string.
23232323- *
23242324- * 1.3.3 Return value
23252325- *
23262326- * The cookie for the provider that the meta provider creates. This is
23272327- * the same value that it passed to dtrace_register().
23282328- *
23292329- * 1.3.4 Caller's context
23302330- *
23312331- * dtms_provide_pid() is called from either ioctl() or module load context.
23322332- * The DTrace framework is locked in such a way that meta providers may not
23332333- * register or unregister. This means that the meta provider cannot call
23342334- * dtrace_meta_register() or dtrace_meta_unregister(). However, the context
23352335- * is such that the provider may -- and is expected to -- call
23362336- * provider-related DTrace provider APIs including dtrace_register().
23372337- *
23382338- * 1.4 void dtms_remove_pid(void *arg, dtrace_meta_provider_t *mprov,
23392339- * pid_t pid)
23402340- *
23412341- * 1.4.1 Overview
23422342- *
23432343- * Called by the DTrace framework to remove a provider that had previously
23442344- * been instantiated via the dtms_provide_pid() entry point. The meta
23452345- * provider need not remove the provider immediately, but this entry
23462346- * point indicates that the provider should be removed as soon as possible
23472347- * using the dtrace_unregister() API.
23482348- *
23492349- * 1.4.2 Arguments and notes
23502350- *
23512351- * The first argument is the cookie as passed to dtrace_meta_register().
23522352- * The second argument is a pointer to a structure describing the helper
23532353- * provider. The third argument is the process identifier for process
23542354- * associated with this new provider.
23552355- *
23562356- * 1.4.3 Return value
23572357- *
23582358- * None
23592359- *
23602360- * 1.4.4 Caller's context
23612361- *
23622362- * dtms_remove_pid() is called from either ioctl() or exit() context.
23632363- * The DTrace framework is locked in such a way that meta providers may not
23642364- * register or unregister. This means that the meta provider cannot call
23652365- * dtrace_meta_register() or dtrace_meta_unregister(). However, the context
23662366- * is such that the provider may -- and is expected to -- call
23672367- * provider-related DTrace provider APIs including dtrace_unregister().
23682368- */
23692369-typedef struct dtrace_helper_probedesc {
23702370- char *dthpb_mod; /* probe module */
23712371- char *dthpb_func; /* probe function */
23722372- char *dthpb_name; /* probe name */
23732373- uint64_t dthpb_base; /* base address */
23742374-#if !defined(__APPLE__)
23752375- uint32_t *dthpb_offs; /* offsets array */
23762376- uint32_t *dthpb_enoffs; /* is-enabled offsets array */
23772377-#else
23782378- int32_t *dthpb_offs; /* (signed) offsets array */
23792379- int32_t *dthpb_enoffs; /* (signed) is-enabled offsets array */
23802380-#endif
23812381- uint32_t dthpb_noffs; /* offsets count */
23822382- uint32_t dthpb_nenoffs; /* is-enabled offsets count */
23832383- uint8_t *dthpb_args; /* argument mapping array */
23842384- uint8_t dthpb_xargc; /* translated argument count */
23852385- uint8_t dthpb_nargc; /* native argument count */
23862386- char *dthpb_xtypes; /* translated types strings */
23872387- char *dthpb_ntypes; /* native types strings */
23882388-} dtrace_helper_probedesc_t;
23892389-23902390-typedef struct dtrace_helper_provdesc {
23912391- char *dthpv_provname; /* provider name */
23922392- dtrace_pattr_t dthpv_pattr; /* stability attributes */
23932393-} dtrace_helper_provdesc_t;
23942394-23952395-typedef struct dtrace_mops {
23962396- void (*dtms_create_probe)(void *, void *, dtrace_helper_probedesc_t *);
23972397- void *(*dtms_provide_pid)(void *, dtrace_helper_provdesc_t *, pid_t);
23982398- void (*dtms_remove_pid)(void *, dtrace_helper_provdesc_t *, pid_t);
23992399-} dtrace_mops_t;
24002400-24012401-typedef uintptr_t dtrace_meta_provider_id_t;
24022402-24032403-extern int dtrace_meta_register(const char *, const dtrace_mops_t *, void *,
24042404- dtrace_meta_provider_id_t *);
24052405-extern int dtrace_meta_unregister(dtrace_meta_provider_id_t);
24062406-24072407-/*
24082408- * DTrace Kernel Hooks
24092409- *
24102410- * The following functions are implemented by the base kernel and form a set of
24112411- * hooks used by the DTrace framework. DTrace hooks are implemented in either
24122412- * uts/common/os/dtrace_subr.c, an ISA-specific assembly file, or in a
24132413- * uts/<platform>/os/dtrace_subr.c corresponding to each hardware platform.
24142414- */
24152415-24162416-typedef enum dtrace_vtime_state {
24172417- DTRACE_VTIME_INACTIVE = 0, /* No DTrace, no TNF */
24182418- DTRACE_VTIME_ACTIVE, /* DTrace virtual time, no TNF */
24192419- DTRACE_VTIME_INACTIVE_TNF, /* No DTrace, TNF active */
24202420- DTRACE_VTIME_ACTIVE_TNF /* DTrace virtual time _and_ TNF */
24212421-} dtrace_vtime_state_t;
24222422-24232423-extern dtrace_vtime_state_t dtrace_vtime_active;
24242424-extern void dtrace_vtime_switch(kthread_t *next);
24252425-extern void dtrace_vtime_enable_tnf(void);
24262426-extern void dtrace_vtime_disable_tnf(void);
24272427-extern void dtrace_vtime_enable(void);
24282428-extern void dtrace_vtime_disable(void);
24292429-24302430-#if !defined(__APPLE__)
24312431-struct regs;
24322432-24332433-extern int (*dtrace_pid_probe_ptr)(struct regs *);
24342434-extern int (*dtrace_return_probe_ptr)(struct regs *);
24352435-#else
24362436-#if defined (__i386__) || defined(__x86_64__)
24372437-extern int (*dtrace_pid_probe_ptr)(x86_saved_state_t *regs);
24382438-extern int (*dtrace_return_probe_ptr)(x86_saved_state_t* regs);
24392439-#else
24402440-#error architecture not supported
24412441-#endif
24422442-#endif /* __APPLE__ */
24432443-extern void (*dtrace_fasttrap_fork_ptr)(proc_t *, proc_t *);
24442444-extern void (*dtrace_fasttrap_exec_ptr)(proc_t *);
24452445-extern void (*dtrace_fasttrap_exit_ptr)(proc_t *);
24462446-extern void dtrace_fasttrap_fork(proc_t *, proc_t *);
24472447-24482448-typedef uintptr_t dtrace_icookie_t;
24492449-typedef void (*dtrace_xcall_t)(void *);
24502450-24512451-extern dtrace_icookie_t dtrace_interrupt_disable(void);
24522452-extern void dtrace_interrupt_enable(dtrace_icookie_t);
24532453-24542454-extern void dtrace_membar_producer(void);
24552455-extern void dtrace_membar_consumer(void);
24562456-24572457-extern void (*dtrace_cpu_init)(processorid_t);
24582458-#if !defined(__APPLE__)
24592459-extern void (*dtrace_modload)(struct modctl *);
24602460-extern void (*dtrace_modunload)(struct modctl *);
24612461-#else
24622462-extern int (*dtrace_modload)(struct kmod_info *, uint32_t);
24632463-extern int (*dtrace_modunload)(struct kmod_info *);
24642464-#endif /* __APPLE__ */
24652465-extern void (*dtrace_helpers_cleanup)(proc_t*);
24662466-extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child);
24672467-extern void (*dtrace_cpustart_init)(void);
24682468-extern void (*dtrace_cpustart_fini)(void);
24692469-24702470-extern void (*dtrace_kreloc_init)(void);
24712471-extern void (*dtrace_kreloc_fini)(void);
24722472-24732473-extern void (*dtrace_debugger_init)(void);
24742474-extern void (*dtrace_debugger_fini)(void);
24752475-extern dtrace_cacheid_t dtrace_predcache_id;
24762476-24772477-extern hrtime_t dtrace_gethrtime(void);
24782478-extern void dtrace_sync(void);
24792479-extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
24802480-extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
24812481-24822482-extern int dtrace_safe_defer_signal(void);
24832483-extern void dtrace_safe_synchronous_signal(void);
24842484-24852485-extern int dtrace_mach_aframes(void);
24862486-24872487-#if !defined(__APPLE__)
24882488-#if defined(__i386) || defined(__amd64)
24892489-extern int dtrace_instr_size(uchar_t *instr);
24902490-extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
24912491-extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t));
24922492-extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t));
24932493-extern void dtrace_invop_callsite(void);
24942494-#endif
24952495-24962496-#ifdef __sparc
24972497-extern int dtrace_blksuword32(uintptr_t, uint32_t *, int);
24982498-extern void dtrace_getfsr(uint64_t *);
24992499-#endif
25002500-#else
25012501-#if defined(__i386__) || defined(__x86_64__)
25022502-extern int dtrace_instr_size(uchar_t *instr);
25032503-extern int dtrace_instr_size_isa(uchar_t *, model_t, int *);
25042504-extern void dtrace_invop_add(int (*)(uintptr_t, uintptr_t *, uintptr_t));
25052505-extern void dtrace_invop_remove(int (*)(uintptr_t, uintptr_t *, uintptr_t));
25062506-extern void *dtrace_invop_callsite_pre;
25072507-extern void *dtrace_invop_callsite_post;
25082508-#endif
25092509-25102510-25112511-#undef proc_t
25122512-#endif /* __APPLE__ */
25132513-25142514-#define DTRACE_CPUFLAG_ISSET(flag) \
25152515- (cpu_core[CPU->cpu_id].cpuc_dtrace_flags & (flag))
25162516-25172517-#define DTRACE_CPUFLAG_SET(flag) \
25182518- (cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= (flag))
25192519-25202520-#define DTRACE_CPUFLAG_CLEAR(flag) \
25212521- (cpu_core[CPU->cpu_id].cpuc_dtrace_flags &= ~(flag))
25222522-25232523-#endif /* _KERNEL */
25242524-25252525-#endif /* _ASM */
25262526-25272527-#if !defined(__APPLE__)
25282528-#if defined(__i386) || defined(__amd64)
25292529-25302530-#define DTRACE_INVOP_PUSHL_EBP 1
25312531-#define DTRACE_INVOP_POPL_EBP 2
25322532-#define DTRACE_INVOP_LEAVE 3
25332533-#define DTRACE_INVOP_NOP 4
25342534-#define DTRACE_INVOP_RET 5
25352535-25362536-#endif
25372537-#else
25382538-#if defined(__i386__) || defined(__x86_64__)
25392539-25402540-#define DTRACE_INVOP_PUSHL_EBP 1
25412541-#define DTRACE_INVOP_POPL_EBP 2
25422542-#define DTRACE_INVOP_LEAVE 3
25432543-#define DTRACE_INVOP_NOP 4
25442544-#define DTRACE_INVOP_RET 5
25452545-25462546-#endif
25472547-25482548-25492549-#endif /* __APPLE__ */
25502550-25512551-#ifdef __cplusplus
25522552-}
25532553-#endif
25542554-25552555-#endif /* _SYS_DTRACE_H */