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;
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;
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];
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;