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 void eFatal(const char* fmt, ...)
84 vsnprintf(buf, 1024, fmt, ap);
86 logOutput(lvlFatal, buf);
87 fprintf(stderr, "FATAL: %s\n",buf );
92 eMessageBox msg(buf, "FATAL ERROR", eMessageBox::iconError|eMessageBox::btOK);
102 void eDebug(const char* fmt, ...)
107 vsnprintf(buf, 1024, fmt, ap);
109 logOutput(lvlDebug, std::string(buf) + "\n");
110 if (logOutputConsole)
111 fprintf(stderr, "%s\n", buf);
114 void eDebugNoNewLine(const char* fmt, ...)
119 vsnprintf(buf, 1024, fmt, ap);
121 logOutput(lvlDebug, buf);
122 if (logOutputConsole)
123 fprintf(stderr, "%s", buf);
126 void eWarning(const char* fmt, ...)
131 vsnprintf(buf, 1024, fmt, ap);
133 logOutput(lvlWarning, std::string(buf) + "\n");
134 if (logOutputConsole)
135 fprintf(stderr, "%s\n", buf);
139 void ePythonOutput(const char *string)
141 logOutput(lvlWarning, string);
142 if (logOutputConsole)
143 fwrite(string, 1, strlen(string), stderr);
146 void eWriteCrashdump()