--- a/patches/bug-buddy-01-use-pstack.diff Tue Aug 28 14:04:42 2007 +0000
+++ b/patches/bug-buddy-01-use-pstack.diff Tue Aug 28 14:35:20 2007 +0000
@@ -1,154 +1,171 @@
-diff -urN bug-buddy-2.12.1/configure.in bug-buddy-2.12.1-hacked/configure.in
---- bug-buddy-2.12.1/configure.in 2005-10-01 14:38:24.000000000 +1200
-+++ bug-buddy-2.12.1-hacked/configure.in 2005-10-26 16:10:33.689331000 +1300
-@@ -86,7 +86,12 @@
- fi
- AC_DEFINE_UNQUOTED(GNOMELIBEXECDIR, "$GNOMELIBEXECDIR", [Libexec directory])
+--- bug-buddy-2.19.0.old/configure.in 2007-08-28 12:05:53.767319000 +0000
++++ bug-buddy-2.19.0/configure.in 2007-08-28 12:06:03.346878000 +0000
+@@ -108,6 +108,13 @@
+ GNOME_COMPILE_WARNINGS([maximum])
+ GNOME_MAINTAINER_MODE_DEFINES
--
+AC_CANONICAL_HOST
+case "$host" in
+*solaris*)
-+ AC_DEFINE(SOLARIS,1,Define to 1 if solaris)
-+ ;;
++ AC_DEFINE(SOLARIS,1,Define to 1 if solaris)
++ ;;
+esac
-
++
AC_OUTPUT([
bug-buddy.spec
-diff -urN bug-buddy-2.12.1/src/gdb-buddy.c bug-buddy-2.12.1-hacked/src/gdb-buddy.c
---- bug-buddy-2.12.1/src/gdb-buddy.c 2005-07-20 06:49:18.000000000 +1200
-+++ bug-buddy-2.12.1-hacked/src/gdb-buddy.c 2005-10-26 16:40:09.449769000 +1300
-@@ -152,15 +152,28 @@
- int status;
- FILE *f;
-
-- gdb_cmd = g_strdup_printf ("gdb --batch --core=%s", core_file);
-+ gboolean use_pstack = FALSE;
-+
-+#ifdef SOLARIS
-+ char *gdb = g_find_program_in_path ("gdb");
-+ if (gdb)
-+#endif
-+ gdb_cmd = g_strdup_printf ("gdb --batch --core=%s", core_file);
-+#ifdef SOLARIS
-+ else {
-+ gdb_cmd = g_strdup_printf ("pstack %s", core_file);
-+ use_pstack = TRUE;
-+ }
-+#endif
-
- f = popen (gdb_cmd, "r");
- g_free (gdb_cmd);
-
- if (!f) {
- buddy_error (GET_WIDGET ("druid-window"),
-- _("Unable to process core file with gdb:\n"
-+ _("Unable to process core file with %s:\n"
- "'%s'"),
-+ use_pstack ? "pstack" : "gdb",
- core_file);
- return;
- }
-@@ -178,14 +191,31 @@
- binary = g_strdup(s);
- }
- }
-+#ifdef SOLARIS
-+ else if (!binary && !strncmp(buf, "core ", 4)) {
-+ gchar *s;
-+ gchar *ptr = buf;
-+ while (*ptr != ':' && *ptr !='\0') ptr++;
-+ if (*ptr == ':') {
-+ ptr++;
-+ while (*ptr == ' ' || *ptr == '\t') ptr++;
-+ s = ptr;
-+ while (*ptr !='\0') ptr++;
-+ *ptr = '\0';
-+ binary = g_strdup(s);
-+ }
-+ }
-+#endif
-+
- }
-
- status = pclose(f);
-
- if (!binary) {
- buddy_error (GET_WIDGET ("druid-window"),
-- _("GDB was unable to determine which binary created\n"
-+ _("%s was unable to determine which binary created\n"
- "'%s'"),
-+ use_pstack ? "pstack" : "gdb",
- core_file);
- return;
- }
-@@ -254,17 +284,33 @@
- const char *short_app;
- char *long_app;
+ bug-buddy.schemas
+--- bug-buddy-2.19.0.old/src/gdb-buddy.c 2007-08-28 12:05:53.764009000 +0000
++++ bug-buddy-2.19.0/src/gdb-buddy.c 2007-08-28 14:48:22.133380000 +0000
+@@ -191,11 +191,9 @@
+ GIOChannel *ioc;
GError *error = NULL;
+ GdbData *gdb_data = NULL;
- char *args[] = { "gdb",
- "--batch",
- "--quiet",
- "--command=" BUDDY_DATADIR "/gdb-cmd",
- NULL, NULL, NULL };
--
-- if (!app || !extra || !*app || !*extra) {
-+ char *args[7];
-+ char *gdb = g_find_program_in_path ("gdb");
++ char *args[7];
++ char *gdb = g_find_program_in_path("gdb");
+ gboolean use_pstack = FALSE;
-+
-+ if (!app || !extra || !*app || !*extra) {
- buddy_error (GET_WIDGET ("druid-window"),
- _("Both a binary file and PID are required to debug."));
-- return;
-+ return;
- }
-+
-+ if (gdb) {
-+ args[0] = gdb;
-+ args[1] = "--batch";
-+ args[2] = "--quiet";
-+ args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
-+ args[4] = NULL;
-+ args[5] = (char *)extra;
-+ args[6] = NULL;
-+ }
+
+ g_return_val_if_fail (app != NULL, 0);
+ g_return_val_if_fail (*app != '\0', 0);
+@@ -206,6 +204,22 @@
+
+ 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;
++ }
+#ifdef SOLARIS
-+ else {
-+ args[0] = g_find_program_in_path ("pstack");
-+ args[1] = (char *)extra;
-+ args[2] = args[3] = args[4] = args[5] = args[6] = NULL;
++ else {
++ args[0] = g_find_program_in_path ("pstack");
++ args[2] = args[3] = args[4] = args[5] = args[6] = NULL;
+ use_pstack = TRUE;
-+ }
-+#endif
++ }
++#endif /* SOLARIS */
++
+ /* apply a SIGCONT to the process */
+ kill (pid, SIGCONT);
- if (app[0] == G_DIR_SEPARATOR) {
- long_app = g_strdup (app);
-@@ -287,14 +333,13 @@
- return;
+@@ -226,33 +240,44 @@
+ 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]);
+ return 0;
}
- args[0] = g_find_program_in_path ("gdb");
- args[4] = long_app;
-- args[5] = (char *)extra;
+ if (!use_pstack)
+ args[4] = long_app;
- if (!args[0]) {
- buddy_error (GET_WIDGET ("druid-window"),
-- _("GDB could not be found on your system.\n"
-- "Debugging information will not be obtained."));
-+ _("%s could not be found on your system.\n"
-+ "Debugging information will not be obtained."), use_pstack ? "pstack" : "gdb");
+ if (args[0] == NULL) {
d(g_message ("Path: %s", getenv ("PATH")));
- } else {
- d(g_message ("About to debug '%s'", long_app));
-@@ -309,7 +354,7 @@
- &druid_data.fd,
- NULL, &error)) {
- buddy_error (GTK_WIDGET ("druid-window"),
-- _("There was an error running gdb:\n\n%s"),
-+ _("There was an error running %s:\n\n%s"), use_pstack ? "pstack" : "gdb",
- error->message);
- g_error_free (error);
- } else {
+ g_free (long_app);
+ g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_NOT_FOUND,
+- _("GDB could not be found on your system. "
+- "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]);
+ return 0;
+ }
+
+ d(g_message ("About to debug '%s'", long_app));
++
++ if (use_pstack)
++ args[1] = g_strdup_printf ("%d", pid);
++ else
++ args[5] = g_strdup_printf ("%d", pid);
+
+ 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]);
++ if (use_pstack)
++ g_free (args[1]);
++ else
++ g_free (args[5]);
+ g_free (long_app);
+ return 0;
+ }
+-
+- args[5] = g_strdup_printf ("%d", pid);
++
+
+ if (!g_spawn_async_with_pipes (NULL, args, NULL, 0, NULL, NULL,
+ &gdb_pid,
+@@ -260,11 +285,15 @@
+ &fd,
+ NULL, &error)) {
+ g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_ERROR,
+- _("There was an error running gdb:\n\n%s"),
++ _("There was an error running %s:\n\n%s"),
++ use_pstack ? "pstack" : "gdb",
+ error->message);
+ g_error_free (error);
+ 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 +318,10 @@
+ g_io_channel_unref (ioc);
+
+ 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;
+--- bug-buddy-2.19.0.old/src/bug-buddy.c 2007-08-28 15:14:14.132839000 +0000
++++ bug-buddy-2.19.0/src/bug-buddy.c 2007-08-28 15:16:13.723776000 +0000
+@@ -968,20 +968,21 @@
+ 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";
+- const char *bt_step3 = "#3";
+-
+- if (!g_strrstr (stacktrace, bt_step1) &&
+- !g_strrstr (stacktrace, bt_step2) &&
+- !g_strrstr (stacktrace, bt_step3)) {
+- return FALSE;
++ if (gdb) {
++ 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;
++ }
+ }
+
+-
+-
+ text_view = GTK_TEXT_VIEW (glade_xml_get_widget (xml, "gdb-text"));
+ buffer = gtk_text_view_get_buffer (text_view);
+ gtk_text_buffer_get_end_iter (buffer, &end);