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 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
36 static char *g_progname;
39 probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *data)
46 (void) printf("\r%6d", ++g_count);
47 (void) fflush(stdout);
49 if (dtrace_probe_info(dtp, pdp, &p) != 0) {
50 (void) printf(" failed to get probe info for "
51 "%s:%s:%s:%s [%d]\n", pdp->dtpd_provider, pdp->dtpd_mod,
52 pdp->dtpd_func, pdp->dtpd_name, pdp->dtpd_id);
57 for (i = 0; i < p.dtp_argc; i++) {
58 if (p.dtp_argv[i].dtt_type == CTF_ERR) {
59 bzero(&arg, sizeof (dtrace_argdesc_t));
60 arg.dtargd_id = pdp->dtpd_id;
62 (void) ioctl(g_fd, DTRACEIOC_PROBEARG, &arg);
64 (void) printf(" failed to get types for args[%d] "
65 "of %s:%s:%s:%s [%d]: <%s> -> <%s>\n", i,
66 pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func,
67 pdp->dtpd_name, pdp->dtpd_id,
68 arg.dtargd_native, arg.dtargd_xlate);
75 } else if (g_verbose) {
76 (void) printf("%d args[%d] : %s\n", pdp->dtpd_id, i,
77 ctf_type_name(p.dtp_argv[i].dtt_ctfp,
78 p.dtp_argv[i].dtt_type, buf, sizeof (buf)));
86 main(int argc, char *argv[])
88 dtrace_probedesc_t pd, *pdp = NULL;
95 if ((dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) {
96 (void) fprintf(stderr, "%s: failed to open dtrace: %s\n",
97 g_progname, dtrace_errmsg(dtp, err));
101 while ((c = getopt(argc, argv, "evx:")) != -1) {
110 if ((p = strchr(optarg, '=')) != NULL)
113 if (dtrace_setopt(dtp, optarg, p) != 0) {
114 (void) fprintf(stderr, "%s: failed to set "
115 "option -x %s: %s\n", g_progname, optarg,
116 dtrace_errmsg(dtp, dtrace_errno(dtp)));
122 (void) fprintf(stderr, "Usage: %s [-ev] "
123 "[-x opt[=arg]] [probedesc]\n", g_progname);
132 if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, argv[0], &pd)) {
133 (void) fprintf(stderr, "%s: invalid probe description "
134 "%s: %s\n", g_progname, argv[0],
135 dtrace_errmsg(dtp, dtrace_errno(dtp)));
141 g_fd = dtrace_ctlfd(dtp);
142 (void) dtrace_probe_iter(dtp, pdp, probe, NULL);
145 (void) printf("\nTotal probes: %d\n", g_count);
146 (void) printf("Total errors: %d\n\n", g_errs);
148 return (g_errs != 0);