/jds/bin/diff -uprN bug-buddy-2.25.2.old/src/bug-buddy.c bug-buddy-2.25.2/src/bug-buddy.c
--- bug-buddy-2.25.2.old/src/bug-buddy.c 2008-12-11 12:35:33.705860000 +0000
+++ bug-buddy-2.25.2/src/bug-buddy.c 2008-12-11 12:38:26.475348000 +0000
@@ -1096,19 +1096,30 @@ gdb_insert_text (const gchar *stacktrace
GtkTextView *text_view;
GtkTextIter end;
GtkTextBuffer *buffer;
+ char *gdb = g_find_program_in_path ("gdb");
+ char *pstack = g_find_program_in_path ("pstack");
- /* 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 defined(sun) && defined(__SVR4)
+ if (pstack) {
+ g_free (gdb);
+ gdb = NULL;
+ }
+#endif /* #if defined(sun) && defined(__SVR4) */
+
+ 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);
@@ -1117,6 +1128,9 @@ gdb_insert_text (const gchar *stacktrace
/* add the stacktrace to the GtkTextView */
gtk_text_buffer_insert (buffer, &end, stacktrace, strlen (stacktrace));
+ g_free (gdb);
+ g_free (pstack);
+
return TRUE;
}
/jds/bin/diff -uprN bug-buddy-2.25.2.old/src/gdb-buddy.c bug-buddy-2.25.2/src/gdb-buddy.c
--- bug-buddy-2.25.2.old/src/gdb-buddy.c 2008-12-11 12:35:33.723199000 +0000
+++ bug-buddy-2.25.2/src/gdb-buddy.c 2008-12-11 12:45:14.364972000 +0000
@@ -210,11 +210,9 @@ gdb_get_trace (const gchar *app, int pid
GIOChannel *ioc;
GError *error = NULL;
GdbData *gdb_data = NULL;
- char *args[] = { "gdb",
- "--batch",
- "--quiet",
- "--command=" BUDDY_DATADIR "/gdb-cmd",
- NULL, NULL, NULL };
+ 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);
@@ -225,6 +223,29 @@ gdb_get_trace (const gchar *app, int pid
d (g_print ("app=%s\n", app));
+#if 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);
@@ -249,30 +270,38 @@ gdb_get_trace (const gchar *app, int pid
}
}
- args[0] = g_find_program_in_path ("gdb");
- args[4] = long_app;
+ if (!pstack)
+ args[4] = long_app;
if (args[0] == NULL) {
d(g_message ("Path: %s", getenv ("PATH")));
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."),
+ pstack != NULL ? "pstack" : "GDB");
+ g_free (args[0]);
+ g_free (long_app);
return 0;
}
d(g_message ("About to debug '%s'", long_app));
- 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 (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,
@@ -284,7 +313,10 @@ gdb_get_trace (const gchar *app, int pid
error->message);
g_error_free (error);
g_free (args[0]);
- g_free (args[5]);
+ if (pstack)
+ g_free (args[1]);
+ else
+ g_free (args[5]);
g_free (long_app);
return 0;
}
@@ -309,7 +341,10 @@ gdb_get_trace (const gchar *app, int pid
g_io_channel_unref (ioc);
g_free (args[0]);
- g_free (args[5]);
+ if (pstack)
+ g_free (args[1]);
+ else
+ g_free (args[5]);
g_free (long_app);
return source_id;
/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
--- bug-buddy-2.25.2.old/gnome-breakpad/gnome-breakpad.cc 2008-12-11 12:35:33.736965000 +0000
+++ bug-buddy-2.25.2/gnome-breakpad/gnome-breakpad.cc 2008-12-11 12:55:07.314379000 +0000
@@ -379,25 +379,50 @@ run_bug_buddy (const gchar *appname, pid
static bool
run_gdb (const gchar *appname, pid_t pid)
{
- gchar *exec_str;
+ gchar *exec_str = NULL;
gchar *title;
gboolean res;
GError *error = NULL;
+ gchar *gdb = NULL;
title = g_strdup_printf ("Debugging %s", appname);
+#if defined(sun) && defined(__SVR4)
+ gdb = g_find_program_in_path("gdb");;
+ if (gdb) {
+ exec_str = g_strdup_printf("gnome-terminal "
+ "--title=\"%s\" "
+ "--disable-factory "
+ "--command=\"gdb %s %d\"",
+ title, appname, (int)pid);
+ g_free (gdb);
+ } else {
+ gchar *dbx = g_find_program_in_path("dbx");
+ if (dbx) {
+ exec_str = g_strdup_printf("gnome-terminal "
+ "--title=\"%s\" "
+ "--disable-factory "
+ "--command=\"dbx /proc/%d/object/a.out %d\"",
+ title, (int)pid, (int)pid);
+ }
+ g_free (dbx);
+ }
+#else
exec_str = g_strdup_printf("gnome-terminal "
"--title=\"%s\" "
"--disable-factory "
"--command=\"gdb %s %d\"",
title, appname, (int)pid);
- g_free (title);
- res = g_spawn_command_line_sync (exec_str, NULL, NULL,
- NULL, &error);
- g_free(exec_str);
- if (!res) {
- g_warning("Couldn't run debugger\n");
- return false;
+#endif /* defined(sun) && defined(__SVR4) */
+ g_free (title);
+ if (exec_str) {
+ res = g_spawn_command_line_sync (exec_str, NULL, NULL,
+ NULL, &error);
+ g_free(exec_str);
+ if (!res) {
+ g_warning("Couldn't run debugger\n");
+ return false;
+ }
}
return true;
@@ -406,8 +431,12 @@ run_gdb (const gchar *appname, pid_t pid
static void
check_if_gdb ()
{
- char *mypath;
- gchar *gdb;
+ char *mypath = NULL;
+ gchar *gdb = NULL;
+#if defined(sun) && defined(__SVR4)
+ gchar *pstack = NULL;
+ gchar *dbx = NULL;
+#endif /* defined(sun) && defined(__SVR4) */
bool has_debug_symbols = false;
char *filename;
gchar *appname;
@@ -421,22 +450,40 @@ check_if_gdb ()
appname = g_get_prgname ();
pid = getpid ();
+
+#if defined(sun) && defined(__SVR4)
+ gdb = g_find_program_in_path ("gdb");
+ pstack = g_find_program_in_path ("pstack");
+ dbx = g_find_program_in_path ("dbx");
+
+ if ((gdb || dbx) && g_getenv("GNOME_HACKER")) {
+#else
gdb = g_find_program_in_path ("gdb");
if (gdb && g_getenv("GNOME_HACKER")) {
+#endif /* defined(sun) && defined(__SVR4) */
res = run_gdb (appname, pid);
if (!res)
_exit (1);
_exit(0);
}
+#if defined(sun) && defined(__SVR4)
+ mypath = g_strdup_printf ("/proc/%d/object/a.out", (int)pid);
+#else
mypath = g_file_read_link ("/proc/self/exe", NULL);
+#endif /* defined(sun) && defined(__SVR4) */
+
if (mypath)
has_debug_symbols = elf_has_debug_symbols (mypath);
g_free (mypath);
+#if defined(sun) && defined(__SVR4)
+ if (bugbuddy && (gdb || pstack) && has_debug_symbols) {
+#else
if (bugbuddy && gdb && has_debug_symbols) {
+#endif /* defined(sun) && defined(__SVR4) */
res = run_bug_buddy (appname, pid, NULL);
if (!res)
_exit (1);