1 /jds/bin/diff -uprN bug-buddy-2.25.2.old/src/bug-buddy.c bug-buddy-2.25.2/src/bug-buddy.c 2 --- bug-buddy-2.25.2.old/src/bug-buddy.c 2008-12-11 12:35:33.705860000 +0000 3 +++ bug-buddy-2.25.2/src/bug-buddy.c 2008-12-11 12:38:26.475348000 +0000 4 @@ -1096,19 +1096,30 @@ gdb_insert_text (const gchar *stacktrace 5 GtkTextView *text_view; 6 GtkTextIter end; 7 GtkTextBuffer *buffer; 8 + char *gdb = g_find_program_in_path ("gdb"); 9 + char *pstack = g_find_program_in_path ("pstack"); 10 11 - /* FIXME: These strings are gdb specific, we should add here also dbx */ 12 - const char *bt_step1 = "#1"; 13 - const char *bt_step2 = "#2"; 14 - const char *bt_step3 = "#3"; 15 - 16 - if (!g_strrstr (stacktrace, bt_step1) && 17 - !g_strrstr (stacktrace, bt_step2) && 18 - !g_strrstr (stacktrace, bt_step3)) { 19 - return FALSE; 20 - } 21 - 22 - 23 +#if defined(sun) && defined(__SVR4) 24 + if (pstack) { 25 + g_free (gdb); 26 + gdb = NULL; 27 + } 28 +#endif /* #if defined(sun) && defined(__SVR4) */ 29 + 30 + if (gdb) { 31 + /* FIXME: These strings are gdb specific, we should add here also dbx */ 32 + const char *bt_step1 = "#1"; 33 + const char *bt_step2 = "#2"; 34 + const char *bt_step3 = "#3"; 35 + 36 + if (!g_strrstr (stacktrace, bt_step1) && 37 + !g_strrstr (stacktrace, bt_step2) && 38 + !g_strrstr (stacktrace, bt_step3)) { 39 + g_free (gdb); 40 + g_free (pstack); 41 + return FALSE; 42 + } 43 + } 44 45 text_view = GTK_TEXT_VIEW (gtk_builder_get_object (ui, "gdb-text")); 46 buffer = gtk_text_view_get_buffer (text_view); 47 @@ -1117,6 +1128,9 @@ gdb_insert_text (const gchar *stacktrace 48 /* add the stacktrace to the GtkTextView */ 49 gtk_text_buffer_insert (buffer, &end, stacktrace, strlen (stacktrace)); 50 51 + g_free (gdb); 52 + g_free (pstack); 53 + 54 return TRUE; 55 } 56 57 /jds/bin/diff -uprN bug-buddy-2.25.2.old/src/gdb-buddy.c bug-buddy-2.25.2/src/gdb-buddy.c 58 --- bug-buddy-2.25.2.old/src/gdb-buddy.c 2008-12-11 12:35:33.723199000 +0000 59 +++ bug-buddy-2.25.2/src/gdb-buddy.c 2008-12-11 12:45:14.364972000 +0000 60 @@ -210,11 +210,9 @@ gdb_get_trace (const gchar *app, int pid 61 GIOChannel *ioc; 62 GError *error = NULL; 63 GdbData *gdb_data = NULL; 64 - char *args[] = { "gdb", 65 - "--batch", 66 - "--quiet", 67 - "--command=" BUDDY_DATADIR "/gdb-cmd", 68 - NULL, NULL, NULL }; 69 + char *args[7]; 70 + char *gdb = NULL; 71 + char *pstack = NULL; 72 73 g_return_val_if_fail (app != NULL, 0); 74 g_return_val_if_fail (*app != '\0', 0); 75 @@ -225,6 +223,29 @@ gdb_get_trace (const gchar *app, int pid 76 77 d (g_print ("app=%s\n", app)); 78 79 +#if defined(sun) && defined(__SVR4) 80 + pstack = g_find_program_in_path ("pstack"); 81 + 82 + if (pstack) { 83 + args[0] = pstack; 84 + args[2] = args[3] = args[4] = args[5] = args[6] = NULL; 85 + } else { 86 + gdb = g_find_program_in_path ("gdb"); 87 + args[0] = gdb; 88 + args[1] = "--batch"; 89 + args[2] = "--quiet"; 90 + args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd"; 91 + args[4] = args[5] = args[6] = NULL; 92 + } 93 +#else 94 + gdb = g_find_program_in_path ("gdb"); 95 + args[0] = gdb; 96 + args[1] = "--batch"; 97 + args[2] = "--quiet"; 98 + args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd"; 99 + args[4] = args[5] = args[6] = NULL; 100 +#endif /* defined(sun) && defined(__SVR4) */ 101 + 102 /* apply a SIGCONT to the process */ 103 kill (pid, SIGCONT); 104 105 @@ -249,30 +270,38 @@ gdb_get_trace (const gchar *app, int pid 106 } 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 + g_free (long_app); 125 return 0; 126 } 127 128 d(g_message ("About to debug '%s'", long_app)); 129 130 - if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) { 131 - g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 132 - _("Could not find the gdb-cmd file.\n" 133 - "Please try reinstalling Bug Buddy.")); 134 - g_free (args[0]); 135 - g_free (long_app); 136 - return 0; 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 @@ -284,7 +313,10 @@ gdb_get_trace (const gchar *app, int pid 157 error->message); 158 g_error_free (error); 159 g_free (args[0]); 160 - g_free (args[5]); 161 + if (pstack) 162 + g_free (args[1]); 163 + else 164 + g_free (args[5]); 165 g_free (long_app); 166 return 0; 167 } 168 @@ -309,7 +341,10 @@ gdb_get_trace (const gchar *app, int pid 169 g_io_channel_unref (ioc); 170 171 g_free (args[0]); 172 - g_free (args[5]); 173 + if (pstack) 174 + g_free (args[1]); 175 + else 176 + g_free (args[5]); 177 g_free (long_app); 178 179 return source_id; 180 /jds/bin/diff -uprN bug-buddy-2.25.2.old/gnome-breakpad/gnome-breakpad.cc bug-buddy-2.25.2/gnome-breakpad/gnome-breakpad.cc 181 --- bug-buddy-2.25.2.old/gnome-breakpad/gnome-breakpad.cc 2008-12-11 12:35:33.736965000 +0000 182 +++ bug-buddy-2.25.2/gnome-breakpad/gnome-breakpad.cc 2008-12-11 12:55:07.314379000 +0000 183 @@ -379,25 +379,50 @@ run_bug_buddy (const gchar *appname, pid 184 static bool 185 run_gdb (const gchar *appname, pid_t pid) 186 { 187 - gchar *exec_str; 188 + gchar *exec_str = NULL; 189 gchar *title; 190 gboolean res; 191 GError *error = NULL; 192 + gchar *gdb = NULL; 193 194 title = g_strdup_printf ("Debugging %s", appname); 195 196 +#if defined(sun) && defined(__SVR4) 197 + gdb = g_find_program_in_path("gdb");; 198 + if (gdb) { 199 + exec_str = g_strdup_printf("gnome-terminal " 200 + "--title=\"%s\" " 201 + "--disable-factory " 202 + "--command=\"gdb %s %d\"", 203 + title, appname, (int)pid); 204 + g_free (gdb); 205 + } else { 206 + gchar *dbx = g_find_program_in_path("dbx"); 207 + if (dbx) { 208 + exec_str = g_strdup_printf("gnome-terminal " 209 + "--title=\"%s\" " 210 + "--disable-factory " 211 + "--command=\"dbx /proc/%d/object/a.out %d\"", 212 + title, (int)pid, (int)pid); 213 + } 214 + g_free (dbx); 215 + } 216 +#else 217 exec_str = g_strdup_printf("gnome-terminal " 218 "--title=\"%s\" " 219 "--disable-factory " 220 "--command=\"gdb %s %d\"", 221 title, appname, (int)pid); 222 - g_free (title); 223 - res = g_spawn_command_line_sync (exec_str, NULL, NULL, 224 - NULL, &error); 225 - g_free(exec_str); 226 - if (!res) { 227 - g_warning("Couldn't run debugger\n"); 228 - return false; 229 +#endif /* defined(sun) && defined(__SVR4) */ 230 + g_free (title); 231 + if (exec_str) { 232 + res = g_spawn_command_line_sync (exec_str, NULL, NULL, 233 + NULL, &error); 234 + g_free(exec_str); 235 + if (!res) { 236 + g_warning("Couldn't run debugger\n"); 237 + return false; 238 + } 239 } 240 241 return true; 242 @@ -406,8 +431,12 @@ run_gdb (const gchar *appname, pid_t pid 243 static void 244 check_if_gdb () 245 { 246 - char *mypath; 247 - gchar *gdb; 248 + char *mypath = NULL; 249 + gchar *gdb = NULL; 250 +#if defined(sun) && defined(__SVR4) 251 + gchar *pstack = NULL; 252 + gchar *dbx = NULL; 253 +#endif /* defined(sun) && defined(__SVR4) */ 254 bool has_debug_symbols = false; 255 char *filename; 256 gchar *appname; 257 @@ -421,22 +450,40 @@ check_if_gdb () 258 259 appname = g_get_prgname (); 260 pid = getpid (); 261 + 262 +#if defined(sun) && defined(__SVR4) 263 + gdb = g_find_program_in_path ("gdb"); 264 + pstack = g_find_program_in_path ("pstack"); 265 + dbx = g_find_program_in_path ("dbx"); 266 + 267 + if ((gdb || dbx) && g_getenv("GNOME_HACKER")) { 268 +#else 269 gdb = g_find_program_in_path ("gdb"); 270 271 if (gdb && g_getenv("GNOME_HACKER")) { 272 +#endif /* defined(sun) && defined(__SVR4) */ 273 res = run_gdb (appname, pid); 274 if (!res) 275 _exit (1); 276 _exit(0); 277 } 278 279 +#if defined(sun) && defined(__SVR4) 280 + mypath = g_strdup_printf ("/proc/%d/object/a.out", (int)pid); 281 +#else 282 mypath = g_file_read_link ("/proc/self/exe", NULL); 283 +#endif /* defined(sun) && defined(__SVR4) */ 284 + 285 if (mypath) 286 has_debug_symbols = elf_has_debug_symbols (mypath); 287 288 g_free (mypath); 289 290 +#if defined(sun) && defined(__SVR4) 291 + if (bugbuddy && (gdb || pstack) && has_debug_symbols) { 292 +#else 293 if (bugbuddy && gdb && has_debug_symbols) { 294 +#endif /* defined(sun) && defined(__SVR4) */ 295 res = run_bug_buddy (appname, pid, NULL); 296 if (!res) 297 _exit (1); 298