Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 2e3355ac02c28ade6ed5fa69cd4c232cd4580366)
+++ uspace/app/trace/trace.c	(revision 119c335983b9db70ad61a6c58978f4982beaba23)
@@ -43,4 +43,5 @@
 #include <async.h>
 #include <task.h>
+#include <loader/loader.h>
 
 // Temporary: service and method names
@@ -71,9 +72,47 @@
 static proto_t *proto_console;
 static task_id_t task_id;
+static loader_t *task_ldr;
 
 /** Combination of events/data to print. */
 display_mask_t display_mask;
 
-static int task_connect(task_id_t task_id)
+static int program_run_fibril(void *arg);
+
+static void program_run(void)
+{
+	fid_t fid;
+
+	fid = fibril_create(program_run_fibril, NULL);
+	if (fid == 0) {
+		printf("Error creating fibril\n");
+		exit(1);
+	}
+
+	fibril_add_ready(fid);
+}
+
+static int program_run_fibril(void *arg)
+{
+	int rc;
+
+	/*
+	 * This must be done in background as it will block until
+	 * we let the task reply to this call.
+	 */
+	rc = loader_run(task_ldr);
+	if (rc != 0) {
+		printf("Error running program\n");
+		exit(1);
+	}
+
+	free(task_ldr);
+	task_ldr = NULL;
+
+	printf("program_run_fibril exiting\n");
+	return 0;
+}
+
+
+static int connect_task(task_id_t task_id)
 {
 	int rc;
@@ -149,4 +188,5 @@
 
 	case V_HASH:
+	case V_PTR:
 		printf("0x%08lx", val);
 		break;
@@ -469,17 +509,50 @@
 }
 
-static void trace_active_task(task_id_t task_id)
+static loader_t *preload_task(const char *path, char *const argv[],
+    task_id_t *task_id)
+{
+	loader_t *ldr;
+	int rc;
+
+	/* Spawn a program loader */	
+	ldr = loader_spawn();
+	if (ldr == NULL)
+		return 0;
+
+	/* Get task ID. */
+	rc = loader_get_task_id(ldr, task_id);
+	if (rc != EOK)
+		goto error;
+
+	/* Send program pathname */
+	rc = loader_set_pathname(ldr, path);
+	if (rc != EOK)
+		goto error;
+
+	/* Send arguments */
+	rc = loader_set_args(ldr, argv);
+	if (rc != EOK)
+		goto error;
+
+	/* Load the program. */
+	rc = loader_load_program(ldr);
+	if (rc != EOK)
+		goto error;
+
+	/* Success */
+	return ldr;
+
+	/* Error exit */
+error:
+	loader_abort(ldr);
+	free(ldr);
+	return NULL;
+}
+
+static void trace_task(task_id_t task_id)
 {
 	int i;
 	int rc;
 	int c;
-
-	rc = task_connect(task_id);
-	if (rc < 0) {
-		printf("Failed to connect to task %lld\n", task_id);
-		return;
-	}
-
-	printf("Connected to task %lld\n", task_id);
 
 	ipcp_init();
@@ -657,4 +730,5 @@
 				--argc; ++argv;
 				task_id = strtol(*argv, &err_p, 10);
+				task_ldr = NULL;
 				if (*err_p) {
 					printf("Task ID syntax error\n");
@@ -687,5 +761,5 @@
 	}
 
-	/* Execute the specified command and trace the new task. */
+	/* Preload the specified program file. */
 	printf("Spawning '%s' with arguments:\n", *argv);
 	{
@@ -693,5 +767,5 @@
 		while (*cp) printf("'%s'\n", *cp++);
 	}
-	task_id = task_spawn(*argv, argv);
+	task_ldr = preload_task(*argv, argv, &task_id);
 
 	return 0;
@@ -700,4 +774,6 @@
 int main(int argc, char *argv[])
 {
+	int rc;
+
 	printf("System Call / IPC Tracer\n");
 
@@ -708,5 +784,18 @@
 
 	main_init();
-	trace_active_task(task_id);
+
+	rc = connect_task(task_id);
+	if (rc < 0) {
+		printf("Failed connecting to task %lld\n", task_id);
+		return 1;
+	}
+
+	printf("Connected to task %lld\n", task_id);
+
+	if (task_ldr != NULL) {
+		program_run();
+	}
+
+	trace_task(task_id);
 
 	return 0;
