using std::endl;
#include <assert.h>
+#include <execinfo.h>
#include "Lock.h"
#include "Autolock.h"
Lock muDPF;
-void bear::DPF(int iLevel, const char* pstr)
-{
- Autolock lock(&muDPF);
-
- cout << pstr << endl;
-}
-
void bear::debug::init()
{
muDPF.init();
muDPF.fini();
}
+void bear::debug::printTrace()
+{
+ int size;
+ char** strings;
+
+ {
+ void* array[50];
+
+ size = backtrace (array, 50);
+ strings = backtrace_symbols (array, size);
+ }
+
+ {
+ Autolock lock(&muDPF);
+
+ cout << "Obtained " << size << " stack frames." << endl;
+
+ for (int i = 0; i < size; i++)
+ {
+ cout << strings[i] << endl;
+ }
+ }
+
+ free (strings);
+}
+
+void bear::DPF(int iLevel, const char* pstr)
+{
+ Autolock lock(&muDPF);
+
+ cout << pstr << endl;
+}
+
void bear::DASSERT(bool fAssert)
{
assert(fAssert);