PERFORCE change 219861 for review

Brooks Davis brooks at FreeBSD.org
Wed Nov 28 21:33:52 UTC 2012


http://p4web.freebsd.org/@@219861?ac=10

Change 219861 by brooks at brooks_zenith on 2012/11/28 21:33:04

	Add verbosity controls to libimagebox, libcheri, and cheripoint.
	For now just push the same level down to all libraries.
	
	CheriPoint should now no longer spam the pictview console.

Affected files ...

.. //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/imagebox.h#4 edit
.. //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/pngbox.c#8 edit
.. //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#15 edit
.. //depot/projects/ctsrd/cheribsd/src/lib/libcheri/sandbox.c#2 edit
.. //depot/projects/ctsrd/cheribsd/src/lib/libcheri/sandbox.h#2 edit

Differences ...

==== //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/imagebox.h#4 (text+ko) ====

@@ -49,6 +49,8 @@
 	void			*private;
 };
 
+extern int ibox_verbose;
+
 void iboxstate_free(struct iboxstate *ps);
 
 struct iboxstate* png_read_start(int pfd, uint32_t maxw, uint32_t maxh,

==== //depot/projects/ctsrd/cheribsd/src/ctsrd-lib/libimagebox/pngbox.c#8 (text+ko) ====

@@ -51,6 +51,8 @@
 #include "iboxpriv.h"
 #include "sandbox.h"
 
+int ibox_verbose;
+
 struct pthr_decode_private
 {
 	pthread_t	pthr;
@@ -239,6 +241,9 @@
             sizeof(*is->buffer))) == NULL)
                 goto error;
 
+	if (ibox_verbose)
+		sb_verbose = ibox_verbose;
+
         if (sandbox_setup("/usr/libexec/readpng-cheri.bin", 4*1024*1024,
             &sandbox) < 0)
                 goto error;
@@ -262,7 +267,8 @@
 
         v = sandbox_invoke(sandbox, width, height, pnglen, 0,
             &c1, &c2, NULL, NULL, NULL, NULL, NULL);
-        printf("%s: sandbox returned %ju\n", __func__, (uintmax_t)v);
+	if (ibox_verbose)
+		printf("%s: sandbox returned %ju\n", __func__, (uintmax_t)v);
         sandbox_destroy(sandbox);
 	is->valid_rows = height;
 	is->passes_remaining = 0;

==== //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#15 (text+ko) ====

@@ -34,6 +34,9 @@
 #include <sys/sysctl.h>
 #include <sys/wait.h>
 
+#include <machine/cheri.h>
+#include <sandbox.h>
+
 #include <de4tc.h>
 #include <dirent.h>
 #include <err.h>
@@ -66,6 +69,7 @@
 	MTL_DM_640x480_CENTER	/* 640x480 VGA from 480p, center pixels */
 };
 
+int verbose = 0;
 int sb_vis = 0;
 uint32_t header_height;
 uint32_t *busyarea, *hourglass;
@@ -447,8 +451,6 @@
 	uint32_t r;
 	struct iboxstate *is;
 
