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"
43 #include <tnf/probe.h>
44 #include "tnf_trace.h"
48 * tnf_probe_debug() - a debug final function
51 #define BUF_LIMIT 1024
53 #define ATTR_LIMIT 128
56 * code coverage comment out
57 * #pragma covcc !instr
61 tnf_probe_debug(tnf_probe_setup_t
*set_p
)
63 char tmp_buf
[BUF_LIMIT
];
65 tnf_probe_control_t
*probe_p
;
66 const char *attr_start
, *name_start
, *name_end
;
68 int num_args
, i
, str_len
, name_len
;
70 tnf_arg_kind_t arg_type
;
74 probe_p
= set_p
->probe_p
;
75 buffer
= set_p
->buffer_p
;
77 /* get the name of the probe */
78 attr_start
= tnf_probe_get_value(probe_p
, "name", &attr_len
);
80 attr_len
= (attr_len
> (NAME_LIMIT
- 1)) ? (NAME_LIMIT
- 1) : attr_len
;
81 str_len
= sprintf(buf_p
, "probe %.*s; ", attr_len
, attr_start
);
84 /* get the sunw%debug attribute */
85 attr_start
= tnf_probe_get_value(probe_p
, "sunw%debug", &attr_len
);
87 attr_len
= (attr_len
> (ATTR_LIMIT
- 1)) ?
88 (ATTR_LIMIT
- 1) : attr_len
;
89 str_len
= sprintf(buf_p
, "sunw%%debug \"%.*s\"; ",
90 attr_len
, attr_start
);
94 /* number of args ? we are done if there are only standard args */
95 num_args
= tnf_probe_get_num_args(probe_p
);
97 (void) sprintf(buf_p
, "\n");
98 (void) write(STDERR_FILENO
, tmp_buf
, strlen(tmp_buf
));
102 /* get the slot names */
103 name_start
= tnf_probe_get_value(probe_p
, "slots", &attr_len
);
106 num_args
= tnf_probe_get_num_args(probe_p
);
109 /* print each of the arguments to the probe */
110 for (i
= 2; i
< num_args
; i
++) {
111 /* find slot names - number of spaces is equal to number of args */
112 name_end
= strchr(name_start
, VAL_SEPARATOR
);
113 /* LINTED - result is <= string length */
114 name_len
= name_end
- name_start
;
115 name_len
= (name_len
> (NAME_LIMIT
- 1)) ?
116 (NAME_LIMIT
- 1) : name_len
;
117 str_len
= sprintf(buf_p
, "%.*s=", name_len
, name_start
);
119 name_start
= name_end
+ 1;
121 arg_position
= tnf_probe_get_arg_indexed(probe_p
, i
, buffer
);
122 arg_type
= tnf_probe_get_type_indexed(probe_p
, i
);
126 str_len
= sprintf(buf_p
, "<unknown>; ");
130 str_len
= sprintf(buf_p
, "%ld; ",
131 tnf_probe_get_int(arg_position
));
135 str_len
= sprintf(buf_p
, "%lu; ",
136 tnf_probe_get_uint(arg_position
));
140 /* LINTED malformed format string */
141 str_len
= sprintf(buf_p
, "%lld; ",
142 tnf_probe_get_longlong(arg_position
));
146 /* LINTED malformed format string */
147 str_len
= sprintf(buf_p
, "%llu; ",
148 tnf_probe_get_ulonglong(arg_position
));
152 str_len
= sprintf(buf_p
, "%f; ",
153 tnf_probe_get_float(arg_position
));
157 str_len
= sprintf(buf_p
, "%f; ",
158 tnf_probe_get_double(arg_position
));
162 attr_start
= tnf_probe_get_chars(arg_position
);
163 attr_len
= strlen(attr_start
);
164 attr_len
= (attr_len
> (ATTR_LIMIT
- 1)) ? (ATTR_LIMIT
- 1) :
166 str_len
= sprintf(buf_p
, "\"%.*s\"; ", attr_len
, attr_start
);
174 str_len
= sprintf(buf_p
, "0x%lx; ",
175 tnf_probe_get_ulong(arg_position
));
179 str_len
= sprintf(buf_p
, "<error>; ");
185 (void) sprintf(buf_p
, "\n");
186 (void) write(STDERR_FILENO
, tmp_buf
, strlen(tmp_buf
));
190 } /* end tnf_probe_debug */
194 * code coverage comment out
195 * #pragma covcc instr
200 * tnf_probe_empty() - an empty final function
205 tnf_probe_empty(tnf_probe_setup_t
*set_p
)
210 } /* end tnf_probe_empty */