PERFORCE change 130772 for review

John Birrell jb at FreeBSD.org
Wed Dec 12 17:18:30 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=130772

Change 130772 by jb at jb_freebsd1 on 2007/12/13 01:17:30

	Merge the DTrace changes from //depot/projects/dtrace/... back into the
	new incoming distribution sources from //depot/vendor/sun/...
	
	This is representative of the number of lines of diffs we will have
	to manage going forward. Many are just to make the code compile
	cleanly so that we can be sure that it is doing the right thing.
	Without that cleanup we can get into a lot of trouble with different
	ioctl API design differences, for instance. Compiler noise hides
	real problems.
	
	I hope to be able to set a WARNS level on the OpenSolaris code built
	into FreeBSD for DTrace so that we can detect when things break
	at compile time. That was what all the -Werror cleanups were about
	in current recently for the gcc version we are using. 4.2.whatever.

Affected files ...

.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/dtrace/dtrace.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/mdb/tools/common/die.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/mdb/tools/common/util.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/include/alist.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/include/sgs.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/tools/common/findprime.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/tools/common/sgsmsg.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/tools/common/string_table.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libctf/common/ctf_lib.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libctf/common/ctf_subr.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/drti.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_cc.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_cg.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_consume.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_dof.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_error.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_handle.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_ident.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_impl.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_lex.l#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_link.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_map.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_module.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_open.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_options.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_parser.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_pid.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_printf.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_proc.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_proc.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_program.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_provider.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_subr.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_work.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dtrace.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/mkerrtags.sh#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/mknames.sh#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/lib/libgen/common/gmatch.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/common/list.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/common/memory.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/alist.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/alist.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/barrier.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/barrier.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/ctf.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/ctftools.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/dwarf.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/hash.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/iidesc.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/input.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/merge.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/output.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/st_parse.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/stabs.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/strtab.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/strtab.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/tdata.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/traverse.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/traverse.h#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/cvt/util.c#2 edit
.. //depot/projects/opensolaris/src/contrib/opensolaris/tools/ctf/dump/dump.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/common/ctf/ctf_create.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/common/ctf/ctf_hash.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/common/ctf/ctf_impl.h#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/common/ctf/ctf_labels.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/common/ctf/ctf_lookup.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/common/ctf/ctf_open.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/common/ctf/ctf_types.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/uts/common/dtrace/dtrace.c#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/uts/common/sys/ctf.h#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/uts/common/sys/ctf_api.h#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/uts/common/sys/cyclic.h#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/uts/common/sys/dtrace.h#2 edit
.. //depot/projects/opensolaris/src/sys/contrib/opensolaris/uts/common/sys/dtrace_impl.h#2 edit

Differences ...

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

@@ -34,15 +34,20 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <string.h>
 #include <strings.h>
 #include <unistd.h>
 #include <limits.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <signal.h>
+#if defined(sun)
 #include <alloca.h>
+#endif
 #include <libgen.h>
+#if defined(sun)
 #include <libproc.h>
+#endif
 
 typedef struct dtrace_cmd {
 	void (*dc_func)(struct dtrace_cmd *);	/* function to compile arg */
@@ -92,8 +97,9 @@
 static int g_status = E_SUCCESS;
 static int g_grabanon = 0;
 static const char *g_ofile = NULL;
-static FILE *g_ofp = stdout;
+static FILE *g_ofp;
 static dtrace_hdl_t *g_dtp;
+#if defined(sun)
 static char *g_etcfile = "/etc/system";
 static const char *g_etcbegin = "* vvvv Added by DTrace";
 static const char *g_etcend = "* ^^^^ Added by DTrace";
@@ -108,6 +114,7 @@
 "* chapter of the Solaris Dynamic Tracing Guide for details.",
 "*",
 NULL };
+#endif
 
 static int
 usage(FILE *fp)
@@ -195,6 +202,10 @@
 static void
 dfatal(const char *fmt, ...)
 {
+#if !defined(sun)
+	char *p_errfile = NULL;
+	int errline = 0;
+#endif
 	va_list ap;
 
 	va_start(ap, fmt);
@@ -212,6 +223,17 @@
 		(void) fprintf(stderr, "%s\n",
 		    dtrace_errmsg(g_dtp, dtrace_errno(g_dtp)));
 	}
