-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtrace.cc
43 lines (34 loc) · 990 Bytes
/
trace.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#include <string>
#include "newlog.h"
#include <cstdio>
#include <windows.h>
#include <DbgHelp.h>
#include "trace.h"
#pragma comment(lib,"Imagehlp.lib")
namespace game
{
void printStack1()
{
unsigned int i;
void * stack[100];
unsigned short frames;
SYMBOL_INFO * symbol;
HANDLE process;
process = GetCurrentProcess();
SymInitialize(process, NULL, TRUE);
frames = CaptureStackBackTrace(0, 6, stack, NULL);
symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1);
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
for (i = 0; i < frames; i++)
{
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol);
LOG("%i: %s - 0x%0X\n", frames - i - 1, symbol->Name, symbol->Address);
}
free(symbol);
}
}