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"
32 #include "tnf_trace.h"
33 #include "tnf_types.h"
39 * tnf_probe_get_num_args: returns the number of arguments at probe site
40 * probe_p. This includes the first 2 args (tag and time delta) in the return
44 tnf_probe_get_num_args(tnf_probe_control_t
*probe_p
)
47 tnf_tag_data_t
***tag_p
;
49 tag_p
= probe_p
->slot_types
;
58 * tnf_probe_get_arg_indexed: returns a pointer into the buffer where
59 * argument i is stored. Returns NULL on error. Argument numbering is
60 * zero based i.e. to get the 3rd argument, the input value should be 2.
63 /* ALIGN_ROUNDUP: y has to be one less than a power of 2 eg. 3, 7, 15, etc. */
64 #define ALIGN_ROUNDUP(x, y) (((x) + (y)) & ~(y))
67 tnf_probe_get_arg_indexed(tnf_probe_control_t
*probe_p
, int index
, void *buffer
)
72 tnf_tag_data_t
***tag_ppp
;
73 tnf_tag_data_t
*tag_p
;
74 unsigned long offset
= 0;
76 tag_ppp
= probe_p
->slot_types
;
80 while (count
<= index
) {
81 /* error checking. REMIND: Do we need it ? */
88 offset
= offset
+ elem_size
;
89 align
= tag_p
->tag_align
- 1;
91 offset
= ALIGN_ROUNDUP(offset
, align
);
92 /* get size of current element */
93 elem_size
= tag_p
->tag_ref_size
;
98 return ((void *)((char *)buffer
+ offset
));
102 * tnf_probe_get_type_indexed: returns the type of the ith argument.
103 * returns TNF_UNKNOWN on error. Argument numbering is zero based
104 * i.e. to get the 3rd argument, the input value should be 2.
108 tnf_probe_get_type_indexed(tnf_probe_control_t
*probe_p
, int index
)
110 tnf_tag_data_t
***tag_ppp
;
111 tnf_tag_data_t
*tag_p
;
113 tag_ppp
= probe_p
->slot_types
+ index
;
115 return (TNF_UNKNOWN
);
117 return (TNF_UNKNOWN
);
120 return (TNF_UNKNOWN
);
121 return (tag_p
->tag_kind
);
126 * tnf_probe_get_value: returns the start of the value string that is
127 * associated with the input attribute. The number of characters in the
128 * value is also returned as the final argument. The size return value
129 * indicates the length of the string that is valid. Returns NULL on no
134 tnf_probe_get_value(tnf_probe_control_t
*probe_p
, char *attribute
,
138 const char *attr_start
, *attr_end
, *str_end
;
139 const char *val_start
;
144 input_len
= strlen(attribute
);
145 attr_start
= probe_p
->attrs
;
147 str_end
= attr_start
+ strlen(attr_start
);
148 separator
= ATTR_SEPARATOR
;
149 while (attr_start
< str_end
) {
150 attr_end
= strchr(attr_start
, separator
);
155 /* LINTED - result <= string length */
156 attr_len
= attr_end
- attr_start
;
158 /* skip over leading white space */
159 while (*attr_start
&& ((*attr_start
== ' ') ||
160 (*attr_start
== '\t'))) {
163 /* search for match on attribute */
164 if (strncmp(attr_start
, attribute
, input_len
) == 0) {
165 /* make sure next char is a space or semicolon */
166 val_start
= attr_start
+ input_len
;
167 if (*val_start
== ATTR_SEPARATOR
) {
170 } else if (*val_start
== VAL_SEPARATOR
) {
171 /* +1 for val separator */
172 *size
= attr_len
- (input_len
+ 1);
173 return (val_start
+ 1);
175 /* a false match - just continue */
177 /* skip to next attribute */
178 attr_start
= attr_end
+ 1;
185 /* used by in-process argument reader */
187 tnf_probe_get_chars(void *slot
)
192 ref
= *((tnf_reference_t
*)slot
);
193 assert(TNF_REF32_IS_FWD(ref
));
194 str_p
= (char *)slot
+ TNF_REF32_VALUE(ref
);
195 str_p
+= ARRAY_HDR_SIZE
;