xref: /titanic_52/usr/src/lib/libtnfprobe/tnf_trace.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  *      Copyright (c) 1994, by Sun Microsytems, Inc.
24*7c478bd9Sstevel@tonic-gate  */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #ifndef _TNF_TRACE_H
27*7c478bd9Sstevel@tonic-gate #define	_TNF_TRACE_H
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #include <tnf/probe.h>
32*7c478bd9Sstevel@tonic-gate #include "tnf_buf.h"
33*7c478bd9Sstevel@tonic-gate #include "tnf_types.h"
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
36*7c478bd9Sstevel@tonic-gate extern "C" {
37*7c478bd9Sstevel@tonic-gate #endif
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate /*
40*7c478bd9Sstevel@tonic-gate  * Size of a TNF buffer block
41*7c478bd9Sstevel@tonic-gate  */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #define	TNF_BLOCK_SIZE 	512
44*7c478bd9Sstevel@tonic-gate #define	TNF_BLOCK_MASK	~(TNF_BLOCK_SIZE - 1)
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /*
47*7c478bd9Sstevel@tonic-gate  * Size of TNF file directory area
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #define	TNF_DIRECTORY_SIZE	(1 << 16)
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate /*
53*7c478bd9Sstevel@tonic-gate  * specification of index field of probe control block
54*7c478bd9Sstevel@tonic-gate  */
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_TYPE_MASK	0x3
57*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_MEM_PTR	0x0	/* index is a normal memory ptr */
58*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_FILE_PTR	0x1	/* index is a file abs ptr */
59*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_LOW_MASK	0xffff0000
60*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_SHIFT	16
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate #define	PROBE_IS_FILE_PTR(x)	\
63*7c478bd9Sstevel@tonic-gate 	(((x) & PROBE_INDEX_TYPE_MASK) == PROBE_INDEX_FILE_PTR)
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #define	ATTR_SEPARATOR		';'
66*7c478bd9Sstevel@tonic-gate #define	VAL_SEPARATOR		' '
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate typedef struct {
69*7c478bd9Sstevel@tonic-gate 	tnf_record_p		record_p;
70*7c478bd9Sstevel@tonic-gate 	tnf_uint32_t		record_gen;
71*7c478bd9Sstevel@tonic-gate 	unsigned long		tid;
72*7c478bd9Sstevel@tonic-gate 	unsigned long		lwpid;
73*7c478bd9Sstevel@tonic-gate 	long			pid;
74*7c478bd9Sstevel@tonic-gate 	hrtime_t		time_base;
75*7c478bd9Sstevel@tonic-gate } tnf_schedule_t;
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate typedef struct {
78*7c478bd9Sstevel@tonic-gate 	tnf_tag_t		tag;
79*7c478bd9Sstevel@tonic-gate 	tnf_uint32_t		tid;
80*7c478bd9Sstevel@tonic-gate 	tnf_uint32_t		lwpid;
81*7c478bd9Sstevel@tonic-gate 	pid_t			pid;
82*7c478bd9Sstevel@tonic-gate 	/*
83*7c478bd9Sstevel@tonic-gate 	 * time base should be on a double word boundary to avoid pads
84*7c478bd9Sstevel@tonic-gate 	 */
85*7c478bd9Sstevel@tonic-gate 	tnf_longlong_t	time_base;
86*7c478bd9Sstevel@tonic-gate } tnf_schedule_prototype_t;
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate typedef struct {
89*7c478bd9Sstevel@tonic-gate 	tnf_tag_t		tag;
90*7c478bd9Sstevel@tonic-gate 	tnf_name_t		name;
91*7c478bd9Sstevel@tonic-gate 	tnf_properties_t	properties;
92*7c478bd9Sstevel@tonic-gate 	tnf_slot_types_t	slot_types;
93*7c478bd9Sstevel@tonic-gate 	tnf_type_size_t		type_size;
94*7c478bd9Sstevel@tonic-gate 	tnf_slot_names_t	slot_names;
95*7c478bd9Sstevel@tonic-gate 	tnf_string_t		string;
96*7c478bd9Sstevel@tonic-gate } tnf_probe_prototype_t;
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate /*
99*7c478bd9Sstevel@tonic-gate  * TNF output ops
100*7c478bd9Sstevel@tonic-gate  */
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate /*
103*7c478bd9Sstevel@tonic-gate  * Data structure that is the glue between the tnf layer and the buffering
104*7c478bd9Sstevel@tonic-gate  * layer.
105*7c478bd9Sstevel@tonic-gate  */
106*7c478bd9Sstevel@tonic-gate struct _tnf_ops {
107*7c478bd9Sstevel@tonic-gate 	/* fields needed by TNF writing layer */
108*7c478bd9Sstevel@tonic-gate 	enum tnf_alloc_mode mode;
109*7c478bd9Sstevel@tonic-gate 	void * (*alloc)(TNFW_B_WCB *, size_t, enum tnf_alloc_mode);
110*7c478bd9Sstevel@tonic-gate 	TNFW_B_STATUS (*commit)(TNFW_B_WCB *);
111*7c478bd9Sstevel@tonic-gate 	TNFW_B_STATUS (*rollback)(TNFW_B_WCB *);
112*7c478bd9Sstevel@tonic-gate 	TNFW_B_WCB wcb;
113*7c478bd9Sstevel@tonic-gate 	/* fields needed by tracing allocation and final function */
114*7c478bd9Sstevel@tonic-gate 	int			busy;
115*7c478bd9Sstevel@tonic-gate 	tnf_schedule_t		schedule;
116*7c478bd9Sstevel@tonic-gate };
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate /*
119*7c478bd9Sstevel@tonic-gate  * Tag data variables
120*7c478bd9Sstevel@tonic-gate  */
121*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_probe_type_tag_data;
122*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_sched_rec_tag_data;
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate tnf_record_p 	tnf_schedule_write(tnf_ops_t *ops, tnf_schedule_t *sched);
125*7c478bd9Sstevel@tonic-gate uintptr_t 	tnf_probe_tag(tnf_ops_t *ops, tnf_probe_control_t *probe);
126*7c478bd9Sstevel@tonic-gate void		_tnf_sched_init(tnf_schedule_t *, hrtime_t);
127*7c478bd9Sstevel@tonic-gate int 		_tnf_trace_initialize(void);
128*7c478bd9Sstevel@tonic-gate void 		_tnf_fork_thread_setup(void);
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate extern char tnf_trace_file_name[];
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate /* PROJECT PRIVATE interfaces between prex and libtnfprobe */
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate void *tnf_trace_alloc(tnf_ops_t *, tnf_probe_control_t *, tnf_probe_setup_t *);
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate void tnf_trace_end(tnf_probe_setup_t *);
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate void tnf_trace_commit(tnf_probe_setup_t *);
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate void tnf_trace_rollback(tnf_probe_setup_t *);
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate void tnf_probe_debug(tnf_probe_setup_t *);
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
145*7c478bd9Sstevel@tonic-gate }
146*7c478bd9Sstevel@tonic-gate #endif
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate #endif /* _TNF_TRACE_H */
149