~ubuntu-branches/ubuntu/oneiric/bug-buddy/oneiric

« back to all changes in this revision

Viewing changes to src/gdb-buddy.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-03-17 11:52:38 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20090317115238-pelki75p8yvl9bw1
Tags: 2.26.0+dfsg-0ubuntu1
* New upstream release: (LP: #344132)
  - Don't hardcode a scrollkeeper check in the configure script.
  - Build correctly with --disable-eds.
  - Fix a segfault (Josseline Mouette).
  - Don't free uninitialized memory.
  - Drop libgnome and libgnomeui dependencies.
  - Make google-breakpad support optional (but enabled by default).
    Thanks to Sjoerd Simons.
  - Obtain the real path of the crashed process by looking in /proc.
    Thanks to Sam Morris and Matt Keenan.
  - Add an option to delete the included file after bug-buddy has
    processed it.
  - Implement a logger for pasting critical and fatal warnings in the
    stacktraces.
  - Include the loaded GTK+ modules in the stacktraces sent to bugzilla.
  - Update google-breakpad to SVN r290.
  - Compile with all the GLib/GTK+ deprecation flags.
* debian/control.in:
  - remove scroolkeeper, libgnome2-dev and libgnomeui-dev b-d
  - bump libgtk2.0-dev to 2.14
  - add libgconf2-dev
  - add Vcs-Bzr tag
  - re-generate debian/control
* debian/patches:
  - remove 01_double-free.patch as taken upstream
  - remove 02_disable_breakpad.patch as upstream handle --disable-*
    (and so, --disable-google-breakpad)
  - refresh 70_automake-autoconf.patch
* debian/rules: remove --disable-scrollkeeper as removed in configure
  file
* Adapt debian/watch to get unstable version

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include "gdb-buddy.h"
35
35
 
36
 
#if 0
37
 
#include <libart_lgpl/libart.h>
38
 
#endif
39
 
 
40
36
#define d(x)
41
37
 
42
38
typedef struct {
162
158
          return g_quark_from_static_string ("gdb_buddy_error");
163
159
}
164
160
 
 
161
static char *
 
162
get_process_executable (int pid)
 
163
{
 
164
        char *link, *exe;
 
165
        GError *error = NULL;
 
166
 
 
167
#if defined (__linux__)
 
168
        link = g_strdup_printf ("/proc/%d/exe", pid);
 
169
#elif defined (sun) && defined (__SVR4)
 
170
        link = g_strdup_printf ("/proc/%d/path/a.out", pid);
 
171
#else
 
172
        /* if someone knows how to do this on BSD, please send a patch */
 
173
        return NULL;
 
174
#endif
 
175
        exe = g_file_read_link (link, &error);
 
176
 
 
177
        if (error) {
 
178
                g_warning ("Could not read %s: %s\n", link, error->message);
 
179
                g_error_free (error);
 
180
        }
 
181
 
 
182
        return exe;
 
183
}
 
184
 
165
185
/**
166
186
 * @app: the executable name of the program that crashed
167
187
 * @pid: the process id of the application that crashed
183
203
gdb_get_trace (const gchar *app, int pid, gpointer user_data, GdbCallback gdb_finish, GError **err)
184
204
{
185
205
        char *s;
186
 
        const char *short_app;
187
206
        char *long_app;
188
207
        int gdb_pid;
189
208
        int fd;
209
228
        /* apply a SIGCONT to the process */
210
229
        kill (pid, SIGCONT);
211
230
 
212
 
        /* check for absolute or relative path */
213
 
        if (app[0] == G_DIR_SEPARATOR) {
 
231
        /* to get the application path do the following:
 
232
         * - if the path is absolute, it has been provided by the user, so just use it.
 
233
         * - otherwise look for it in /proc based on its pid.
 
234
         * - if that fails, look for the program in path.
 
235
         * - finally, use $libexecdir as fallback.
 
236
         */
 
237
 
 
238
        if (g_path_is_absolute (app)) {
214
239
                long_app = g_strdup (app);
215
 
                short_app = strrchr (app, G_DIR_SEPARATOR) + 1;
216
240
        } else {
217
 
                /* app is a relative path... get absolute path in long_app */
 
241
                long_app = get_process_executable (pid);
 
242
        }
 
243
 
 
244
        if (!long_app) {
218
245
                long_app = g_find_program_in_path (app);
219
246
                if (!long_app) {
220
 
                        /* Applets are not in path... */
221
 
                        long_app = g_strconcat(GNOMELIBEXECDIR,"/", app, NULL);
 
247
                        /* this should never fail */
 
248
                        long_app = g_strconcat (GNOMELIBEXECDIR,"/", app, NULL);
222
249
                }
223
 
                short_app = app;
224
 
        }       
225
 
 
226
 
        if (!long_app) {
227
 
                g_set_error (err, GDB_BUDDY_ERROR, GDB_BUDDY_BINARY_NOT_FOUND, 
228
 
                             _("The binary file could not be found. Try using an absolute path."));
229
 
                return 0;
230
250
        }
231
251
 
232
252
        args[0] = g_find_program_in_path ("gdb");