1 #include <lib/base/eerror.h>
9 // #include <lib/gui/emessage.h>
13 pthread_mutex_t memLock =
14 PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
18 AllocList::iterator i;
19 unsigned int totalSize = 0;
25 char *buffer = (char*)malloc(1024);
26 for(i = allocList->begin(); i != allocList->end(); i++)
29 printf("%s\tLINE %d\tADDRESS %p\t%d unfreed\ttype %d (btcount %d)\n",
30 i->second.file, i->second.line, (void*)i->second.address, i->second.size, i->second.type, i->second.btcount);
31 totalSize += i->second.size;
32 char **bt_string = backtrace_symbols( i->second.backtrace, i->second.btcount );
33 for ( tmp=0; tmp < i->second.btcount; tmp++ )
37 char *beg = strchr(bt_string[tmp], '(');
40 std::string tmp1(beg+1);
41 int pos1=tmp1.find('+'), pos2=tmp1.find(')');
42 if ( pos1 != std::string::npos && pos2 != std::string::npos )
44 std::string tmp2(tmp1.substr(pos1,(pos2-pos1)));
49 abi::__cxa_demangle(tmp1.c_str(), buffer, &len, &state);
51 printf("%d %s%s\n", tmp, buffer,tmp2.c_str());
53 printf("%d %s\n", tmp, bt_string[tmp]);
58 printf("%d %s\n", tmp, bt_string[tmp]);
66 printf("-----------------------------------------------------------\n");
67 printf("Total Unfreed: %d bytes\n", totalSize);
71 #include <lib/base/elock.h>
76 Signal2<void, int, const std::string&> logOutput;
77 int logOutputConsole=1;
79 pthread_mutex_t signalLock =
80 PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
82 void eFatal(const char* fmt, ...)
87 vsnprintf(buf, 1024, fmt, ap);
89 singleLock s(signalLock);
90 logOutput(lvlFatal, buf);
91 fprintf(stderr, "FATAL: %s\n",buf );
96 eMessageBox msg(buf, "FATAL ERROR", eMessageBox::iconError|eMessageBox::btOK);
105 void eDebug(const char* fmt, ...)
110 vsnprintf(buf, 1024, fmt, ap);
112 singleLock s(signalLock);
113 logOutput(lvlDebug, std::string(buf) + "\n");
114 if (logOutputConsole)
115 fprintf(stderr, "%s\n", buf);
118 void eDebugNoNewLine(const char* fmt, ...)
123 vsnprintf(buf, 1024, fmt, ap);
125 singleLock s(signalLock);
126 logOutput(lvlDebug, buf);
127 if (logOutputConsole)
128 fprintf(stderr, "%s", buf);
131 void eWarning(const char* fmt, ...)
136 vsnprintf(buf, 1024, fmt, ap);
138 singleLock s(signalLock);
139 logOutput(lvlWarning, std::string(buf) + "\n");
140 if (logOutputConsole)
141 fprintf(stderr, "%s\n", buf);
145 void ePythonOutput(const char *string)
147 logOutput(lvlWarning, string);
148 if (logOutputConsole)
149 fwrite(string, 1, strlen(string), stderr);
152 void eWriteCrashdump()