summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris/uts/common/sys/fasttrap.h
blob: 7f803144bcf878a2db39b8f24dbc111330fb4d46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_FASTTRAP_H
#define	_SYS_FASTTRAP_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <sys/fasttrap_isa.h>
#include <sys/dtrace.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	FASTTRAPIOC		(('m' << 24) | ('r' << 16) | ('f' << 8))
#define	FASTTRAPIOC_MAKEPROBE	(FASTTRAPIOC | 1)
#define	FASTTRAPIOC_GETINSTR	(FASTTRAPIOC | 2)

typedef enum fasttrap_probe_type {
	DTFTP_NONE = 0,
	DTFTP_ENTRY,
	DTFTP_RETURN,
	DTFTP_OFFSETS,
	DTFTP_POST_OFFSETS,
	DTFTP_IS_ENABLED
} fasttrap_probe_type_t;

typedef struct fasttrap_probe_spec {
	pid_t			ftps_pid;
	fasttrap_probe_type_t	ftps_type;

	char			ftps_func[DTRACE_FUNCNAMELEN];
	char			ftps_mod[DTRACE_MODNAMELEN];

	uint64_t		ftps_pc;
	uint64_t		ftps_size;
	uint64_t		ftps_noffs;
	uint64_t		ftps_offs[1];
} fasttrap_probe_spec_t;

typedef struct fasttrap_instr_query {
	uint64_t		ftiq_pc;
	pid_t			ftiq_pid;
	fasttrap_instr_t	ftiq_instr;
} fasttrap_instr_query_t;

/*
 * To support the fasttrap provider from very early in a process's life,
 * the run-time linker, ld.so.1, has a program header of type PT_SUNWDTRACE
 * which points to a data object which must be PT_SUNWDTRACE_SIZE bytes.
 * This structure mimics the fasttrap provider section of the ulwp_t structure.
 * When the fasttrap provider is changed to require new or different
 * instructions, the data object in ld.so.1 and the thread initializers in libc
 * (libc_init() and _thrp_create()) need to be updated to include the new
 * instructions, and PT_SUNWDTRACE needs to be changed to a new unique number
 * (while the old value gets assigned something like PT_SUNWDTRACE_1). Since the
 * linker must be backward compatible with old Solaris releases, it must have
 * program headers for each of the PT_SUNWDTRACE versions. The kernel's
 * elfexec() function only has to look for the latest version of the
 * PT_SUNWDTRACE program header.
 */
#define	PT_SUNWDTRACE_SIZE	FASTTRAP_SUNWDTRACE_SIZE

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_FASTTRAP_H */
OpenPOWER on IntegriCloud