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