diff options
author | Karel Klic <kklic@redhat.com> | 2010-01-20 18:51:28 +0100 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2010-01-20 18:51:28 +0100 |
commit | bbb210c836aaa6487e643176548b8b3feb11c347 (patch) | |
tree | 4a12b2a9672c639ddf9042a8d6bb06b14821d983 /lib | |
parent | d8ea20ec8a17f387ea75f4a19cadfbd33699d1d9 (diff) | |
parent | 932c4d77abddb62ca4df1aca6d6c7d4e634a9e8d (diff) | |
download | abrt-bbb210c836aaa6487e643176548b8b3feb11c347.tar.gz abrt-bbb210c836aaa6487e643176548b8b3feb11c347.tar.xz abrt-bbb210c836aaa6487e643176548b8b3feb11c347.zip |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Plugins/Bugzilla.cpp | 48 | ||||
-rw-r--r-- | lib/Plugins/Bugzilla.h | 2 | ||||
-rw-r--r-- | lib/Plugins/CCpp.cpp | 6 | ||||
-rw-r--r-- | lib/Plugins/Catcut.cpp | 30 | ||||
-rw-r--r-- | lib/Plugins/Catcut.h | 2 | ||||
-rw-r--r-- | lib/Plugins/Firefox.cpp | 6 | ||||
-rw-r--r-- | lib/Plugins/Kerneloops.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsReporter.cpp | 8 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsReporter.h | 2 | ||||
-rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 9 | ||||
-rw-r--r-- | lib/Plugins/Logger.cpp | 4 | ||||
-rw-r--r-- | lib/Plugins/Logger.h | 4 | ||||
-rw-r--r-- | lib/Plugins/Mailx.cpp | 8 | ||||
-rw-r--r-- | lib/Plugins/Mailx.h | 2 | ||||
-rw-r--r-- | lib/Plugins/Python.cpp | 7 | ||||
-rw-r--r-- | lib/Plugins/RunApp.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/TicketUploader.cpp | 6 | ||||
-rw-r--r-- | lib/Plugins/TicketUploader.h | 2 | ||||
-rw-r--r-- | lib/Utils/CrashTypes.cpp | 61 | ||||
-rw-r--r-- | lib/Utils/CrashTypesSocket.cpp | 12 | ||||
-rw-r--r-- | lib/Utils/DebugDump.h | 19 | ||||
-rw-r--r-- | lib/Utils/Makefile.am | 1 | ||||
-rw-r--r-- | lib/Utils/Plugin.h | 6 | ||||
-rw-r--r-- | lib/Utils/Reporter.h | 4 | ||||
-rw-r--r-- | lib/Utils/daemon.cpp | 2 | ||||
-rw-r--r-- | lib/Utils/make_descr.cpp | 30 | ||||
-rw-r--r-- | lib/Utils/test.cpp | 4 |
27 files changed, 160 insertions, 129 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index f963eb9c..aafa0198 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -32,8 +32,8 @@ struct ctx: public abrt_xmlrpc_conn { int32_t check_uuid_in_bugzilla(const char* component, const char* UUID); bool check_cc_and_reporter(uint32_t bug_id, const char* login); void add_plus_one_cc(uint32_t bug_id, const char* login); - uint32_t new_bug(const map_crash_report_t& pCrashReport); - void add_attachments(const char* bug_id_str, const map_crash_report_t& pCrashReport); + uint32_t new_bug(const map_crash_data_t& pCrashData); + void add_attachments(const char* bug_id_str, const map_crash_data_t& pCrashData); }; void ctx::login(const char* login, const char* passwd) @@ -278,22 +278,22 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID) return -1; } -uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport) +uint32_t ctx::new_bug(const map_crash_data_t& pCrashData) { xmlrpc_env env; xmlrpc_env_init(&env); - std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; - std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; - std::string release = pCrashReport.find(FILENAME_RELEASE)->second[CD_CONTENT]; - std::string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]; - std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; + const std::string& package = get_crash_data_item_content(pCrashData, FILENAME_PACKAGE); + const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); + const std::string& release = get_crash_data_item_content(pCrashData, FILENAME_RELEASE); + const std::string& arch = get_crash_data_item_content(pCrashData, FILENAME_ARCHITECTURE); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); std::string summary = "[abrt] crash in " + package; std::string status_whiteboard = "abrt_hash:" + uuid; std::string description = "abrt "VERSION" detected a crash.\n\n"; - description += make_description_bz(pCrashReport); + description += make_description_bz(pCrashData); std::string product; std::string version; @@ -346,15 +346,15 @@ uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport) return bug_id; } -void ctx::add_attachments(const char* bug_id_str, const map_crash_report_t& pCrashReport) +void ctx::add_attachments(const char* bug_id_str, const map_crash_data_t& pCrashData) { xmlrpc_env env; xmlrpc_env_init(&env); xmlrpc_value* result = NULL; - map_crash_report_t::const_iterator it = pCrashReport.begin(); - for (; it != pCrashReport.end(); it++) + map_crash_data_t::const_iterator it = pCrashData.begin(); + for (; it != pCrashData.end(); it++) { const std::string &filename = it->first; const std::string &type = it->second[CD_TYPE]; @@ -404,7 +404,7 @@ CReporterBugzilla::CReporterBugzilla() : CReporterBugzilla::~CReporterBugzilla() {} -std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, +std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { @@ -433,8 +433,8 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, NoSSLVerify = m_bNoSSLVerify; } - std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; - std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; + const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); try { ctx bz_server(BugzillaXMLRPC.c_str(), NoSSLVerify); @@ -442,12 +442,12 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, update_client(_("Checking for duplicates...")); bug_id = bz_server.check_uuid_in_bugzilla(component.c_str(), uuid.c_str()); - update_client(_("Logging into bugzilla...")); if ((Login == "") && (Password == "")) { VERB3 log("Empty login and password"); throw CABRTException(EXCEP_PLUGIN, _("Empty login and password. Please check Bugzilla.conf")); } + update_client(_("Logging into bugzilla...")); bz_server.login(Login.c_str(), Password.c_str()); if (bug_id > 0) @@ -458,12 +458,14 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, bz_server.add_plus_one_cc(bug_id, Login.c_str()); } bz_server.logout(); - return BugzillaURL + "/show_bug.cgi?id=" + to_string(bug_id); + BugzillaURL += "/show_bug.cgi?id="; + BugzillaURL += to_string(bug_id); + return BugzillaURL; } update_client(_("Creating new bug...")); - bug_id = bz_server.new_bug(pCrashReport); - bz_server.add_attachments(to_string(bug_id).c_str(), pCrashReport); + bug_id = bz_server.new_bug(pCrashData); + bz_server.add_attachments(to_string(bug_id).c_str(), pCrashData); update_client(_("Logging out...")); bz_server.logout(); @@ -475,12 +477,16 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, if (bug_id > 0) { - return BugzillaURL + "/show_bug.cgi?id=" + to_string(bug_id); + BugzillaURL += "/show_bug.cgi?id="; + BugzillaURL += to_string(bug_id); + return BugzillaURL; } - return BugzillaURL + "/show_bug.cgi?id="; + BugzillaURL += "/show_bug.cgi?id="; + return BugzillaURL; } +//todo: make static map_plugin_settings_t CReporterBugzilla::parse_settings(const map_plugin_settings_t& pSettings) { map_plugin_settings_t plugin_settings; diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h index ee6bc6a5..571d0c60 100644 --- a/lib/Plugins/Bugzilla.h +++ b/lib/Plugins/Bugzilla.h @@ -20,7 +20,7 @@ class CReporterBugzilla : public CReporter CReporterBugzilla(); virtual ~CReporterBugzilla(); - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs); diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index ab29fbbe..28e6bac3 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -40,10 +40,6 @@ using namespace std; #define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern" #define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u %c" -#define FILENAME_COREDUMP "coredump" -#define FILENAME_BACKTRACE "backtrace" -#define FILENAME_MEMORYMAP "memorymap" - #define DEBUGINFO_CACHE_DIR LOCALSTATEDIR"/cache/abrt-di" CAnalyzerCCpp::CAnalyzerCCpp() : @@ -233,7 +229,7 @@ static int rate_backtrace(const char *backtrace) } } - /* Bogus "backtrace" with zero frames? */ + /* Bogus 'backtrace' with zero frames? */ if (best_possible_rating == 0) return 0; diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp index b69038fb..1bc51f97 100644 --- a/lib/Plugins/Catcut.cpp +++ b/lib/Plugins/Catcut.cpp @@ -215,13 +215,13 @@ struct ctx: public abrt_xmlrpc_conn { ctx(const char* url, bool no_ssl_verify): abrt_xmlrpc_conn(url, no_ssl_verify) {} string login(const char* login, const char* passwd); - string new_bug(const char *auth_cookie, const map_crash_report_t& pCrashReport); + string new_bug(const char *auth_cookie, const map_crash_data_t& pCrashData); string request_upload(const char* auth_cookie, const char* pTicketName, const char* fileName, const char* description); void add_attachments(const char* xmlrpc_URL, const char* auth_cookie, const char* pTicketName, - const map_crash_report_t& pCrashReport, + const map_crash_data_t& pCrashData, int retryCount, int retryDelaySeconds); }; @@ -263,21 +263,21 @@ ctx::login(const char* login, const char* passwd) } string -ctx::new_bug(const char *auth_cookie, const map_crash_report_t& pCrashReport) +ctx::new_bug(const char *auth_cookie, const map_crash_data_t& pCrashData) { xmlrpc_env env; xmlrpc_env_init(&env); - string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; - string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT]; - string release = pCrashReport.find(FILENAME_RELEASE)->second[CD_CONTENT]; - string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT]; - string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT]; + const string& package = get_crash_data_item_content(pCrashData, FILENAME_PACKAGE); + const string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); + const string& release = get_crash_data_item_content(pCrashData, FILENAME_RELEASE); + const string& arch = get_crash_data_item_content(pCrashData, FILENAME_ARCHITECTURE); + const string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); string summary = "[abrt] crash in " + package; string status_whiteboard = "abrt_hash:" + uuid; - string description = make_description_catcut(pCrashReport); + string description = make_description_catcut(pCrashData); string product; string version; @@ -382,13 +382,13 @@ void ctx::add_attachments(const char* xmlrpc_URL, const char* auth_cookie, const char* pTicketName, - const map_crash_report_t& pCrashReport, + const map_crash_data_t& pCrashData, int retryCount, int retryDelaySeconds) { - map_crash_report_t::const_iterator it = pCrashReport.begin(); - for (; it != pCrashReport.end(); it++) + map_crash_data_t::const_iterator it = pCrashData.begin(); + for (; it != pCrashData.end(); it++) { if (it->second[CD_TYPE] == CD_TXT && it->second[CD_TYPE].size() > CD_TEXT_ATT_SIZE) { @@ -446,7 +446,7 @@ CReporterCatcut::CReporterCatcut() : CReporterCatcut::~CReporterCatcut() {} -string CReporterCatcut::Report(const map_crash_report_t& pCrashReport, +string CReporterCatcut::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { @@ -459,14 +459,14 @@ string CReporterCatcut::Report(const map_crash_report_t& pCrashReport, string message; if (auth_cookie != "") { - string ticket_name = catcut_server.new_bug(auth_cookie.c_str(), pCrashReport); + string ticket_name = catcut_server.new_bug(auth_cookie.c_str(), pCrashData); if (ticket_name != "") { catcut_server.add_attachments( m_sCatcutURL.c_str(), auth_cookie.c_str(), ticket_name.c_str(), - pCrashReport, + pCrashData, m_nRetryCount, m_nRetryDelay ); diff --git a/lib/Plugins/Catcut.h b/lib/Plugins/Catcut.h index 00f486c0..65c70444 100644 --- a/lib/Plugins/Catcut.h +++ b/lib/Plugins/Catcut.h @@ -20,7 +20,7 @@ class CReporterCatcut : public CReporter virtual void SetSettings(const map_plugin_settings_t& pSettings); - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *Args); }; diff --git a/lib/Plugins/Firefox.cpp b/lib/Plugins/Firefox.cpp index d9807556..e8b12f56 100644 --- a/lib/Plugins/Firefox.cpp +++ b/lib/Plugins/Firefox.cpp @@ -36,10 +36,6 @@ #define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern" #define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u" -#define FILENAME_COREDUMP "coredump" -#define FILENAME_BACKTRACE "backtrace" -#define FILENAME_MEMORYMAP "memorymap" - #define DEBUGINFO_CACHE_DIR LOCALSTATEDIR"/cache/abrt-di" CAnalyzerFirefox::CAnalyzerFirefox() : @@ -227,7 +223,7 @@ static int rate_backtrace(const char *backtrace) } } - /* Bogus "backtrace" with zero frames? */ + /* Bogus 'backtrace' with zero frames? */ if (best_possible_rating == 0) return 0; diff --git a/lib/Plugins/Kerneloops.cpp b/lib/Plugins/Kerneloops.cpp index 2e28cf4a..bcb7a723 100644 --- a/lib/Plugins/Kerneloops.cpp +++ b/lib/Plugins/Kerneloops.cpp @@ -30,8 +30,6 @@ #include "ABRTException.h" #include "CommLayerInner.h" -#define FILENAME_KERNELOOPS "kerneloops" - std::string CAnalyzerKerneloops::GetLocalUUID(const char *pDebugDumpDir) { log(_("Getting local universal unique identification")); diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp index 5cb525bc..18932aea 100644 --- a/lib/Plugins/KerneloopsReporter.cpp +++ b/lib/Plugins/KerneloopsReporter.cpp @@ -30,8 +30,6 @@ #include "CommLayerInner.h" #include "ABRTException.h" -#define FILENAME_KERNELOOPS "kerneloops" - /* helpers */ static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream) { @@ -93,7 +91,7 @@ CKerneloopsReporter::CKerneloopsReporter() : m_sSubmitURL("http://submit.kerneloops.org/submitoops.php") {} -std::string CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport, +std::string CKerneloopsReporter::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { @@ -101,8 +99,8 @@ std::string CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport, update_client(_("Creating and submitting a report...")); - map_crash_report_t::const_iterator it = pCrashReport.find(FILENAME_KERNELOOPS); - if (it != pCrashReport.end()) { + map_crash_data_t::const_iterator it = pCrashData.find(FILENAME_KERNELOOPS); + if (it != pCrashData.end()) { ret = http_post_to_kerneloops_site( m_sSubmitURL.c_str(), it->second[CD_CONTENT].c_str() diff --git a/lib/Plugins/KerneloopsReporter.h b/lib/Plugins/KerneloopsReporter.h index 10e5e644..91326526 100644 --- a/lib/Plugins/KerneloopsReporter.h +++ b/lib/Plugins/KerneloopsReporter.h @@ -43,7 +43,7 @@ class CKerneloopsReporter : public CReporter virtual void SetSettings(const map_plugin_settings_t& pSettings); //ok to delete? // virtual const map_plugin_settings_t& GetSettings(); - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs); }; diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index 1bb45aba..42ffd409 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -34,10 +34,6 @@ #include "KerneloopsSysLog.h" #include "KerneloopsScanner.h" -#include <limits.h> - -#define FILENAME_KERNELOOPS "kerneloops" - // TODO: https://fedorahosted.org/abrt/ticket/78 CKerneloopsScanner::CKerneloopsScanner() @@ -54,8 +50,7 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs) { const char *syslog_file = "/var/log/messages"; map_plugin_settings_t::const_iterator it = m_pSettings.find("SysLogFile"); - if (it != m_pSettings.end()) - { + if (it != m_pSettings.end()) { syslog_file = it->second.c_str(); } @@ -205,4 +200,4 @@ void save_oops_to_debug_dump(CKerneloopsScanner *This) This->SaveOopsToDebugDump(); } -} +} /* extern "C" */ diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index d6cc124e..f428aec5 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -59,12 +59,12 @@ void CLogger::SetSettings(const map_plugin_settings_t& pSettings) // return m_pSettings; //} -std::string CLogger::Report(const map_crash_report_t& pCrashReport, +std::string CLogger::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { - std::string description = make_description_logger(pCrashReport); + std::string description = make_description_logger(pCrashData); description += "\n\n\n"; FILE *fOut; diff --git a/lib/Plugins/Logger.h b/lib/Plugins/Logger.h index c7d76798..02429b2c 100644 --- a/lib/Plugins/Logger.h +++ b/lib/Plugins/Logger.h @@ -1,6 +1,6 @@ /* Logger.h - header file for Logger reporter plugin - - it simple writes report to specific file + - it simply writes report to specific file Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) Copyright (C) 2009 RedHat inc. @@ -37,7 +37,7 @@ class CLogger : public CReporter virtual void SetSettings(const map_plugin_settings_t& pSettings); //ok to delete? // virtual const map_plugin_settings_t& GetSettings(); - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs); }; diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 2f8448f5..ae8c2dc9 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -65,7 +65,7 @@ static char** append_str_to_vector(char **vec, unsigned &size, const char *str) return vec; } -std::string CMailx::Report(const map_crash_report_t& pCrashReport, +std::string CMailx::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { @@ -75,8 +75,8 @@ std::string CMailx::Report(const map_crash_report_t& pCrashReport, //TODO: move email body generation to make_descr.cpp std::string binaryFiles, commonFiles, additionalFiles, UUIDFile; - map_crash_report_t::const_iterator it; - for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) + map_crash_data_t::const_iterator it; + for (it = pCrashData.begin(); it != pCrashData.end(); it++) { if (it->second[CD_TYPE] == CD_TXT) { @@ -135,7 +135,7 @@ std::string CMailx::Report(const map_crash_report_t& pCrashReport, args = append_str_to_vector(args, arg_size, m_sEmailTo.c_str()); update_client(_("Sending an email...")); - const char *uid_str = pCrashReport.find(CD_MWUID)->second[CD_CONTENT].c_str(); + const char *uid_str = get_crash_data_item_content(pCrashData, CD_MWUID).c_str(); exec_and_feed_input(xatoi_u(uid_str), emailBody.c_str(), args); while (*args) diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h index 1ddb5ff0..619e349c 100644 --- a/lib/Plugins/Mailx.h +++ b/lib/Plugins/Mailx.h @@ -41,7 +41,7 @@ class CMailx : public CReporter virtual void SetSettings(const map_plugin_settings_t& pSettings); //ok to delete? // virtual const map_plugin_settings_t& GetSettings(); - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs); }; diff --git a/lib/Plugins/Python.cpp b/lib/Plugins/Python.cpp index 23d6f5c0..ad954681 100644 --- a/lib/Plugins/Python.cpp +++ b/lib/Plugins/Python.cpp @@ -1,15 +1,14 @@ +#include "abrtlib.h" #include "Python.h" #include "DebugDump.h" #include "ABRTException.h" -#define FILENAME_BACKTRACE "backtrace" - static std::string CreateHash(const char *pDebugDumpDir) { - std::string uuid; CDebugDump dd; dd.Open(pDebugDumpDir); - dd.LoadText("uuid", uuid); + std::string uuid; + dd.LoadText(FILENAME_UUID, uuid); return uuid; } diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index e2147e26..77f5d3c8 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -19,7 +19,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - +#include "abrtlib.h" #include "RunApp.h" #include "DebugDump.h" #include "ABRTException.h" diff --git a/lib/Plugins/TicketUploader.cpp b/lib/Plugins/TicketUploader.cpp index 7483768d..b273ae8b 100644 --- a/lib/Plugins/TicketUploader.cpp +++ b/lib/Plugins/TicketUploader.cpp @@ -150,7 +150,7 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename) } -string CTicketUploader::Report(const map_crash_report_t& pCrashReport, +string CTicketUploader::Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) { @@ -200,8 +200,8 @@ string CTicketUploader::Report(const map_crash_report_t& pCrashReport, // Copy each entry into the tarball root, // files are simply copied, strings are written to a file - map_crash_report_t::const_iterator it; - for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) + map_crash_data_t::const_iterator it; + for (it = pCrashData.begin(); it != pCrashData.end(); it++) { if (it->second[CD_TYPE] == CD_TXT) { diff --git a/lib/Plugins/TicketUploader.h b/lib/Plugins/TicketUploader.h index 1bc8f6ba..fcc59f06 100644 --- a/lib/Plugins/TicketUploader.h +++ b/lib/Plugins/TicketUploader.h @@ -48,7 +48,7 @@ class CTicketUploader : public CReporter virtual const map_plugin_settings_t& GetSettings(); virtual void SetSettings(const map_plugin_settings_t& pSettings); - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs); }; diff --git a/lib/Utils/CrashTypes.cpp b/lib/Utils/CrashTypes.cpp new file mode 100644 index 00000000..4824e507 --- /dev/null +++ b/lib/Utils/CrashTypes.cpp @@ -0,0 +1,61 @@ +/* + Copyright (C) 2010 Denys Vlasenko (dvlasenk@redhat.com) + Copyright (C) 2010 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#include "abrt_types.h" +#include "abrtlib.h" +#include "CrashTypes.h" + +void add_to_crash_data_ext(map_crash_data_t& pCrashData, + const char *pItem, + const char *pType, + const char *pEditable, + const char *pContent) +{ + map_crash_data_t::iterator it = pCrashData.find(pItem); + if (it == pCrashData.end()) { + pCrashData[pItem].push_back(pType); + pCrashData[pItem].push_back(pEditable); + pCrashData[pItem].push_back(pContent); + return; + } + vector_string_t& v = it->second; + while (v.size() < 3) + v.push_back(""); + v[CD_TYPE] = pType; + v[CD_EDITABLE] = pEditable; + v[CD_CONTENT] = pContent; +} + +void add_to_crash_data(map_crash_data_t& pCrashData, + const char *pItem, + const char *pContent) +{ + add_to_crash_data_ext(pCrashData, pItem, CD_TXT, CD_ISNOTEDITABLE, pContent); +} + +const std::string& get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key) +{ + map_crash_data_t::const_iterator it = crash_data.find(key); + if (it == crash_data.end()) { + error_msg_and_die("Error accessing crash data: no ['%s']", key); + } + if (it->second.size() <= CD_CONTENT) { + error_msg_and_die("Error accessing crash data: no ['%s'][%d]", key, CD_CONTENT); + } + return it->second[CD_CONTENT]; +} diff --git a/lib/Utils/CrashTypesSocket.cpp b/lib/Utils/CrashTypesSocket.cpp index 3525c6a5..d555571b 100644 --- a/lib/Utils/CrashTypesSocket.cpp +++ b/lib/Utils/CrashTypesSocket.cpp @@ -87,13 +87,13 @@ std::string crash_data_to_string(const map_crash_data_t& pCrashData) return sCD.str(); } -std::string crash_infos_to_string(const vector_crash_infos_t& pCrashInfos) +std::string crash_infos_to_string(const vector_map_crash_data_t& pCrashDatas) { std::stringstream sCI; unsigned int ii; - for (ii = 0; ii < pCrashInfos.size(); ii++) + for (ii = 0; ii < pCrashDatas.size(); ii++) { - sCI << crash_data_to_string(pCrashInfos[ii]); + sCI << crash_data_to_string(pCrashDatas[ii]); } return sCI.str(); } @@ -164,15 +164,15 @@ map_crash_data_t string_to_crash_data(const std::string& pMessage, int& len) return ci; } -vector_crash_infos_t string_to_crash_infos(const std::string& pMessage) +vector_map_crash_data_t string_to_crash_infos(const std::string& pMessage) { - vector_crash_infos_t vci; + vector_map_crash_data_t vci; std::string message = pMessage; int len; while (message != "") { - map_crash_info_t crash_info = string_to_crash_data(message, len); + map_crash_data_t crash_info = string_to_crash_data(message, len); if (crash_info.size() == 0) { return vci; diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h index d3eebb45..60d3bd3b 100644 --- a/lib/Utils/DebugDump.h +++ b/lib/Utils/DebugDump.h @@ -24,25 +24,6 @@ #define DEBUGDUMP_H_ #include <string> -#include <dirent.h> -#include <stdint.h> - -#define FILENAME_ARCHITECTURE "architecture" -#define FILENAME_KERNEL "kernel" -#define FILENAME_TIME "time" -#define FILENAME_UID "uid" -#define FILENAME_PACKAGE "package" -#define FILENAME_COMPONENT "component" -#define FILENAME_DESCRIPTION "description" -#define FILENAME_ANALYZER "analyzer" -#define FILENAME_RELEASE "release" -#define FILENAME_EXECUTABLE "executable" -#define FILENAME_REASON "reason" -#define FILENAME_COMMENT "comment" -#define FILENAME_REPRODUCE "reproduce" -#define FILENAME_RATING "rating" -#define FILENAME_CMDLINE "cmdline" - class CDebugDump { diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index a944d977..59607104 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -20,6 +20,7 @@ libABRTUtils_la_SOURCES = \ stringops.cpp \ dirsize.cpp \ DebugDump.h DebugDump.cpp \ + CrashTypes.cpp \ ABRTException.cpp libABRTUtils_la_CPPFLAGS = \ -Wall -Werror \ diff --git a/lib/Utils/Plugin.h b/lib/Utils/Plugin.h index d7108ce9..e8464032 100644 --- a/lib/Utils/Plugin.h +++ b/lib/Utils/Plugin.h @@ -120,8 +120,8 @@ 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); +std::string make_description_bz(const map_crash_data_t& pCrashData); +std::string make_description_logger(const map_crash_data_t& pCrashData); +std::string make_description_catcut(const map_crash_data_t& pCrashData); #endif diff --git a/lib/Utils/Reporter.h b/lib/Utils/Reporter.h index 0a06a7c9..e9445f93 100644 --- a/lib/Utils/Reporter.h +++ b/lib/Utils/Reporter.h @@ -36,11 +36,11 @@ class CReporter : public CPlugin * A method, which reports a crash report to particular receiver. * The plugin can takes arguments, but the plugin has to parse them * by itself. - * @param pCrashReport A crash report. + * @param pCrashData A crash report. * @param pArgs Plugin's arguments. * @retun A message which can be displayed after a report is created. */ - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) = 0; }; diff --git a/lib/Utils/daemon.cpp b/lib/Utils/daemon.cpp index 05270624..7d60ce31 100644 --- a/lib/Utils/daemon.cpp +++ b/lib/Utils/daemon.cpp @@ -16,7 +16,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "abrtlib.h" -#define FILENAME_CMDLINE "cmdline" + #define VAR_RUN_PID_FILE VAR_RUN"/abrt.pid" static char *append_escaped(char *start, const char *s) diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp index 2a0d4a99..e74e9b1d 100644 --- a/lib/Utils/make_descr.cpp +++ b/lib/Utils/make_descr.cpp @@ -50,27 +50,27 @@ static void add_content(bool &was_multiline, string& description, const char *he } } -string make_description_bz(const map_crash_report_t& pCrashReport) +string make_description_bz(const map_crash_data_t& pCrashData) { string description; - map_crash_report_t::const_iterator it; - map_crash_report_t::const_iterator end = pCrashReport.end(); + map_crash_data_t::const_iterator it; + map_crash_data_t::const_iterator end = pCrashData.end(); bool was_multiline = 0; - it = pCrashReport.find(CD_REPRODUCE); + it = pCrashData.find(CD_REPRODUCE); if (it != end && it->second[CD_CONTENT] != "1.\n2.\n3.\n") { add_content(was_multiline, description, "How to reproduce", it->second[CD_CONTENT].c_str()); } - it = pCrashReport.find(CD_COMMENT); + it = pCrashData.find(CD_COMMENT); if (it != end) { add_content(was_multiline, description, "Comment", it->second[CD_CONTENT].c_str()); } - it = pCrashReport.begin(); + it = pCrashData.begin(); for (; it != end; it++) { const string &filename = it->first; @@ -97,13 +97,13 @@ string make_description_bz(const map_crash_report_t& pCrashReport) return description; } -string make_description_logger(const map_crash_report_t& pCrashReport) +string make_description_logger(const map_crash_data_t& pCrashData) { string description; string long_description; - map_crash_report_t::const_iterator it = pCrashReport.begin(); - for (; it != pCrashReport.end(); it++) + map_crash_data_t::const_iterator it = pCrashData.begin(); + for (; it != pCrashData.end(); it++) { const string &filename = it->first; const string &type = it->second[CD_TYPE]; @@ -141,13 +141,13 @@ string make_description_logger(const map_crash_report_t& pCrashReport) } /* This needs more work to make the result less ugly */ -string make_description_catcut(const map_crash_report_t& pCrashReport) +string make_description_catcut(const map_crash_data_t& pCrashData) { - map_crash_report_t::const_iterator end = pCrashReport.end(); - map_crash_report_t::const_iterator it; + map_crash_data_t::const_iterator end = pCrashData.end(); + map_crash_data_t::const_iterator it; string howToReproduce; - it = pCrashReport.find(CD_REPRODUCE); + it = pCrashData.find(CD_REPRODUCE); if (it != end) { howToReproduce = "\n\nHow to reproduce\n" @@ -155,7 +155,7 @@ string make_description_catcut(const map_crash_report_t& pCrashReport) howToReproduce += it->second[CD_CONTENT]; } string comment; - it = pCrashReport.find(CD_COMMENT); + it = pCrashData.find(CD_COMMENT); if (it != end) { comment = "\n\nComment\n" @@ -169,7 +169,7 @@ string make_description_catcut(const map_crash_report_t& pCrashReport) pDescription += "\n\nAdditional information\n" "======\n"; - for (it = pCrashReport.begin(); it != end; it++) + for (it = pCrashData.begin(); it != end; it++) { const string &filename = it->first; const string &type = it->second[CD_TYPE]; diff --git a/lib/Utils/test.cpp b/lib/Utils/test.cpp index fbad1db9..160c107b 100644 --- a/lib/Utils/test.cpp +++ b/lib/Utils/test.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) std::cout << "-------------------------------------------" << std::endl; } /* Try to save it into DB */ - map_crash_info_t crashInfo; + map_crash_data_t crashInfo; if (middleWare.SaveDebugDump(argv[1], crashInfo)) { std::cout << "Application Crashed! " << @@ -91,7 +91,7 @@ int main(int argc, char** argv) /* Get Report, so user can change data (remove private stuff) * If we do not want user interaction, just send data immediately */ - map_crash_report_t crashReport; + map_crash_data_t crashReport; middleWare.CreateCrashReport(crashInfo[CD_UUID][CD_CONTENT], crashInfo[CD_UID][CD_CONTENT], crashReport); |