+#if !defined(sun)
+	dt_get_errloc(g_dtp, &p_errfile, &errline);
+	if (p_errfile != NULL)
+		printf("File '%s', line %d\n", p_errfile, errline);
+#endif
+
+	/*
+	 * Close the DTrace handle to ensure that any controlled processes are
+	 * correctly restored and continued.
+	 */
+	dtrace_close(g_dtp);
 
 	/*
 	 * Close the DTrace handle to ensure that any controlled processes are
@@ -372,6 +394,7 @@
 	free(buf);
 }
 
+#if defined(sun)
 static void
 etcsystem_prune(void)
 {
@@ -482,6 +505,7 @@
 
 	error("added forceload directives to %s\n", g_ofile);
 }
+#endif
 
 static void
 print_probe_info(const dtrace_probeinfo_t *p)
@@ -611,12 +635,26 @@
 	p = (uchar_t *)dof;
 	q = p + dof->dofh_loadsz;
 
+#if defined(sun)
 	oprintf("dof-data-%d=0x%x", n, *p++);
 
 	while (p < q)
 		oprintf(",0x%x", *p++);
 
 	oprintf(";\n");
+#else
+	/*
+	 * On FreeBSD, the DOF data is handled as a kernel environment (kenv)
+	 * string. We use two hex characters per DOF byte.
+	 */
+	oprintf("dof-data-%d=%02x", n, *p++);
+
+	while (p < q)
+		oprintf("%02x", *p++);
+
+	oprintf("\n");
+#endif
+
 	dtrace_dof_destroy(g_dtp, dof);
 }
 
@@ -741,6 +779,8 @@
 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;
 	char name[SIG2STR_MAX];
@@ -778,6 +818,7 @@
 		g_pslive--;
 		break;
 	}
+#endif
 }
 
 /*ARGSUSED*/
@@ -1159,6 +1200,7 @@
 	dtrace_optval_t opt;
 	dtrace_cmd_t *dcp;
 
+	g_ofp = stdout;
 	int done = 0, mode = 0;
 	int err, i;
 	char c, *p, **v;
@@ -1616,10 +1658,21 @@
 
 	case DMODE_ANON:
 		if (g_ofile == NULL)
+#if defined(sun)
 			g_ofile = "/kernel/drv/dtrace.conf";
+#else
+			/*
+			 * On FreeBSD, anonymous DOF data is written to
+			 * the DTrace DOF file that the boot loader will
+			 * read if booting with the DTrace option.
+			 */
+			g_ofile = "/boot/dtrace.dof";
+#endif
 
 		dof_prune(g_ofile); /* strip out any old DOF directives */
+#if defined(sun)
 		etcsystem_prune(); /* string out any forceload directives */
+#endif
 
 		if (g_cmdc == 0) {
 			dtrace_close(g_dtp);
@@ -1650,8 +1703,10 @@
 		 * that itself contains a #pragma D option quiet.
 		 */
 		error("saved anonymous enabling in %s\n", g_ofile);
+#if defined(sun)
 		etcsystem_add();
 		error("run update_drv(1M) or reboot to enable changes\n");
+#endif
 
 		dtrace_close(g_dtp);
 		return (g_status);

==== //depot/projects/opensolaris/src/contrib/opensolaris/cmd/mdb/tools/common/die.c#2 (text) ====

@@ -40,6 +40,9 @@
 {
 	va_list ap;
 	int err = errno;
+#if !defined(sun)
+	const char *progname = getprogname();
+#endif
 
 	(void) fprintf(stderr, "%s: ", progname);
 
@@ -51,13 +54,20 @@
 	if (format[strlen(format) - 1] != '\n')
 		(void) fprintf(stderr, ": %s\n", strerror(err));
 
+#if defined(__FreeBSD__)
+	exit(0);
+#else
 	exit(1);
+#endif
 }
 
 void
 elfdie(char *format, ...)
 {
 	va_list ap;
+#if !defined(sun)
+	const char *progname = getprogname();
+#endif
 
 	(void) fprintf(stderr, "%s: ", progname);
 
@@ -69,5 +79,9 @@
 	if (format[strlen(format) - 1] != '\n')
 		(void) fprintf(stderr, ": %s\n", elf_errmsg(elf_errno()));
 
+#if defined(__FreeBSD__)
+	exit(0);
+#else
 	exit(1);
+#endif
 }

==== //depot/projects/opensolaris/src/contrib/opensolaris/cmd/mdb/tools/common/util.h#2 (text) ====

@@ -40,7 +40,9 @@
 extern void die(char *, ...);
 extern void elfdie(char *, ...);
 
+#if defined(sun)
 extern const char *progname;
+#endif
 
 #ifdef __cplusplus
 }

