On Thu, Apr 5, 2018 at 11:20 AM, Charlie Sale <softwaresal...@gmail.com>
wrote:

> Hey Brent
>
> I would be willing to help with that project. I'll see what I can do to
> contribute.
>
> You said that you had some code written. Where can I find it? Is it in a
> branch on the main tree?
>

No, unfortunately.  Part of the reason is how we interact with Debian.  I
run a Debian/Hurd system, and there are Debian-specific patches that
haven't been incorporated into our main source tree.  Also, when you get a
Debian source tree, it doesn't come with any git version control
information.  If I worked on our git tree, then I'd have to figure how to
apply the Debian patches to get something that actually runs right.  So, I
tend to work on the Debian-ized source tree, without any version control
per se.  It's not ideal.

I'm attaching a patch with the work I've done so far on the tracing
facility.  It doesn't really do anything, yet, just adds a new system port
to each task, and a first crack at a subroutine to create trace messages,
but if you read the design message I sent to the list, you'll see that the
subroutine isn't as sophisticated as I'm now thinking it needs to be.

Also, I should mention that a major issue on the mailing list for the last
two months has been upstreaming glibc.  It's again related to how we
interact with Debian.  There are so many Hurd-specific, Debian-specific
changes to glibc, that the Debian maintainers have threatened to drop us
completely unless we get our code upstreamed into the main glibc code
base.  I'm not working on that code, because the Free Software Foundation
wants me to sign a copyright assignment whose language I object to, but if
you're willing to sign the copyright assignment, I'm sure Samuel Thibault
would appreciate some help with that.  It's a bit of a mess, while the
project that I'm proposing is more self-contained, but you should know that
there's at least one other ongoing project we could use help with.

I'm hoping the copyright assignment won't be an issue with the kernel
proper, since it's based on Mach and isn't owned by the FSF, but I'm not
100% of that.

Also, I gave a lecture on Hurd a few months ago that might interest you.
It's an hour and half, and the first part talks about generic HPC issues,
but the second part goes into some detail about how Hurd is designed, and
my own vision for what I'm trying to do with it.  I've got a screencast on
youtube, if you're interested:

https://www.youtube.com/watch?v=JwsuAEF2FYE

<https://www.youtube.com/watch?v=JwsuAEF2FYE>

<https://www.youtube.com/watch?v=JwsuAEF2FYE>

> Also, would you recommend developing in a GNU/Hurd environment as opposed
> to a GNU/Linux environment? I tried running Debian GNU/Hurd in qemu, but I
> had some major troubles with that (keyboard didn't work at all). Should I
> request an account on the main Hurd machine?
>

I agree with Samuel that qemu is the way to go.  I use Hurd exclusively in
qemu, with Linux running on my bare metal.  Don't try to run Hurd bare
metal.  We're not likely to have device drivers to support all of your
hardware, plus if you're going to do kernel work, you really want to have
it in a virtual machine so you can run gdb on the kernel.

We think your keyboard should work!  Once you get it up and running,
though, I don't use its console for day-to-day work.  I ssh into it.


> I am excited to try to help!
>
> Thanks!
> Charlie
>
>
diff -ur -x 'Makefile*' -x debian -x configure -x config.sub -x config.guess gnumach-1.8+git20171101/include/mach/task_special_ports.h mnt/root/gnumach-1.8+git20171101/include/mach/task_special_ports.h
--- gnumach-1.8+git20171101/include/mach/task_special_ports.h	2014-03-17 14:29:32.000000000 -0400
+++ mnt/root/gnumach-1.8+git20171101/include/mach/task_special_ports.h	2018-03-06 22:31:19.000000000 -0500
@@ -40,6 +40,8 @@
 #define TASK_EXCEPTION_PORT	3	/* Exception messages for task are
 					   sent to this port. */
 #define TASK_BOOTSTRAP_PORT	4	/* Bootstrap environment for task. */
+#define TASK_TRACE_PORT		5	/* Trace port that receives a copy
+                                           of all messages sent to/from task. */
 
 /*
  *	Definitions for ease of use
@@ -63,4 +65,10 @@
 #define task_set_bootstrap_port(task, port)	\
 		(task_set_special_port((task), TASK_BOOTSTRAP_PORT, (port)))
 
+#define task_get_trace_port(task, port)	\
+		(task_get_special_port((task), TASK_TRACE_PORT, (port)))
+
+#define task_set_trace_port(task, port)	\
+		(task_set_special_port((task), TASK_TRACE_PORT, (port)))
+
 #endif	/* _MACH_TASK_SPECIAL_PORTS_H_ */
diff -ur -x 'Makefile*' -x debian -x configure -x config.sub -x config.guess gnumach-1.8+git20171101/ipc/ipc_kmsg.c mnt/root/gnumach-1.8+git20171101/ipc/ipc_kmsg.c
--- gnumach-1.8+git20171101/ipc/ipc_kmsg.c	2016-12-19 09:53:33.000000000 -0500
+++ mnt/root/gnumach-1.8+git20171101/ipc/ipc_kmsg.c	2018-03-07 00:08:16.000000000 -0500
@@ -2627,6 +2627,73 @@
 	}
 }
 
