Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Apr 2006 23:11:17 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 95558 for review
Message-ID:  <200604182311.k3INBHAW059769@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95558

Change 95558 by jb@jb_freebsd2 on 2006/04/18 23:11:03

	Uncomment-out all but the body of one function (which requires access to
	process info and I need to start creating a FreeBSD-specific process library
	for).
	
	There are a few diagnostic printfs in here to remind me of things that are
	incomplete. This is still work-in-progress.
	
	It won't be long before a I can stop messing with this file.

Affected files ...

.. //depot/projects/dtrace/src/contrib/opensolaris/cmd/dtrace/dtrace.c#2 edit

Differences ...

==== //depot/projects/dtrace/src/contrib/opensolaris/cmd/dtrace/dtrace.c#2 (text) ====

@@ -213,7 +213,6 @@
 
 	va_end(ap);
 
-#ifdef DOODAD
 	if (fmt != NULL && fmt[strlen(fmt) - 1] != '\n') {
 		(void) fprintf(stderr, ": %s\n",
 		    dtrace_errmsg(g_dtp, dtrace_errno(g_dtp)));
@@ -221,7 +220,6 @@
 		(void) fprintf(stderr, "%s\n",
 		    dtrace_errmsg(g_dtp, dtrace_errno(g_dtp)));
 	}
-#endif
 
 	exit(E_ERROR);
 }
@@ -457,7 +455,6 @@
 static void
 etcsystem_add(void)
 {
-#ifdef DOODAD
 	const char *mods[20];
 	int nmods, line;
 
@@ -486,13 +483,11 @@
 		fatal("failed to close output file '%s'", g_ofile);
 
 	error("added forceload directives to %s\n", g_ofile);
-#endif
 }
 
 static void
 print_probe_info(const dtrace_probeinfo_t *p)
 {
-#ifdef DOODAD
 	char buf[BUFSIZ];
 	int i;
 
@@ -527,7 +522,6 @@
 		oprintf("\t\tNone\n");
 
 	oprintf("\n");
-#endif
 }
 
 /*ARGSUSED*/
@@ -545,10 +539,8 @@
 	oprintf("\n%s:%s:%s:%s\n",
 	    pdp->dtpd_provider, pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name);
 
-#ifdef DOODAD
 	if (dtrace_probe_info(dtp, pdp, &p) == 0)
 		print_probe_info(&p);
-#endif
 
 	*last = edp;
 	return (0);
@@ -562,7 +554,6 @@
 static void
 exec_prog(const dtrace_cmd_t *dcp)
 {
-#ifdef DOODAD
 	dtrace_ecbdesc_t *last = NULL;
 	dtrace_proginfo_t dpi;
 
@@ -605,7 +596,6 @@
 	}
 
 	g_total += dpi.dpi_matches;
