From: William Douglas Date: Thu, 28 Apr 2011 21:23:53 +0000 (-0700) Subject: Revert "Remove rpm information gathering as we don't use it" X-Git-Tag: 2.1b_release~80 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fdf41a786c8b22c419ef23e5a659c521492f97d;p=external%2Fcorewatcher.git Revert "Remove rpm information gathering as we don't use it" This reverts commit 6b98180a0081b109a973f609669256c7e2237122. --- diff --git a/coredump.c b/coredump.c index d2f8f78..f9cbe2c 100644 --- a/coredump.c +++ b/coredump.c @@ -43,6 +43,9 @@ int do_unlink = 0; int uid; int sig; +char *package; +char *component; +char *arch; #define MAX(A,B) ((A) > (B) ? (A) : (B)) @@ -156,6 +159,63 @@ void set_wrapped_app(char *line) */ } +void get_package_info(char *appfile) { + char *command = NULL, *line = NULL; + char *c; + FILE *file; + int ret = 0; + size_t size = 0; + + if (asprintf(&command, "rpm -q --whatprovides %s --queryformat \"%%{NAME}-%%{VERSION}-%%{RELEASE}-%%{ARCH}\"", appfile) < 0) { + package = strdup("Unknown"); + } else { + file = popen(command, "r"); + free(command); + ret = getline(&line, &size, file); + if ((!size) || (ret < 0)) { + package = strdup("Unknown"); + } else { + c = strchr(line, '\n'); + if (c) *c = 0; + package = strdup(line); + } + pclose(file); + } + + if (asprintf(&command, "rpm -q --whatprovides %s --queryformat \"%%{NAME}\"", appfile) < 0) { + component = strdup("Unknown"); + } else { + file = popen(command, "r"); + free(command); + ret = getline(&line, &size, file); + if ((!size) || (ret < 0)) { + component = strdup("Unknown"); + } else { + c = strchr(line, '\n'); + if (c) *c = 0; + component = strdup(line); + } + pclose(file); + } + + if (asprintf(&command, "rpm -q --whatprovides %s --queryformat \"%%{ARCH}\"", appfile) < 0) { + arch = strdup("Unknown"); + } else { + file = popen(command, "r"); + free(command); + ret = getline(&line, &size, file); + if ((!size) || (ret < 0)) { + arch = strdup("Unknown"); + } else { + c = strchr(line, '\n'); + if (c) *c = 0; + arch = strdup(line); + } + pclose(file); + } + free(line); +} + char *signame(int sig) { switch(sig) { @@ -208,11 +268,16 @@ char *build_core_header(char *appfile, char *corefile) { long int time = get_time(corefile); char *private = private_report ? "private: yes\n" : ""; + get_package_info(appfile); + ret = asprintf(&result, "analyzer: corewatcher-gdb\n" + "architecture: %s\n" + "component: %s\n" "coredump: %s\n" "executable: %s\n" "kernel: %s\n" + "package: %s\n" "reason: Process %s was killed by signal %d (%s)\n" "release: %s\n" "build: %s\n" @@ -220,9 +285,12 @@ char *build_core_header(char *appfile, char *corefile) { "uid: %d\n" "%s" "\nbacktrace\n-----\n", + arch, + component, corefile, appfile, kernel, + package, appfile, sig, signame(sig), release, build, @@ -231,8 +299,11 @@ char *build_core_header(char *appfile, char *corefile) { private); free(kernel); + free(package); free(release); free(build); + free(component); + free(arch); if (ret < 0) result = strdup("Unknown");