4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
35 #include <tnf/writer.h>
36 #include <tnf/probe.h>
39 #include "tnf_types.h"
40 #include "tnf_trace.h"
49 #endif /* TNFW_DEBUG */
57 #define TNF_ASSERT(expr) ASSERT(expr)
59 #define TNF_ASSERT(expr) assert(expr)
63 * New properties need for tracing
66 static tnf_tag_data_t
**derived_tagarg_properties
[] = {
67 &TAG_DATA(tnf_derived
),
68 &TAG_DATA(tnf_tag_arg
),
72 static tnf_tag_data_t
***derived_tagarg_properties_ptr
=
73 derived_tagarg_properties
;
76 * New derived types for probes
79 TNF_STD_DERIVED_TAG(tnf_probe_event
, tnf_tag
,
80 derived_tagarg_properties_ptr
, TNF_OPAQUE
);
82 TNF_STD_DERIVED_TAG(tnf_time_base
, tnf_int64
,
83 tnf_derived_properties
, TNF_INT64
);
85 TNF_STD_DERIVED_TAG(tnf_time_delta
, tnf_uint32
,
86 tnf_derived_properties
, TNF_UINT32
);
88 TNF_STD_DERIVED_TAG(tnf_pid
, tnf_int32
,
89 tnf_derived_properties
, TNF_INT32
);
91 TNF_STD_DERIVED_TAG(tnf_lwpid
, tnf_uint32
,
92 tnf_derived_properties
, TNF_UINT32
);
95 * Schedule records -CAUTION- keep in sync with tnf_internal.h
96 * Note that tnf_schedule_prototype_t has different sizes for
100 static char *user_schedule_slot_names
[] = {
108 static tnf_tag_data_t
**user_schedule_slots
[] = {
109 &TAG_DATA(tnf_tag
), /* tag */
110 &TAG_DATA(tnf_uint32
), /* tid XXX */
111 &TAG_DATA(tnf_lwpid
), /* lwpid */
112 &TAG_DATA(tnf_pid
), /* pid */
113 &TAG_DATA(tnf_time_base
), /* time_base */
116 TNF_STD_STRUCT_TAG(tnf_sched_rec
,
118 user_schedule_slot_names
,
119 sizeof (tnf_schedule_prototype_t
));
122 * Probe type record (metatag)
125 static tnf_tag_data_t
**probe_type_slots
[] = {
128 &TAG_DATA(tnf_properties
),
129 &TAG_DATA(tnf_slot_types
),
130 &TAG_DATA(tnf_type_size
),
131 &TAG_DATA(tnf_slot_names
),
132 &TAG_DATA(tnf_string
), /* detail */
135 TNF_STRUCT_TAG(tnf_probe_type
,
139 sizeof (tnf_probe_prototype_t
));
145 TAG_EXPORT(tnf_probe_event
);
146 TAG_EXPORT(tnf_time_base
);
147 TAG_EXPORT(tnf_time_delta
);
149 TAG_EXPORT(tnf_lwpid
);
151 TAG_EXPORT(tnf_sched_rec
);
152 TAG_EXPORT(tnf_probe_type
);
155 * Write a schedule record
156 * Can only be written in reusable data space.
160 tnf_schedule_write(tnf_ops_t
*ops
, tnf_schedule_t
*sched
)
162 tnf_tag_data_t
*metatag_data
;
163 tnf_record_p metatag_index
;
164 tnf_schedule_prototype_t
*buffer
;
167 fprintf(stderr
, "tnf_schedule_write: \n");
169 /* Cannot be called when writing into tag space */
170 TNF_ASSERT(ops
->mode
== TNF_ALLOC_REUSABLE
);
171 ALLOC(ops
, sizeof (*buffer
), buffer
, sched
->record_p
, ops
->mode
);
173 metatag_data
= TAG_DATA(tnf_sched_rec
);
175 metatag_index
= metatag_data
->tag_index
?
176 metatag_data
->tag_index
:
177 metatag_data
->tag_desc(ops
, metatag_data
);
179 ASSIGN(buffer
, tag
, metatag_index
);
180 /* LINTED - tid is 32 bits */
181 ASSIGN2(buffer
, tid
, sched
->tid
, uint32
);
182 /* LINTED - lwpid is 32 bits */
183 ASSIGN(buffer
, lwpid
, sched
->lwpid
);
184 /* LINTED - pid is 32 bits */
185 ASSIGN(buffer
, pid
, sched
->pid
);
186 ASSIGN(buffer
, time_base
, sched
->time_base
);
189 * Remember schedule record generation number so the distance
190 * in virtual space can be calculated from an event record
192 sched
->record_gen
= ((tnf_block_header_t
*)
193 ((uintptr_t)buffer
& TNF_BLOCK_MASK
))->generation
;
194 /* Cannot have been written into tag space */
195 TNF_ASSERT(sched
->record_gen
!= TNF_TAG_GENERATION_NUM
);
197 return ((tnf_record_p
) buffer
);