4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
40 probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *data)
47 (void) printf("\r%6d", ++g_count);
48 (void) fflush(stdout);
50 if (dtrace_probe_info(dtp, pdp, &p) != 0) {
51 (void) printf(" failed to get probe info for "
52 "%s:%s:%s:%s [%d]\n", pdp->dtpd_provider, pdp->dtpd_mod,
53 pdp->dtpd_func, pdp->dtpd_name, pdp->dtpd_id);
58 for (i = 0; i < p.dtp_argc; i++) {
59 if (p.dtp_argv[i].dtt_type == CTF_ERR) {
60 bzero(&arg, sizeof (dtrace_argdesc_t));
61 arg.dtargd_id = pdp->dtpd_id;
63 (void) ioctl(g_fd, DTRACEIOC_PROBEARG, &arg);
65 (void) printf(" failed to get types for args[%d] "
66 "of %s:%s:%s:%s [%d]: <%s> -> <%s>\n", i,
67 pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func,
68 pdp->dtpd_name, pdp->dtpd_id,
69 arg.dtargd_native, arg.dtargd_xlate);
76 } else if (g_verbose) {
77 (void) printf("%d args[%d] : %s\n", pdp->dtpd_id, i,
78 ctf_type_name(p.dtp_argv[i].dtt_ctfp,
79 p.dtp_argv[i].dtt_type, buf, sizeof (buf)));
87 main(int argc, char *argv[])
89 dtrace_probedesc_t pd, *pdp = NULL;
94 if ((dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) {
95 (void) fprintf(stderr, "%s: failed to open dtrace: %s\n",
96 argv[0], dtrace_errmsg(dtp, err));
100 while ((c = getopt(argc, argv, "evx:")) != -1) {
109 if ((p = strchr(optarg, '=')) != NULL)
112 if (dtrace_setopt(dtp, optarg, p) != 0) {
113 (void) fprintf(stderr, "%s: failed to set "
114 "option -x %s: %s\n", argv[0], optarg,
115 dtrace_errmsg(dtp, dtrace_errno(dtp)));
121 (void) fprintf(stderr, "Usage: %s [-ev] "
122 "[-x opt[=arg]] [probedesc]\n", argv[0]);
131 if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, argv[1], &pd)) {
132 (void) fprintf(stderr, "%s: invalid probe description "
133 "%s: %s\n", argv[0], argv[1],
134 dtrace_errmsg(dtp, dtrace_errno(dtp)));
140 g_fd = dtrace_ctlfd(dtp);
141 (void) dtrace_probe_iter(dtp, pdp, probe, NULL);
144 (void) printf("\nTotal probes: %d\n", g_count);
145 (void) printf("Total errors: %d\n\n", g_errs);
147 return (g_errs != 0);