-#endif
 }
 
 /*
@@ -615,7 +605,6 @@
 static void
 anon_prog(const dtrace_cmd_t *dcp, dof_hdr_t *dof, int n)
 {
-#ifdef DOODAD
 	const uchar_t *p, *q;
 
 	if (dof == NULL)
@@ -631,7 +620,6 @@
 
 	oprintf(";\n");
 	dtrace_dof_destroy(g_dtp, dof);
-#endif
 }
 
 /*
@@ -644,7 +632,6 @@
 static void
 link_prog(dtrace_cmd_t *dcp)
 {
-#ifdef DOODAD
 	char *p;
 
 	if (g_cmdc == 1 && g_ofile != NULL) {
@@ -662,14 +649,12 @@
 	if (dtrace_program_link(g_dtp, dcp->dc_prog, DTRACE_D_PROBES,
 	    dcp->dc_ofile, g_objc - 1, g_objv + 1) != 0)
 		dfatal("failed to link %s %s", dcp->dc_desc, dcp->dc_name);
-#endif
 }
 
 /*ARGSUSED*/
 static int
 list_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
 {
-#ifdef DOODAD
 	dtrace_probeinfo_t p;
 
 	oprintf("%5d %10s %17s %33s %s\n", pdp->dtpd_id,
@@ -677,7 +662,6 @@
 
 	if (g_verbose && dtrace_probe_info(dtp, pdp, &p) == 0)
 		print_probe_info(&p);
-#endif
 
 	return (0);
 }
@@ -710,18 +694,15 @@
 static void
 list_prog(const dtrace_cmd_t *dcp)
 {
-#ifdef DOODAD
 	dtrace_ecbdesc_t *last = NULL;
 
 	(void) dtrace_stmt_iter(g_dtp, dcp->dc_prog,
 	    (dtrace_stmt_f *)list_stmt, &last);
-#endif
 }
 
 static void
 compile_file(dtrace_cmd_t *dcp)
 {
-#ifdef DOODAD
 	char *arg0;
 	FILE *fp;
 
@@ -740,13 +721,11 @@
 
 	dcp->dc_desc = "script";
 	dcp->dc_name = dcp->dc_arg;
-#endif
 }
 
 static void
 compile_str(dtrace_cmd_t *dcp)
 {
-#ifdef DOODAD
 	char *p;
 
 	if ((dcp->dc_prog = dtrace_program_strcompile(g_dtp, dcp->dc_arg,
@@ -758,13 +737,13 @@
 
 	dcp->dc_desc = "description";
 	dcp->dc_name = dcp->dc_arg;
-#endif
 }
 
 /*ARGSUSED*/
 static void
 prochandler(struct ps_prochandle *P, const char *msg, void *arg)
 {
+fatal("DOODAD in function %s, file %s, line %d\n",__FUNCTION__,__FILE__,__LINE__);
 #ifdef DOODAD
 	const psinfo_t *prp = Ppsinfo(P);
 	int pid = Pstatus(P)->pr_pid;
@@ -1072,7 +1051,6 @@
 static void
 go(void)
 {
-#ifdef DOODAD
 	int i;
 
 	struct {
@@ -1164,7 +1142,6 @@
 		error("%s %s to once every %lld nanoseconds\n",
 		    rates[i].name, dir, (long long)nval);
 	}
-#endif
 }
 
 /*ARGSUSED*/
@@ -1306,7 +1283,6 @@
 	 * Open libdtrace.  If we are not actually going to be enabling any
 	 * instrumentation attempt to reopen libdtrace using DTRACE_O_NODEV.
 	 */
-#ifdef DOODAD
 	while ((g_dtp = dtrace_open(DTRACE_VERSION, g_oflags, &err)) == NULL) {
 		if (!(g_oflags & DTRACE_O_NODEV) && !g_exec && !g_grabanon) {
 			g_oflags |= DTRACE_O_NODEV;
@@ -1316,12 +1292,9 @@
 		fatal("failed to initialize dtrace: %s\n",
 		    dtrace_errmsg(NULL, err));
 	}
-#endif
 
-#ifdef DOODAD
 	(void) dtrace_setopt(g_dtp, "bufsize", "4m");
 	(void) dtrace_setopt(g_dtp, "aggsize", "4m");
-#endif
 
 	/*
 	 * If -G is specified, enable -xlink=dynamic and -xunodefs to permit
@@ -1329,7 +1302,6 @@
 	 * If -A is specified, enable -xlink=primary to permit static linking
 	 * only to kernel symbols that are defined in a primary kernel module.
 	 */
-#ifdef DOODAD
 	if (g_mode == DMODE_LINK) {
 		(void) dtrace_setopt(g_dtp, "linkmode", "dynamic");
 		(void) dtrace_setopt(g_dtp, "unodefs", NULL);
@@ -1343,7 +1315,6 @@
 		g_argc = 1;
 	} else if (g_mode == DMODE_ANON)
 		(void) dtrace_setopt(g_dtp, "linkmode", "primary");
-#endif
 
 	/*
 	 * Now that we have libdtrace open, make a second pass through argv[]
@@ -1355,18 +1326,14 @@
 		while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != EOF) {
 			switch (c) {
 			case 'a':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "grabanon", 0) != 0)
 					dfatal("failed to set -a");
-#endif
 				break;
 
 			case 'b':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp,
 				    "bufsize", optarg) != 0)
 					dfatal("failed to set -b %s", optarg);
-#endif
 				break;
 
 			case 'B':
@@ -1378,10 +1345,8 @@
 				break;
 
 			case 'D':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "define", optarg) != 0)
 					dfatal("failed to set -D %s", optarg);
-#endif
 				break;
 
 			case 'f':
@@ -1392,17 +1357,13 @@
 				break;
 
 			case 'F':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "flowindent", 0) != 0)
 					dfatal("failed to set -F");
-#endif
 				break;
 
 			case 'H':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "cpphdrs", 0) != 0)
 					dfatal("failed to set -H");
-#endif
 				break;
 
 			case 'i':
@@ -1413,17 +1374,13 @@
 				break;
 
 			case 'I':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "incdir", optarg) != 0)
 					dfatal("failed to set -I %s", optarg);
-#endif
 				break;
 
 			case 'L':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "libdir", optarg) != 0)
 					dfatal("failed to set -L %s", optarg);
-#endif
 				break;
 
 			case 'm':
@@ -1438,6 +1395,7 @@
 				dcp->dc_func = compile_str;
 				dcp->dc_spec = DTRACE_PROBESPEC_NAME;
 				dcp->dc_arg = optarg;
+printf("Compile '%s'\n",dcp->dc_arg);
 				break;
 
 			case 'P':
@@ -1448,10 +1406,8 @@
 				break;
 
 			case 'q':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "quiet", 0) != 0)
 					dfatal("failed to set -q");
-#endif
 				break;
 
 			case 'o':
@@ -1470,10 +1426,8 @@
 				break;
 
 			case 'U':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "undef", optarg) != 0)
 					dfatal("failed to set -U %s", optarg);
-#endif
 				break;
 
 			case 'v':
@@ -1481,27 +1435,21 @@
 				break;
 
 			case 'w':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "destructive", 0) != 0)
 					dfatal("failed to set -w");
-#endif
 				break;
 
 			case 'x':
 				if ((p = strchr(optarg, '=')) != NULL)
 					*p++ = '\0';
 
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, optarg, p) != 0)
 					dfatal("failed to set -x %s", optarg);
-#endif
 				break;
 
 			case 'X':
-#ifdef DOODAD
 				if (dtrace_setopt(g_dtp, "stdc", optarg) != 0)
 					dfatal("failed to set -X %s", optarg);
-#endif
 				break;
 
 			case 'Z':
@@ -1539,14 +1487,12 @@
 				if ((v = make_argv(optarg)) == NULL)
 					fatal("failed to allocate memory");
 
-#ifdef DOODAD
 				P = dtrace_proc_create(g_dtp, v[0], v);
 				if (P == NULL)
 					dfatal(NULL); /* dtrace_errmsg() only */
 
 				g_psv[g_psc++] = P;
 				free(v);
-#endif
 				break;
 
 			case 'p':
@@ -1556,13 +1502,11 @@
 				if (errno != 0 || p == optarg || p[0] != '\0')
 					fatal("invalid pid: %s\n", optarg);
 
-#ifdef DOODAD
 				P = dtrace_proc_grab(g_dtp, pid, 0);
 				if (P == NULL)
 					dfatal(NULL); /* dtrace_errmsg() only */
 
 				g_psv[g_psc++] = P;
-#endif
 				break;
 			}
 		}
@@ -1575,7 +1519,6 @@
 	for (i = 0; i < g_cmdc; i++)
 		g_cmdv[i].dc_func(&g_cmdv[i]);
 
-#ifdef DOODAD
 	if (g_mode != DMODE_LIST) {
 		if (dtrace_handle_err(g_dtp, &errhandler, NULL) == -1)
 			dfatal("failed to establish error handler");
@@ -1602,7 +1545,6 @@
 
 	(void) dtrace_getopt(g_dtp, "quiet", &opt);
 	g_quiet = opt != DTRACEOPT_UNSET;
-#endif
 
 	/*
 	 * Now make a fifth and final pass over the options that have been
@@ -1613,7 +1555,6 @@
 	 */
 	switch (g_mode) {
 	case DMODE_EXEC:
-#ifdef DOODAD
 		if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL)
 			fatal("failed to open output file '%s'", g_ofile);
 
@@ -1624,11 +1565,9 @@
 			dtrace_close(g_dtp);
 			return (g_status);
 		}
-#endif
 		break;
 
 	case DMODE_ANON:
-#ifdef DOODAD
 		if (g_ofile == NULL)
 			g_ofile = "/kernel/drv/dtrace.conf";
 
@@ -1668,11 +1607,9 @@
 		error("run update_drv(1M) or reboot to enable changes\n");
 
 		dtrace_close(g_dtp);
-#endif
 		return (g_status);
 
 	case DMODE_LINK:
-#ifdef DOODAD
 		if (g_cmdc == 0) {
 			(void) fprintf(stderr, "%s: -G requires one or more "
 			    "scripts or enabling options\n", g_pname);
@@ -1695,11 +1632,9 @@
 		}
 
 		dtrace_close(g_dtp);
-#endif
 		return (g_status);
 
 	case DMODE_LIST:
-#ifdef DOODAD
 		if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL)
 			fatal("failed to open output file '%s'", g_ofile);
 
@@ -1713,11 +1648,9 @@
 			(void) dtrace_probe_iter(g_dtp, NULL, list_probe, NULL);
 
 		dtrace_close(g_dtp);
-#endif
 		return (g_status);
 
 	case DMODE_HEADER:
-#ifdef DOODAD
 		if (g_cmdc == 0) {
 			(void) fprintf(stderr, "%s: -h requires one or more "
 			    "scripts or enabling options\n", g_pname);
@@ -1761,7 +1694,6 @@
 			dfatal("failed to create header file %s", g_ofile);
 
 		dtrace_close(g_dtp);
-#endif
 		return (g_status);
 	}
 
@@ -1778,7 +1710,6 @@
 	 */
 	go();
 
-#ifdef DOODAD
 	(void) dtrace_getopt(g_dtp, "flowindent", &opt);
 	g_flowindent = opt != DTRACEOPT_UNSET;
 
@@ -1791,7 +1722,6 @@
 	(void) dtrace_getopt(g_dtp, "destructive", &opt);
 	if (opt != DTRACEOPT_UNSET)
 		notice("allowing destructive actions\n");
-#endif
 
 	(void) sigemptyset(&act.sa_mask);
 	act.sa_flags = 0;
@@ -1808,14 +1738,11 @@
 	 * continue any grabbed or created processes, setting them running
 	 * using the /proc control mechanism inside of libdtrace.
 	 */
-#ifdef DOODAD
 	for (i = 0; i < g_psc; i++)
 		dtrace_proc_continue(g_dtp, g_psv[i]);
-#endif
 
 	g_pslive = g_psc; /* count for prochandler() */
 
-#ifdef DOODAD
 	do {
 		if (!g_intr && !done)
 			dtrace_sleep(g_dtp);
@@ -1850,11 +1777,9 @@
 		if (g_ofp != NULL && fflush(g_ofp) == EOF)
 			clearerr(g_ofp);
 	} while (!done);
-#endif
 
 	oprintf("\n");
 
-#ifdef DOODAD
 	if (!g_impatient) {
 		if (dtrace_aggregate_print(g_dtp, g_ofp, NULL) == -1 &&
 		    dtrace_errno(g_dtp) != EINTR)
@@ -1862,6 +1787,5 @@
 	}
 
 	dtrace_close(g_dtp);
-#endif
 	return (g_status);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604182311.k3INBHAW059769>