1 --- bug-buddy-2.22.0.old/src/bug-buddy.c 2008-04-28 11:59:20.005224000 +0100 2 +++ bug-buddy-2.22.0/src/bug-buddy.c 2008-04-28 12:00:04.933927000 +0100 3 @@ -963,19 +963,30 @@ 4 GtkTextView *text_view; 5 GtkTextIter end; 6 GtkTextBuffer *buffer; 7 + char *gdb = g_find_program_in_path ("gdb"); 8 + char *pstack = g_find_program_in_path ("pstack"); 9 10 - /* FIXME: These strings are gdb specific, we should add here also dbx */ 11 - const char *bt_step1 = "#1"; 12 - const char *bt_step2 = "#2"; 13 - const char *bt_step3 = "#3"; 14 - 15 - if (!g_strrstr (stacktrace, bt_step1) && 16 - !g_strrstr (stacktrace, bt_step2) && 17 - !g_strrstr (stacktrace, bt_step3)) { 18 - return FALSE; 19 - } 20 - 21 - 22 +#if defined(sun) && defined(__SVR4) 23 + if (pstack) { 24 + g_free (gdb); 25 + gdb = NULL; 26 + } 27 +#endif /* defined(sun) && defined(__SVR4) */ 28 + 29 + if (gdb) { 30 + /* FIXME: These strings are gdb specific, we should add here also dbx */ 31 + const char *bt_step1 = "#1"; 32 + const char *bt_step2 = "#2"; 33 + const char *bt_step3 = "#3"; 34 + 35 + if (!g_strrstr (stacktrace, bt_step1) && 36 + !g_strrstr (stacktrace, bt_step2) && 37 + !g_strrstr (stacktrace, bt_step3)) { 38 + g_free (gdb); 39 + g_free (pstack); 40 + return FALSE; 41 + } 42 + } 43 44 text_view = GTK_TEXT_VIEW (gtk_builder_get_object (ui, "gdb-text")); 45 buffer = gtk_text_view_get_buffer (text_view); 46 @@ -984,6 +995,8 @@ 47 /* add the stacktrace to the GtkTextView */ 48 gtk_text_buffer_insert (buffer, &end, stacktrace, strlen (stacktrace)); 49 50 + g_free (gdb); 51 + g_free (pstack); 52 return TRUE; 53 } 54 55 --- bug-buddy-2.22.0.old/src/gdb-buddy.c 2008-04-28 11:59:20.026360000 +0100 56 +++ bug-buddy-2.22.0/src/gdb-buddy.c 2008-04-28 12:01:31.033484000 +0100 57 @@ -191,11 +191,9 @@ 58 GIOChannel *ioc; 59 GError *error = NULL; 60 GdbData *gdb_data = NULL; 61 - char *args[] = { "gdb", 62 - "--batch", 63 - "--quiet", 64 - "--command=" BUDDY_DATADIR "/gdb-cmd", 65 - NULL, NULL, NULL }; 66 + char *args[7]; 67 + char *gdb = NULL; 68 + char *pstack = NULL; 69 70 g_return_val_if_fail (app != NULL, 0); 71 g_return_val_if_fail (*app != '\0', 0); 72 @@ -206,6 +204,28 @@ 73 74 d (g_print ("app=%s\n", app)); 75 76 +#if defined(sun) && defined(__SVR4) 77 + pstack = g_find_program_in_path ("pstack"); 78 + if (pstack) { 79 + args[0] = pstack; 80 + args[2] = args[3] = args[4] = args[5] = args[6] = NULL; 81 + } else { 82 + gdb = g_find_program_in_path ("gdb"); 83 + args[0] = gdb; 84 + args[1] = "--batch"; 85 + args[2] = "--quiet"; 86 + args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd"; 87 + args[4] = args[5] = args[6] = NULL; 88 + } 89 +#else 90 + gdb = g_find_program_in_path ("gdb"); 91 + args[0] = gdb; 92 + args[1] = "--batch"; 93 + args[2] = "--quiet"; 94 + args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd"; 95 + args[4] = args[5] = args[6] = NULL; 96 +#endif /* defined(sun) && defined(__SVR4) */ 97 + 98 /* apply a SIGCONT to the process */ 99 kill (pid, SIGCONT); 100 101 @@ -226,33 +246,41 @@ 102 if (!long_app) { 103 g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_BINARY_NOT_FOUND, 104 _("The binary file could not be found. Try using an absolute path.")); 105 + g_free (args[0]); 106 return 0; 107 } 108 109 - args[0] = g_find_program_in_path ("gdb"); 110 - args[4] = long_app; 111 + if (!pstack) 112 + args[4] = long_app; 113 114 if (args[0] == NULL) { 115 d(g_message ("Path: %s", getenv ("PATH"))); 116 g_free (long_app); 117 g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_NOT_FOUND, 118 - _("GDB could not be found on your system. " 119 - "Debugging information will not be obtained.")); 120 + _("%s could not be found on your system. " 121 + "Debugging information will not be obtained."), 122 + pstack != NULL ? "pstack" : "gdb"); 123 + g_free (args[0]); 124 return 0; 125 } 126 127 d(g_message ("About to debug '%s'", long_app)); 128 129 - if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) { 130 - g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 131 - _("Could not find the gdb-cmd file.\n" 132 - "Please try reinstalling Bug Buddy.")); 133 - g_free (args[0]); 134 - g_free (long_app); 135 - return 0; 136 - } 137 + if (gdb) { 138 + if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) { 139 + g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 140 + _("Could not find the gdb-cmd file.\n" 141 + "Please try reinstalling Bug Buddy.")); 142 + g_free (args[0]); 143 + g_free (long_app); 144 + return 0; 145 + } 146 + } 147 148 - args[5] = g_strdup_printf ("%d", pid); 149 + if (pstack) 150 + args[1] = g_strdup_printf ("%d", pid); 151 + else 152 + args[5] = g_strdup_printf ("%d", pid); 153 154 if (!g_spawn_async_with_pipes (NULL, args, NULL, 0, NULL, NULL, 155 &gdb_pid, 156 @@ -263,8 +291,11 @@ 157 _("There was an error running gdb:\n\n%s"), 158 error->message); 159 g_error_free (error); 160 - g_free (args[0]); 161 - g_free (args[5]); 162 + if (pstack) 163 + g_free (args[1]); 164 + else 165 + g_free (args[5]); 166 + g_free (args[0]); 167 g_free (long_app); 168 return 0; 169 } 170 @@ -288,8 +319,11 @@ 171 gdb_handle_input, gdb_data, gdb_destroy); 172 g_io_channel_unref (ioc); 173 174 - g_free (args[0]); 175 - g_free (args[5]); 176 + if (pstack) 177 + g_free (args[1]); 178 + else 179 + g_free (args[5]); 180 + g_free (args[0]); 181 g_free (long_app); 182 183 return source_id; 184