1 #include <lib/base/eerror.h>
7 #include <lib/gui/emessage.h>
11 pthread_mutex_t memLock
=
12 PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
;
16 AllocList::iterator i
;
17 unsigned int totalSize
= 0;
23 char *buffer
= (char*)malloc(1024);
24 for(i
= allocList
->begin(); i
!= allocList
->end(); i
++)
27 printf("%s\tLINE %d\tADDRESS %p\t%d unfreed\ttype %d (btcount %d)\n",
28 i
->second
.file
, i
->second
.line
, (void*)i
->second
.address
, i
->second
.size
, i
->second
.type
, i
->second
.btcount
);
29 totalSize
+= i
->second
.size
;
30 char **bt_string
= backtrace_symbols( i
->second
.backtrace
, i
->second
.btcount
);
31 for ( tmp
=0; tmp
< i
->second
.btcount
; tmp
++ )
35 char *beg
= strchr(bt_string
[tmp
], '(');
38 std::string
tmp1(beg
+1);
39 int pos1
=tmp1
.find('+'), pos2
=tmp1
.find(')');
40 if ( pos1
!= std::string::npos
&& pos2
!= std::string::npos
)
42 std::string
tmp2(tmp1
.substr(pos1
,(pos2
-pos1
)));
47 abi::__cxa_demangle(tmp1
.c_str(), buffer
, &len
, &state
);
49 printf("%d %s%s\n", tmp
, buffer
,tmp2
.c_str());
51 printf("%d %s\n", tmp
, bt_string
[tmp
]);
56 printf("%d %s\n", tmp
, bt_string
[tmp
]);
64 printf("-----------------------------------------------------------\n");
65 printf("Total Unfreed: %d bytes\n", totalSize
);
70 #include <lib/system/elock.h>
72 pthread_mutex_t signalLock
=
73 PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
;
77 Signal2
<void, int, const eString
&> logOutput
;
78 int logOutputConsole
=1;
80 void eFatal(const char* fmt
, ...)
85 vsnprintf(buf
, 1024, fmt
, ap
);
88 singleLock
s(signalLock
);
89 logOutput(lvlFatal
, buf
);
90 fprintf(stderr
, "%s\n",buf
);
95 eMessageBox
msg(buf
, "FATAL ERROR", eMessageBox::iconError
|eMessageBox::btOK
);
103 void eDebug(const char* fmt
, ...)
108 vsnprintf(buf
, 1024, fmt
, ap
);
110 singleLock
s(signalLock
);
111 if (logOutputConsole
)
112 fprintf(stderr
, "%s\n", buf
);
114 logOutput(lvlDebug
, eString(buf
) + "\n");
117 void eDebugNoNewLine(const char* fmt
, ...)
122 vsnprintf(buf
, 1024, fmt
, ap
);
124 singleLock
s(signalLock
);
125 if (logOutputConsole
)
126 fprintf(stderr
, buf
);
128 logOutput(lvlDebug
, buf
);
131 void eWarning(const char* fmt
, ...)
136 vsnprintf(buf
, 1024, fmt
, ap
);
138 singleLock
s(signalLock
);
139 if (logOutputConsole
)
140 fprintf(stderr
, "%s\n", buf
);
142 logOutput(lvlWarning
, eString(buf
) + "\n");