diff options
| author | Michal Toman <mtoman@redhat.com> | 2010-08-18 11:18:39 +0200 |
|---|---|---|
| committer | Michal Toman <mtoman@redhat.com> | 2010-08-18 11:18:39 +0200 |
| commit | 4ef4bc1ba11d9c185db584ed97ce520a6306b462 (patch) | |
| tree | 5b37f6ca52fd5911b7e65157b4246cc99d7f3fab /lib/plugins/CCpp.cpp | |
| parent | e0b0da307a78b038045e2cb86934d60befd74339 (diff) | |
| download | abrt-4ef4bc1ba11d9c185db584ed97ce520a6306b462.tar.gz abrt-4ef4bc1ba11d9c185db584ed97ce520a6306b462.tar.xz abrt-4ef4bc1ba11d9c185db584ed97ce520a6306b462.zip | |
get rid of exceptions in CDebugDump class
Diffstat (limited to 'lib/plugins/CCpp.cpp')
| -rw-r--r-- | lib/plugins/CCpp.cpp | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/lib/plugins/CCpp.cpp b/lib/plugins/CCpp.cpp index 629da665..2e8b9177 100644 --- a/lib/plugins/CCpp.cpp +++ b/lib/plugins/CCpp.cpp @@ -178,7 +178,7 @@ static int ExecVP(char **pArgs, uid_t uid, int redirect_stderr, string& pOutput) return status; } -static void GetBacktrace(const char *pDebugDumpDir, +static bool GetBacktrace(const char *pDebugDumpDir, const char *pDebugInfoDirs, string& pBacktrace) { @@ -186,13 +186,17 @@ static void GetBacktrace(const char *pDebugDumpDir, string UID; string executable; + CDebugDump dd; + if (!dd.Open(pDebugDumpDir)) { - CDebugDump dd; - dd.Open(pDebugDumpDir); - dd.LoadText(FILENAME_EXECUTABLE, executable); - dd.LoadText(CD_UID, UID); + VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir); + return false; } + dd.LoadText(FILENAME_EXECUTABLE, executable); + dd.LoadText(CD_UID, UID); + dd.Close(); + // Workaround for // http://sourceware.org/bugzilla/show_bug.cgi?id=9622 unsetenv("TERM"); @@ -276,7 +280,7 @@ static void GetBacktrace(const char *pDebugDumpDir, pBacktrace = ""; ExecVP(args, xatoi_u(UID.c_str()), /*redirect_stderr:*/ 1, pBacktrace); if (bt_depth <= 64 || pBacktrace.size() < 256*1024) - return; + return true; bt_depth /= 2; if (bt_depth <= 64 && thread_apply_all[0] != '\0') { @@ -323,12 +327,16 @@ static void GetIndependentBuildIdPC(const char *unstrip_n_output, static string run_unstrip_n(const char *pDebugDumpDir) { string UID; + CDebugDump dd; + if (!dd.Open(pDebugDumpDir)) { - CDebugDump dd; - dd.Open(pDebugDumpDir); - dd.LoadText(CD_UID, UID); + VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir); + return string(""); } + dd.LoadText(CD_UID, UID); + dd.Close(); + char* args[4]; args[0] = (char*)"eu-unstrip"; args[1] = xasprintf("--core=%s/"FILENAME_COREDUMP, pDebugDumpDir); @@ -506,13 +514,17 @@ string CAnalyzerCCpp::GetLocalUUID(const char *pDebugDumpDir) { string executable; string package; + CDebugDump dd; + if (!dd.Open(pDebugDumpDir)) { - CDebugDump dd; - dd.Open(pDebugDumpDir); - dd.LoadText(FILENAME_EXECUTABLE, executable); - dd.LoadText(FILENAME_PACKAGE, package); + VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir); + return string(""); } + dd.LoadText(FILENAME_EXECUTABLE, executable); + dd.LoadText(FILENAME_PACKAGE, package); + dd.Close(); + string unstrip_n_output = run_unstrip_n(pDebugDumpDir); string independentBuildIdPC; GetIndependentBuildIdPC(unstrip_n_output.c_str(), independentBuildIdPC); @@ -552,11 +564,17 @@ string CAnalyzerCCpp::GetLocalUUID(const char *pDebugDumpDir) string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) { CDebugDump dd; - dd.Open(pDebugDumpDir); + if (!dd.Open(pDebugDumpDir)) + { + VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir); + return string(""); + } + if (dd.Exist(FILENAME_GLOBAL_UUID)) { string uuid; dd.LoadText(FILENAME_GLOBAL_UUID, uuid); + dd.Close(); return uuid; } else @@ -670,6 +688,7 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) { dd.SaveText(FILENAME_RATING, "0"); } + dd.Close(); string hash_base = package + executable + independent_backtrace; return create_hash(hash_base.c_str()); @@ -710,7 +729,11 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) string package, executable, UID; CDebugDump dd; - dd.Open(pDebugDumpDir); + if (!dd.Open(pDebugDumpDir)) + { + VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir); + return; + } /* Skip remote crashes. */ if (dd.Exist(FILENAME_REMOTE)) @@ -750,7 +773,12 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) /* Create and store backtrace. */ string backtrace_str; GetBacktrace(pDebugDumpDir, m_sDebugInfoDirs.c_str(), backtrace_str); - dd.Open(pDebugDumpDir); + if (!dd.Open(pDebugDumpDir)) + { + VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir); + return; + } + dd.SaveText(FILENAME_BACKTRACE, (backtrace_str + build_ids).c_str()); if (m_bMemoryMap) |
