Home | History | Annotate | Download | only in patches
      1 --- bug-buddy-2.24.0.old/src/bug-buddy.c	2008-09-23 17:34:14.787129000 +0100
      2 +++ bug-buddy-2.24.0/src/bug-buddy.c	2008-09-23 17:40:40.385214000 +0100
      3 @@ -1082,19 +1082,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 @@ -1103,6 +1114,9 @@
     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 +
     53  	return TRUE;
     54  }
     55  
     56 --- bug-buddy-2.24.0.old/src/gdb-buddy.c	2008-09-23 17:34:14.917079000 +0100
     57 +++ bug-buddy-2.24.0/src/gdb-buddy.c	2008-09-23 17:39:09.080668000 +0100
     58 @@ -191,11 +191,9 @@
     59  	GIOChannel *ioc;
     60  	GError *error = NULL;
     61  	GdbData *gdb_data = NULL;
     62 -	char *args[] = { "gdb",
     63 -			 "--batch", 
     64 -			 "--quiet",
     65 -			 "--command=" BUDDY_DATADIR "/gdb-cmd",
     66 -			 NULL, NULL, NULL };
     67 +    char *args[7];
     68 +    char *gdb = NULL;
     69 +    char *pstack = NULL;
     70  
     71  	g_return_val_if_fail (app != NULL, 0);
     72  	g_return_val_if_fail (*app != '\0', 0);
     73 @@ -206,6 +204,29 @@
     74  
     75  	d (g_print ("app=%s\n", app));
     76  
     77 +#if defined(sun) && defined(__SVR4)
     78 +    pstack = g_find_program_in_path ("pstack");
     79 +
     80 +    if (pstack) {
     81 +        args[0] = pstack;
     82 +        args[2] = args[3] = args[4] = args[5] = args[6] = NULL;
     83 +    } else {
     84 +        gdb = g_find_program_in_path ("gdb");
     85 +        args[0] = gdb;
     86 +        args[1] = "--batch";
     87 +        args[2] = "--quiet";
     88 +        args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
     89 +        args[4] = args[5] = args[6] = NULL;
     90 +    }
     91 +#else
     92 +    gdb = g_find_program_in_path ("gdb");
     93 +    args[0] = gdb;
     94 +    args[1] = "--batch";
     95 +    args[2] = "--quiet";
     96 +    args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
     97 +    args[4] = args[5] = args[6] = NULL;
     98 +#endif /* defined(sun) && defined(__SVR4) */
     99 +
    100  	/* apply a SIGCONT to the process */
    101  	kill (pid, SIGCONT);
    102  
    103 @@ -226,33 +247,40 @@
    104  	if (!long_app) {
    105  		g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_BINARY_NOT_FOUND, 
    106  		             _("The binary file could not be found. Try using an absolute path."));
    107 +        g_free (args[0]);
    108  		return 0;
    109  	}
    110  
    111 -	args[0] = g_find_program_in_path ("gdb");
    112 -	args[4] = long_app;
    113 +    if (!pstack)
    114 +	    args[4] = long_app;
    115  
    116  	if (args[0] == NULL) {
    117  		d(g_message ("Path: %s", getenv ("PATH")));
    118  		g_free (long_app);
    119  		g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_NOT_FOUND, 
    120 -			     _("GDB could not be found on your system. "
    121 -			       "Debugging information will not be obtained."));
    122 +			     _("%s could not be found on your system. "
    123 +			       "Debugging information will not be obtained."),
    124 +                    pstack != NULL ? "pstack" : "GDB");
    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 -	}
    138 +    if (gdb) {
    139 +	    if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) {
    140 +		    g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 
    141 +			        _("Could not find the gdb-cmd file.\n"
    142 +			        "Please try reinstalling Bug Buddy."));
    143 +		    g_free (args[0]);
    144 +		    g_free (long_app);
    145 +		    return 0;
    146 +	    }
    147 +    }
    148  	
    149 -	args[5] = g_strdup_printf ("%d", pid);
    150 +    if (pstack)
    151 +	    args[1] = g_strdup_printf ("%d", pid);
    152 +    else
    153 +	    args[5] = g_strdup_printf ("%d", pid);
    154  	
    155  	if (!g_spawn_async_with_pipes (NULL, args, NULL, 0, NULL, NULL,
    156  				       &gdb_pid,
    157 @@ -264,7 +292,10 @@
    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 (long_app);
    167  		return 0;
    168  	} 
    169 @@ -289,7 +320,10 @@
    170  	g_io_channel_unref (ioc);
    171  
    172  	g_free (args[0]);
    173 -	g_free (args[5]);
    174 +    if (pstack)
    175 +	    g_free (args[1]);
    176 +    else
    177 +	    g_free (args[5]);
    178  	g_free (long_app);
    179  
    180  	return source_id;
    181 --- bug-buddy-2.24.0.old/gnome-breakpad/gnome-breakpad.cc	2008-09-23 17:34:14.923569000 +0100
    182 +++ bug-buddy-2.24.0/gnome-breakpad/gnome-breakpad.cc	2008-09-23 17:45:01.808420000 +0100
    183 @@ -232,25 +232,52 @@
    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 +#endif /* defined(sun) && defined(__SVR4) */
    225 +
    226 +	g_free (title);
    227 +
    228 +	if (exec_str) {
    229 +		res = g_spawn_command_line_sync (exec_str, NULL, NULL,
    230  					 NULL, &error);
    231 -	g_free(exec_str);
    232 -	if (!res) {
    233 -		g_warning("Couldn't run debugger\n");
    234 -		return false;
    235 +		g_free(exec_str);
    236 +		if (!res) {
    237 +			g_warning("Couldn't run debugger\n");
    238 +			return false;
    239 +		}
    240  	}
    241  
    242  	return true;
    243 @@ -260,7 +287,11 @@
    244  check_if_gdb ()
    245  {
    246  	char mypath[255];
    247 -	gchar *gdb;
    248 +	gchar *gdb = NULL;
    249 +#if defined(sun) && defined(__SVR4)
    250 +	gchar *pstack = NULL;
    251 +	gchar *dbx = NULL;
    252 +#endif /* defined(sun) && defined(__SVR4) */
    253  	bool has_debug_symbols;
    254  	char *filename;
    255  	gchar *appname;
    256 @@ -274,9 +305,18 @@
    257  
    258  	appname = g_get_prgname ();
    259  	pid = getpid ();
    260 +
    261 +#if defined(sun) && defined(__SVR4)
    262 +	gdb = g_find_program_in_path ("gdb");
    263 +	pstack = g_find_program_in_path ("pstack");
    264 +	dbx = g_find_program_in_path ("dbx");
    265 +
    266 +	if ((gdb || dbx) && g_getenv("GNOME_HACKER")) {
    267 +#else
    268  	gdb = g_find_program_in_path ("gdb");
    269  
    270  	if (gdb && g_getenv("GNOME_HACKER")) {
    271 +#endif /* defined(sun) && defined(__SVR4) */
    272  		res = run_gdb (appname, pid);
    273  		if (!res)
    274  			_exit (1);
    275 @@ -284,10 +324,18 @@
    276  	}
    277  	
    278  	memset(mypath, 0, sizeof(mypath));
    279 +#if defined(sun) && defined(__SVR4)
    280 +    snprintf (mypath, sizeof (mypath), "/proc/%d/object/a.out", (int)pid);
    281 +#else
    282  	readlink ("/proc/self/exe", mypath, sizeof(mypath));
    283 +#endif /* defined(sun) && defined(__SVR4) */
    284  	has_debug_symbols = elf_has_debug_symbols (mypath);
    285  
    286 +#if defined(sun) && defined(__SVR4)
    287 +	if (bugbuddy && (gdb || pstack) && has_debug_symbols) {
    288 +#else
    289  	if (bugbuddy && gdb && has_debug_symbols) {
    290 +#endif /* defined(sun) && defined(__SVR4) */
    291  		res = run_bug_buddy (appname, pid, NULL);
    292  		if (!res)
    293  			_exit (1);
    294