summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-11-20 12:22:36 +0100
committerKarel Klic <kklic@redhat.com>2009-11-20 12:22:36 +0100
commit18363807e6ffa8dab5a76f40bacac3695985147a (patch)
tree8195336c29136a4761db501160c9f4620b16aa70 /lib
parentbd60681c8227bc31ef0991e98a9a3e849032c924 (diff)
parent6ec2390e40ba4b0f6e10a2c8ce858d3431b34964 (diff)
downloadabrt-18363807e6ffa8dab5a76f40bacac3695985147a.tar.gz
abrt-18363807e6ffa8dab5a76f40bacac3695985147a.tar.xz
abrt-18363807e6ffa8dab5a76f40bacac3695985147a.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/Bugzilla.cpp25
-rw-r--r--lib/Plugins/Catcut.cpp58
-rw-r--r--lib/Plugins/KerneloopsSysLog.cpp196
-rw-r--r--lib/Plugins/Mailx.cpp1
-rw-r--r--lib/Utils/DebugDump.cpp90
-rw-r--r--lib/Utils/DebugDump.h3
-rw-r--r--lib/Utils/Plugin.h12
-rw-r--r--lib/Utils/make_descr.cpp85
8 files changed, 212 insertions, 258 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp
index 7ddacf7..5734238 100644
--- a/lib/Plugins/Bugzilla.cpp
+++ b/lib/Plugins/Bugzilla.cpp
@@ -14,13 +14,6 @@
#define XML_RPC_SUFFIX "/xmlrpc.cgi"
-static void create_new_bug_description(const map_crash_report_t& pCrashReport, std::string& pDescription)
-{
- pDescription = "abrt "VERSION" detected a crash.\n\n";
- pDescription += make_description_bz(pCrashReport);
-}
-
-
/*
* Static namespace for xmlrpc stuff.
* Used mainly to ensure we always destroy xmlrpc client and server_info.
@@ -236,8 +229,8 @@ uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport)
std::string summary = "[abrt] crash detected in " + package;
std::string status_whiteboard = "abrt_hash:" + uuid;
- std::string description;
- create_new_bug_description(pCrashReport, description);
+ std::string description = "abrt "VERSION" detected a crash.\n\n";
+ description += make_description_bz(pCrashReport);
std::string product;
std::string version;
@@ -287,15 +280,17 @@ void ctx::add_attachments(const char* bug_id_str, const map_crash_report_t& pCra
map_crash_report_t::const_iterator it = pCrashReport.begin();
for (; it != pCrashReport.end(); it++)
{
- if (it->second[CD_TYPE] == CD_ATT)
+ const std::string &filename = it->first;
+ const std::string &type = it->second[CD_TYPE];
+ const std::string &content = it->second[CD_CONTENT];
+
+ if (type == CD_ATT)
{
- std::string description = "File: " + it->first;
- const std::string& to_encode = it->second[CD_CONTENT];
- char *encoded64 = encode_base64(to_encode.c_str(), to_encode.length());
+ char *encoded64 = encode_base64(content.c_str(), content.length());
xmlrpc_value* param = xmlrpc_build_value(&env,"(s{s:s,s:s,s:s,s:s})",
bug_id_str,
- "description", description.c_str(),
- "filename", it->first.c_str(),
+ "description", ("File: " + filename).c_str(),
+ "filename", filename.c_str(),
"contenttype", "text/plain",
"data", encoded64
);
diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp
index cf1d7d9..e353cbe 100644
--- a/lib/Plugins/Catcut.cpp
+++ b/lib/Plugins/Catcut.cpp
@@ -9,65 +9,12 @@
#include "ABRTException.h"
#include "CommLayerInner.h"
#ifdef HAVE_CONFIG_H
- #include "config.h"
+# include "config.h"
#endif
using namespace std;
-//TODO: move to make_descr.cpp
-static void create_new_bug_description(const map_crash_report_t& pCrashReport, string& pDescription)
-{
- string howToReproduce;
- string comment;
-
- if (pCrashReport.find(CD_REPRODUCE) != pCrashReport.end())
- {
- howToReproduce = "\n\nHow to reproduce\n"
- "-----\n" +
- pCrashReport.find(CD_REPRODUCE)->second[CD_CONTENT];
- }
- if (pCrashReport.find(CD_COMMENT) != pCrashReport.end())
- {
- comment = "\n\nComment\n"
- "-----\n" +
- pCrashReport.find(CD_COMMENT)->second[CD_CONTENT];
- }
- pDescription = "\nabrt "VERSION" detected a crash.\n" +
- howToReproduce +
- comment +
- "\n\nAdditional information\n"
- "======\n";
-
- map_crash_report_t::const_iterator it;
- for (it = pCrashReport.begin(); it != pCrashReport.end(); it++)
- {
- if (it->second[CD_TYPE] == CD_TXT)
- {
- if (it->first != CD_UUID &&
- it->first != FILENAME_ARCHITECTURE &&
- it->first != FILENAME_RELEASE &&
- it->first != CD_REPRODUCE &&
- it->first != CD_COMMENT)
- {
- pDescription += "\n" + it->first + "\n";
- pDescription += "-----\n";
- pDescription += it->second[CD_CONTENT] + "\n\n";
- }
- }
- else if (it->second[CD_TYPE] == CD_ATT)
- {
- pDescription += "\n\nAttached files\n"
- "----\n";
- pDescription += it->first + "\n";
- }
- else if (it->second[CD_TYPE] == CD_BIN)
- {
- error_msg(_("Binary file %s will not be reported"), it->first.c_str());
- }
- }
-}
-
static int
put_stream(const char *pURL, FILE* f, size_t content_length)
{
@@ -324,8 +271,7 @@ ctx::new_bug(const char *auth_cookie, const map_crash_report_t& pCrashReport)
string summary = "[abrt] crash detected in " + package;
string status_whiteboard = "abrt_hash:" + uuid;
- string description;
- create_new_bug_description(pCrashReport, description);
+ string description = make_description_catcut(pCrashReport);
string product;
string version;
diff --git a/lib/Plugins/KerneloopsSysLog.cpp b/lib/Plugins/KerneloopsSysLog.cpp
index cb15fcc..4e32f04 100644
--- a/lib/Plugins/KerneloopsSysLog.cpp
+++ b/lib/Plugins/KerneloopsSysLog.cpp
@@ -87,7 +87,6 @@ int extract_oopses(vector_string_t &oopses, char *buffer, size_t buflen)
while (c < buffer + buflen) {
char linelevel;
char *c9;
- char *linepointer;
c9 = (char*)memchr(c, '\n', buffer + buflen - c); /* a \n will always be found */
assert(c9);
@@ -124,6 +123,7 @@ int extract_oopses(vector_string_t &oopses, char *buffer, size_t buflen)
* "hostname abrt: Kerneloops: Reported 1 kernel oopses to Abrt"
* we know we submitted everything upto here already */
if (strstr(c, "abrt:") && strstr(c, "Abrt")) {
+ VERB3 log("Found our marker at line %d, restarting line count from 0", linecount);
linecount = 0;
lines_info_alloc = 0;
free(lines_info);
@@ -142,23 +142,20 @@ int extract_oopses(vector_string_t &oopses, char *buffer, size_t buflen)
}
/* remove jiffies time stamp counter if present */
if (*c == '[') {
- char *c2, *c3;
- c2 = strchr(c, '.');
- c3 = strchr(c, ']');
+ char *c2 = strchr(c, '.');
+ char *c3 = strchr(c, ']');
if (c2 && c3 && (c2 < c3) && (c3-c) < 14 && (c2-c) < 8) {
c = c3 + 1;
if (*c == ' ')
c++;
}
}
- linepointer = c;
-
if (linecount >= lines_info_alloc) {
lines_info_alloc += REALLOC_CHUNK;
lines_info = (line_info*)xrealloc(lines_info,
lines_info_alloc * sizeof(struct line_info));
}
- lines_info[linecount].ptr = linepointer;
+ lines_info[linecount].ptr = c;
lines_info[linecount].level = linelevel;
linecount++;
next_line:
@@ -170,68 +167,66 @@ next_line:
int i;
char prevlevel = 0;
int oopsstart = -1;
- int oopsend = linecount;
int inbacktrace = 0;
int oopsesfound = 0;
i = 0;
while (i < linecount) {
- char *c = lines_info[i].ptr;
+ char *const curline = lines_info[i].ptr;
- if (c == NULL) {
+ if (curline == NULL) {
i++;
continue;
}
if (oopsstart < 0) {
/* find start-of-oops markers */
- if (strstr(c, "general protection fault:"))
+ if (strstr(curline, "general protection fault:"))
oopsstart = i;
- else if (strstr(c, "BUG:"))
+ else if (strstr(curline, "BUG:"))
oopsstart = i;
- else if (strstr(c, "kernel BUG at"))
+ else if (strstr(curline, "kernel BUG at"))
oopsstart = i;
- else if (strstr(c, "do_IRQ: stack overflow:"))
+ else if (strstr(curline, "do_IRQ: stack overflow:"))
oopsstart = i;
- else if (strstr(c, "RTNL: assertion failed"))
+ else if (strstr(curline, "RTNL: assertion failed"))
oopsstart = i;
- else if (strstr(c, "Eeek! page_mapcount(page) went negative!"))
+ else if (strstr(curline, "Eeek! page_mapcount(page) went negative!"))
oopsstart = i;
- else if (strstr(c, "near stack overflow (cur:"))
+ else if (strstr(curline, "near stack overflow (cur:"))
oopsstart = i;
- else if (strstr(c, "double fault:"))
+ else if (strstr(curline, "double fault:"))
oopsstart = i;
- else if (strstr(c, "Badness at"))
+ else if (strstr(curline, "Badness at"))
oopsstart = i;
- else if (strstr(c, "NETDEV WATCHDOG"))
+ else if (strstr(curline, "NETDEV WATCHDOG"))
oopsstart = i;
- else if (strstr(c, "WARNING:") &&
- !strstr(c, "appears to be on the same physical disk"))
+ else if (strstr(curline, "WARNING:")
+ && !strstr(curline, "appears to be on the same physical disk")
+ ) {
oopsstart = i;
- else if (strstr(c, "Unable to handle kernel"))
+ }
+ else if (strstr(curline, "Unable to handle kernel"))
oopsstart = i;
- else if (strstr(c, "sysctl table check failed"))
+ else if (strstr(curline, "sysctl table check failed"))
oopsstart = i;
- else if (strstr(c, "------------[ cut here ]------------"))
+ else if (strstr(curline, "------------[ cut here ]------------"))
oopsstart = i;
- else if (strstr(c, "list_del corruption."))
+ else if (strstr(curline, "list_del corruption."))
oopsstart = i;
- else if (strstr(c, "list_add corruption."))
+ else if (strstr(curline, "list_add corruption."))
oopsstart = i;
- if (strstr(c, "Oops:") && i >= 3)
+ if (strstr(curline, "Oops:") && i >= 3)
oopsstart = i-3;
-#if DEBUG
- /* debug information */
- if (oopsstart >= 0) {
- printf("Found start of oops at line %i\n", oopsstart);
- printf(" start line is -%s-\n", lines_info[oopsstart].ptr);
- if (oopsstart != i)
- printf(" trigger line is -%s-\n", c);
- }
-#endif
- /* try to find the end marker */
+
if (oopsstart >= 0) {
- int i2;
- i2 = i+1;
+ /* debug information */
+ VERB3 {
+ log("Found oops at line %d: '%s'", oopsstart, lines_info[oopsstart].ptr);
+ if (oopsstart != i)
+ log("Trigger line is %d: '%s'", i, c);
+ }
+ /* try to find the end marker */
+ int i2 = i + 1;
while (i2 < linecount && i2 < (i+50)) {
if (strstr(lines_info[i2].ptr, "---[ end trace")) {
inbacktrace = 1;
@@ -243,61 +238,58 @@ next_line:
}
}
- /* a calltrace starts with "Call Trace:" or with the " [<.......>] function+0xFF/0xAA" pattern */
- if (oopsstart >= 0 && strstr(lines_info[i].ptr, "Call Trace:"))
- inbacktrace = 1;
-
- else if (oopsstart >= 0 && inbacktrace == 0 && strlen(lines_info[i].ptr) > 8) {
- char *c1, *c2, *c3;
- c1 = strstr(lines_info[i].ptr, ">]");
- c2 = strstr(lines_info[i].ptr, "+0x");
- c3 = strstr(lines_info[i].ptr, "/0x");
- if (lines_info[i].ptr[0] == ' '
- && lines_info[i].ptr[1] == '['
- && lines_info[i].ptr[2] == '<'
- && c1 && c2 && c3
+ /* Are we entering a call trace part? */
+ /* a call trace starts with "Call Trace:" or with the " [<.......>] function+0xFF/0xAA" pattern */
+ if (oopsstart >= 0 && !inbacktrace) {
+ if (strstr(curline, "Call Trace:"))
+ inbacktrace = 1;
+ else
+ if (strnlen(curline, 9) > 8
+ && curline[0] == ' ' && curline[1] == '[' && curline[2] == '<'
+ && strstr(curline, ">]")
+ && strstr(curline, "+0x")
+ && strstr(curline, "/0x")
) {
inbacktrace = 1;
}
}
- /* try to see if we're at the end of an oops */
- else if (oopsstart >= 0 && inbacktrace > 0) {
- char c2, c3;
- c2 = lines_info[i].ptr[0];
- c3 = lines_info[i].ptr[1];
-
- /* line needs to start with " [" or have "] ["*/
- if ((c2 != ' ' || c3 != '[')
- && strstr(lines_info[i].ptr, "] [") == NULL
- && strstr(lines_info[i].ptr, "--- Exception") == NULL
- && strstr(lines_info[i].ptr, " LR =") == NULL
- && strstr(lines_info[i].ptr, "<#DF>") == NULL
- && strstr(lines_info[i].ptr, "<IRQ>") == NULL
- && strstr(lines_info[i].ptr, "<EOI>") == NULL
- && strstr(lines_info[i].ptr, "<<EOE>>") == NULL
+ /* Are we at the end of an oops? */
+ else if (oopsstart >= 0 && inbacktrace) {
+ int oopsend = INT_MAX;
+
+ /* The Code: line means we're done with the backtrace */
+ if (strstr(curline, "Code:") != NULL)
+ oopsend = i;
+ /* line needs to start with " [" or have "] [" if it is still a call trace */
+ /* example: "[<ffffffffa006c156>] radeon_get_ring_head+0x16/0x41 [radeon]" */
+ else if ((curline[0] != ' ' || curline[1] != '[')
+ && curline[0] != '[' /* in syslog format, leading space is lost */
+ && strstr(curline, "] [") == NULL
+ && strstr(curline, "--- Exception") == NULL
+ && strstr(curline, " LR =") == NULL
+ && strstr(curline, "<#DF>") == NULL
+ && strstr(curline, "<IRQ>") == NULL
+ && strstr(curline, "<EOI>") == NULL
+ && strstr(curline, "<<EOE>>") == NULL
) {
- oopsend = i-1;
+ oopsend = i-1; /* not a call trace line */
}
-
- /* oops lines are always more than 8 long */
- if (strlen(lines_info[i].ptr) < 8)
+ /* oops lines are always more than 8 chars long */
+ else if (strnlen(curline, 8) < 8)
oopsend = i-1;
/* single oopses are of the same loglevel */
- if (lines_info[i].level != prevlevel)
+ else if (lines_info[i].level != prevlevel)
oopsend = i-1;
- /* The Code: line means we're done with the backtrace */
- if (strstr(lines_info[i].ptr, "Code:") != NULL)
- oopsend = i;
- if (strstr(lines_info[i].ptr, "Instruction dump::") != NULL)
+ else if (strstr(curline, "Instruction dump::") != NULL) /* why "::"? is it a typo? */
oopsend = i;
/* if a new oops starts, this one has ended */
- if (strstr(lines_info[i].ptr, "WARNING:") != NULL && oopsstart != i)
+ else if (strstr(curline, "WARNING:") != NULL && oopsstart != i)
oopsend = i-1;
- if (strstr(lines_info[i].ptr, "Unable to handle") != NULL && oopsstart != i)
+ else if (strstr(curline, "Unable to handle") != NULL && oopsstart != i)
oopsend = i-1;
/* kernel end-of-oops marker */
- if (strstr(lines_info[i].ptr, "---[ end trace") != NULL)
+ else if (strstr(curline, "---[ end trace") != NULL)
oopsend = i;
if (oopsend <= i) {
@@ -307,6 +299,8 @@ next_line:
char *oops;
char *version;
+ VERB3 log("End of oops at line %d (%d): '%s'", oopsend, i, lines_info[oopsend].ptr);
+
len = 2;
for (q = oopsstart; q <= oopsend; q++)
len += strlen(lines_info[q].ptr) + 1;
@@ -327,27 +321,38 @@ next_line:
if (strlen(oops) > 100) {
queue_oops(oopses, oops, version);
oopsesfound++;
+ } else {
+ VERB3 log("Dropped oops: too short");
}
oopsstart = -1;
inbacktrace = 0;
- oopsend = linecount;
free(oops);
free(version);
}
}
+
prevlevel = lines_info[i].level;
i++;
- if (oopsstart > 0 && i-oopsstart > 50) {
- oopsstart = -1;
- inbacktrace = 0;
- oopsend = linecount;
- }
- if (oopsstart > 0 && !inbacktrace && i-oopsstart > 30) {
- oopsstart = -1;
- inbacktrace = 0;
- oopsend = linecount;
+
+ if (oopsstart >= 0) {
+ /* Do we have a suspiciously long oops? Cancel it */
+ if (i-oopsstart > 50) {
+ inbacktrace = 0;
+ oopsstart = -1;
+ VERB3 log("Dropped oops, too long");
+ continue;
+ }
+ if (!inbacktrace && i-oopsstart > 30) {
+ /*inbacktrace = 0; - already is */
+ oopsstart = -1;
+ VERB3 log("Dropped oops, too long");
+ continue;
+ }
}
- }
+ } /* while (i < linecount) */
+
+ /* process last oops if we have one */
+// TODO: do not duplicate code
if (oopsstart >= 0) {
int q;
int len;
@@ -355,7 +360,9 @@ next_line:
char *oops;
char *version;
- oopsend = i-1;
+ int oopsend = i-1;
+
+ VERB3 log("End of oops at line %d (end of file): '%s'", oopsend, lines_info[oopsend].ptr);
len = 2;
while (oopsend > 0 && lines_info[oopsend].ptr == NULL)
@@ -377,10 +384,9 @@ next_line:
if (strlen(oops) > 100) {
queue_oops(oopses, oops, version);
oopsesfound++;
+ } else {
+ VERB3 log("Dropped oops: too short");
}
- oopsstart = -1;
- inbacktrace = 0;
- oopsend = linecount;
free(oops);
free(version);
}
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp
index 32eeb25..dc6e2b0 100644
--- a/lib/Plugins/Mailx.cpp
+++ b/lib/Plugins/Mailx.cpp
@@ -90,6 +90,7 @@ std::string CMailx::Report(const map_crash_report_t& pCrashReport,
unsigned arg_size = 0;
args = append_str_to_vector(args, arg_size, MAILX_COMMAND);
+//TODO: move email body generation to make_descr.cpp
std::string binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile;
map_crash_report_t::const_iterator it;
for (it = pCrashReport.begin(); it != pCrashReport.end(); it++)
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index 2883d01..fff4695 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -23,7 +23,6 @@
#include <iostream>
#include <sstream>
#include <sys/utsname.h>
-//#include <magic.h>
#include "abrtlib.h"
#include "DebugDump.h"
#include "ABRTException.h"
@@ -287,72 +286,6 @@ static void DeleteFileDir(const char *pDir)
}
}
-static bool IsTextFile(const char *name)
-{
- /* Some files in our dump directories are known to always be textual */
- if (strcmp(name, "backtrace") == 0
- || strcmp(name, "cmdline") == 0
- ) {
- return true;
- }
-
-/* This idiotic library thinks that file containing just "0" is not text (!!)
-
- magic_t m = magic_open(MAGIC_MIME_TYPE);
-
- if (m == NULL)
- {
- throw CABRTException(EXCEP_ERROR, std::string(__func__) + "Cannot open magic cookie: " + magic_error(m));
- }
-
- int r = magic_load(m, NULL);
-
- if (r == -1)
- {
- magic_close(m);
- throw CABRTException(EXCEP_ERROR, std::string(__func__) + "Cannot load magic db: " + magic_error(m));
- }
-
- char* ch = (char *) magic_file(m, pName.c_str());
-
- if (ch == NULL)
- {
- magic_close(m);
- throw CABRTException(EXCEP_ERROR, std::string(__func__) + "Cannot determine file type: " + magic_error(m));
- }
-
- bool isText = (strncmp(ch, "text", 4) == 0);
-
- magic_close(m);
-
- return isText;
- */
- int fd = open(name, O_RDONLY);
- if (fd < 0)
- return false;
-
- unsigned char buf[4*1024];
- int r = full_read(fd, buf, sizeof(buf));
- close(fd);
-
- /* Every once in a while, even a text file contains a few garbled
- * or unexpected non-ASCII chars. We should not declare it "binary".
- */
- const unsigned RATIO = 50;
- unsigned total_chars = r + RATIO;
- unsigned bad_chars = 1; /* 1 prevents division by 0 later */
- while (--r >= 0)
- {
- if (buf[r] >= 0x7f
- /* among control chars, only '\t','\n' etc are allowed */
- || (buf[r] < ' ' && !isspace(buf[r]))
- ) {
- bad_chars++;
- }
- }
- return (total_chars / bad_chars) >= RATIO;
-}
-
void CDebugDump::Delete()
{
if (!ExistFileDir(m_sDebugDumpDir.c_str()))
@@ -460,7 +393,7 @@ void CDebugDump::InitGetNextFile()
{
if (!m_bOpened)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::InitGetNextFile(): DebugDump is not opened.");
+ throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
}
if (m_pGetNextFileDir != NULL)
{
@@ -469,11 +402,11 @@ void CDebugDump::InitGetNextFile()
m_pGetNextFileDir = opendir(m_sDebugDumpDir.c_str());
if (m_pGetNextFileDir == NULL)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::InitGetNextFile(): Cannot open dir " + m_sDebugDumpDir);
+ throw CABRTException(EXCEP_DD_OPEN, "Can't open dir " + m_sDebugDumpDir);
}
}
-bool CDebugDump::GetNextFile(std::string& pFileName, std::string& pContent, bool& pIsTextFile)
+bool CDebugDump::GetNextFile(std::string *short_name, std::string *full_name)
{
if (m_pGetNextFileDir == NULL)
{
@@ -485,19 +418,10 @@ bool CDebugDump::GetNextFile(std::string& pFileName, std::string& pContent, bool
{
if (is_regular_file(dent, m_sDebugDumpDir.c_str()))
{
- std::string fullname = concat_path_file(m_sDebugDumpDir.c_str(), dent->d_name);
-
- pFileName = dent->d_name;
- if (IsTextFile(fullname.c_str()))
- {
- LoadText(dent->d_name, pContent);
- pIsTextFile = true;
- }
- else
- {
- pContent.clear();
- pIsTextFile = false;
- }
+ if (short_name)
+ *short_name = dent->d_name;
+ if (full_name)
+ *full_name = concat_path_file(m_sDebugDumpDir.c_str(), dent->d_name);
return true;
}
}
diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h
index b48a386..d753353 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -72,7 +72,8 @@ class CDebugDump
void SaveBinary(const char* pName, const char* pData, unsigned pSize);
void InitGetNextFile();
- bool GetNextFile(std::string& pFileName, std::string& pContent, bool& pIsTextFile);
+ /* Pointers may be NULL */
+ bool GetNextFile(std::string *short_name, std::string *full_name);
};
#endif /*DEBUGDUMP_H_*/
diff --git a/lib/Utils/Plugin.h b/lib/Utils/Plugin.h
index f93f7e7..d7108ce 100644
--- a/lib/Utils/Plugin.h
+++ b/lib/Utils/Plugin.h
@@ -26,13 +26,13 @@
#include "abrt_types.h"
#include "CrashTypes.h"
#if HAVE_CONFIG_H
- #include <config.h>
+# include <config.h>
#endif
#if ENABLE_NLS
- #include <libintl.h>
- #define _(S) gettext(S)
+# include <libintl.h>
+# define _(S) gettext(S)
#else
- #define _(S) (S)
+# define _(S) (S)
#endif
#define PLUGINS_MAGIC_NUMBER 6
@@ -83,7 +83,8 @@ typedef enum {
ANALYZER, /**< An analyzer plugin*/
ACTION, /**< An action plugin*/
REPORTER, /**< A reporter plugin*/
- DATABASE /**< A database plugin*/
+ DATABASE, /**< A database plugin*/
+ MAX_PLUGIN_TYPE = DATABASE,
} plugin_type_t;
/**
@@ -121,5 +122,6 @@ typedef struct SPluginInfo
/* helper finctions */
std::string make_description_bz(const map_crash_report_t& pCrashReport);
std::string make_description_logger(const map_crash_report_t& pCrashReport);
+std::string make_description_catcut(const map_crash_report_t& pCrashReport);
#endif
diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp
index 0c09614..c4cc3f3 100644
--- a/lib/Utils/make_descr.cpp
+++ b/lib/Utils/make_descr.cpp
@@ -2,6 +2,15 @@
//#include "abrt_types.h"
#include "CrashTypes.h"
#include "DebugDump.h" /* FILENAME_ARCHITECTURE etc */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#if ENABLE_NLS
+# include <libintl.h>
+# define _(S) gettext(S)
+#else
+# define _(S) (S)
+#endif
using namespace std;
@@ -42,6 +51,9 @@ static void add_content(bool &was_multiline, string& description, const char *he
}
}
+/* Text attachments smaller than this will be also included in descrition */
+#define INLINE_TEXT_ATT_SIZE 1024
+
string make_description_bz(const map_crash_report_t& pCrashReport)
{
string description;
@@ -68,8 +80,9 @@ string make_description_bz(const map_crash_report_t& pCrashReport)
const string &filename = it->first;
const string &type = it->second[CD_TYPE];
const string &content = it->second[CD_CONTENT];
- if (type == CD_TXT)
- {
+ if (type == CD_TXT
+ || (type == CD_ATT && content.size() < INLINE_TEXT_ATT_SIZE)
+ ) {
if (filename != CD_UUID
&& filename != FILENAME_ARCHITECTURE
&& filename != FILENAME_RELEASE
@@ -78,8 +91,9 @@ string make_description_bz(const map_crash_report_t& pCrashReport)
) {
add_content(was_multiline, description, filename.c_str(), content.c_str());
}
+ continue;
}
- else if (type == CD_ATT)
+ if (type == CD_ATT)
{
add_content(was_multiline, description, "Attached file", filename.c_str());
}
@@ -131,3 +145,68 @@ string make_description_logger(const map_crash_report_t& pCrashReport)
return description;
}
+
+/* This needs more work to make the result less ugly */
+string make_description_catcut(const map_crash_report_t& pCrashReport)
+{
+ map_crash_report_t::const_iterator end = pCrashReport.end();
+ map_crash_report_t::const_iterator it;
+
+ string howToReproduce;
+ it = pCrashReport.find(CD_REPRODUCE);
+ if (it != end)
+ {
+ howToReproduce = "\n\nHow to reproduce\n"
+ "-----\n";
+ howToReproduce += it->second[CD_CONTENT];
+ }
+ string comment;
+ it = pCrashReport.find(CD_COMMENT);
+ if (it != end)
+ {
+ comment = "\n\nComment\n"
+ "-----\n";
+ comment += it->second[CD_CONTENT];
+ }
+
+ string pDescription = "\nabrt "VERSION" detected a crash.\n";
+ pDescription += howToReproduce;
+ pDescription += comment;
+ pDescription += "\n\nAdditional information\n"
+ "======\n";
+
+ for (it = pCrashReport.begin(); it != end; it++)
+ {
+ const string &filename = it->first;
+ const string &type = it->second[CD_TYPE];
+ const string &content = it->second[CD_CONTENT];
+ if (type == CD_TXT)
+ {
+ if (filename != CD_UUID
+ && filename != FILENAME_ARCHITECTURE
+ && filename != FILENAME_RELEASE
+ && filename != CD_REPRODUCE
+ && filename != CD_COMMENT
+ ) {
+ pDescription += '\n';
+ pDescription += filename;
+ pDescription += "\n-----\n";
+ pDescription += content;
+ pDescription += "\n\n";
+ }
+ }
+ else if (type == CD_ATT)
+ {
+ pDescription += "\n\nAttached files\n"
+ "----\n";
+ pDescription += filename;
+ pDescription += '\n';
+ }
+ else if (type == CD_BIN)
+ {
+ error_msg(_("Binary file %s will not be reported"), filename.c_str());
+ }
+ }
+
+ return pDescription;
+}