==== //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/include/alist.h#2 (text) ====

@@ -39,7 +39,11 @@
 #endif
 
 #include <sys/types.h>
+#if defined(sun)
 #include <sys/machelf.h>
+#else
+#include <sys/elf.h>
+#endif
 
 #define	ALO_DATA	(sizeof (Alist) - sizeof (void *))
 

==== //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/include/sgs.h#2 (text) ====

@@ -35,7 +35,6 @@
 
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
-
 #ifdef	__cplusplus
 extern "C" {
 #endif
@@ -49,7 +48,11 @@
 
 #ifndef	_ASM
 #include <sys/types.h>
+#if defined(sun)
 #include <sys/machelf.h>
+#else
+#include <elf.h>
+#endif
 #include <stdlib.h>
 #include <libelf.h>
 #include <assert.h>

==== //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/tools/common/findprime.c#2 (text) ====

@@ -27,6 +27,7 @@
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <sys/types.h>
+#include <sgs.h>
 
 /*
  * function that will find a prime'ish number.  Usefull for

==== //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/tools/common/sgsmsg.c#2 (text) ====

@@ -67,6 +67,7 @@
  *		the data array being built in msg.c.  The index into this array
  *		becomes the `message' identifier created in the msg.h file.
  */
+
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include	<fcntl.h>
@@ -318,21 +319,21 @@
  * Dump contents of String Table to standard out
  */
 static void
-dump_stringtab(Str_tbl *stp)
+dump_stringtab(Str_tbl *dump_stp)
 {
 	uint_t	i;
 
-	if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
+	if ((dump_stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
 		(void) printf("uncompressed strings: %d\n",
-			stp->st_fullstringsize);
+			dump_stp->st_fullstringsize);
 		return;
 	}
 
 
-	for (i = 0; i < stp->st_hbckcnt; i++) {
+	for (i = 0; i < dump_stp->st_hbckcnt; i++) {
 		Str_hash	*sthash;
 		(void) printf("Bucket: [%3d]\n", i);
-		for (sthash = stp->st_hashbcks[i]; sthash;
+		for (sthash = dump_stp->st_hashbcks[i]; sthash;
 		    sthash = sthash->hi_next) {
 			uint_t		stroff;
 			stroff = sthash->hi_mstr->sm_stlen - sthash->hi_stlen;
@@ -350,7 +351,7 @@
 		}
 	}
 	(void) printf("fullstringsize: %d compressed: %d\n",
-		stp->st_fullstringsize, stp->st_stringsize);
+		dump_stp->st_fullstringsize, dump_stp->st_stringsize);
 }
 /*
  * Initialize the message definition header file stream.
@@ -552,7 +553,7 @@
 			return (1);
 		}
 		if (fddefs && fprintf(fddefs, "#define\t%s_SIZE\t%d\n",
-		    msg->ms_defn, strlen(msg->ms_message)) < 0) {
+		    msg->ms_defn, (int) strlen(msg->ms_message)) < 0) {
 			(void) fprintf(stderr, Errmsg_wrte,
 			    fldefs, strerror(errno));
 			return (1);
@@ -630,7 +631,7 @@
 }
 
 static int
-file()
+file(void)
 {
 	char	buffer[LINE_MAX], * token;
 	uint_t	bufsize;
@@ -646,8 +647,9 @@
 	line = 1;
 
 	while ((token = fgets(buffer, LINE_MAX, fddesc)) != NULL) {
-		char	defn[PATH_MAX], * _defn, * str;
-		int	len;
+		char	defn[PATH_MAX], * _defn;
+		const char *str;
+		int	len = 0;
 
 		switch (*token) {
 		case '#':
@@ -940,7 +942,7 @@
 					return (1);
 				}
 
-				if (len >= bufsize) {
+				if (len >= (int) bufsize) {
 					bufsize += LINE_MAX;
 					if ((token_buffer = realloc(
 					    token_buffer, bufsize)) == 0) {

==== //depot/projects/opensolaris/src/contrib/opensolaris/cmd/sgs/tools/common/string_table.c#2 (text) ====

@@ -28,6 +28,7 @@
 
 #include <string_table.h>
 #include <strings.h>
+#include <string.h>
 #include <sgs.h>
 #include <stdio.h>
 
@@ -124,12 +125,12 @@
 /* LINTLIBRARY */
 
 
-int
+static int
 strlen_compare(const void *elem1, const void *elem2)
 {
 	uint_t	l1, l2;
-	l1 = ((Stringelem *)elem1)->se_stlen;
-	l2 = ((Stringelem *)elem2)->se_stlen;
+	l1 = ((const Stringelem *)elem1)->se_stlen;
+	l2 = ((const Stringelem *)elem2)->se_stlen;
 
 	if (l1 == l2)
 		return (0);

==== //depot/projects/opensolaris/src/contrib/opensolaris/lib/libctf/common/ctf_lib.c#2 (text) ====

@@ -29,6 +29,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <sys/zmod.h>
 #include <ctf_impl.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -51,7 +52,11 @@
 static size_t _PAGESIZE;
 static size_t _PAGEMASK;
 
+#if defined(sun)
 #pragma init(_libctf_init)
+#else
+void    _libctf_init(void) __attribute__ ((constructor));
+#endif
 void
 _libctf_init(void)
 {
@@ -85,8 +90,8 @@
 	if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL)
 		return (ctf_set_open_errno(errp, ECTF_ZINIT));
 
-	zlib.z_uncompress = (int (*)()) dlsym(zlib.z_dlp, "uncompress");
-	zlib.z_error = (const char *(*)()) dlsym(zlib.z_dlp, "zError");
+	zlib.z_uncompress = (int (*)(uchar_t *, ulong_t *, const uchar_t *, ulong_t)) dlsym(zlib.z_dlp, "uncompress");
+	zlib.z_error = (const char *(*)(int)) dlsym(zlib.z_dlp, "zError");
 
 	if (zlib.z_uncompress == NULL || zlib.z_error == NULL) {
 		(void) dlclose(zlib.z_dlp);
@@ -220,7 +225,7 @@
 	 * If we have read enough bytes to form a CTF header and the magic
 	 * string matches, attempt to interpret the file as raw CTF.
 	 */
-	if (nbytes >= sizeof (ctf_preamble_t) &&
+	if (nbytes >= (ssize_t) sizeof (ctf_preamble_t) &&
 	    hdr.ctf.ctp_magic == CTF_MAGIC) {
 		if (hdr.ctf.ctp_version > CTF_VERSION)
 			return (ctf_set_open_errno(errp, ECTF_CTFVERS));
@@ -250,7 +255,7 @@
 	 * do our own largefile ELF processing, and convert everything to
 	 * GElf structures so that clients can operate on any data model.
 	 */
-	if (nbytes >= sizeof (Elf32_Ehdr) &&
+	if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) &&
 	    bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
 #ifdef	_BIG_ENDIAN
 		uchar_t order = ELFDATA2MSB;
@@ -262,7 +267,7 @@
 
 		void *strs_map;
 		size_t strs_mapsz;
-		const char *strs;
+		char *strs;
 
 		if (hdr.e32.e_ident[EI_DATA] != order)
 			return (ctf_set_open_errno(errp, ECTF_ENDIAN));
@@ -270,7 +275,7 @@
 			return (ctf_set_open_errno(errp, ECTF_ELFVERS));
 
 		if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS64) {
-			if (nbytes < sizeof (GElf_Ehdr))
+			if (nbytes < (ssize_t) sizeof (GElf_Ehdr))
 				return (ctf_set_open_errno(errp, ECTF_FMT));
 		} else {
 			Elf32_Ehdr e32 = hdr.e32;
@@ -321,7 +326,7 @@
 		strs_map = mmap64(NULL, strs_mapsz, PROT_READ, MAP_PRIVATE,
 		    fd, sp[hdr.e64.e_shstrndx].sh_offset & _PAGEMASK);
 
-		strs = (const char *)strs_map +
+		strs = (char *)strs_map +
 		    (sp[hdr.e64.e_shstrndx].sh_offset & ~_PAGEMASK);
 
 		if (strs_map == MAP_FAILED) {

==== //depot/projects/opensolaris/src/contrib/opensolaris/lib/libctf/common/ctf_subr.c#2 (text) ====

@@ -27,7 +27,6 @@
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <ctf_impl.h>
-#include <libctf.h>
 #include <sys/mman.h>
 #include <stdarg.h>
 
@@ -58,7 +57,7 @@
 
 /*ARGSUSED*/
 void
-ctf_free(void *buf, size_t size)
+ctf_free(void *buf, __unused size_t size)
 {
 	free(buf);
 }
@@ -66,7 +65,7 @@
 const char *
 ctf_strerror(int err)
 {
-	return (strerror(err));
+	return ((const char *) strerror(err));
 }
 
 /*PRINTFLIKE1*/

==== //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/drti.c#2 (text) ====

@@ -55,7 +55,7 @@
  *	DTRACE_DOF_INIT_DEVNAME		set the path to the helper node
  */
 
-static const char *devname = "/dev/dtrace/helper";
+static const char *devnamep = "/dev/dtrace/helper";
 static const char *olddevname = "/devices/pseudo/dtrace at 0:helper";
 
 static const char *modname;	/* Name of this load object */
@@ -86,6 +86,7 @@
 }
 
 #pragma init(dtrace_dof_init)
+
 static void
 dtrace_dof_init(void)
 {
@@ -141,10 +142,10 @@
 	}
 
 	if ((p = getenv("DTRACE_DOF_INIT_DEVNAME")) != NULL)
-		devname = p;
+		devnamep = p;
 
-	if ((fd = open64(devname, O_RDWR)) < 0) {
-		dprintf(1, "failed to open helper device %s", devname);
+	if ((fd = open64(devnamep, O_RDWR)) < 0) {
+		dprintf(1, "failed to open helper device %s", devnamep);
 
 		/*
 		 * If the device path wasn't explicitly set, try again with
@@ -153,10 +154,10 @@
 		if (p != NULL)
 			return;
 
-		devname = olddevname;
+		devnamep = olddevname;
 
-		if ((fd = open64(devname, O_RDWR)) < 0) {
-			dprintf(1, "failed to open helper device %s", devname);
+		if ((fd = open64(devnamep, O_RDWR)) < 0) {
+			dprintf(1, "failed to open helper device %s", devnamep);
 			return;
 		}
 	}
@@ -175,8 +176,8 @@
 {
 	int fd;
 
-	if ((fd = open64(devname, O_RDWR)) < 0) {
-		dprintf(1, "failed to open helper device %s", devname);
+	if ((fd = open64(devnamep, O_RDWR)) < 0) {
+		dprintf(1, "failed to open helper device %s", devnamep);
 		return;
 	}
 

==== //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c#2 (text) ====

@@ -32,7 +32,11 @@
 #include <unistd.h>
 #include <dt_impl.h>
 #include <assert.h>
+#if defined(sun)
 #include <alloca.h>
+#else
+#include <sys/sysctl.h>
+#endif
 #include <limits.h>
 
 #define	DTRACE_AHASHSIZE	32779		/* big 'ol prime */
@@ -54,7 +58,7 @@
 static void
 dt_aggregate_count(int64_t *existing, int64_t *new, size_t size)
 {
-	int i;
+	uint_t i;
 
 	for (i = 0; i < size / sizeof (int64_t); i++)
 		existing[i] = existing[i] + new[i];
@@ -192,9 +196,10 @@
 static int
 dt_aggregate_quantizedcmp(int64_t *lhs, int64_t *rhs)
 {
-	int nbuckets = DTRACE_QUANTIZE_NBUCKETS, i;
+	int nbuckets = DTRACE_QUANTIZE_NBUCKETS;
 	long double ltotal = 0, rtotal = 0;
 	int64_t lzero, rzero;
+	uint_t i;
 
 	for (i = 0; i < nbuckets; i++) {
 		int64_t bucketval = DTRACE_QUANTIZE_BUCKETVAL(i);
@@ -231,6 +236,8 @@
 static void
 dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data)
 {
+printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
+#ifdef DOODAD
 	uint64_t pid = data[0];
 	uint64_t *pc = &data[1];
 	struct ps_prochandle *P;
@@ -249,11 +256,14 @@
 
 	dt_proc_unlock(dtp, P);
 	dt_proc_release(dtp, P);
+#endif
 }
 
 static void
 dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data)
 {
+printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
+#ifdef DOODAD
 	uint64_t pid = data[0];
 	uint64_t *pc = &data[1];
 	struct ps_prochandle *P;
@@ -272,6 +282,7 @@
 
 	dt_proc_unlock(dtp, P);
 	dt_proc_release(dtp, P);
+#endif
 }
 
 static void
@@ -352,7 +363,11 @@
 
 	buf->dtbd_cpu = cpu;
 
+#if defined(sun)
 	if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, buf) == -1) {
+#else
+	if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, &buf) == -1) {
+#endif
 		if (errno == ENOENT) {
 			/*
 			 * If that failed with ENOENT, it may be because the
@@ -620,7 +635,7 @@
 		return (0);
 
 	for (i = 0; i < agp->dtat_ncpus; i++) {
-		if (rval = dt_aggregate_snap_cpu(dtp, agp->dtat_cpus[i]))
+		if ((rval = dt_aggregate_snap_cpu(dtp, agp->dtat_cpus[i])))
 			return (rval);
 	}
 
@@ -1094,7 +1109,7 @@
 
 	case DTRACE_AGGWALK_REMOVE: {
 		dtrace_aggdata_t *aggdata = &h->dtahe_data;
-		int i, max_cpus = agp->dtat_maxcpu;
+		int max_cpus = agp->dtat_maxcpu;
 
 		/*
 		 * First, remove this hash entry from its hash chain.

==== //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_cc.c#2 (text) ====

@@ -87,6 +87,7 @@
 #include <sys/wait.h>
 
 #include <assert.h>
+#include <string.h>
 #include <strings.h>
 #include <signal.h>
 #include <unistd.h>
@@ -1589,7 +1590,9 @@
 	char **argv = malloc(sizeof (char *) * (argc + 5));
 	FILE *ofp = tmpfile();
 
+#if defined(sun)
 	char ipath[20], opath[20]; /* big enough for /dev/fd/ + INT_MAX + \0 */
+#endif
 	char verdef[32]; /* big enough for -D__SUNW_D_VERSION=0x%08x + \0 */
 
 	struct sigaction act, oact;
@@ -1597,7 +1600,11 @@
 
 	int wstat, estat;
 	pid_t pid;
+#if defined(sun)
 	off64_t off;
+#else
+	off_t off = 0;
+#endif
 	int c;
 
 	if (argv == NULL || ofp == NULL) {
@@ -1624,8 +1631,10 @@
 		(void) fseeko64(ifp, off, SEEK_SET);
 	}
 
+#if defined(sun)
 	(void) snprintf(ipath, sizeof (ipath), "/dev/fd/%d", fileno(ifp));
 	(void) snprintf(opath, sizeof (opath), "/dev/fd/%d", fileno(ofp));
+#endif
 
 	bcopy(dtp->dt_cpp_argv, argv, sizeof (char *) * argc);
 
@@ -1633,6 +1642,7 @@
 	    "-D__SUNW_D_VERSION=0x%08x", dtp->dt_vmax);
 	argv[argc++] = verdef;
 
+#if defined(sun)
 	switch (dtp->dt_stdcmode) {
 	case DT_STDC_XA:
 	case DT_STDC_XT:
@@ -1645,6 +1655,9 @@
 
 	argv[argc++] = ipath;
 	argv[argc++] = opath;
+#else
+	argv[argc++] = "-P";
+#endif
 	argv[argc] = NULL;
 
 	/*
@@ -1671,6 +1684,12 @@
 	}
 
 	if (pid == 0) {
+#if !defined(sun)
+		if (isatty(fileno(ifp)) == 0)
+			lseek(fileno(ifp), off, SEEK_SET);
+		dup2(fileno(ifp), 0);
+		dup2(fileno(ofp), 1);
+#endif
 		(void) execvp(dtp->dt_cpp_path, argv);
 		_exit(errno == ENOENT ? 127 : 126);
 	}

==== //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_cg.c#2 (text) ====

@@ -267,7 +267,7 @@
 	 * properties are used to compute shift as USHIFT or SSHIFT, below.
 	 */
 	if (dnp->dn_flags & DT_NF_SIGNED) {
-#ifdef _BIG_ENDIAN
+#if BYTE_ORDER == _BIG_ENDIAN
 		shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY -
 		    mp->ctm_offset % NBBY;
 #else
@@ -281,7 +281,7 @@
 		instr = DIF_INSTR_FMT(DIF_OP_SRA, r1, r2, r1);
 		dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
 	} else {
-#ifdef _BIG_ENDIAN
+#if BYTE_ORDER == _BIG_ENDIAN
 		shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY -
 		    (mp->ctm_offset % NBBY + e.cte_bits);
 #else

==== //depot/projects/opensolaris/src/contrib/opensolaris/lib/libdtrace/common/dt_consume.c#2 (text) ====

@@ -33,7 +33,9 @@
 #include <limits.h>
 #include <assert.h>
 #include <ctype.h>
+#if defined(sun)
 #include <alloca.h>
+#endif
 #include <dt_impl.h>
 
 /*
@@ -521,7 +523,7 @@
 			return (dt_set_errno(dtp, EDT_BADSTACKPC));
 		}
 
-		if (pc == NULL)
+		if (pc == 0)
 			break;
 
 		addr += size;
@@ -566,6 +568,8 @@
 dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
     caddr_t addr, uint64_t arg)
 {
+printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
+#ifdef DOODAD
 	/* LINTED - alignment */
 	uint64_t *pc = (uint64_t *)addr;
 	uint32_t depth = DTRACE_USTACK_NFRAMES(arg);
@@ -609,8 +613,11 @@
 	if (P != NULL)
 		dt_proc_lock(dtp, P); /* lock handle while we perform lookups */
 
-	for (i = 0; i < depth && pc[i] != NULL; i++) {
+	for (i = 0; i < depth && pc[i] != 0; i++) {
+printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
+#ifdef DOODAD
 		const prmap_t *map;
+#endif
 
 		if ((err = dt_printf(dtp, fp, "%*s", indent, "")) < 0)
 			break;
@@ -627,6 +634,8 @@
 				(void) snprintf(c, sizeof (c),
 				    "%s`%s", dt_basename(objname), name);
 			}
+printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
+#ifdef DOODAD
 		} else if (str != NULL && str[0] != '\0' && str[0] != '@' &&
 		    (P != NULL && ((map = Paddr_to_map(P, pc[i])) == NULL ||
 		    (map->pr_mflags & MA_WRITE)))) {
@@ -644,9 +653,10 @@
 			 * case and we refuse to use the string.
 			 */
 			(void) snprintf(c, sizeof (c), "%s", str);
+#endif
 		} else {
 			if (P != NULL && Pobjname(P, pc[i], objname,
-			    sizeof (objname)) != NULL) {
+			    sizeof (objname)) != 0) {
 				(void) snprintf(c, sizeof (c), "%s`0x%llx",
 				    dt_basename(objname), (u_longlong_t)pc[i]);
 			} else {
@@ -693,11 +703,16 @@
 	}
 
 	return (err);
+#else
+return 0;
+#endif
 }
 
 static int
 dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act)
 {
+printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
+#ifdef DOODAD
 	/* LINTED - alignment */
 	uint64_t pid = ((uint64_t *)addr)[0];
 	/* LINTED - alignment */
@@ -729,11 +744,16 @@
 	} while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) >= n);
 
 	return (dt_printf(dtp, fp, format, s));
+#else
+return 0;
+#endif
 }
 
 int
 dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
 {
+printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__);
+#ifdef DOODAD
 	/* LINTED - alignment */
 	uint64_t pid = ((uint64_t *)addr)[0];
 	/* LINTED - alignment */
@@ -758,7 +778,7 @@
 	if (P != NULL)
 		dt_proc_lock(dtp, P); /* lock handle while we perform lookups */
 
-	if (P != NULL && Pobjname(P, pc, objname, sizeof (objname)) != NULL) {
+	if (P != NULL && Pobjname(P, pc, objname, sizeof (objname)) != 0) {
 		(void) snprintf(c, sizeof (c), "%s", dt_basename(objname));
 	} else {
 		(void) snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc);
@@ -772,6 +792,9 @@
 	}
 
 	return (err);
+#else
+return 0;
+#endif
 }
 
 static int
@@ -1724,13 +1747,20 @@
 	dt_begin_t begin;
 	processorid_t cpu = dtp->dt_beganon;
 	dtrace_bufdesc_t nbuf;
+#if !defined(sun)
+	dtrace_bufdesc_t *pbuf;
+#endif
 	int rval, i;
 	static int max_ncpus;
 	dtrace_optval_t size;
 
 	dtp->dt_beganon = -1;
 
+#if defined(sun)
 	if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
+#else
+	if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) {
+#endif
 		/*
 		 * We really don't expect this to fail, but it is at least
 		 * technically possible for this to fail with ENOENT.  In this
@@ -1792,7 +1822,12 @@
 		if (i == cpu)
 			continue;
 
+#if defined(sun)
 		if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &nbuf) == -1) {
+#else
+		pbuf = &nbuf;

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list