From d924772eeced2429c007e51ce6dcb50dadec2836 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Tue, 18 Nov 2008 15:47:32 +0100 Subject: [PATCH] don't try to look for python files when handling a C++ crash --- lib/base/eerror.cpp | 4 ++-- lib/python/python.cpp | 16 ++++++++-------- main/bsod.cpp | 51 ++++++++++++++++++++++++++++----------------------- main/bsod.h | 2 +- main/enigma.cpp | 2 +- 5 files changed, 40 insertions(+), 35 deletions(-) diff --git a/lib/base/eerror.cpp b/lib/base/eerror.cpp index 7ebac21..4c4d655 100644 --- a/lib/base/eerror.cpp +++ b/lib/base/eerror.cpp @@ -77,7 +77,7 @@ int logOutputConsole=1; static pthread_mutex_t DebugLock = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP; -extern void bsodFatal(); +extern void bsodFatal(const char *component); void eFatal(const char* fmt, ...) { @@ -91,7 +91,7 @@ void eFatal(const char* fmt, ...) logOutput(lvlFatal, "FATAL: " + std::string(buf) + "\n"); fprintf(stderr, "FATAL: %s\n",buf ); } - bsodFatal(); + bsodFatal("enigma2"); } #ifdef DEBUG diff --git a/lib/python/python.cpp b/lib/python/python.cpp index 50b6610..c5faeed 100644 --- a/lib/python/python.cpp +++ b/lib/python/python.cpp @@ -5,7 +5,7 @@ extern "C" void init_enigma(); extern "C" void eBaseInit(void); extern "C" void eConsoleInit(void); -extern void bsodFatal(); +extern void bsodFatal(const char *component); #define SKIP_PART2 #include @@ -44,7 +44,7 @@ ePyObject::operator PyObject*() if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } return 0; } @@ -57,7 +57,7 @@ void ePyObject::incref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } if (m_erased || m_ob->ob_refcnt <= 0) { @@ -66,7 +66,7 @@ void ePyObject::incref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } if (m_ob->ob_refcnt == 0x7FFFFFFF) { @@ -75,7 +75,7 @@ void ePyObject::incref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } m_file = file; m_line = line; @@ -92,7 +92,7 @@ void ePyObject::decref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } if (m_erased || m_ob->ob_refcnt <= 0) { @@ -101,7 +101,7 @@ void ePyObject::decref(const char *file, int line) if (m_file) eDebug("last modified in file %s line %d from %d to %d", m_file, m_line, m_from, m_to); - bsodFatal(); + bsodFatal("enigma2, refcnt"); } m_file = file; m_line = line; @@ -207,7 +207,7 @@ int ePython::call(ePyObject pFunc, ePyObject pArgs) eDebug("(PyObject_CallObject(%s,%s) failed)", PyString_AS_STRING(FuncStr), PyString_AS_STRING(ArgStr)); Py_DECREF(FuncStr); Py_DECREF(ArgStr); - bsodFatal(); + bsodFatal(0); } } return res; diff --git a/main/bsod.cpp b/main/bsod.cpp index 173a2cc..583107d 100644 --- a/main/bsod.cpp +++ b/main/bsod.cpp @@ -67,7 +67,7 @@ extern std::string getLogBuffer(); #define INFOFILE "/maintainer.info" -void bsodFatal() +void bsodFatal(const char *component) { char logfile[128]; sprintf(logfile, "/media/hdd/enigma2_crash_%u.log", (unsigned int)time(0)); @@ -81,30 +81,35 @@ void bsodFatal() char crash_emailaddr[256] = CRASH_EMAILADDR; char crash_component[256] = "enigma2"; - while ((start = lines.find("\n File \"", start)) != std::string::npos) + if (component) + snprintf(crash_component, 256, component); + else { - start += 9; - size_t end = lines.find("\"", start); - if (end == std::string::npos) - break; - end = lines.rfind("/", end); - if (end == std::string::npos) - break; - if (end - start >= (256 - strlen(INFOFILE))) - continue; - char filename[256]; - snprintf(filename, 256, "%s%s", lines.substr(start, end - start).c_str(), INFOFILE); - FILE *cf = fopen(filename, "r"); - if (cf) + while ((start = lines.find("\n File \"", start)) != std::string::npos) { - fgets(crash_emailaddr, sizeof crash_emailaddr, cf); - if (*crash_emailaddr && crash_emailaddr[strlen(crash_emailaddr)-1] == '\n') - crash_emailaddr[strlen(crash_emailaddr)-1] = 0; + start += 9; + size_t end = lines.find("\"", start); + if (end == std::string::npos) + break; + end = lines.rfind("/", end); + if (end == std::string::npos) + break; + if (end - start >= (256 - strlen(INFOFILE))) + continue; + char filename[256]; + snprintf(filename, 256, "%s%s", lines.substr(start, end - start).c_str(), INFOFILE); + FILE *cf = fopen(filename, "r"); + if (cf) + { + fgets(crash_emailaddr, sizeof crash_emailaddr, cf); + if (*crash_emailaddr && crash_emailaddr[strlen(crash_emailaddr)-1] == '\n') + crash_emailaddr[strlen(crash_emailaddr)-1] = 0; - fgets(crash_component, sizeof crash_component, cf); - if (*crash_component && crash_component[strlen(crash_component)-1] == '\n') - crash_component[strlen(crash_component)-1] = 0; - fclose(cf); + fgets(crash_component, sizeof crash_component, cf); + if (*crash_component && crash_component[strlen(crash_component)-1] == '\n') + crash_component[strlen(crash_component)-1] = 0; + fclose(cf); + } } } @@ -242,7 +247,7 @@ void handleFatalSignal(int signum, siginfo_t *si, void *ctx) oops(uc->uc_mcontext, signum == SIGSEGV || signum == SIGABRT); #endif eDebug("-------"); - bsodFatal(); + bsodFatal("enigma2, signal"); } void bsodCatchSignals() diff --git a/main/bsod.h b/main/bsod.h index aa8cfb7..4ee4c48 100644 --- a/main/bsod.h +++ b/main/bsod.h @@ -3,6 +3,6 @@ void bsodLogInit(); void bsodCatchSignals(); -void bsodFatal(); +void bsodFatal(const char *component); #endif diff --git a/main/enigma.cpp b/main/enigma.cpp index 0893b03..98175c4 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -248,7 +248,7 @@ int main(int argc, char **argv) if (exit_code == 5) /* python crash */ { eDebug("(exit code 5)"); - bsodFatal(); + bsodFatal(0); } dsk.paint(); -- 2.7.4