--- old-trash/lib/rb-debug.c	2006-12-13 22:19:18.000000000 +1000
+++ new-trash/lib/rb-debug.c	2006-12-13 22:19:18.000000000 +1000
@@ -81,12 +81,12 @@
 	rb_debug_init_match (debug ? debug_everything : NULL);
 }
 
-void 
+void
 rb_debug_init_match (const char *match)
 {
 	guint i;
 
-	/* This is a workaround for the fact that there is not way to 
+	/* This is a workaround for the fact that there is no way to
 	 * make this useful debugging feature happen for ALL domains.
 	 *
 	 * What we did here is list all the ones we could think of that
@@ -141,6 +141,25 @@
 	rb_debug ("Debugging enabled");
 }
 
+char **
+rb_debug_get_args (void)
+{
+	char **args;
+	if (debug_match == NULL) {
+		args = (char **)g_new0 (char *, 1);
+		args[0] = NULL;
+	} else if (debug_match == debug_everything) {
+		args = (char **)g_new0 (char *, 2);
+		args[0] = g_strdup ("--debug");
+	} else {
+		args = (char **)g_new0 (char *, 3);
+		args[0] = g_strdup ("--debug-match");
+		args[1] = g_strdup (debug_match);
+	}
+	return args;
+
+}
+
 /* Raise a SIGINT signal to get the attention of the debugger.
  * When not running under the debugger, we don't want to stop,
  * so we ignore the signal for just the moment that we raise it.

--- old-trash/lib/rb-debug.h	2006-12-13 22:19:18.000000000 +1000
+++ new-trash/lib/rb-debug.h	2006-12-13 22:19:18.000000000 +1000
@@ -45,6 +45,8 @@
 				gboolean newline,
 				const char *format, ...) G_GNUC_PRINTF (5, 6);
 
+char **rb_debug_get_args       (void);
+
 void rb_debug_stop_in_debugger (void);
 
 typedef struct RBProfiler RBProfiler;

--- old-trash/metadata/rb-metadata-dbus-client.c	2006-12-13 22:19:18.000000000 +1000
+++ new-trash/metadata/rb-metadata-dbus-client.c	2006-12-13 22:19:18.000000000 +1000
@@ -186,11 +186,15 @@
 #else
 		LIBEXEC_DIR "/rhythmbox-metadata",
 #endif
-		"unix:tmpdir=/tmp", NULL
+		NULL,	/* --debug or --debug-match */
+		NULL,	/* debug match string */
+		NULL,   /* address */
+		NULL
 	};
 	DBusError dbus_error = {0,};
 	GIOChannel *stdout_channel;
 	GIOStatus status;
+	char *default_address = "unix:tmpdir=/tmp";
 	gchar *dbus_address = NULL;
 
 	if (dbus_connection) {
@@ -218,6 +222,20 @@
 
 	if (dbus_address == NULL) {
 		gint metadata_stdout;
+		char **debug_args;
+		int i;
+		int base;
+
+		/* fill in debug arguments */
+		debug_args = rb_debug_get_args ();
+		i = 0;
+		base = 1;
+		while (debug_args[i] != NULL) {
+			argv[base + i] = debug_args[i];
+			g_print ("argv[%d] = %s\n", base+i, argv[base+i]);
+			i++;
+		}
+		argv[base + i] = default_address;
 
 		if (!g_spawn_async_with_pipes (NULL,
 					       argv,
@@ -229,8 +247,10 @@
 					       &metadata_stdout,
 					       NULL,
 					       error)) {
+			g_strfreev (debug_args);
 			return FALSE;
 		}
+		g_strfreev (debug_args);
 
 		stdout_channel = g_io_channel_unix_new (metadata_stdout);
 		status = g_io_channel_read_line (stdout_channel, &dbus_address, NULL, NULL, error);

--- old-trash/metadata/rb-metadata-dbus-service.c	2006-12-13 22:19:18.000000000 +1000
+++ new-trash/metadata/rb-metadata-dbus-service.c	2006-12-13 22:19:18.000000000 +1000
@@ -424,7 +424,6 @@
 {
 	ServiceData svc = {0,};
 	DBusError dbus_error = {0,};
-	gboolean debug = FALSE;
 	const char *address = NULL;
 
 #ifdef ENABLE_NLS
@@ -443,9 +442,13 @@
 
 	if (argv[1] != NULL && strcmp(argv[1], "--debug") == 0) {
 		argv++;
-		debug = TRUE;
+		rb_debug_init (TRUE);
+	} else if (argv[1] != NULL && strcmp (argv[1], "--debug-match") == 0) {
+		rb_debug_init_match (argv[2]);
+		argv += 2;
+	} else {
+		rb_debug_init (FALSE);
 	}
-	rb_debug_init (debug);
 
 	/* bug report modes */
 	if (argv[1] != NULL && strcmp(argv[1], "--load") == 0) {

