diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-07 12:37:45 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-07 12:37:45 +0100 |
commit | 6b36135970dd9ba4694e626e3fbd8166c64d8cdc (patch) | |
tree | 09468c7403bdd77ceddb02ac3571e83a6a504406 /lib/Plugins | |
parent | 9fa0918b822b4d81a8adf7392c4e18e87d351872 (diff) | |
download | abrt-6b36135970dd9ba4694e626e3fbd8166c64d8cdc.tar.gz abrt-6b36135970dd9ba4694e626e3fbd8166c64d8cdc.tar.xz abrt-6b36135970dd9ba4694e626e3fbd8166c64d8cdc.zip |
ccpp: add a possibility to disable backtrace generation
+ assorted minor tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins')
-rw-r--r-- | lib/Plugins/CCpp.conf | 3 | ||||
-rw-r--r-- | lib/Plugins/CCpp.cpp | 147 | ||||
-rw-r--r-- | lib/Plugins/CCpp.h | 1 | ||||
-rw-r--r-- | lib/Plugins/Firefox.cpp | 23 | ||||
-rw-r--r-- | lib/Plugins/Firefox.h | 1 | ||||
-rw-r--r-- | lib/Plugins/Mailx.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/Python.cpp | 1 |
7 files changed, 106 insertions, 72 deletions
diff --git a/lib/Plugins/CCpp.conf b/lib/Plugins/CCpp.conf index e42b85a4..dfdbec8b 100644 --- a/lib/Plugins/CCpp.conf +++ b/lib/Plugins/CCpp.conf @@ -4,6 +4,9 @@ # in crashed process' current dir, set to "yes" MakeCompatCore = no +# Generate backtrace +Backtrace = yes + # Generate memory map too (IGNORED FOR NOW) MemoryMap = no diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index a5315b73..1a01c010 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -46,6 +46,7 @@ using namespace std; #define DEBUGINFO_CACHE_DIR LOCALSTATEDIR"/cache/abrt-di" CAnalyzerCCpp::CAnalyzerCCpp() : + m_bBacktrace(true), m_bMemoryMap(false), m_bInstallDebugInfo(true), m_nDebugInfoCacheMB(4000) @@ -157,7 +158,7 @@ static int ExecVP(char **pArgs, uid_t uid, int redirect_stderr, string& pOutput) close(pipeout[0]); int status; - wait(&status); /* prevent having zombie child process */ + waitpid(child, &status, 0); /* prevent having zombie child process */ return status; } @@ -410,7 +411,7 @@ static void InstallDebugInfos(const char *pDebugDumpDir, if (pipeout_fp == NULL) /* never happens */ { close(pipeout[0]); - wait(NULL); + waitpid(child, NULL, 0); return; } @@ -544,7 +545,7 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) { log(_("Getting global universal unique identification...")); - string backtrace_path = (string)pDebugDumpDir + "/" + FILENAME_BACKTRACE; + string backtrace_path = concat_path_file(pDebugDumpDir, FILENAME_BACKTRACE); string executable; string package; string uid_str; @@ -553,74 +554,82 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) dd.Open(pDebugDumpDir); dd.LoadText(FILENAME_EXECUTABLE, executable); dd.LoadText(FILENAME_PACKAGE, package); - dd.LoadText(FILENAME_UID, uid_str); + if (m_bBacktrace) + dd.LoadText(FILENAME_UID, uid_str); } - /* Run abrt-backtrace to get independent backtrace suitable - to UUID calculation. */ - char *args[7]; - args[0] = (char*)"abrt-backtrace"; - args[1] = (char*)"--single-thread"; - args[2] = (char*)"--remove-exit-handlers"; - args[3] = (char*)"--frame-depth=5"; - args[4] = (char*)"--remove-noncrash-frames"; - args[5] = (char*)backtrace_path.c_str(); - args[6] = NULL; - - int pipeout[2]; - xpipe(pipeout); /* stdout of abrt-backtrace */ - pid_t child = fork(); - if (child == -1) - perror_msg_and_die("fork"); - if (child == 0) - { - VERB1 log("Executing: %s", concat_str_vector(args).c_str()); - - xmove_fd(pipeout[1], STDOUT_FILENO); - close(pipeout[0]); /* read side of the pipe */ - - /* abrt-backtrace is executed under the user's uid and gid. */ - uid_t uid = xatoi_u(uid_str.c_str()); - struct passwd* pw = getpwuid(uid); - gid_t gid = pw ? pw->pw_gid : uid; - setgroups(1, &gid); - xsetregid(gid, gid); - xsetreuid(uid, uid); + string independent_backtrace; + if (m_bBacktrace) + { + /* Run abrt-backtrace to get independent backtrace suitable + to UUID calculation. */ + char *args[7]; + args[0] = (char*)"abrt-backtrace"; + args[1] = (char*)"--single-thread"; + args[2] = (char*)"--remove-exit-handlers"; + args[3] = (char*)"--frame-depth=5"; + args[4] = (char*)"--remove-noncrash-frames"; + args[5] = (char*)backtrace_path.c_str(); + args[6] = NULL; + + int pipeout[2]; + xpipe(pipeout); /* stdout of abrt-backtrace */ + pid_t child = fork(); + if (child == -1) + perror_msg_and_die("fork"); + if (child == 0) + { + VERB1 log("Executing: %s", concat_str_vector(args).c_str()); + + xmove_fd(pipeout[1], STDOUT_FILENO); + close(pipeout[0]); /* read side of the pipe */ + + /* abrt-backtrace is executed under the user's uid and gid. */ + uid_t uid = xatoi_u(uid_str.c_str()); + struct passwd* pw = getpwuid(uid); + gid_t gid = pw ? pw->pw_gid : uid; + setgroups(1, &gid); + xsetregid(gid, gid); + xsetreuid(uid, uid); + + execvp(args[0], args); + VERB1 perror_msg("Can't execute '%s'", args[0]); + exit(1); + } - execvp(args[0], args); - VERB1 perror_msg("Can't execute '%s'", args[0]); - exit(1); - } + close(pipeout[1]); /* write side of the pipe */ - close(pipeout[1]); /* write side of the pipe */ + /* Read the result from abrt-backtrace. */ + int r; + char buff[1024]; + while ((r = safe_read(pipeout[0], buff, sizeof(buff) - 1)) > 0) + { + buff[r] = '\0'; + independent_backtrace += buff; + } + close(pipeout[0]); - /* Read the result from abrt-backtrace. */ - int r; - char buff[1024]; - string independent_backtrace; - while ((r = read(pipeout[0], buff, sizeof(buff) - 1)) > 0) - { - buff[r] = '\0'; - independent_backtrace += buff; - } - close(pipeout[0]); + /* Wait until it exits, and check the exit status. */ + errno = 0; + int status; + waitpid(child, &status, 0); + if (!WIFEXITED(status)) + { + perror_msg("abrt-backtrace not executed properly, " + "status: %x signal: %d", status, WIFSIGNALED(status)); + } else + { + int exit_status = WEXITSTATUS(status); + if (exit_status != 0) + { + error_msg("abrt-backtrace run failed, exit value: %d", + exit_status); + } + } - /* Wait until it ends, and check the exit status. */ - int status; - wait(&status); /* prevent having zombie child process */ - if (!WIFEXITED(status)) - { - perror_msg_and_die("abrt-backtrace not executed properly, " - "status: %x", status); - } - int exit_status = WEXITSTATUS(status); - if (exit_status > 0 && exit_status <= EX__MAX) - { - error_msg_and_die("abrt-backtrace run failed, exit value: %d", - exit_status); + /*VERB1 log("abrt-backtrace result: %s", independent_backtrace.c_str());*/ } - - /*VERB1 log("abrt-backtrace result: %s", independent_backtrace.c_str());*/ + /* else: no backtrace, independent_backtrace == "" */ string hash_base = package + executable + independent_backtrace; return CreateHash(hash_base.c_str()); @@ -661,6 +670,11 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) CDebugDump dd; dd.Open(pDebugDumpDir); + if (!m_bBacktrace) + { + return; + } + if (!force) { bool bt_exists = dd.Exist(FILENAME_BACKTRACE); @@ -753,6 +767,11 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) map_plugin_settings_t::const_iterator end = pSettings.end(); map_plugin_settings_t::const_iterator it; + it = pSettings.find("Backtrace"); + if (it != end) + { + m_bBacktrace = string_to_bool(it->second.c_str()); + } it = pSettings.find("MemoryMap"); if (it != end) { diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h index 26dedead..03ba5ee4 100644 --- a/lib/Plugins/CCpp.h +++ b/lib/Plugins/CCpp.h @@ -30,6 +30,7 @@ class CAnalyzerCCpp : public CAnalyzer { private: + bool m_bBacktrace; bool m_bMemoryMap; bool m_bInstallDebugInfo; unsigned m_nDebugInfoCacheMB; diff --git a/lib/Plugins/Firefox.cpp b/lib/Plugins/Firefox.cpp index ab2ea8aa..92ef4e58 100644 --- a/lib/Plugins/Firefox.cpp +++ b/lib/Plugins/Firefox.cpp @@ -43,6 +43,7 @@ #define DEBUGINFO_CACHE_DIR LOCALSTATEDIR"/cache/abrt-di" CAnalyzerFirefox::CAnalyzerFirefox() : + m_bBacktrace(true), m_bMemoryMap(false), m_bInstallDebugInfo(true), m_nDebugInfoCacheMB(4000) @@ -148,7 +149,7 @@ static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput) } close(pipeout[0]); - wait(NULL); /* prevent having zombie child process */ + waitpid(child, NULL, 0); /* prevent having zombie child process */ return 0; } @@ -608,7 +609,7 @@ Another application is holding the yum lock, cannot continue if (pipeout_fp == NULL) /* never happens */ { close(pipeout[0]); - wait(NULL); + waitpid(child, NULL, 0); return; } @@ -652,14 +653,14 @@ Another application is holding the yum lock, cannot continue { fclose(pipeout_fp); kill(child, SIGTERM); - wait(NULL); + waitpid(child, NULL, 0); throw CABRTException(EXCEP_PLUGIN, "%s: can't install debuginfos for %s", __func__, pPackage); } #endif } fclose(pipeout_fp); - wait(NULL); + waitpid(child, NULL, 0); } #endif /* Needs gdb feature from here: https://bugzilla.redhat.com/show_bug.cgi?id=528668 @@ -704,7 +705,7 @@ static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids) if (pipeout_fp == NULL) /* never happens */ { close(pipeout[0]); - wait(NULL); + waitpid(child, NULL, 0); return; } @@ -735,7 +736,7 @@ static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids) } fclose(pipeout_fp); - wait(NULL); + waitpid(child, NULL, 0); } static double get_dir_size(const char *dirname, std::string *worst_file, double *maxsz) @@ -873,6 +874,11 @@ void CAnalyzerFirefox::CreateReport(const char *pDebugDumpDir, int force) CDebugDump dd; dd.Open(pDebugDumpDir); + if (!m_bBacktrace) + { + return; + } + if (!force) { bool bt_exists = dd.Exist(FILENAME_BACKTRACE); @@ -962,6 +968,11 @@ void CAnalyzerFirefox::SetSettings(const map_plugin_settings_t& pSettings) map_plugin_settings_t::const_iterator end = pSettings.end(); map_plugin_settings_t::const_iterator it; + it = pSettings.find("Backtrace"); + if (it != end) + { + m_bBacktrace = string_to_bool(it->second.c_str()); + } it = pSettings.find("MemoryMap"); if (it != end) { diff --git a/lib/Plugins/Firefox.h b/lib/Plugins/Firefox.h index 0669f4fd..dd7758d9 100644 --- a/lib/Plugins/Firefox.h +++ b/lib/Plugins/Firefox.h @@ -30,6 +30,7 @@ class CAnalyzerFirefox : public CAnalyzer { private: + bool m_bBacktrace; bool m_bMemoryMap; bool m_bInstallDebugInfo; unsigned m_nDebugInfoCacheMB; diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 6904c169..70eddb8e 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -68,7 +68,7 @@ static void exec_and_feed_input(uid_t uid, const char* pText, char **pArgs) safe_write(pipein[1], pText, strlen(pText)); close(pipein[1]); - wait(NULL); /* wait for command completion */ + waitpid(child, NULL, 0); /* wait for command completion */ } static char** append_str_to_vector(char **vec, unsigned &size, const char *str) diff --git a/lib/Plugins/Python.cpp b/lib/Plugins/Python.cpp index 906e815d..23d6f5c0 100644 --- a/lib/Plugins/Python.cpp +++ b/lib/Plugins/Python.cpp @@ -1,4 +1,3 @@ -#include <fstream> #include "Python.h" #include "DebugDump.h" #include "ABRTException.h" |