don't try to look for python files when handling a C++ crash
authorFelix Domke <tmbinc@elitedvb.net>
Tue, 18 Nov 2008 14:47:32 +0000 (15:47 +0100)
committerFelix Domke <tmbinc@elitedvb.net>
Tue, 18 Nov 2008 14:47:32 +0000 (15:47 +0100)
lib/base/eerror.cpp
lib/python/python.cpp
main/bsod.cpp
main/bsod.h
main/enigma.cpp

index 7ebac213930fd8472612c6774fa58c0855176797..4c4d6551affb77f71c3d7f2337cea520c133c1e2 100644 (file)
@@ -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
index 50b66103887caca878f17b3b2aac611d01d9aa30..c5faeed41b59558c6a6358e04394f103fc7cc7ae 100644 (file)
@@ -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 <lib/python/python.h>
@@ -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;
index 173a2cce00e68bfb38e7b1105e81b669ece7e442..583107d78f1312b1b5682ea963ffc607386df641 100644 (file)
@@ -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()
index aa8cfb741778f8f819a8fcad84e1b8d76f4d4dc6..4ee4c48b19fad8099edfd8ee6a073684431e7bce 100644 (file)
@@ -3,6 +3,6 @@
 
 void bsodLogInit();
 void bsodCatchSignals();
-void bsodFatal();
+void bsodFatal(const char *component);
 
 #endif
index 0893b035f74cb4cbf814f8ccfbb1f95579022ba9..98175c49425f927a358a41f8d1471f04b96ab328 100644 (file)
@@ -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();