MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / handler

Function handler

src/launch/xstudio/src/xstudio.cpp:96–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94#include <DbgHelp.h>
95
96void handler(int sig) {
97 void *stack[10];
98 HANDLE process = GetCurrentProcess();
99 SymInitialize(process, nullptr, TRUE);
100
101 // Capture the call stack
102 WORD frames = CaptureStackBackTrace(0, 10, stack, nullptr);
103
104 // Print out the frames to stderr
105 fprintf(stderr, "Error: signal %d:\n", sig);
106 for (int i = 0; i < frames; ++i) {
107 DWORD64 address = reinterpret_cast<DWORD64>(stack[i]);
108 char symbolBuffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
109 SYMBOL_INFO *symbol = reinterpret_cast<SYMBOL_INFO *>(symbolBuffer);
110 symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
111 symbol->MaxNameLen = MAX_SYM_NAME;
112
113 if (SymFromAddr(process, address, nullptr, symbol)) {
114 fprintf(stderr, "%d: %s\n", i, symbol->Name);
115 } else {
116 fprintf(stderr, "%d: [Unknown Symbol]\n", i);
117 }
118 }
119
120 SymCleanup(process);
121 exit(1);
122}
123#else
124void handler(int sig) {
125 void *array[10];

Callers 4

httplib.hFile · 0.85
dispatch_requestMethod · 0.85
attribute_changedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected