From 64c5d35aebc38f93ce5c086c15c15de5acb21b2f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 5 Nov 2009 17:21:11 +0100 Subject: InformAllUsers support. enabled by default for Kerneloops. Tested wuth CCpp. Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 8362216..8a86e14 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -948,6 +948,8 @@ void CAnalyzerCCpp::DeInit() void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) { + m_pSettings = pSettings; + map_plugin_settings_t::const_iterator end = pSettings.end(); map_plugin_settings_t::const_iterator it; it = pSettings.find("MemoryMap"); @@ -976,7 +978,7 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) map_plugin_settings_t CAnalyzerCCpp::GetSettings() { - map_plugin_settings_t ret; + map_plugin_settings_t ret = m_pSettings; ret["MemoryMap"] = m_bMemoryMap ? "yes" : "no"; ret["DebugInfo"] = m_sDebugInfo; -- cgit From c8e9e69f96c2bd0b9248d6dfab91e2d27ab8e608 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Nov 2009 12:41:24 +0100 Subject: mass replace of const string& params by const char* Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 8a86e14..3a3604b 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -223,7 +223,7 @@ int rate_backtrace(const std::string & backtrace) return 0; } -static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace) +static void GetBacktrace(const char *pDebugDumpDir, std::string& pBacktrace) { update_client(_("Getting backtrace...")); @@ -258,7 +258,7 @@ static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktra args[4] = (char*)"-ex"; args[5] = xasprintf("file %s", executable.c_str()); args[6] = (char*)"-ex"; - args[7] = xasprintf("core-file %s/"FILENAME_COREDUMP, pDebugDumpDir.c_str()); + args[7] = xasprintf("core-file %s/"FILENAME_COREDUMP, pDebugDumpDir); args[8] = (char*)"-ex"; args[9] = (char*)"thread apply all backtrace full"; args[10] = NULL; @@ -420,7 +420,7 @@ static void GetIndependentBuildIdPC(const std::string& pBuildIdPC, std::string& } } -static std::string run_unstrip_n(const std::string& pDebugDumpDir) +static std::string run_unstrip_n(const char *pDebugDumpDir) { std::string UID; { @@ -431,7 +431,7 @@ static std::string run_unstrip_n(const std::string& pDebugDumpDir) char* args[4]; args[0] = (char*)"eu-unstrip"; - args[1] = xasprintf("--core=%s/"FILENAME_COREDUMP, pDebugDumpDir.c_str()); + args[1] = xasprintf("--core=%s/"FILENAME_COREDUMP, pDebugDumpDir); args[2] = (char*)"-n"; args[3] = NULL; @@ -455,7 +455,7 @@ static bool is_hexstr(const char* str) } return true; } -static void InstallDebugInfos(const std::string& pDebugDumpDir, std::string& build_ids) +static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids) { log("Getting module names, file names, build IDs from core file"); std::string unstrip_list = run_unstrip_n(pDebugDumpDir); @@ -648,7 +648,7 @@ Another application is holding the yum lock, cannot continue /* Needs gdb feature from here: https://bugzilla.redhat.com/show_bug.cgi?id=528668 * It is slated to be in F12/RHEL6. */ -static void InstallDebugInfos(const std::string& pDebugDumpDir, std::string& build_ids) +static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids) { update_client(_("Searching for debug-info packages...")); @@ -673,7 +673,7 @@ static void InstallDebugInfos(const std::string& pDebugDumpDir, std::string& bui setsid(); - char *coredump = xasprintf("%s/"FILENAME_COREDUMP, pDebugDumpDir.c_str()); + char *coredump = xasprintf("%s/"FILENAME_COREDUMP, pDebugDumpDir); /* SELinux guys are not happy with /tmp, using /var/run/abrt */ char *tempdir = xasprintf(LOCALSTATEDIR"/run/abrt/tmp-%u-%lu", (int)getpid(), (long)time(NULL)); /* log() goes to stderr/syslog, it's ok to use it here */ @@ -787,7 +787,7 @@ static void trim_debuginfo_cache(unsigned max_mb) } } -std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir) +std::string CAnalyzerCCpp::GetLocalUUID(const char *pDebugDumpDir) { log(_("Getting local universal unique identification...")); @@ -806,7 +806,7 @@ std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir) return CreateHash(package + executable + independentBuildIdPC); } -std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir) +std::string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) { log(_("Getting global universal unique identification...")); @@ -851,7 +851,7 @@ static bool DebuginfoCheckPolkit(int uid) return false; } -void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir, int force) +void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) { update_client(_("Starting report creation...")); @@ -889,13 +889,12 @@ void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir, int force) GetBacktrace(pDebugDumpDir, backtrace); dd.Open(pDebugDumpDir); - dd.SaveText(FILENAME_BACKTRACE, build_ids + backtrace); + dd.SaveText(FILENAME_BACKTRACE, (build_ids + backtrace).c_str()); if (m_bMemoryMap) { dd.SaveText(FILENAME_MEMORYMAP, "memory map of the crashed C/C++ application, not implemented yet"); } - std::string rating = ssprintf("%d", rate_backtrace(backtrace)); - dd.SaveText(FILENAME_RATING, rating); + dd.SaveText(FILENAME_RATING, to_string(rate_backtrace(backtrace)).c_str()); dd.Close(); } -- cgit From 80975b02ec1a2e8dfc6f7ce21e47cf71b16b5a6e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Nov 2009 14:52:32 +0100 Subject: lib/Plugins/FileTransfer: massive surgery text data bss dec hex filename 50212 2144 16 52372 cc94 0/libTicketUploader.so 34693 1888 24 36605 8efd 1/libTicketUploader.so Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 3a3604b..a2d65f3 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -95,7 +95,6 @@ static std::string concat_str_vector(char **strings) static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput) { int pipeout[2]; - char buff[1024]; pid_t child; struct passwd* pw = getpwuid(uid); @@ -137,6 +136,7 @@ static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput) close(pipeout[1]); /* write side of the pipe */ int r; + char buff[1024]; while ((r = read(pipeout[0], buff, sizeof(buff) - 1)) > 0) { buff[r] = '\0'; -- cgit From 1202706839ec42299e8794750cec66dfa7db0206 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Nov 2009 17:51:17 +0100 Subject: simplify logging a bit. warn_client() is gone, reuse error_msg() for it. Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index a2d65f3..b6a5db8 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -610,8 +610,8 @@ Another application is holding the yum lock, cannot continue if (last >= 0 && buff[last] == '\n') buff[last] = '\0'; - /* log(buff); - update_client logs it too */ - update_client(buff); /* maybe only if buff != ""? */ + log("%s", buff); + update_client("%s", buff); /* maybe only if buff != ""? */ #ifdef COMPLAIN_IF_NO_DEBUGINFO if (already_installed == false) @@ -715,8 +715,8 @@ static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids) } if (*p) { - /* log(buff); - update_client logs it too */ - update_client(buff); + log("%s", buff); + update_client("%s", buff); } } -- cgit From 57039b590e4411606795893c90f9871e0412ca31 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 6 Nov 2009 18:26:42 +0100 Subject: give Plugin class a map_plugin_settings_t member This simplifies and unifies get/set settings ops Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index b6a5db8..4b73938 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -975,16 +975,14 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) } } -map_plugin_settings_t CAnalyzerCCpp::GetSettings() +const map_plugin_settings_t& CAnalyzerCCpp::GetSettings() { - map_plugin_settings_t ret = m_pSettings; + m_pSettings["MemoryMap"] = m_bMemoryMap ? "yes" : "no"; + m_pSettings["DebugInfo"] = m_sDebugInfo; + m_pSettings["DebugInfoCacheMB"] = to_string(m_nDebugInfoCacheMB); + m_pSettings["InstallDebugInfo"] = m_bInstallDebugInfo ? "yes" : "no"; - ret["MemoryMap"] = m_bMemoryMap ? "yes" : "no"; - ret["DebugInfo"] = m_sDebugInfo; - ret["DebugInfoCacheMB"] = to_string(m_nDebugInfoCacheMB); - ret["InstallDebugInfo"] = m_bInstallDebugInfo ? "yes" : "no"; - - return ret; + return m_pSettings; } PLUGIN_INFO(ANALYZER, -- cgit From b5cbb9b03aeab5fd452f0014474163864f2d0c10 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Nov 2009 12:37:19 +0100 Subject: reinstate code which returns rating 0 on empty backtraces Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 4b73938..bc10f11 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -210,7 +210,11 @@ int rate_backtrace(const std::string & backtrace) } } - /* returning number of "stars" to show */ + /* Bogus "backtrace" with zero frames? */ + if (best_possible_rating == 0) + return 0; + + /* Returning number of "stars" to show */ if (rating*10 >= best_possible_rating*8) /* >= 0.8 */ return 4; if (rating*10 >= best_possible_rating*6) -- cgit From ff0d8ed597eeaf8d80238ace1b26b65b43495e26 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Nov 2009 13:05:02 +0100 Subject: lib/Plugins/CCpp: simpler rating code (do not painfully concatenate byte-by-byte) Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 55 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 22 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index bc10f11..e06d9bc 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -160,17 +160,25 @@ enum LineRating BestRating = Good, }; -static LineRating rate_line(const std::string & line) +static LineRating rate_line(const char *line) { -#define FOUND(x) (line.find(x) != std::string::npos) - bool function = FOUND(" in ") && !FOUND(" in ??"); - bool library = FOUND(" from "); - bool source_file = FOUND(" at "); -#undef FOUND - +#define FOUND(x) (strstr(line, x) != NULL) /* see the "enum LineRating" comments for possible combinations */ - if (function && source_file) - return Good; + const char *function = strstr(line, " in "); + if (function) + { + if (function[4] == '?') /* " in ??" does not count */ + { + function = NULL; + } + else + { + bool source_file = FOUND(" at "); + if (source_file) + return Good; + } + } + bool library = FOUND(" from "); if (function && library) return MissingSourceFile; if (function) @@ -179,34 +187,37 @@ static LineRating rate_line(const std::string & line) return MissingFunction; return MissingEverything; +#undef FOUND } /* returns number of "stars" to show */ -int rate_backtrace(const std::string & backtrace) +static int rate_backtrace(const char *backtrace) { - int l = backtrace.length(); - int i; - std::string s; + int i, len; int multiplier = 0; int rating = 0; int best_possible_rating = 0; - /* We look at the frames in reversed order, since - * - rate_line() looks at the first line of the frame + /* We look at the frames in reversed order, since: + * - rate_line() checks starting from the first line of the frame + * (note: it may need to look at more than one line!) * - we increase weight (multiplier) for every frame, - * so that topmost frames end up most important. + * so that topmost frames end up most important */ - for (i = l-1; i >= 0; i--) + len = 0; + for (i = strlen(backtrace) - 1; i >= 0; i--) { if (backtrace[i] == '#') /* this separates frames from each other */ { + std::string s(backtrace + 1, len); multiplier++; - rating += rate_line(s) * multiplier; + rating += rate_line(s.c_str()) * multiplier; best_possible_rating += BestRating * multiplier; - s = ""; /* starting new line */ - } else + len = 0; /* starting new line */ + } + else { - s = backtrace[i] + s; + len++; } } @@ -898,7 +909,7 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) { dd.SaveText(FILENAME_MEMORYMAP, "memory map of the crashed C/C++ application, not implemented yet"); } - dd.SaveText(FILENAME_RATING, to_string(rate_backtrace(backtrace)).c_str()); + dd.SaveText(FILENAME_RATING, to_string(rate_backtrace(backtrace.c_str())).c_str()); dd.Close(); } -- cgit From a5e45d3eea8a239c71da8ff871952d3e80030902 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 9 Nov 2009 13:42:44 +0100 Subject: fix my thinko in rate code. run tested Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index e06d9bc..6d6edd5 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -209,7 +209,7 @@ static int rate_backtrace(const char *backtrace) { if (backtrace[i] == '#') /* this separates frames from each other */ { - std::string s(backtrace + 1, len); + std::string s(backtrace + i + 1, len); multiplier++; rating += rate_line(s.c_str()) * multiplier; best_possible_rating += BestRating * multiplier; -- cgit From 35e5d37931a4548df96d0d49f6bd0138e65e4b5b Mon Sep 17 00:00:00 2001 From: danny Date: Mon, 9 Nov 2009 15:34:19 +0100 Subject: fix and update rating --- lib/Plugins/CCpp.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 6d6edd5..1ab0e64 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -164,6 +164,8 @@ static LineRating rate_line(const char *line) { #define FOUND(x) (strstr(line, x) != NULL) /* see the "enum LineRating" comments for possible combinations */ + if (FOUND(" at ")) + return Good; const char *function = strstr(line, " in "); if (function) { @@ -171,12 +173,6 @@ static LineRating rate_line(const char *line) { function = NULL; } - else - { - bool source_file = FOUND(" at "); - if (source_file) - return Good; - } } bool library = FOUND(" from "); if (function && library) @@ -193,7 +189,7 @@ static LineRating rate_line(const char *line) /* returns number of "stars" to show */ static int rate_backtrace(const char *backtrace) { - int i, len; + int i, j, len; int multiplier = 0; int rating = 0; int best_possible_rating = 0; @@ -210,6 +206,9 @@ static int rate_backtrace(const char *backtrace) if (backtrace[i] == '#') /* this separates frames from each other */ { std::string s(backtrace + i + 1, len); + for (j=0; j Date: Mon, 9 Nov 2009 16:33:15 +0100 Subject: prevent gdb from i18izing its output Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 1ab0e64..5f87235 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -127,6 +127,18 @@ static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput) setreuid(uid, uid); setsid(); + /* Nuke everything which may make setlocale() switch to non-POSIX locale: + * we need to avoid having gdb output in some obscure language. + */ + unsetenv("LANG"); + unsetenv("LC_ALL"); + unsetenv("LC_COLLATE"); + unsetenv("LC_CTYPE"); + unsetenv("LC_MESSAGES"); + unsetenv("LC_MONETARY"); + unsetenv("LC_NUMERIC"); + unsetenv("LC_TIME"); + execvp(pArgs[0], pArgs); /* VERB1 since sometimes we expect errors here */ VERB1 perror_msg("Can't execute '%s'", pArgs[0]); -- cgit From c0ee9dabb895e9079a6367a823187f9e687c3e4a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 Nov 2009 14:25:40 +0100 Subject: remove getSettings from most plugins (inherited one is ok) Also move parse_release() to abrtlib, it's shared among Bugzilla and Catcut. Tested Bugzilla and Catcut, both work. Signed-off-by: Denys Vlasenko --- lib/Plugins/CCpp.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'lib/Plugins/CCpp.cpp') diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 5f87235..82c5677 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -980,7 +980,7 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("MemoryMap"); if (it != end) { - m_bMemoryMap = it->second == "yes"; + m_bMemoryMap = string_to_bool(it->second.c_str()); } it = pSettings.find("DebugInfo"); if (it != end) @@ -997,19 +997,20 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) it = pSettings.find("InstallDebuginfo"); if (it != end) { - m_bInstallDebugInfo = it->second == "yes"; + m_bInstallDebugInfo = string_to_bool(it->second.c_str()); } } -const map_plugin_settings_t& CAnalyzerCCpp::GetSettings() -{ - m_pSettings["MemoryMap"] = m_bMemoryMap ? "yes" : "no"; - m_pSettings["DebugInfo"] = m_sDebugInfo; - m_pSettings["DebugInfoCacheMB"] = to_string(m_nDebugInfoCacheMB); - m_pSettings["InstallDebugInfo"] = m_bInstallDebugInfo ? "yes" : "no"; - - return m_pSettings; -} +//ok to delete? +//const map_plugin_settings_t& CAnalyzerCCpp::GetSettings() +//{ +// m_pSettings["MemoryMap"] = m_bMemoryMap ? "yes" : "no"; +// m_pSettings["DebugInfo"] = m_sDebugInfo; +// m_pSettings["DebugInfoCacheMB"] = to_string(m_nDebugInfoCacheMB); +// m_pSettings["InstallDebugInfo"] = m_bInstallDebugInfo ? "yes" : "no"; +// +// return m_pSettings; +//} PLUGIN_INFO(ANALYZER, CAnalyzerCCpp, -- cgit