summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-04-08 16:39:59 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-04-08 16:39:59 +0200
commitfcb0620a371475f154a5a1fb91a319ff3483ca0d (patch)
tree526459564575155e32abe1697a1a73301b725446 /src/lib
parent11cda4235472caaa1fc015897ee4372a782555f5 (diff)
downloadabrt-fcb0620a371475f154a5a1fb91a319ff3483ca0d.tar.gz
abrt-fcb0620a371475f154a5a1fb91a319ff3483ca0d.tar.xz
abrt-fcb0620a371475f154a5a1fb91a319ff3483ca0d.zip
abrt-cli is one of several places where we hardcode usage of various
elements of dump directory. This patch changes it to generic handling, where abrt-cli doesn't know anything about particular elements (like backtrace). Changes in detail: * crash_item->flags how has CD_FLAG_UNIXTIME bit. * format_crash_item(item) returns malloced formatted string (currently only formatted time for items with CD_FLAG_UNIXTIME) or NULL, if item->content is to be used as-is * crash_item->flags how has CD_FLAG_LIST bit, it is set on a small number of elements which are to be shown by abrt-cli -l. * abrt-cli -l doesn't use fixed names, it looks at CD_FLAG_LIST. * abrt-cli -i doesn't use fixed names, it prints all one-line elements: Directory : /var/spool/abrt/ccpp-1298264192-2705 analyzer : CCpp architecture : x86_64 cmdline : metacity comment : Abrt testing, please disregard component : metacity coredump : /var/spool/abrt/ccpp-1298264192-2705/coredump count : 1 crash_function : pa_atomic_load executable : /usr/bin/metacity global_uuid : 1e8b716d2094fb22dccdb5321ac0cf6f14eb6689 hostname : dhcp-25-227.brq.redhat.com kernel : 2.6.34.7-61.fc13.x86_64 os_release : Fedora release 13 (Goddard) package : metacity-2.30.0-3.fc13 rating : 4 reason : Process /usr/bin/metacity was killed by signal 11 (SIGSEGV) time : Mon 21 Feb 2011 05:56:32 AM CET uid : 500 uuid : 453085d0f703b96ddc3a5172dd7d5a29479f5b3f * abrt-cli -i --backtrace is removed. Instead, abrt-cli -i --full is to be used. It shows all elements, one-line and multi-line ones. * abrt-cli code now has an example how to list crast_data_t in the sorted-by-key order. Further ideas: abrt-cli needs -o elem1,elem2,elem3 option which tells which elements to show, and/or -O elem1,elem2,elem3 option which tells elements to NOT show. Rationale: abrt-cli -i --full output is way too long because of smaps, need a way to suppress unneeded elements display Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/crash_data.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/lib/crash_data.c b/src/lib/crash_data.c
index a3ba3fb6..81513388 100644
--- a/src/lib/crash_data.c
+++ b/src/lib/crash_data.c
@@ -28,6 +28,26 @@ static void free_crash_item(void *ptr)
}
}
+char *format_crash_item(struct crash_item *item)
+{
+ if (!item)
+ return xstrdup("(nullitem)");
+
+ if (item->flags & CD_FLAG_UNIXTIME)
+ {
+ errno = 0;
+ char *end;
+ time_t time = strtol(item->content, &end, 10);
+ if (!errno && !*end && end != item->content)
+ {
+ char timeloc[256];
+ int success = strftime(timeloc, sizeof(timeloc), "%c", localtime(&time));
+ if (success)
+ return xstrdup(timeloc);
+ }
+ }
+ return NULL;
+}
/* crash_data["name"] = { "content", CD_FLAG_foo_bits } */
@@ -43,11 +63,7 @@ void add_to_crash_data_ext(crash_data_t *crash_data,
unsigned flags)
{
if (!(flags & CD_FLAG_BIN))
- {
flags |= CD_FLAG_TXT;
- if (!strchr(content, '\n'))
- flags |= CD_FLAG_ONELINE;
- }
if (!(flags & CD_FLAG_ISEDITABLE))
flags |= CD_FLAG_ISNOTEDITABLE;
@@ -244,9 +260,19 @@ void load_crash_data_from_dump_dir(crash_data_t *crash_data, struct dump_dir *dd
else
flags |= CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE;
- int oneline = strchr(content, '\n') == NULL;
- if (oneline)
- flags |= CD_FLAG_ONELINE;
+ static const char *const list_files[] = {
+ FILENAME_UID ,
+ FILENAME_PACKAGE ,
+ FILENAME_EXECUTABLE,
+ FILENAME_TIME ,
+ FILENAME_COUNT ,
+ NULL
+ };
+ if (is_in_list(short_name, list_files))
+ flags |= CD_FLAG_LIST;
+
+ if (strcmp(short_name, FILENAME_TIME) == 0)
+ flags |= CD_FLAG_UNIXTIME;
add_to_crash_data_ext(crash_data,
short_name,