]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/fasttrap.h
xnu-2782.30.5.tar.gz
[apple/xnu.git] / bsd / sys / fasttrap.h
CommitLineData
2d21ac55
A
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef _SYS_FASTTRAP_H
28#define _SYS_FASTTRAP_H
29
30/* #pragma ident "@(#)fasttrap.h 1.5 06/03/30 SMI" */
31
32#include <sys/fasttrap_isa.h>
33#include <sys/dtrace.h>
34#include <sys/types.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#if !defined(__APPLE__)
41#define FASTTRAPIOC (('m' << 24) | ('r' << 16) | ('f' << 8))
42#else
43#define FASTTRAPIOC _IO('d', 0)
44#endif /* __APPLE__ */
45#define FASTTRAPIOC_MAKEPROBE (FASTTRAPIOC | 1)
46#define FASTTRAPIOC_GETINSTR (FASTTRAPIOC | 2)
47
48typedef enum fasttrap_probe_type {
49 DTFTP_NONE = 0,
50 DTFTP_ENTRY,
51 DTFTP_RETURN,
52 DTFTP_OFFSETS,
53 DTFTP_POST_OFFSETS,
54 DTFTP_IS_ENABLED
55} fasttrap_probe_type_t;
56
57#if defined(__APPLE__)
58typedef enum fasttrap_provider_type {
59 DTFTP_PROVIDER_NONE = 0,
60 DTFTP_PROVIDER_USDT,
61 DTFTP_PROVIDER_PID,
62 DTFTP_PROVIDER_OBJC,
63 DTFTP_PROVIDER_ONESHOT
64} fasttrap_provider_type_t;
65
66/* Moved from fasttrap.c */
67#define FASTTRAP_PID_NAME "pid"
68#define FASTTRAP_OBJC_NAME "objc"
69#define FASTTRAP_ONESHOT_NAME "oneshot"
70
71#endif
72
73typedef struct fasttrap_probe_spec {
74 pid_t ftps_pid;
75#if defined(__APPLE__)
76 fasttrap_provider_type_t ftps_provider_type;
77 fasttrap_probe_type_t ftps_probe_type;
78#endif
79 char ftps_func[DTRACE_FUNCNAMELEN];
80 char ftps_mod[DTRACE_MODNAMELEN];
81
b0d623f7
A
82#if defined(__APPLE__)
83#if !defined(__LP64__)
84 uint32_t pad; /* Explicit pad to keep ILP32 and LP64 lined up. */
85#endif
86#endif
2d21ac55
A
87 uint64_t ftps_pc;
88 uint64_t ftps_size;
89 uint64_t ftps_noffs;
90 uint64_t ftps_offs[1];
91} fasttrap_probe_spec_t;
92
93typedef struct fasttrap_instr_query {
94 uint64_t ftiq_pc;
95 pid_t ftiq_pid;
96 fasttrap_instr_t ftiq_instr;
97} fasttrap_instr_query_t;
98
99/*
100 * To support the fasttrap provider from very early in a process's life,
101 * the run-time linker, ld.so.1, has a program header of type PT_SUNWDTRACE
102 * which points to a data object which must be PT_SUNWDTRACE_SIZE bytes.
103 * This structure mimics the fasttrap provider section of the ulwp_t structure.
104 * When the fasttrap provider is changed to require new or different
105 * instructions, the data object in ld.so.1 and the thread initializers in libc
106 * (libc_init() and _thrp_create()) need to be updated to include the new
107 * instructions, and PT_SUNWDTRACE needs to be changed to a new unique number
108 * (while the old value gets assigned something like PT_SUNWDTRACE_1). Since the
109 * linker must be backward compatible with old Solaris releases, it must have
110 * program headers for each of the PT_SUNWDTRACE versions. The kernel's
111 * elfexec() function only has to look for the latest version of the
112 * PT_SUNWDTRACE program header.
113 */
114#define PT_SUNWDTRACE_SIZE FASTTRAP_SUNWDTRACE_SIZE
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif /* _SYS_FASTTRAP_H */