patches/bug-buddy-01-use-pstack.diff
branchgnome-2-20
changeset 11037 c373b88b3686
parent 10740 e9d843bc6102
--- a/patches/bug-buddy-01-use-pstack.diff	Mon May 05 14:42:30 2008 +0000
+++ b/patches/bug-buddy-01-use-pstack.diff	Tue May 06 10:23:04 2008 +0000
@@ -1,11 +1,10 @@
---- bug-buddy-2.20.1.old/src/bug-buddy.c	2007-10-08 11:45:55.467502000 +0100
-+++ bug-buddy-2.20.1/src/bug-buddy.c	2007-10-08 11:52:30.215028000 +0100
-@@ -981,16 +981,19 @@
+--- bug-buddy-2.20.1.old/src/bug-buddy.c	2008-04-28 11:36:31.386062000 +0100
++++ bug-buddy-2.20.1/src/bug-buddy.c	2008-04-28 11:41:15.972183000 +0100
+@@ -981,19 +981,31 @@
  	GtkTextView *text_view;
  	GtkTextIter end;
  	GtkTextBuffer *buffer;
-+	char *gdb = g_find_program_in_path ("gdb");
- 
+-
 -	/* FIXME: These strings are gdb specific, we should add here also dbx */
 -	const char *bt_step1 = "#1";
 -	const char *bt_step2 = "#2";
@@ -15,22 +14,47 @@
 -            !g_strrstr (stacktrace, bt_step2) &&
 -            !g_strrstr (stacktrace, bt_step3)) {
 -		return FALSE;
-+	if (gdb) {
-+		/* FIXME: These strings are gdb specific, we should add here also dbx */
-+		const char *bt_step1 = "#1";
-+		const char *bt_step2 = "#2";
-+		const char *bt_step3 = "#3";
-+	
-+		if (!g_strrstr (stacktrace, bt_step1) &&
-+            	!g_strrstr (stacktrace, bt_step2) &&
-+            	!g_strrstr (stacktrace, bt_step3)) {
-+			return FALSE;
-+		}
- 	}
+-	}
++    char *gdb = g_find_program_in_path ("gdb");
++    char *pstack = g_find_program_in_path ("pstack");
  
  
---- bug-buddy-2.20.1.old/src/gdb-buddy.c	2007-10-08 13:50:19.900981000 +0100
-+++ bug-buddy-2.20.1/src/gdb-buddy.c	2007-10-08 13:52:16.554963000 +0100
++#if defined(sun) && defined(__SVR4)
++    if (pstack) {
++        g_free (gdb);
++        gdb = NULL;    
++    }
++#endif
++
++    if (gdb) {
++	    /* FIXME: These strings are gdb specific, we should add here also dbx */
++	    const char *bt_step1 = "#1";
++	    const char *bt_step2 = "#2";
++	    const char *bt_step3 = "#3";
++
++	    if (!g_strrstr (stacktrace, bt_step1) &&
++                !g_strrstr (stacktrace, bt_step2) &&
++                !g_strrstr (stacktrace, bt_step3)) {
++            g_free (gdb);
++            g_free (pstack);
++		    return FALSE;
++	    }
++    }
+ 
+ 	text_view = GTK_TEXT_VIEW (gtk_builder_get_object (ui, "gdb-text"));
+ 	buffer = gtk_text_view_get_buffer (text_view);
+@@ -1002,6 +1014,9 @@
+ 	/* add the stacktrace to the GtkTextView */
+ 	gtk_text_buffer_insert (buffer, &end, stacktrace, strlen (stacktrace));
+ 
++    g_free (gdb);
++    g_free (pstack);
++
+ 	return TRUE;
+ }
+ 
+--- bug-buddy-2.20.1.old/src/gdb-buddy.c	2008-04-28 11:36:31.388511000 +0100
++++ bug-buddy-2.20.1/src/gdb-buddy.c	2008-04-28 11:50:52.153541000 +0100
 @@ -191,11 +191,9 @@
  	GIOChannel *ioc;
  	GError *error = NULL;
@@ -40,47 +64,53 @@
 -			 "--quiet",
 -			 "--command=" BUDDY_DATADIR "/gdb-cmd",
 -			 NULL, NULL, NULL };
-+	char *args[7];
-+	char *gdb = g_find_program_in_path ("gdb");
-+	gboolean use_pstack = FALSE;
++    char *args[7];
++    char *gdb = NULL;
++    char *pstack = NULL;
  
  	g_return_val_if_fail (app != NULL, 0);
  	g_return_val_if_fail (*app != '\0', 0);
-@@ -206,6 +204,22 @@
+@@ -206,6 +204,28 @@
  
  	d (g_print ("app=%s\n", app));
  
