1
This commit is contained in:
parent
fbf50878bf
commit
58f14b7107
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <execinfo.h>
|
||||
|
||||
#include "tracemgr.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -47,4 +49,25 @@ void TraceMgr::Trace(const std::string& hint)
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string TraceMgr::GetBackTrace()
|
||||
{
|
||||
const int BT_BUF_SIZE = 1024 * 10;
|
||||
|
||||
std::string data;
|
||||
|
||||
void *buffer[BT_BUF_SIZE];
|
||||
char **strings = nullptr;
|
||||
int nptrs = backtrace(buffer, BT_BUF_SIZE);
|
||||
strings = backtrace_symbols(buffer, nptrs);
|
||||
if (strings) {
|
||||
for (int i = 0; i < nptrs; i++) {
|
||||
data += strings[i];
|
||||
data += "\n";
|
||||
}
|
||||
free(strings);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -19,6 +19,7 @@ class TraceMgr : public a8::Singleton<TraceMgr>
|
||||
void UnInit();
|
||||
|
||||
void Trace(const std::string& hint);
|
||||
std::string GetBackTrace();
|
||||
|
||||
private:
|
||||
std::string filename_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user