X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/f3a0cb3a38480f1bef9fe6e50e1873f2a88a0e0a..a6f7c725e21a4b6ed064e92b453331837d12f267:/lib/base/eerror.cpp diff --git a/lib/base/eerror.cpp b/lib/base/eerror.cpp index 4093d012..35e46e05 100644 --- a/lib/base/eerror.cpp +++ b/lib/base/eerror.cpp @@ -1,8 +1,9 @@ #include #include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -20,14 +21,16 @@ void DumpUnfreed() if(!allocList) return; + FILE *f = fopen("/var/tmp/enigma2_mem.out", "w"); size_t len = 1024; char *buffer = (char*)malloc(1024); for(i = allocList->begin(); i != allocList->end(); i++) { unsigned int tmp; - printf("%s\tLINE %d\tADDRESS %p\t%d unfreed\ttype %d (btcount %d)\n", + fprintf(f, "%s\tLINE %d\tADDRESS %p\t%d unfreed\ttype %d (btcount %d)\n", i->second.file, i->second.line, (void*)i->second.address, i->second.size, i->second.type, i->second.btcount); totalSize += i->second.size; + char **bt_string = backtrace_symbols( i->second.backtrace, i->second.btcount ); for ( tmp=0; tmp < i->second.btcount; tmp++ ) { @@ -47,24 +50,25 @@ void DumpUnfreed() int state; abi::__cxa_demangle(tmp1.c_str(), buffer, &len, &state); if (!state) - printf("%d %s%s\n", tmp, buffer,tmp2.c_str()); + fprintf(f, "%d %s%s\n", tmp, buffer,tmp2.c_str()); else - printf("%d %s\n", tmp, bt_string[tmp]); + fprintf(f, "%d %s\n", tmp, bt_string[tmp]); } } } else - printf("%d %s\n", tmp, bt_string[tmp]); + fprintf(f, "%d %s\n", tmp, bt_string[tmp]); } } free(bt_string); - printf("\n"); + if (i->second.btcount) + fprintf(f, "\n"); } free(buffer); - printf("-----------------------------------------------------------\n"); - printf("Total Unfreed: %d bytes\n", totalSize); - fflush(stdout); + fprintf(f, "-----------------------------------------------------------\n"); + fprintf(f, "Total Unfreed: %d bytes\n", totalSize); + fflush(f); }; #endif @@ -74,7 +78,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, ...) { @@ -83,10 +87,12 @@ void eFatal(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); - singleLock s(DebugLock); - logOutput(lvlFatal, "FATAL: " + std::string(buf) + "\n"); - fprintf(stderr, "FATAL: %s\n",buf ); - bsodFatal(); + { + singleLock s(DebugLock); + logOutput(lvlFatal, "FATAL: " + std::string(buf) + "\n"); + fprintf(stderr, "FATAL: %s\n",buf ); + } + bsodFatal("enigma2"); } #ifdef DEBUG