- improved gnmoe3 compatibility - added analyzer selector to cli - fixed problems with hash+retrace+bugzilla
311 lines
10 KiB
Diff
311 lines
10 KiB
Diff
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
|
|
---
|
|
src/cli/cli.c | 31 ++++++++++-
|
|
src/cli/report.cpp | 135 ++++++++++++++++++++++++++++++++++++++++-------
|
|
src/cli/report.h | 4 +-
|
|
src/plugins/Makefile.am | 4 +-
|
|
4 files changed, 148 insertions(+), 26 deletions(-)
|
|
|
|
diff --git a/src/cli/cli.c b/src/cli/cli.c
|
|
index 0c895a7..4e0042f 100644
|
|
--- a/src/cli/cli.c
|
|
+++ b/src/cli/cli.c
|
|
@@ -360,6 +360,9 @@ int main(int argc, char** argv)
|
|
print_usage_and_die(argv[0]);
|
|
}
|
|
|
|
+ /* Get settings */
|
|
+ load_event_config_data();
|
|
+
|
|
/* Do the selected operation. */
|
|
int exitcode = 0;
|
|
switch (op)
|
|
@@ -409,15 +412,37 @@ int main(int argc, char** argv)
|
|
}
|
|
case OPT_INFO:
|
|
{
|
|
- if (run_analyze_event(dump_dir_name) != 0)
|
|
- return 1;
|
|
-
|
|
/* Load crash_data from (possibly updated by analyze) dump dir */
|
|
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
|
|
if (!dd)
|
|
return -1;
|
|
+
|
|
+ char *analyze_events_as_lines = list_possible_events(dd, NULL, "analyze");
|
|
+ dd_close(dd);
|
|
+
|
|
+ if (analyze_events_as_lines && *analyze_events_as_lines)
|
|
+ {
|
|
+ GList *list_analyze_events = str_to_glist(analyze_events_as_lines, '\n');
|
|
+ free(analyze_events_as_lines);
|
|
+
|
|
+ char *event = select_event_option(list_analyze_events);
|
|
+ list_free_with_free(list_analyze_events);
|
|
+
|
|
+ int analyzer_result = run_analyze_event(dump_dir_name, event);
|
|
+ free(event);
|
|
+
|
|
+ if (analyzer_result != 0)
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
+ /* Load crash_data from (possibly updated by analyze) dump dir */
|
|
+ dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
|
|
+ if (!dd)
|
|
+ return -1;
|
|
+
|
|
crash_data_t *crash_data = create_crash_data_from_dump_dir(dd);
|
|
dd_close(dd);
|
|
+
|
|
add_to_crash_data_ext(crash_data, CD_DUMPDIR, dump_dir_name,
|
|
CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
|
|
|
|
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
|
|
index da37bea..7181fe3 100644
|
|
--- a/src/cli/report.cpp
|
|
+++ b/src/cli/report.cpp
|
|
@@ -15,9 +15,9 @@
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
-#include "report.h"
|
|
-#include "run-command.h"
|
|
#include "abrtlib.h"
|
|
+#include "run-command.h"
|
|
+#include "report.h"
|
|
|
|
/* Field separator for the crash report file that is edited by user. */
|
|
#define FIELD_SEP "%----"
|
|
@@ -553,7 +553,8 @@ static int run_events(const char *dump_dir_name,
|
|
int r = run_event_on_dir_name(run_state, dump_dir_name, event.c_str());
|
|
if (r == 0 && run_state->children_count == 0)
|
|
{
|
|
- l_state.last_line = xasprintf("Error: no processing is specified for event '%s'", event.c_str());
|
|
+ l_state.last_line = xasprintf("Error: no processing is specified for event '%s'",
|
|
+ event.c_str());
|
|
r = -1;
|
|
}
|
|
if (r == 0)
|
|
@@ -585,31 +586,128 @@ static char *do_log(char *log_line, void *param)
|
|
log("%s", log_line);
|
|
return log_line;
|
|
}
|
|
-int run_analyze_event(const char *dump_dir_name)
|
|
+
|
|
+int run_analyze_event(const char *dump_dir_name, const char *analyzer)
|
|
{
|
|
VERB2 log("run_analyze_event('%s')", dump_dir_name);
|
|
|
|
struct run_event_state *run_state = new_run_event_state();
|
|
run_state->logging_callback = do_log;
|
|
- int res = run_event_on_dir_name(run_state, dump_dir_name, "analyze_LocalGDB");
|
|
+ int res = run_event_on_dir_name(run_state, dump_dir_name, analyzer);
|
|
free_run_event_state(run_state);
|
|
return res;
|
|
}
|
|
|
|
+/* show even description? */
|
|
+char *select_event_option(GList *list_options)
|
|
+{
|
|
+ if (!list_options)
|
|
+ return NULL;
|
|
+
|
|
+ unsigned count = g_list_length(list_options) - 1;
|
|
+ if (!count)
|
|
+ return NULL;
|
|
+
|
|
+ int pos = -1;
|
|
+ fprintf(stdout, _("Select how you would like to analyze the problem:\n"));
|
|
+ for (GList *li = list_options; li; li = li->next)
|
|
+ {
|
|
+ char *opt = (char*)li->data;
|
|
+ event_config_t *config = get_event_config(opt);
|
|
+ if (config)
|
|
+ {
|
|
+ ++pos;
|
|
+ printf(" %i) %s\n", pos, config->screen_name);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ unsigned picked;
|
|
+ unsigned ii;
|
|
+ for (ii = 0; ii < 3; ++ii)
|
|
+ {
|
|
+ fprintf(stdout, _("Choose option [0 - %u]: "), count);
|
|
+ fflush(NULL);
|
|
+
|
|
+ char answer[16];
|
|
+ if (!fgets(answer, sizeof(answer), stdin))
|
|
+ continue;
|
|
+
|
|
+ answer[strlen(answer) - 1] = '\0';
|
|
+ if (!*answer)
|
|
+ continue;
|
|
+
|
|
+ picked = xatou(answer);
|
|
+ if (picked > count)
|
|
+ {
|
|
+ fprintf(stdout, _("You have chosen number out of range"));
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ if (ii == 3)
|
|
+ error_msg_and_die(_("Invalid input, program exiting..."));
|
|
+
|
|
+ GList *choosen = g_list_nth(list_options, picked);
|
|
+ return xstrdup((char*)choosen->data);
|
|
+}
|
|
+
|
|
+GList *str_to_glist(char *str, int delim)
|
|
+{
|
|
+ GList *list = NULL;
|
|
+ while (*str)
|
|
+ {
|
|
+ char *end = strchrnul(str, delim);
|
|
+ char *tmp = xstrndup(str, end - str);
|
|
+ if (*tmp)
|
|
+ list = g_list_append(list, tmp);
|
|
+
|
|
+ str = end;
|
|
+ if (!*str)
|
|
+ break;
|
|
+ str++;
|
|
+ }
|
|
+
|
|
+ if (!list && !g_list_length(list))
|
|
+ return NULL;
|
|
+
|
|
+ return list;
|
|
+}
|
|
|
|
/* Report the crash */
|
|
int report(const char *dump_dir_name, int flags)
|
|
{
|
|
- if (run_analyze_event(dump_dir_name) != 0)
|
|
- return 1;
|
|
-
|
|
/* Load crash_data from (possibly updated by analyze) dump dir */
|
|
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
|
|
if (!dd)
|
|
return -1;
|
|
|
|
+ char *analyze_events_as_lines = list_possible_events(dd, NULL, "analyze");
|
|
+ dd_close(dd);
|
|
+
|
|
+ if (analyze_events_as_lines && *analyze_events_as_lines)
|
|
+ {
|
|
+ GList *list_analyze_events = str_to_glist(analyze_events_as_lines, '\n');
|
|
+ free(analyze_events_as_lines);
|
|
+
|
|
+ char *event = select_event_option(list_analyze_events);
|
|
+ list_free_with_free(list_analyze_events);
|
|
+
|
|
+ int analyzer_result = run_analyze_event(dump_dir_name, event);
|
|
+ free(event);
|
|
+
|
|
+ if (analyzer_result != 0)
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
+ /* Load crash_data from (possibly updated by analyze) dump dir */
|
|
+ dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
|
|
+ if (!dd)
|
|
+ return -1;
|
|
+
|
|
+ char *report_events_as_lines = list_possible_events(dd, NULL, "report");
|
|
crash_data_t *crash_data = create_crash_data_from_dump_dir(dd);
|
|
- char *events_as_lines = list_possible_events(dd, NULL, "");
|
|
dd_close(dd);
|
|
|
|
if (!(flags & CLI_REPORT_BATCH))
|
|
@@ -620,7 +718,7 @@ int report(const char *dump_dir_name, int flags)
|
|
if (result != 0)
|
|
{
|
|
free_crash_data(crash_data);
|
|
- free(events_as_lines);
|
|
+ free(report_events_as_lines);
|
|
return 1;
|
|
}
|
|
/* Save comment, backtrace */
|
|
@@ -639,26 +737,24 @@ int report(const char *dump_dir_name, int flags)
|
|
}
|
|
|
|
/* Get possible reporters associated with this particular crash */
|
|
+ /* TODO: npajkovs: remove this annoying c++ vector_string_t */
|
|
vector_string_t report_events;
|
|
- if (events_as_lines)
|
|
+ if (report_events_as_lines && *report_events_as_lines)
|
|
{
|
|
- char *events = events_as_lines;
|
|
+ char *events = report_events_as_lines;
|
|
while (*events)
|
|
{
|
|
char *end = strchrnul(events, '\n');
|
|
- if (strncmp(events, "report", 6) == 0
|
|
- && (events[6] == '\0' || events[6] == '_')
|
|
- ) {
|
|
- char *tmp = xstrndup(events, end - events);
|
|
- report_events.push_back(tmp);
|
|
- free(tmp);
|
|
- }
|
|
+ char *tmp = xstrndup(events, end - events);
|
|
+ report_events.push_back(tmp);
|
|
+ free(tmp);
|
|
events = end;
|
|
if (!*events)
|
|
break;
|
|
events++;
|
|
}
|
|
}
|
|
+ free(report_events_as_lines);
|
|
|
|
/* Get settings */
|
|
load_event_config_data();
|
|
@@ -723,6 +819,5 @@ int report(const char *dump_dir_name, int flags)
|
|
|
|
printf(_("Crash reported via %d report events (%d errors)\n"), plugins, errors);
|
|
free_crash_data(crash_data);
|
|
- free(events_as_lines);
|
|
return errors;
|
|
}
|
|
diff --git a/src/cli/report.h b/src/cli/report.h
|
|
index 58b8c25..a393784 100644
|
|
--- a/src/cli/report.h
|
|
+++ b/src/cli/report.h
|
|
@@ -22,7 +22,9 @@
|
|
extern "C" {
|
|
#endif
|
|
|
|
-int run_analyze_event(const char *dump_dir_name);
|
|
+int run_analyze_event(const char *dump_dir_name, const char *analyzer);
|
|
+char *select_event_option(GList *list_options);
|
|
+GList *str_to_glist(char *str, int delim);
|
|
|
|
/* Report the crash */
|
|
enum {
|
|
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
|
|
index 5344cdb..7468188 100644
|
|
--- a/src/plugins/Makefile.am
|
|
+++ b/src/plugins/Makefile.am
|
|
@@ -65,8 +65,8 @@ $(DESTDIR)/$(DEBUG_INFO_DIR):
|
|
$(mkdir_p) '$@'
|
|
|
|
install-data-hook: $(DESTDIR)/$(DEBUG_INFO_DIR)
|
|
- $(LN_S) analyze_RetraceServer.xml $(DESTDIR)$(eventsdir)/reanalyze_RetraceServer.xml
|
|
- $(LN_S) analyze_LocalGDB.xml $(DESTDIR)$(eventsdir)/reanalyze_LocalGDB.xml
|
|
+ $(LN_S) -f analyze_RetraceServer.xml $(DESTDIR)$(eventsdir)/reanalyze_RetraceServer.xml
|
|
+ $(LN_S) -f analyze_LocalGDB.xml $(DESTDIR)$(eventsdir)/reanalyze_LocalGDB.xml
|
|
|
|
abrt_dump_oops_SOURCES = \
|
|
abrt-dump-oops.c
|
|
--
|
|
1.7.1
|
|
|
|
_______________________________________________
|
|
Crash-catcher mailing list
|
|
Crash-catcher@lists.fedorahosted.org
|
|
https://fedorahosted.org/mailman/listinfo/crash-catcher
|