+/*
+ *	Routine:	ipc_kmsg_trace
+ *	Purpose:
+ *		If the current task has a trace port set, send a duplicate
+ *		copy of the message to the trace port.
+ *	Conditions:
+ *		Nothing locked.
+ */
+
+typedef struct {
+	mach_msg_header_t     header;
+	mach_msg_type_t       retval_type;
+	mach_msg_return_t     retval;
+	mach_msg_type_long_t  trace_message_type;
+} mach_trace_message_t;
+
+static mach_trace_message_t trace_template = {
+	.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND, 0),
+
+	.retval_type.msgt_name = MACH_MSG_TYPE_INTEGER_32,
+	.retval_type.msgt_size = 32,
+	.retval_type.msgt_number = 1,
+	.retval_type.msgt_inline = TRUE,
+	.retval_type.msgt_longform = FALSE,
+
+	.trace_message_type.msgtl_header.msgt_inline = TRUE,
+	.trace_message_type.msgtl_header.msgt_longform = TRUE,
+	.trace_message_type.msgtl_name = MACH_MSG_TYPE_BYTE,
+	.trace_message_type.msgtl_size = 8
+};
+
+void
+ipc_kmsg_trace(
+	ipc_kmsg_t 		kmsg,
+	mach_msg_size_t 	size,
+	mach_msg_return_t	retval)
+{
+	if (current_task()->itk_trace != MACH_PORT_NULL) {
+
+		/* XXX: check to make sure trace port doesn't belong to current_task, or we'll loop endlessly */
+
+		ipc_kmsg_t trace_kmsg;
+
+		trace_kmsg = ikm_alloc(size + sizeof(mach_trace_message_t));
+
+		if (trace_kmsg == IKM_NULL) {
+			printf("dropped trace message (alloc failed)\n");
+			return;
+		}
+
+		mach_trace_message_t * trace_msg = (mach_trace_message_t *) & trace_kmsg->ikm_header;
+
+		memcpy(trace_msg, & trace_template, sizeof(mach_trace_message_t));
+
+		trace_msg->header.msgh_size = size + sizeof(mach_trace_message_t);
+		trace_msg->header.msgh_remote_port = (mach_port_t) current_task()->itk_trace;
+		trace_msg->trace_message_type.msgtl_number = size;
+
+		memcpy(trace_msg + 1, & kmsg->ikm_header, size);
+
+		if (ipc_mqueue_send(trace_kmsg, 0, 0) != MACH_MSG_SUCCESS) {
+			printf("dropped trace message (send failed)\n");
+			ikm_free(trace_kmsg);
+		}
+	}
+}
+
 #if	MACH_KDB
 
 char *
diff -ur -x 'Makefile*' -x debian -x configure -x config.sub -x config.guess gnumach-1.8+git20171101/kern/ipc_tt.c mnt/root/gnumach-1.8+git20171101/kern/ipc_tt.c
--- gnumach-1.8+git20171101/kern/ipc_tt.c	2016-10-02 13:45:20.000000000 -0400
+++ mnt/root/gnumach-1.8+git20171101/kern/ipc_tt.c	2018-03-06 22:29:11.000000000 -0500
@@ -89,6 +89,7 @@
 	if (parent == TASK_NULL) {
 		task->itk_exception = IP_NULL;
 		task->itk_bootstrap = IP_NULL;
+		task->itk_trace = IP_NULL;
 		for (i = 0; i < TASK_PORT_REGISTER_MAX; i++)
 			task->itk_registered[i] = IP_NULL;
 	} else {
@@ -101,12 +102,14 @@
 			task->itk_registered[i] =
 				ipc_port_copy_send(parent->itk_registered[i]);
 
-		/* inherit exception and bootstrap ports */
+		/* inherit exception, bootstrap, and trace ports */
 
 		task->itk_exception =
 			ipc_port_copy_send(parent->itk_exception);
 		task->itk_bootstrap =
 			ipc_port_copy_send(parent->itk_bootstrap);
+		task->itk_trace =
+			ipc_port_copy_send(parent->itk_trace);
 
 		itk_unlock(parent);
 	}
@@ -190,6 +193,8 @@
 		ipc_port_release_send(task->itk_exception);
 	if (IP_VALID(task->itk_bootstrap))
 		ipc_port_release_send(task->itk_bootstrap);
+	if (IP_VALID(task->itk_trace))
+		ipc_port_release_send(task->itk_trace);
 
 	for (i = 0; i < TASK_PORT_REGISTER_MAX; i++)
 		if (IP_VALID(task->itk_registered[i]))
@@ -609,6 +614,10 @@
 		whichp = &task->itk_bootstrap;
 		break;
 
+	    case TASK_TRACE_PORT:
+		whichp = &task->itk_trace;
+		break;
+
 	    default:
 		return KERN_INVALID_ARGUMENT;
 	}
@@ -666,6 +675,10 @@
 		whichp = &task->itk_bootstrap;
 		break;
 
+	    case TASK_TRACE_PORT:
+		whichp = &task->itk_trace;
+		break;
+
 	    default:
 		return KERN_INVALID_ARGUMENT;
 	}
diff -ur -x 'Makefile*' -x debian -x configure -x config.sub -x config.guess gnumach-1.8+git20171101/kern/task.h mnt/root/gnumach-1.8+git20171101/kern/task.h
--- gnumach-1.8+git20171101/kern/task.h	2017-10-31 14:03:02.000000000 -0400
+++ mnt/root/gnumach-1.8+git20171101/kern/task.h	2018-03-06 22:27:28.000000000 -0500
@@ -94,6 +94,7 @@
 	struct ipc_port *itk_sself;	/* a send right */
 	struct ipc_port *itk_exception;	/* a send right */
 	struct ipc_port *itk_bootstrap;	/* a send right */
+	struct ipc_port *itk_trace;	/* a send right */
 	struct ipc_port *itk_registered[TASK_PORT_REGISTER_MAX];
 					/* all send rights */
 

Reply via email to