-+	if (gdb) {
-+		args[0] = gdb;
-+		args[1] = "--batch";
-+		args[2] = "--quiet";
-+		args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
-+		args[4] = NULL;
-+		args[6] = NULL;
-+	}
 +#if defined(sun) && defined(__SVR4)
-+	else {
-+		args[0] = g_find_program_in_path ("pstack");
-+		args[2] = args[3] = args[4] = args[5] = args[6] = NULL;
-+		use_pstack = TRUE;
-+	}
-+#endif /*  defined(sun) && defined(__SVR4) */
++    pstack = g_find_program_in_path ("pstack");
++    if (pstack) {
++        args[0] = pstack;
++        args[2] = args[3] = args[4] = args[5] = args[6] = NULL;
++    } else {
++        gdb = g_find_program_in_path ("gdb");
++        args[0] = gdb;
++        args[1] = "--batch";
++        args[2] = "--quiet";
++        args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
++        args[4] = args[5] = args[6] = NULL;
++    }
++#else
++    gdb = g_find_program_in_path ("gdb");
++    args[0] = gdb;
++    args[1] = "--batch";
++    args[2] = "--quiet";
++    args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
++    args[4] = args[5] = args[6] = NULL;
++#endif /* defined(sun) && defined(__SVR4) */
 +
  	/* apply a SIGCONT to the process */
  	kill (pid, SIGCONT);
  
-@@ -226,33 +240,41 @@
+@@ -226,33 +246,41 @@
  	if (!long_app) {
  		g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_BINARY_NOT_FOUND, 
  		             _("The binary file could not be found. Try using an absolute path."));
-+		g_free (args[0]);
++        g_free (args[0]);
  		return 0;
  	}
  
 -	args[0] = g_find_program_in_path ("gdb");
 -	args[4] = long_app;
-+	if (!use_pstack)
-+		args[4] = long_app;
++    if (!pstack)
++	    args[4] = long_app;
  
  	if (args[0] == NULL) {
  		d(g_message ("Path: %s", getenv ("PATH")));
@@ -90,8 +120,8 @@
 -			       "Debugging information will not be obtained."));
 +			     _("%s could not be found on your system. "
 +			       "Debugging information will not be obtained."),
-+				 use_pstack ? "pstack" : "gdb");
-+		g_free (args[0]);
++                 pstack != NULL ? "pstack" : "gdb");
++        g_free (args[0]);
  		return 0;
  	} 
  	
@@ -104,46 +134,50 @@
 -		g_free (args[0]);
 -		g_free (long_app);
 -		return 0;
-+	if (gdb) {
-+		if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) {
-+			g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 
-+			     	_("Could not find the gdb-cmd file.\n"
-+			       	"Please try reinstalling Bug Buddy."));
-+			g_free (args[0]);
-+			g_free (long_app);
-+			return 0;
-+		}
- 	}
+-	}
++    if (gdb) {
++	    if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) {
++		    g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 
++			        _("Could not find the gdb-cmd file.\n"
++			        "Please try reinstalling Bug Buddy."));
++		    g_free (args[0]);
++		    g_free (long_app);
++		    return 0;
++	    }
++    }
  	
 -	args[5] = g_strdup_printf ("%d", pid);
-+	if (use_pstack)
-+		args[1] = g_strdup_printf ("%d", pid);
-+	else
-+		args[5] = g_strdup_printf ("%d", pid);
++    if (pstack)
++	    args[1] = g_strdup_printf ("%d", pid);
++    else
++	    args[5] = g_strdup_printf ("%d", pid);
  	
  	if (!g_spawn_async_with_pipes (NULL, args, NULL, 0, NULL, NULL,
  				       &gdb_pid,
-@@ -264,7 +286,10 @@
+@@ -263,8 +291,12 @@
+ 			     _("There was an error running gdb:\n\n%s"),
  			     error->message);
  		g_error_free (error);
++        if (pstack)
++		    g_free (args[1]);
++        else
++		    g_free (args[5]);
++
  		g_free (args[0]);
 -		g_free (args[5]);
-+		if (use_pstack)
-+			g_free (args[1]);
-+		else
-+			g_free (args[5]);
  		g_free (long_app);
  		return 0;
  	} 
-@@ -289,7 +314,10 @@
+@@ -288,8 +320,11 @@
+ 	                                 gdb_handle_input, gdb_data, gdb_destroy);
  	g_io_channel_unref (ioc);
  
++	if (pstack)
++        g_free (args[1]);
++    else
++        g_free (args[5]);
  	g_free (args[0]);
 -	g_free (args[5]);
-+	if (use_pstack)
-+		g_free (args[1]);
-+	else
-+		g_free (args[5]);
  	g_free (long_app);
  
  	return source_id;