| 39 | } |
| 40 | |
| 41 | std::string |
| 42 | formatStackTrace(StackTrace *trace) |
| 43 | { |
| 44 | auto process = GetCurrentProcess(); |
| 45 | static bool symInitialise = false; |
| 46 | |
| 47 | if (!symInitialise) { |
| 48 | SymInitialize(process, NULL, TRUE); |
| 49 | symInitialise = true; |
| 50 | } |
| 51 | |
| 52 | auto symbol = std::make_unique<MySymbol>(); |
| 53 | symbol->MaxNameLen = MAX_SYM_NAME; |
| 54 | symbol->SizeOfStruct = sizeof(SYMBOL_INFO); |
| 55 | |
| 56 | fmt::memory_buffer out; |
| 57 | |
| 58 | for (auto i = 0u; i < trace->frames; ++i) { |
| 59 | SymFromAddr(process, (DWORD64)trace->data[i], 0, symbol.get()); |
| 60 | fmt::format_to(std::back_inserter(out), "{}: {} - 0x{:X}x\n", |
| 61 | trace->frames - i - 1, |
| 62 | (const char*)symbol->Name, |
| 63 | symbol->Address); |
| 64 | } |
| 65 | |
| 66 | return out.data(); |
| 67 | } |
| 68 | |
| 69 | void |
| 70 | printStackTrace(StackTrace *trace) |
no test coverage detected