summaryrefslogtreecommitdiffstats
path: root/lib/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/CCpp.cpp60
-rw-r--r--lib/plugins/Kerneloops.cpp9
-rw-r--r--lib/plugins/KerneloopsScanner.cpp40
-rw-r--r--lib/plugins/Python.cpp8
-rw-r--r--lib/plugins/RunApp.cpp8
-rw-r--r--lib/plugins/SOSreport.cpp14
6 files changed, 101 insertions, 38 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)
diff --git a/lib/plugins/Kerneloops.cpp b/lib/plugins/Kerneloops.cpp
index 1a2532e8..379197b2 100644
--- a/lib/plugins/Kerneloops.cpp
+++ b/lib/plugins/Kerneloops.cpp
@@ -118,12 +118,15 @@ std::string CAnalyzerKerneloops::GetLocalUUID(const char *pDebugDumpDir)
VERB3 log("Getting local universal unique identification");
std::string oops;
+ CDebugDump dd;
+ if (!dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.LoadText(FILENAME_BACKTRACE, oops);
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return std::string("");
}
+ dd.LoadText(FILENAME_BACKTRACE, oops);
+
unsigned hash = hash_oops_str(oops.c_str());
hash &= 0x7FFFFFFF;
diff --git a/lib/plugins/KerneloopsScanner.cpp b/lib/plugins/KerneloopsScanner.cpp
index dc1f6d0a..7e0e8e74 100644
--- a/lib/plugins/KerneloopsScanner.cpp
+++ b/lib/plugins/KerneloopsScanner.cpp
@@ -113,7 +113,8 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename, time_t *la
return cnt_FoundOopses;
}
-void save_oops_to_debug_dump(const vector_string_t& oopsList)
+/* returns number of errors */
+int save_oops_to_debug_dump(const vector_string_t& oopsList)
{
unsigned countdown = 16; /* do not report hundreds of oopses */
unsigned idx = oopsList.size();
@@ -122,19 +123,21 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList)
VERB1 log("Saving %u oopses as crash dump dirs", idx >= countdown ? countdown-1 : idx);
+ int errors = 0;
+
while (idx != 0 && --countdown != 0)
{
char path[sizeof(DEBUG_DUMPS_DIR"/kerneloops-%lu-%lu-%lu") + 3 * sizeof(long)*3];
sprintf(path, DEBUG_DUMPS_DIR"/kerneloops-%lu-%lu-%lu", (long)t, (long)my_pid, (long)idx);
- try
- {
- std::string oops = oopsList.at(--idx);
- const char *first_line = oops.c_str();
- char *second_line = (char*)strchr(first_line, '\n'); /* never NULL */
- *second_line++ = '\0';
- CDebugDump dd;
- dd.Create(path, /*uid:*/ 0);
+ std::string oops = oopsList.at(--idx);
+ const char *first_line = oops.c_str();
+ char *second_line = (char*)strchr(first_line, '\n'); /* never NULL */
+ *second_line++ = '\0';
+
+ CDebugDump dd;
+ if (dd.Create(path, /*uid:*/ 0))
+ {
dd.SaveText(FILENAME_ANALYZER, "Kerneloops");
dd.SaveText(FILENAME_EXECUTABLE, "kernel");
dd.SaveText(FILENAME_KERNEL, first_line);
@@ -143,12 +146,13 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList)
/* Optional, makes generated bz more informative */
strchrnul(second_line, '\n')[0] = '\0';
dd.SaveText(FILENAME_REASON, second_line);
+ dd.Close();
}
- catch (CABRTException& e)
- {
- throw CABRTException(EXCEP_PLUGIN, "%s: %s", __func__, e.what());
- }
+ else
+ errors++;
}
+
+ return errors;
}
} /* extern "C" */
@@ -163,7 +167,11 @@ CKerneloopsScanner::CKerneloopsScanner()
vector_string_t oopsList;
cnt_FoundOopses = scan_dmesg(oopsList);
if (cnt_FoundOopses > 0)
- save_oops_to_debug_dump(oopsList);
+ {
+ int errors = save_oops_to_debug_dump(oopsList);
+ if (errors > 0)
+ log("%d errors while dumping oopses", errors);
+ }
}
void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs, int force)
@@ -177,7 +185,9 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs, int forc
int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file, &m_syslog_last_change);
if (cnt_FoundOopses > 0)
{
- save_oops_to_debug_dump(oopsList);
+ int errors = save_oops_to_debug_dump(oopsList);
+ if (errors > 0)
+ log("%d errors while dumping oopses", errors);
/*
* This marker in syslog file prevents us from
* re-parsing old oopses (any oops before it is
diff --git a/lib/plugins/Python.cpp b/lib/plugins/Python.cpp
index 5f2f6e17..b4d6cefc 100644
--- a/lib/plugins/Python.cpp
+++ b/lib/plugins/Python.cpp
@@ -27,9 +27,15 @@ using namespace std;
string CAnalyzerPython::GetLocalUUID(const char *pDebugDumpDir)
{
CDebugDump dd;
- dd.Open(pDebugDumpDir);
+ if (!dd.Open(pDebugDumpDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return string("");
+ }
+
string bt;
dd.LoadText(FILENAME_BACKTRACE, bt);
+ dd.Close();
const char *bt_str = bt.c_str();
const char *bt_end = strchrnul(bt_str, '\n');
diff --git a/lib/plugins/RunApp.cpp b/lib/plugins/RunApp.cpp
index 69c9384c..632c26f1 100644
--- a/lib/plugins/RunApp.cpp
+++ b/lib/plugins/RunApp.cpp
@@ -59,8 +59,14 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs, int force)
if (args.size() > FILENAME)
{
CDebugDump dd;
- dd.Open(pActionDir);
+ if (!dd.Open(pActionDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pActionDir);
+ return;
+ }
+
dd.SaveBinary(args[FILENAME].c_str(), cmd_out, cmd_out_size);
+ dd.Close();
}
free(cmd_out);
diff --git a/lib/plugins/SOSreport.cpp b/lib/plugins/SOSreport.cpp
index 6c8ab1f8..df254ec3 100644
--- a/lib/plugins/SOSreport.cpp
+++ b/lib/plugins/SOSreport.cpp
@@ -53,13 +53,19 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs, int force)
if (!force)
{
CDebugDump dd;
- dd.Open(pActionDir);
+ if (!dd.Open(pActionDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pActionDir);
+ return;
+ }
+
bool bt_exists = dd.Exist("sosreport.tar.bz2") || dd.Exist("sosreport.tar.xz");
if (bt_exists)
{
VERB3 log("%s already exists, not regenerating", "sosreport.tar.bz2");
return;
}
+ dd.Close();
}
static const char command_default[] =
@@ -125,7 +131,11 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs, int force)
sosreport_dd_filename += ext;
}
CDebugDump dd;
- dd.Open(pActionDir);
+ if (!dd.Open(pActionDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return;
+ }
//Not useful: dd.SaveText("sosreportoutput", output);
off_t sz = copy_file(sosreport_filename, sosreport_dd_filename.c_str(), 0644);