-	printf("rendering cover\n");
-
 	busy(1);
 
 	if ((pfd = openat(dfd, cover, O_RDONLY)) == -1) {
@@ -504,8 +506,6 @@
 
 	error = 0;
 
-	printf("rendering slide %s\n", slide);
-
 	busy(1);
 
 	if ((pfd = openat(dfd, slide, O_RDONLY)) == -1) {
@@ -840,11 +840,14 @@
 	int slide, nslides, maxslides;
 	struct tsstate *ts, tshack = {0, 0, 0, 0, 0, 0,};
 
-	while ((ch = getopt(argc, argv, "f")) != -1) {
+	while ((ch = getopt(argc, argv, "fv")) != -1) {
 		switch (ch) {
 		case 'f':
 			forkflag = 1;
 			break;
+		case 'v':
+			verbose++;
+			break;
 		default:
 			usage();
 		}
@@ -852,6 +855,9 @@
 	argc -= optind;
 	argv += optind;
 
+	if (verbose)
+		ibox_verbose = verbose;
+
 	if (argc != 1)
 		usage();
 	
@@ -879,8 +885,6 @@
 	set_display_mode(res);
 	init_header_height();
 
-	printf("reading slides\n");
-
 	maxcovers = ncovers = 0;
 	maxslides = nslides = 0;
 	if ((dirp = opendir(argv[0])) == NULL)
@@ -898,7 +902,8 @@
 		else
 			addslide(&nslides, &maxslides, &slides, entry->d_name);
 	}
-	printf("read %d covers and %d slides\n", ncovers, nslides);
+	if (verbose)
+		printf("read %d covers and %d slides\n", ncovers, nslides);
 	qsort(slides, nslides, sizeof(*slides), &strpcmp);
 	qsort(covers, ncovers, sizeof(*covers), &strpcmp);
 	

==== //depot/projects/ctsrd/cheribsd/src/lib/libcheri/sandbox.c#2 (text+ko) ====

@@ -51,6 +51,8 @@
 #define	PAGE_SIZE	0x1000
 #define	STACK_SIZE	(32*PAGE_SIZE)
 
+int sb_verbose;
+
 /*
  * Library routine for setting up a sandbox.
  */
@@ -209,23 +211,25 @@
 	CHERI_CSC(10, 0, &sb->sb_segment, 0);
 	sb->sb_sandboxlen = sandboxlen;
 
-	printf("Sandbox configured:\n");
-	printf("  Path: %s\n", sb->sb_path);
-	printf("  Mem: %p\n", sb->sb_mem);
-	printf("  Len: %ju\n", (uintmax_t)sb->sb_sandboxlen);
-	printf("  Segment:\n");
-	CHERI_CGETTAG(v, 10);
-	printf("    t %u", (u_int)v);
-	CHERI_CGETUNSEALED(v, 10);
-	printf(" u %u", (u_int)v);
-	CHERI_CGETPERM(v, 10);
-	printf(" perms %04x", (u_int)v);
-	CHERI_CGETTYPE(v, 10);
-	printf(" otype %p\n", (void *)v);
-	CHERI_CGETBASE(v, 10);
-	printf("    base %p", (void *)v);
-	CHERI_CGETLEN(v, 10);
-	printf(" length %p\n", (void *)v);
+	if (sb_verbose) {
+		printf("Sandbox configured:\n");
+		printf("  Path: %s\n", sb->sb_path);
+		printf("  Mem: %p\n", sb->sb_mem);
+		printf("  Len: %ju\n", (uintmax_t)sb->sb_sandboxlen);
+		printf("  Segment:\n");
+		CHERI_CGETTAG(v, 10);
+		printf("    t %u", (u_int)v);
+		CHERI_CGETUNSEALED(v, 10);
+		printf(" u %u", (u_int)v);
+		CHERI_CGETPERM(v, 10);
+		printf(" perms %04x", (u_int)v);
+		CHERI_CGETTYPE(v, 10);
+		printf(" otype %p\n", (void *)v);
+		CHERI_CGETBASE(v, 10);
+		printf("    base %p", (void *)v);
+		CHERI_CGETLEN(v, 10);
+		printf(" length %p\n", (void *)v);
+	}
 
 	*sbp = sb;
 	return (0);

==== //depot/projects/ctsrd/cheribsd/src/lib/libcheri/sandbox.h#2 (text+ko) ====

@@ -31,6 +31,8 @@
 #ifndef _SANDBOX_H_
 #define	_SANDBOX_H_
 
+extern int sb_verbose;
+
 struct sandbox;
 int	sandbox_setup(const char *path, register_t sandboxlen,
 	    struct sandbox **sbp);


More information about the p4-projects mailing list