Home | History | Annotate | Download | only in patches
      1 --- bug-buddy-2.23.90.old/src/gdb-buddy.c	2008-09-01 16:29:22.471669000 +0100
      2 +++ bug-buddy-2.23.90/src/gdb-buddy.c	2008-09-01 16:34:09.490863000 +0100
      3 @@ -191,11 +191,9 @@
      4  	GIOChannel *ioc;
      5  	GError *error = NULL;
      6  	GdbData *gdb_data = NULL;
      7 -	char *args[] = { "gdb",
      8 -			 "--batch", 
      9 -			 "--quiet",
     10 -			 "--command=" BUDDY_DATADIR "/gdb-cmd",
     11 -			 NULL, NULL, NULL };
     12 +    char *args[7];
     13 +    char *gdb = NULL;
     14 +    char *pstack = NULL;
     15  
     16  	g_return_val_if_fail (app != NULL, 0);
     17  	g_return_val_if_fail (*app != '\0', 0);
     18 @@ -206,6 +204,29 @@
     19  
     20  	d (g_print ("app=%s\n", app));
     21  
     22 +#if defined(sun) && defined(__SVR4)
     23 +    pstack = g_find_program_in_path ("pstack");
     24 +
     25 +    if (pstack) {
     26 +        args[0] = pstack;
     27 +        args[2] = args[3] = args[4] = args[5] = args[6] = NULL;
     28 +    } else {
     29 +        gdb = g_find_program_in_path ("gdb");
     30 +        args[0] = gdb;
     31 +        args[1] = "--batch";
     32 +        args[2] = "--quiet";
     33 +        args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
     34 +        args[4] = args[5] = args[6] = NULL;
     35 +    }
     36 +#else
     37 +    gdb = g_find_program_in_path ("gdb");
     38 +    args[0] = gdb;
     39 +    args[1] = "--batch";
     40 +    args[2] = "--quiet";
     41 +    args[3] = "--command=" BUDDY_DATADIR "/gdb-cmd";
     42 +    args[4] = args[5] = args[6] = NULL;
     43 +#endif /* defined(sun) && defined(__SVR4) */
     44 +
     45  	/* apply a SIGCONT to the process */
     46  	kill (pid, SIGCONT);
     47  
     48 @@ -226,33 +247,41 @@
     49  	if (!long_app) {
     50  		g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_BINARY_NOT_FOUND, 
     51  		             _("The binary file could not be found. Try using an absolute path."));
     52 +        g_free (args[0]);
     53  		return 0;
     54  	}
     55  
     56 -	args[0] = g_find_program_in_path ("gdb");
     57 -	args[4] = long_app;
     58 +    if (!pstack)
     59 +        args[4] = long_app;
     60  
     61  	if (args[0] == NULL) {
     62  		d(g_message ("Path: %s", getenv ("PATH")));
     63  		g_free (long_app);
     64  		g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_NOT_FOUND, 
     65 -			     _("GDB could not be found on your system. "
     66 -			       "Debugging information will not be obtained."));
     67 +			     _("%s could not be found on your system. "
     68 +			       "Debugging information will not be obtained."),
     69 +                    pstack != NULL ? "pstack" : "GDB");
     70 +        g_free (args[0]);
     71  		return 0;
     72  	} 
     73  	
     74  	d(g_message ("About to debug '%s'", long_app));
     75  	
     76 -	if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) {
     77 -		g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 
     78 -			     _("Could not find the gdb-cmd file.\n"
     79 -			       "Please try reinstalling Bug Buddy."));
     80 -		g_free (args[0]);
     81 -		g_free (long_app);
     82 -		return 0;
     83 -	}
     84 +    if (gdb) {
     85 +	    if (!g_file_test (BUDDY_DATADIR "/gdb-cmd", G_FILE_TEST_EXISTS)) {
     86 +		    g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_GDB_CMD_NOT_FOUND, 
     87 +			        _("Could not find the gdb-cmd file.\n"
     88 +			        "Please try reinstalling Bug Buddy."));
     89 +            g_free (args[0]);
     90 +		    g_free (long_app);
     91 +		    return 0;
     92 +	    }
     93 +    }
     94  	
     95 -	args[5] = g_strdup_printf ("%d", pid);
     96 +    if (pstack) 
     97 +	    args[1] = g_strdup_printf ("%d", pid);
     98 +    else
     99 +	    args[5] = g_strdup_printf ("%d", pid);
    100  	
    101  	if (!g_spawn_async_with_pipes (NULL, args, NULL, 0, NULL, NULL,
    102  				       &gdb_pid,
    103 @@ -263,8 +292,11 @@
    104  			     _("There was an error running gdb:\n\n%s"),
    105  			     error->message);
    106  		g_error_free (error);
    107 -		g_free (args[0]);
    108 -		g_free (args[5]);
    109 +        g_free (args[0]);
    110 +        if (pstack)
    111 +		    g_free (args[1]);
    112 +        else
    113 +		    g_free (args[5]);
    114  		g_free (long_app);
    115  		return 0;
    116  	} 
    117 @@ -288,8 +320,11 @@
    118  	                                 gdb_handle_input, gdb_data, gdb_destroy);
    119  	g_io_channel_unref (ioc);
    120  
    121 -	g_free (args[0]);
    122 -	g_free (args[5]);
    123 +    g_free (args[0]);
    124 +    if (pstack)
    125 +	    g_free (args[1]);
    126 +    else
    127 +	    g_free (args[5]);
    128  	g_free (long_app);
    129  
    130  	return source_id;
    131 --- bug-buddy-2.23.90.old/src/bug-buddy.c	2008-09-01 16:29:22.470638000 +0100
    132 +++ bug-buddy-2.23.90/src/bug-buddy.c	2008-09-01 16:35:04.943188000 +0100
    133 @@ -1082,19 +1082,30 @@
    134  	GtkTextView *text_view;
    135  	GtkTextIter end;
    136  	GtkTextBuffer *buffer;
    137 +    char *gdb = g_find_program_in_path ("gdb");
    138 +    char *pstack = g_find_program_in_path ("pstack");
    139  
    140 -	/* FIXME: These strings are gdb specific, we should add here also dbx */
    141 -	const char *bt_step1 = "#1";
    142 -	const char *bt_step2 = "#2";
    143 -	const char *bt_step3 = "#3";
    144 -
    145 -	if (!g_strrstr (stacktrace, bt_step1) &&
    146 -            !g_strrstr (stacktrace, bt_step2) &&
    147 -            !g_strrstr (stacktrace, bt_step3)) {
    148 -		return FALSE;
    149 -	}
    150 -
    151 -
    152 +#if defined(sun) && defined(__SVR4)
    153 +    if (pstack) {
    154 +        g_free (gdb);
    155 +        gdb = NULL;
    156 +    }
    157 +#endif /* defined(sun) && defined(__SVR4) */
    158 +
    159 +    if (gdb) {
    160 +	    /* FIXME: These strings are gdb specific, we should add here also dbx */
    161 +	    const char *bt_step1 = "#1";
    162 +	    const char *bt_step2 = "#2";
    163 +	    const char *bt_step3 = "#3";
    164 +
    165 +	    if (!g_strrstr (stacktrace, bt_step1) &&
    166 +                !g_strrstr (stacktrace, bt_step2) &&
    167 +                !g_strrstr (stacktrace, bt_step3)) {
    168 +            g_free (gdb);
    169 +            g_free (pstack);
    170 +		    return FALSE;
    171 +	    }
    172 +    }
    173  
    174  	text_view = GTK_TEXT_VIEW (gtk_builder_get_object (ui, "gdb-text"));
    175  	buffer = gtk_text_view_get_buffer (text_view);
    176 @@ -1103,6 +1114,8 @@
    177  	/* add the stacktrace to the GtkTextView */
    178  	gtk_text_buffer_insert (buffer, &end, stacktrace, strlen (stacktrace));
    179  
    180 +    g_free (gdb);
    181 +    g_free (pstack);
    182  	return TRUE;
    183  }
    184  
    185 --- bug-buddy-2.23.91.old/gnome-breakpad/gnome-breakpad.cc	2008-09-01 16:48:05.336792000 +0100
    186 +++ bug-buddy-2.23.91/gnome-breakpad/gnome-breakpad.cc	2008-09-01 16:47:48.785366000 +0100
    187 @@ -222,25 +222,52 @@
    188  static bool
    189  run_gdb (const gchar *appname, pid_t pid)
    190  {
    191 -	gchar *exec_str;
    192 +	gchar *exec_str = NULL;
    193  	gchar *title;
    194  	gboolean res;
    195  	GError *error = NULL;
    196 +	gchar *gdb = NULL;
    197  
    198  	title = g_strdup_printf ("Debugging %s", appname);
    199  
    200 +#if defined(sun) && defined(__SVR4)
    201 +	gdb = g_find_program_in_path("gdb");;
    202 +	if (gdb) {
    203 +		exec_str = g_strdup_printf("gnome-terminal "
    204 +				 "--title=\"%s\" "
    205 +				 "--disable-factory "
    206 +				 "--command=\"gdb %s %d\"",
    207 +				title, appname, (int)pid);
    208 +		g_free (gdb);
    209 +	} else {
    210 +		gchar *dbx = g_find_program_in_path("dbx");
    211 +		if (dbx) {
    212 +			exec_str = g_strdup_printf("gnome-terminal "
    213 +				 	"--title=\"%s\" "
    214 +				 	"--disable-factory "
    215 +				 	"--command=\"dbx /proc/%d/object/a.out %d\"",
    216 +					title, (int)pid, (int)pid);
    217 +		}
    218 +		g_free (dbx);
    219 +	}
    220 +#else
    221  	exec_str = g_strdup_printf("gnome-terminal "
    222  				 "--title=\"%s\" "
    223  				 "--disable-factory "
    224  				 "--command=\"gdb %s %d\"",
    225  				title, appname, (int)pid);
    226 -				g_free (title);
    227 -	res = g_spawn_command_line_sync (exec_str, NULL, NULL,
    228 +#endif /* defined(sun) && defined(__SVR4) */
    229 +
    230 +	g_free (title);
    231 +
    232 +	if (exec_str) {
    233 +		res = g_spawn_command_line_sync (exec_str, NULL, NULL,
    234  					 NULL, &error);
    235 -	g_free(exec_str);
    236 -	if (!res) {
    237 -		g_warning("Couldn't run debugger\n");
    238 -		return false;
    239 +		g_free(exec_str);
    240 +		if (!res) {
    241 +			g_warning("Couldn't run debugger\n");
    242 +			return false;
    243 +		}
    244  	}
    245  
    246  	return true;
    247 @@ -250,7 +277,11 @@
    248  check_if_gdb (void *callback_context)
    249  {
    250  	char mypath[255];
    251 -	gchar *gdb;
    252 +	gchar *gdb = NULL;
    253 +#if defined(sun) && defined(__SVR4)
    254 +	gchar *pstack = NULL;
    255 +	gchar *dbx = NULL;
    256 +#endif /* defined(sun) && defined(__SVR4) */
    257  	bool has_debug_symbols;
    258  	char *filename;
    259  	gchar *appname;
    260 @@ -264,9 +295,18 @@
    261  
    262  	appname = g_get_prgname ();
    263  	pid = getpid ();
    264 +
    265 +#if defined(sun) && defined(__SVR4)
    266 +	gdb = g_find_program_in_path ("gdb");
    267 +	pstack = g_find_program_in_path ("pstack");
    268 +	dbx = g_find_program_in_path ("dbx");
    269 +
    270 +	if ((gdb || dbx) && g_getenv("GNOME_HACKER")) {
    271 +#else
    272  	gdb = g_find_program_in_path ("gdb");
    273  
    274  	if (gdb && g_getenv("GNOME_HACKER")) {
    275 +#endif /* defined(sun) && defined(__SVR4) */
    276  		res = run_gdb (appname, pid);
    277  		if (!res)
    278  			_exit (1);
    279 @@ -274,11 +314,19 @@
    280  	}
    281  	
    282  	memset(mypath, 0, sizeof(mypath));
    283 +#if defined(sun) && defined(__SVR4)
    284 +    snprintf (mypath, sizeof (mypath), "/proc/%d/object/a.out", (int)pid);
    285 +#else
    286  	readlink ("/proc/self/exe", mypath, sizeof(mypath));
    287 +#endif /* defined(sun) && defined(__SVR4) */
    288  	has_debug_symbols = elf_has_debug_symbols (mypath);
    289  
    290  
    291 +#if defined(sun) && defined(__SVR4)
    292 +	if (bugbuddy && (gdb || pstack) && has_debug_symbols) {
    293 +#else
    294  	if (bugbuddy && gdb && has_debug_symbols) {
    295 +#endif /* defined(sun) && defined(__SVR4) */
    296  		res = run_bug_buddy (appname, pid, NULL);
    297  		if (!res)
    298  			_exit (1);
    299