summaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-11-23 15:51:54 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-11-23 15:51:54 +0100
commit86fc61db75385d6fb452b4cf88aec1deffa3a5be (patch)
tree8b88bd46ef8fe05167f72b3d1f0bff034620b9a1 /src/cli
parentd992b91c61b4da10e1f977038d85cd640f8d7ae5 (diff)
downloadabrt-86fc61db75385d6fb452b4cf88aec1deffa3a5be.tar.gz
abrt-86fc61db75385d6fb452b4cf88aec1deffa3a5be.tar.xz
abrt-86fc61db75385d6fb452b4cf88aec1deffa3a5be.zip
remove sqlite DB
This change removes sqlite database. Database was used to find dump dirs by [UID:]UUID. This patch uses more natural way: dump dirs are addressed by their directory names. DB was also used to produce a list of dump dirs. Now it is done by iterating over the /var/spool/abrt directory. And finally, DB was also used to find duplicate UUIDs. Now it is done by iterating over the /var/spool/abrt directory. Crash count, "inform all" and reporting result message are moved from DB field to a file in dump dir. "Reported" DB field is deleted - if message != "", then this dump was reported. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/CLI.cpp39
-rw-r--r--src/cli/abrt-cli.16
-rw-r--r--src/cli/report.cpp101
3 files changed, 40 insertions, 106 deletions
diff --git a/src/cli/CLI.cpp b/src/cli/CLI.cpp
index d4bb333d..6ef5b1e9 100644
--- a/src/cli/CLI.cpp
+++ b/src/cli/CLI.cpp
@@ -44,18 +44,18 @@ static void print_crash(const map_crash_data_t &crash)
const char *timestr = get_crash_data_item_content(crash, FILENAME_TIME).c_str();
const char *timeloc = localize_crash_time(timestr);
- printf(_("\tUID : %s\n"
- "\tUUID : %s\n"
+ printf(_("\tCrash dump : %s\n"
+ "\tUID : %s\n"
"\tPackage : %s\n"
"\tExecutable : %s\n"
"\tCrash Time : %s\n"
"\tCrash Count: %s\n"),
- get_crash_data_item_content(crash, CD_UID).c_str(),
- get_crash_data_item_content(crash, CD_UUID).c_str(),
+ get_crash_data_item_content(crash, CD_DUMPDIR).c_str(),
+ get_crash_data_item_content(crash, FILENAME_UID).c_str(),
get_crash_data_item_content(crash, FILENAME_PACKAGE).c_str(),
get_crash_data_item_content(crash, FILENAME_EXECUTABLE).c_str(),
timeloc,
- get_crash_data_item_content(crash, CD_COUNT).c_str());
+ get_crash_data_item_content(crash, FILENAME_COUNT).c_str());
free((void *)timeloc);
@@ -75,7 +75,7 @@ static void print_crash_list(const vector_map_crash_data_t& crash_list, bool inc
for (unsigned i = 0; i < crash_list.size(); ++i)
{
const map_crash_data_t& crash = crash_list[i];
- if (get_crash_data_item_content(crash, CD_REPORTED) == "1" && !include_reported)
+ if (get_crash_data_item_content(crash, FILENAME_MESSAGE) != "" && !include_reported)
continue;
printf("%u.\n", i);
@@ -91,7 +91,7 @@ static void print_crash_info(const map_crash_data_t& crash, bool show_backtrace)
const char *timestr = get_crash_data_item_content(crash, FILENAME_TIME).c_str();
const char *timeloc = localize_crash_time(timestr);
- printf(_("Crash ID: %s:%s\n"
+ printf(_("Dump directory: %s\n"
"Last crash: %s\n"
"Analyzer: %s\n"
"Component: %s\n"
@@ -100,8 +100,7 @@ static void print_crash_info(const map_crash_data_t& crash, bool show_backtrace)
"Executable: %s\n"
"System: %s, kernel %s\n"
"Reason: %s\n"),
- get_crash_data_item_content(crash, CD_UID).c_str(),
- get_crash_data_item_content(crash, CD_UUID).c_str(),
+ get_crash_data_item_content(crash, CD_DUMPDIR).c_str(),
timeloc,
get_crash_data_item_content(crash, FILENAME_ANALYZER).c_str(),
get_crash_data_item_content(crash, FILENAME_COMPONENT).c_str(),
@@ -151,8 +150,7 @@ static void print_crash_info(const map_crash_data_t& crash, bool show_backtrace)
}
/**
- * Converts crash reference from user's input to unique crash identification
- * in form UID:UUID.
+ * Converts crash reference from user's input to crash dump dir name.
* The returned string must be released by caller.
*/
static char *guess_crash_id(const char *str)
@@ -165,10 +163,7 @@ static char *guess_crash_id(const char *str)
if (position >= num_crashinfos)
error_msg_and_die("There are only %u crash infos", num_crashinfos);
map_crash_data_t& info = ci[position];
- return xasprintf("%s:%s",
- get_crash_data_item_content(info, CD_UID).c_str(),
- get_crash_data_item_content(info, CD_UUID).c_str()
- );
+ return xstrdup(get_crash_data_item_content(info, CD_DUMPDIR).c_str());
}
unsigned len = strlen(str);
@@ -177,19 +172,16 @@ static char *guess_crash_id(const char *str)
for (ii = 0; ii < num_crashinfos; ii++)
{
map_crash_data_t& info = ci[ii];
- const char *this_uuid = get_crash_data_item_content(info, CD_UUID).c_str();
- if (strncmp(str, this_uuid, len) == 0)
+ const char *this_dir = get_crash_data_item_content(info, CD_DUMPDIR).c_str();
+ if (strncmp(str, this_dir, len) == 0)
{
if (result)
error_msg_and_die("Crash prefix '%s' is not unique", str);
- result = xasprintf("%s:%s",
- get_crash_data_item_content(info, CD_UID).c_str(),
- this_uuid
- );
+ result = xstrdup(this_dir);
}
}
if (!result)
- error_msg_and_die("Crash '%s' not found", str);
+ error_msg_and_die("Crash dump directory '%s' not found", str);
return result;
}
@@ -257,8 +249,7 @@ static void usage(char *argv0)
" -i, --info CRASH_ID print detailed information about a crash\n"
" -b, --backtrace print detailed information about a crash including backtrace\n"
"CRASH_ID can be:\n"
- " UID:UUID pair,\n"
- " unique UUID prefix - the crash with matching UUID will be acted upon\n"
+ " a name of dump directory, or\n"
" @N - N'th crash (as displayed by --list --full) will be acted upon\n"
),
name, name);
diff --git a/src/cli/abrt-cli.1 b/src/cli/abrt-cli.1
index 3ad858b3..1622fb14 100644
--- a/src/cli/abrt-cli.1
+++ b/src/cli/abrt-cli.1
@@ -21,13 +21,13 @@ Print a help message describing all of abrt-cli’s command-line options.
.B Crash action options
.IP "\-l, \-\-list"
Prints list of crashes which are not reported yet.
-.IP "\-r, \-\-report \fIUUID\fR"
+.IP "\-r, \-\-report \fIDUMPDIR\fR"
Creates a crash report and then the text editor is invoked on that
report. When you are done with editing the report just exit the editor
and then you will be asked if you want to send the report.
-.IP "\-d, \-\-delete \fIUUID\fR"
+.IP "\-d, \-\-delete \fIDUMPDIR\fR"
Removes data about particular crash.
-.IP "\-i, \-\-info \fIUUID\fR"
+.IP "\-i, \-\-info \fIDUMPDIR\fR"
Prints detailed information about particular crash.
.PP
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 178a6028..1378b6b0 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -455,81 +455,6 @@ static GList *split(const char *s, const char delim)
return elems;
}
-/** Returns a list of enabled Reporter plugins, that are used to report
- * a particular crash.
- * @todo
- * Very similar code is used in the GUI, and also in the Daemon.
- * It should be shared.
- */
-static vector_string_t get_enabled_reporters(map_crash_data_t &crash_data)
-{
- vector_string_t result;
-
- /* Get global daemon settings. Analyzer->Reporters mapping is stored there. */
- map_map_string_t settings = call_GetSettings();
- /* Reporters are separated by comma in the following map. */
- map_string_t &analyzer_to_reporters = settings["AnalyzerActionsAndReporters"];
-
- /* Get the analyzer from the crash. */
- const char *analyzer = get_crash_data_item_content_or_NULL(crash_data, FILENAME_ANALYZER);
- if (!analyzer)
- return result; /* No analyzer found in the crash data. */
-
- /* First try to find package name dependent analyzer.
- * nvr = name-version-release
- * TODO: Similar code is in MiddleWare.cpp. It should not be duplicated.
- */
- const char *package_nvr = get_crash_data_item_content_or_NULL(crash_data, FILENAME_PACKAGE);
- if (!package_nvr)
- return result; /* No package name found in the crash data. */
- char * package_name = get_package_name_from_NVR_or_NULL(package_nvr);
- // analyzer with package name (CCpp:xorg-x11-app) has higher priority
- map_string_t::const_iterator reporters_iter;
- if (package_name != NULL)
- {
- char* package_specific_analyzer = xasprintf("%s:%s", analyzer, package_name);
- reporters_iter = analyzer_to_reporters.find(package_specific_analyzer);
- free(package_specific_analyzer);
- free(package_name);
- }
-
- if (analyzer_to_reporters.end() == reporters_iter)
- {
- reporters_iter = analyzer_to_reporters.find(analyzer);
- if (analyzer_to_reporters.end() == reporters_iter)
- return result; /* No reporters found for the analyzer. */
- }
-
- /* Reporters found, now parse the list. */
- GList *reporter_list = split(reporters_iter->second.c_str(), ',');
-
- // Get informations about all plugins.
- map_map_string_t plugins = call_GetPluginsInfo();
- // Check the configuration of each enabled Reporter plugin.
- map_map_string_t::iterator it, itend = plugins.end();
- for (it = plugins.begin(); it != itend; ++it)
- {
- // Skip disabled plugins.
- if (string_to_bool(it->second["Enabled"].c_str()) != true)
- continue;
- // Skip nonReporter plugins.
- if (0 != strcmp(it->second["Type"].c_str(), "Reporter"))
- continue;
- // Skip plugins not used in this particular crash.
- for (GList *li = reporter_list; li != NULL; li = g_list_next(li))
- {
- if (strcmp((char*)li->data, it->first.c_str()) == 0)
- result.push_back(it->first);
- }
- }
-
- for (GList *li = reporter_list; li != NULL; li = g_list_next(li))
- free((char*)li->data);
- g_list_free(reporter_list);
-
- return result;
-}
-
/**
* Asks a [y/n] question on stdin/stdout.
* Returns true if the answer is yes, false otherwise.
@@ -684,9 +609,27 @@ int report(const char *crash_id, int flags)
return result;
}
- /* Get enabled reporters associated with this particular crash. */
- vector_string_t reporters = get_enabled_reporters(cr);
- map_map_string_t reporters_settings; /* to be filled on the next line */
+ /* Get possible reporters associated with this particular crash. */
+ const char *events = get_crash_data_item_content_or_NULL(cr, CD_EVENTS);
+ vector_string_t reporters;
+ if (events) while (*events)
+ {
+ const char *end = strchrnul(events, '\n');
+ if (strncmp(events, "report", 6) == 0
+ && (events[6] == '\0' || events[6] == '_')
+ ) {
+ char *tmp = xstrndup(events, end - events);
+ reporters.push_back(tmp);
+ free(tmp);
+ }
+ events = end;
+ if (!*events)
+ break;
+ events++;
+ }
+
+ /* Get settings */
+ map_map_string_t reporters_settings;
get_reporter_plugin_settings(reporters, reporters_settings);
int errors = 0;
@@ -759,6 +702,6 @@ int report(const char *crash_id, int flags)
}
}
- printf(_("Crash reported via %d plugins (%d errors)\n"), plugins, errors);
+ printf(_("Crash reported via %d report events (%d errors)\n"), plugins, errors);
return errors != 0;
}