diff options
| -rw-r--r-- | lib/MiddleWare/CrashTypes.h | 65 | ||||
| -rw-r--r-- | lib/MiddleWare/MiddleWare.cpp | 40 | ||||
| -rw-r--r-- | lib/Plugins/Logger.cpp | 4 | ||||
| -rw-r--r-- | lib/Plugins/Mailx.cpp | 4 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 2 |
5 files changed, 63 insertions, 52 deletions
diff --git a/lib/MiddleWare/CrashTypes.h b/lib/MiddleWare/CrashTypes.h index 6cef6f7..b285ee6 100644 --- a/lib/MiddleWare/CrashTypes.h +++ b/lib/MiddleWare/CrashTypes.h @@ -8,36 +8,30 @@ // SYS - system value, should not be displayed // BIN - binary value, should be displayed // TXT = text value, should be displayed -typedef enum { CD_SYS, CD_BIN, CD_TXT } content_crash_data_t; +#define CD_SYS "s" +#define CD_BIN "b" +#define CD_TXT "t" -const char* const type_crash_data_t_str[] = { "s", "b", "t" }; +#define CD_ISEDITABLE "y" +#define CD_ISNOTEDITABLE "n" -typedef enum { CI_UUID, - CI_UID, - CI_COUNT, - CI_EXECUTABLE, - CI_PACKAGE, - CI_DESCRIPTION, - CI_TIME, - CI_REPORTED, - CI_MWANALYZER, - CI_MWUID, - CI_MWUUID } item_crash_into_t; +#define CD_TYPE (0) +#define CD_EDITABLE (1) +#define CD_CONTENT (2) -const char* const item_crash_into_t_str[] = { "UUID", - "UID", - "Count", - "Executable", - "Package", - "Time", - "Reported", - "_MWAnalyzer", - "_MWUID", - "_MWUUID" }; +#define CI_UUID "UUID" +#define CI_UID "UID" +#define CI_COUNT "Count" +#define CI_EXECUTABLE "Executable" +#define CI_PACKAGE "Package" +#define CI_DESCRIPTION "Description" +#define CI_TIME "Time" +#define CI_REPORTED "Reported" +#define CI_MWANALYZER "_MWAnalyzer" +#define CI_MWUID "_MWUID" +#define CI_MWUUID "_MWUUID" -typedef enum { CD_TYPE, CD_CONTENT } item_crash_data_t; - -// now, size of a vecor is always 2 -> <type, content> +// now, size of a vecor is always 3 -> <type, editable, content> typedef std::vector<std::string> vector_strings_t; // <key, data> typedef std::map<std::string, vector_strings_t> map_crash_data_t; @@ -47,21 +41,24 @@ typedef std::vector<map_crash_info_t> vector_crash_infos_t; typedef map_crash_data_t map_crash_report_t; inline void add_crash_data_to_crash_info(map_crash_info_t& pCrashInfo, - const item_crash_into_t& pItem, - const content_crash_data_t& pType, + const std::string& pItem, + const std::string& pType, const std::string& pContent) { - pCrashInfo[item_crash_into_t_str[pItem]].push_back(type_crash_data_t_str[pType]); - pCrashInfo[item_crash_into_t_str[pItem]].push_back(pContent); + pCrashInfo[pItem].push_back(pType); + pCrashInfo[pItem].push_back(CD_ISNOTEDITABLE); + pCrashInfo[pItem].push_back(pContent); } inline void add_crash_data_to_crash_report(map_crash_report_t& pCrashReport, - const std::string& pFileName, - const content_crash_data_t& pType, + const std::string& pItem, + const std::string& pType, + const std::string& pEditable, const std::string& pContent) { - pCrashReport[pFileName].push_back(type_crash_data_t_str[pType]); - pCrashReport[pFileName].push_back(pContent); + pCrashReport[pItem].push_back(pType); + pCrashReport[pItem].push_back(pEditable); + pCrashReport[pItem].push_back(pContent); } diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp index cf2f699..c0465c5 100644 --- a/lib/MiddleWare/MiddleWare.cpp +++ b/lib/MiddleWare/MiddleWare.cpp @@ -59,11 +59,26 @@ void CMiddleWare::DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_c { if (!isTextFile) { - add_crash_data_to_crash_report(pCrashReport, fileName, CD_BIN, pDebugDumpDir + "/" + fileName); + add_crash_data_to_crash_report(pCrashReport, + fileName, + CD_BIN, + CD_ISNOTEDITABLE, + pDebugDumpDir + "/" + fileName); } else { - add_crash_data_to_crash_report(pCrashReport, fileName, CD_TXT, content); + if (fileName == FILENAME_UUID || + fileName == FILENAME_ARCHITECTURE || + fileName == FILENAME_KERNEL || + fileName == FILENAME_PACKAGE || + fileName == FILENAME_EXECUTABLE) + { + add_crash_data_to_crash_report(pCrashReport, fileName, CD_TXT, CD_ISNOTEDITABLE, content); + } + else + { + add_crash_data_to_crash_report(pCrashReport, fileName, CD_TXT, CD_ISEDITABLE, content); + } } } dd.Close(); @@ -139,22 +154,22 @@ void CMiddleWare::CreateCrashReport(const std::string& pUUID, RunAnalyzerActions(analyzer, row.m_sDebugDumpDir); DebugDumpToCrashReport(row.m_sDebugDumpDir, pCrashReport); - add_crash_data_to_crash_report(pCrashReport, item_crash_into_t_str[CI_MWANALYZER], CD_SYS, analyzer); - add_crash_data_to_crash_report(pCrashReport, item_crash_into_t_str[CI_MWUID], CD_SYS, pUID); - add_crash_data_to_crash_report(pCrashReport, item_crash_into_t_str[CI_MWUUID], CD_SYS, pUUID); + add_crash_data_to_crash_report(pCrashReport, CI_MWANALYZER, CD_SYS, CD_ISNOTEDITABLE, analyzer); + add_crash_data_to_crash_report(pCrashReport, CI_MWUID, CD_SYS, CD_ISNOTEDITABLE, pUID); + add_crash_data_to_crash_report(pCrashReport, CI_MWUUID, CD_SYS, CD_ISNOTEDITABLE, pUUID); } void CMiddleWare::Report(const map_crash_report_t& pCrashReport) { - if (pCrashReport.find(item_crash_into_t_str[CI_MWANALYZER]) == pCrashReport.end() || - pCrashReport.find(item_crash_into_t_str[CI_MWUID]) == pCrashReport.end() || - pCrashReport.find(item_crash_into_t_str[CI_MWUUID]) == pCrashReport.end()) + if (pCrashReport.find(CI_MWANALYZER) == pCrashReport.end() || + pCrashReport.find(CI_MWUID) == pCrashReport.end() || + pCrashReport.find(CI_MWUUID) == pCrashReport.end()) { throw std::string("CMiddleWare::Report(): Important data are missing."); } - std::string analyzer = pCrashReport.find(item_crash_into_t_str[CI_MWANALYZER])->second[CD_CONTENT]; - std::string UID = pCrashReport.find(item_crash_into_t_str[CI_MWUID])->second[CD_CONTENT]; - std::string UUID = pCrashReport.find(item_crash_into_t_str[CI_MWUUID])->second[CD_CONTENT]; + std::string analyzer = pCrashReport.find(CI_MWANALYZER)->second[CD_CONTENT]; + std::string UID = pCrashReport.find(CI_MWUID)->second[CD_CONTENT]; + std::string UUID = pCrashReport.find(CI_MWUUID)->second[CD_CONTENT]; if (m_mapAnalyzerReporters.find(analyzer) != m_mapAnalyzerReporters.end()) { @@ -337,6 +352,7 @@ int CMiddleWare::SaveDebugDumpToDatabase(const std::string& pDebugDumpDir, map_c return 2; } dd.Close(); + return 1; } @@ -360,7 +376,6 @@ int CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir, map_crash_info_ { return 0; } - return SaveDebugDumpToDatabase(pDebugDumpDir, pCrashInfo); } @@ -393,7 +408,6 @@ map_crash_info_t CMiddleWare::GetCrashInfo(const std::string& pUUID, dd.LoadText(FILENAME_DESCRIPTION, data); add_crash_data_to_crash_info(crashInfo, CI_DESCRIPTION, CD_TXT, data); dd.Close(); - add_crash_data_to_crash_info(crashInfo, CI_UUID, CD_TXT, row.m_sUUID); add_crash_data_to_crash_info(crashInfo, CI_UID, CD_TXT, row.m_sUID); add_crash_data_to_crash_info(crashInfo, CI_COUNT, CD_TXT, row.m_sCount); diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index c6e076f..de9e68f 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -53,7 +53,7 @@ void CLogger::Report(const map_crash_report_t& pCrashReport) map_crash_report_t::const_iterator it; for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) { - if (it->second[CD_TYPE] == type_crash_data_t_str[CD_TXT]) + if (it->second[CD_TYPE] == CD_TXT) { if (it->first != FILENAME_UUID && it->first != FILENAME_ARCHITECTURE && @@ -77,7 +77,7 @@ void CLogger::Report(const map_crash_report_t& pCrashReport) commonFiles << it->second[CD_CONTENT] << std::endl << std::endl; } } - if (it->second[CD_TYPE] == type_crash_data_t_str[CD_BIN]) + if (it->second[CD_TYPE] == CD_BIN) { binaryFiles << it->first << std::endl; binaryFiles << "-----" << std::endl; diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 172f5fd..dbadb1e 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -66,7 +66,7 @@ void CMailx::Report(const map_crash_report_t& pCrashReport) map_crash_report_t::const_iterator it; for (it = pCrashReport.begin(); it != pCrashReport.end(); it++) { - if (it->second[CD_TYPE] == type_crash_data_t_str[CD_TXT]) + if (it->second[CD_TYPE] == CD_TXT) { if (it->first != FILENAME_UUID && it->first != FILENAME_ARCHITECTURE && @@ -90,7 +90,7 @@ void CMailx::Report(const map_crash_report_t& pCrashReport) commonFiles << it->second[CD_CONTENT] << std::endl; } } - if (it->second[CD_TYPE] == type_crash_data_t_str[CD_BIN]) + if (it->second[CD_TYPE] == CD_BIN) { binaryFiles << " -a " << it->second[CD_CONTENT]; } diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index f3eb96f..bd9ea13 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -77,7 +77,7 @@ gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition, if(cc->m_pMW->SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo)) { /* send message to dbus */ - cc->m_pCommLayer->Crash(crashinfo[item_crash_into_t_str[CI_PACKAGE]][CD_CONTENT]); + cc->m_pCommLayer->Crash(crashinfo[CI_PACKAGE][CD_CONTENT]); } } catch(std::string err) |
