MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / exceptionFilter

Method exceptionFilter

source/utils/StackTraceWinMinGW.cpp:200–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200LONG WINAPI StackTracePrintPrivateData::exceptionFilter(LPEXCEPTION_POINTERS info)
201{
202 // We print the callstack in a stringstream. Then, we will print it to the crashStream
203 // and, then, to the log manager
204 std::stringstream crashStream;
205
206 if (!SymInitialize(GetCurrentProcess(), 0, TRUE))
207 return 0;
208
209 bfd_init();
210
211 std::vector<struct BfdSet> listSets;
212 int depth = 128;
213
214 PCONTEXT context = info->ContextRecord;
215
216 char procname[MAX_PATH];
217 GetModuleFileNameA(nullptr, procname, sizeof procname);
218
219 struct BfdCtx* bfdCtx = nullptr;
220
221 STACKFRAME frame;
222 memset(&frame,0,sizeof(frame));
223
224 frame.AddrPC.Offset = context->Eip;
225 frame.AddrPC.Mode = AddrModeFlat;
226 frame.AddrStack.Offset = context->Esp;
227 frame.AddrStack.Mode = AddrModeFlat;
228 frame.AddrFrame.Offset = context->Ebp;
229 frame.AddrFrame.Mode = AddrModeFlat;
230
231 HANDLE process = GetCurrentProcess();
232 HANDLE thread = GetCurrentThread();
233
234 char symbol_buffer[sizeof(IMAGEHLP_SYMBOL) + 255];
235 char processNameRaw[MAX_PATH];
236
237 while(StackWalk(IMAGE_FILE_MACHINE_I386, process, thread, &frame, context,
238 0, SymFunctionTableAccess, SymGetModuleBase, 0))
239 {
240 --depth;
241 if (depth < 0)
242 break;
243
244 IMAGEHLP_SYMBOL *symbol = reinterpret_cast<IMAGEHLP_SYMBOL*>(symbol_buffer);
245 symbol->SizeOfStruct = (sizeof *symbol) + 255;
246 symbol->MaxNameLength = 254;
247
248 DWORD moduleBase = SymGetModuleBase(process, frame.AddrPC.Offset);
249
250 const char * processName = "[unknown module]";
251 if ((moduleBase != 0) && GetModuleFileNameA(reinterpret_cast<HINSTANCE>(moduleBase), processNameRaw, MAX_PATH))
252 {
253 processName = processNameRaw;
254 for(struct BfdSet& setSearch : listSets)
255 {
256 if(setSearch.name.compare(processName) == 0)
257 bfdCtx = &setSearch.bfdCtx;

Callers

nothing calls this directly

Calls 6

BfdSetClass · 0.85
readNextLineNotEmptyFunction · 0.85
bfdInitCtxMethod · 0.80
logMessageMethod · 0.80
clearMethod · 0.80
bfdCloseCtxMethod · 0.80

Tested by

no test coverage detected