Index: utils/rpctrace.c
===================================================================
RCS file: /cvsroot/hurd/hurd/utils/rpctrace.c,v
retrieving revision 1.18
diff -u -p -r1.18 rpctrace.c
--- utils/rpctrace.c	14 Mar 2006 23:30:38 -0000	1.18
+++ utils/rpctrace.c	23 Nov 2006 00:18:34 -0000
@@ -36,6 +36,7 @@
 #include <sys/wait.h>
 #include <inttypes.h>
 #include <stddef.h>
+#include <ctype.h>
 
 const char *argp_program_version = STANDARD_HURD_VERSION (rpctrace);
 
@@ -546,7 +547,7 @@ print_contents (mach_msg_header_t *inp,
 		  /* XXX
 		   */
 		  fprintf (ostream,
-			   "\t\t[%d] = pass through port %d, type %d\n",
+			   "[%d] = pass through port %d, type %d",
 			   i, portnames[i], name);
 		  continue;
 		}
@@ -843,14 +844,15 @@ print_request_header (struct traced_info
   expected_reply_port = msg->msgh_local_port;
 
   if (receiver->name != 0)
-    fprintf (ostream, "%4s->", receiver->name);
-  else
-    fprintf (ostream, "%4u->", (unsigned int) receiver->pi.port_right);
-
+    fprintf (ostream, "%4s[", receiver->name); 
+  else 
+    fprintf (ostream, "Request Port Right(%4u  ) \n\trequest: ", (unsigned int) receiver->pi.port_right); 
+  
   if (msgname != 0)
-    fprintf (ostream, "%5s (", msgname);
-  else
-    fprintf (ostream, "%5u (", (unsigned int) msg->msgh_id);
+    fprintf (ostream, "%5s (", msgname); 
+  else 
+    fprintf (ostream, "%5u (", (unsigned int) msg->msgh_id); 
+
 }
 
 static void
@@ -871,7 +873,7 @@ print_reply_header (struct traced_info *
       /* We have printed a partial line for the request message,
 	 and now we have the corresponding reply.  */
       if (reply->Head.msgh_id == info->u.send_once.sent_msgid + 100)
-	fprintf (ostream, " = "); /* normal case */
+	fprintf (ostream, " \n\t  reply: "); /* normal case */
       else
 	/* This is not the proper reply message ID.  */
 	fprintf (ostream, " =(%u != %u) ",
@@ -920,6 +922,35 @@ print_reply_header (struct traced_info *
   expected_reply_port = MACH_PORT_NULL;
 }
 
+/*
+ * This should clean the output up a little making things look just that
+ * much nicer.
+ */
+int stripSpaces (char *old, char *new) {
+  int space = 0;
+  int n = 0;
+  int i = 0;
+
+  for (i = 0; old[i] != '\0'; i++) {
+    if (!isalpha (old[i])   && 
+	!isalnum (old[i])   && 
+	!ispunct (old[i])   &&
+	space == 0) {
+      new[n] = ' ';
+      space = 1;
+      ++n;
+    }
+    
+    if (isalpha (old[i]) ||
+	isalnum (old[i]) || 
+	ispunct (old[i])) {
+      new[n] = old[i];
+      space = 0;
+      ++n;
+    }
+  }
+  return 0;
+}
 
 static void
 print_data (mach_msg_type_name_t type,
@@ -933,7 +964,7 @@ print_data (mach_msg_type_name_t type,
       assert (eltsize == sizeof (mach_port_t));
       {
 	mach_msg_type_number_t i;
-	fprintf (ostream, "pn{");
+	fprintf (ostream, "port name{");
 	for (i = 0; i < nelt; ++i)
 	  {
 	    fprintf (ostream, "%*u", (i > 0) ? 4 : 3,
@@ -945,9 +976,20 @@ print_data (mach_msg_type_name_t type,
 
     case MACH_MSG_TYPE_STRING:
     case MACH_MSG_TYPE_CHAR:
-      fprintf (ostream, "\"%.*s\"",
-	       (int) (nelt * eltsize), (const char *) data);
-      return;
+      {
+	int dataLen = strlen ((const char *)data);
+	char *strippedData = (char *)malloc (dataLen + 1);
+	/*
+	 * Strip out all the spaces, and insert just one space
+	 * inbetween each data element.  This should make the
+	 * output look a little bit cleaner and not so spaced
+	 * out.
+	 */
+	stripSpaces ((const char *)data, strippedData);
+	fprintf (ostream, "\"%.*s\"",
+		 (int) (nelt * eltsize), (const char *) strippedData);
+	return;
+      }
 
 #if 0
     case MACH_MSG_TYPE_CHAR:
@@ -960,8 +1002,8 @@ print_data (mach_msg_type_name_t type,
 	mach_msg_type_number_t i;					      \
 	for (i = 0; i < nelt; ++i)					      \
 	  {								      \
-	    fprintf (ostream, "%s" fmt,					      \
-		     (i == 0 && nelt > 1) ? "{" : i > 0 ? " " : "",	      \
+	    fprintf (ostream, "%s" fmt,		        		      \
+		     (i == 0 && nelt > 1) ? "\n\tDATA{" : i > 0 ? ((i % 12) == 0) ? "\n\t" : " " : "",   \
 		     *(const ctype *) data);				      \
 	    data += eltsize;						      \
 	  }								      \
@@ -1036,9 +1078,11 @@ traced_spawn (char **argv, char **envp)
   if (pid < 0)
     error (2, errno, "task2pid");
 
+  /* Print the header. */
+  fprintf (ostream, "Tracing all RPC request and replies for task %s with pid %d\n\n", argv[0], (int) pid);
+    
   /* Create a trace wrapper for the task port.  */
   ti = new_send_wrapper (traced_task, &task_wrapper);/* consumes ref */
-  asprintf (&ti->name, "task%d", (int) pid);
 
   /* Replace the task's kernel port with the wrapper.  When this task calls
      `mach_task_self ()', it will get our wrapper send right instead of its
@@ -1160,16 +1204,17 @@ main (int argc, char **argv, char **envp
   {
     pid_t child, pid;
     int status;
+
     child = traced_spawn (cmd_argv, envp);
     pid = waitpid (child, &status, 0);
     sleep (1);			/* XXX gives other thread time to print */
     if (pid != child)
       error (1, errno, "waitpid");
     if (WIFEXITED (status))
-      fprintf (ostream, "Child %d exited with %d\n",
+      fprintf (ostream, "\nProcess %d exited with %d\n",
 	       pid, WEXITSTATUS (status));
     else
-      fprintf (ostream, "Child %d %s\n", pid, strsignal (WTERMSIG (status)));
+      fprintf (ostream, "\nProcess %d %s\n", pid, strsignal (WTERMSIG (status)));
   }
 
   return 0;
