Have the process reported be the actual process run by meego-tablet-wrapper
authorWilliam Douglas <william.douglas@linux.intel.com>
Thu, 10 Feb 2011 22:44:06 +0000 (14:44 -0800)
committerWilliam Douglas <william.douglas@linux.intel.com>
Thu, 10 Feb 2011 22:44:06 +0000 (14:44 -0800)
coredump.c
find_file.c

index 3532a95..ad166ca 100644 (file)
@@ -82,6 +82,32 @@ static char *get_release(void) {
        return line;
 }
 
+void set_wrapped_app(char *line)
+{
+       char *dline = NULL, *app = NULL, delim[] = " '";
+
+       dline = strdup(line);
+
+       app = strtok(dline, delim);
+       while(app) {
+               if (strcmp(app, "--app") == 0) {
+                       app = strtok(NULL, delim);
+                       break;
+               }
+               app = strtok(NULL, delim);
+       }
+
+       if (app != NULL)
+               /*
+                * This may return NULL if app isn't on the path
+                * but we aren't going to worry about that here.
+                */
+               app = find_executable(app);
+       free(dline);
+
+       return;
+}
+
 void get_package_info(char *appfile) {
        char *command = NULL, *line = NULL;
        char *c;
@@ -229,11 +255,34 @@ char *extract_core(char *corefile)
        if (!appfile)
                return NULL;
 
-       c1 = build_core_header(appfile, corefile);
-
        if (asprintf(&command, "LANG=C gdb --batch -f %s %s -x /var/lib/corewatcher/gdb.command 2> /dev/null", appfile, corefile) < 0)
                return NULL;
 
+       /*
+        * Scan core dump in case meego-tablet-wrapper was used
+        * to run the process and get the actual app name
+        */
+       file = popen(command, "r");
+       while (!feof(file)) {
+               size_t size = 0;
+               int ret;
+
+               line = NULL;
+               ret = getline(&line, &size, file);
+               if (!size)
+                       break;
+               if (ret < 0)
+                       break;
+
+               if (strstr(line, "Core was generated by `")) {
+                       /* attempt to update appfile */
+                       set_wrapped_app(line);
+                       break;
+               }
+       }
+
+       c1 = build_core_header(appfile, corefile);
+
        file = popen(command, "r");
        while (!feof(file)) {
                size_t size = 0;
index dd0b122..6d9de80 100644 (file)
 
 char *find_executable(char *fragment)
 {
+       /*
+        * Added path_filename to avoid writing over
+        * filename if this function is called twice.
+        * (When meego-tablet-wrapper is used)
+        */
+       char path_filename[PATH_MAX*2];
        char *path, *c1, *c2;
        static char filename[PATH_MAX*2];
 
@@ -42,9 +48,10 @@ char *find_executable(char *fragment)
        while (c1 && strlen(c1)>0) {
                c2 = strchr(c1, ':');
                if (c2) *c2=0;
-               sprintf(filename, "%s/%s", c1, fragment);
-               if (!access(filename, X_OK)) {
-                       printf("Found %s\n", filename);
+               sprintf(path_filename, "%s/%s", c1, fragment);
+               if (!access(path_filename, X_OK)) {
+                       printf("Found %s\n", path_filename);
+                       strcpy(filename, path_filename);
                        return filename;
                }
                c1 = c2;