根据网上大佬的写法魔改了一下,把自己的debug系统忽略掉,然后只输出到main就结束。同时传入了log文件stream来记录log
void TraceStack(std::ofstream & ofs)
{
static const int MAX_STACK_FRAMES = 7;
void* pStack[MAX_STACK_FRAMES];
HANDLE process = GetCurrentProcess();
SymInitialize(process, NULL, TRUE);
WORD frames = CaptureStackBackTrace(0, MAX_STACK_FRAMES, pStack, NULL);
ofs << "\tstack traceback: " << std::endl;
for (WORD i = 0; i < frames; ++i) {
if (i < 2)
{
&nb