MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / DumpStats

Method DumpStats

Source/ModularSynth.cpp:124–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122#endif
123
124void ModularSynth::DumpStats(bool isCrash, void* crashContext)
125{
126 std::string filename;
127 if (isCrash)
128 filename = ofToDataPath(ofGetTimestampString("crash_%Y-%m-%d_%H-%M.txt"));
129 else
130 filename = ofToDataPath(ofGetTimestampString("stats_%Y-%m-%d_%H-%M.txt"));
131 juce::File log(filename);
132
133 if (isCrash)
134 {
135#if BESPOKE_WINDOWS
136 if (crashContext != nullptr)
137 {
138 log.appendText("stack frame:\n");
139 PEXCEPTION_POINTERS pExceptionInfo = (PEXCEPTION_POINTERS)crashContext;
140
141 HANDLE process = GetCurrentProcess();
142 SymInitialize(process, NULL, TRUE);
143
144 // StackWalk64() may modify context record passed to it, so we will
145 // use a copy.
146 CONTEXT context_record = *pExceptionInfo->ContextRecord;
147 // Initialize stack walking.
148 STACKFRAME64 stack_frame;
149 memset(&stack_frame, 0, sizeof(stack_frame));
150#if defined(_WIN64)
151 int machine_type = IMAGE_FILE_MACHINE_AMD64;
152 stack_frame.AddrPC.Offset = context_record.Rip;
153 stack_frame.AddrFrame.Offset = context_record.Rbp;
154 stack_frame.AddrStack.Offset = context_record.Rsp;
155#else
156 int machine_type = IMAGE_FILE_MACHINE_I386;
157 stack_frame.AddrPC.Offset = context_record.Eip;
158 stack_frame.AddrFrame.Offset = context_record.Ebp;
159 stack_frame.AddrStack.Offset = context_record.Esp;
160#endif
161 stack_frame.AddrPC.Mode = AddrModeFlat;
162 stack_frame.AddrFrame.Mode = AddrModeFlat;
163 stack_frame.AddrStack.Mode = AddrModeFlat;
164
165 juce::HeapBlock<SYMBOL_INFO> symbol;
166 symbol.calloc(sizeof(SYMBOL_INFO) + 256, 1);
167 symbol->MaxNameLen = 255;
168 symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
169
170 while (StackWalk64(machine_type,
171 GetCurrentProcess(),
172 GetCurrentThread(),
173 &stack_frame,
174 &context_record,
175 NULL,
176 &SymFunctionTableAccess64,
177 &SymGetModuleBase64,
178 NULL))
179 {
180
181 DWORD64 displacement = 0;

Callers

nothing calls this directly

Calls 5

ofToDataPathFunction · 0.85
ofGetTimestampStringFunction · 0.85
StringClass · 0.85
ofToStringFunction · 0.85
GetBuildInfoStringFunction · 0.85

Tested by

no test coverage detected