To update on this, for Windows apps, we now have this super-smooth … crashes get uploaded to a server and when double clicked with visual studio resybolicate themselves and give up their secrets.
I don’t have anything better than Crash Reporter on the Mac yet!
Basics
Use symstore to archive all pdb files from your builds. https://msdn.microsoft.com/en-us/library/windows/desktop/ms681417(v=vs.85).aspx
Call the following code on a crash to generate a minidump file which you can then later load into VS, with the symbol path set to your symstore.
#ifdef JUCE_WINDOWS
#include <windows.h>
#include <DbgHelp.h>
#include <tchar.h>
/**
* Crash handler for Windows.
*/
LONG WINAPI createMiniDump(LPEXCEPTION_POINTERS exceptionPointers)
{
auto dumpFileName = _T(AnalyticsManager::windowsMiniDumpFile.toUTF8());
HANDLE hFile = CreateFile(dumpFileName, GENERIC_READ | GENERIC_WRITE,
0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile != nullptr && hFile != INVALID_HANDLE_VALUE)
{
MINIDUMP_EXCEPTION_INFORMATION exceptionInformation;
exceptionInformation.ThreadId = GetCurrentThreadId();
exceptionInformation.ExceptionPointers = exceptionPointers;
exceptionInformation.ClientPointers = FALSE;
MINIDUMP_TYPE dumpType = MiniDumpNormal;
BOOL dumpWriteResult = MiniDumpWriteDump(GetCurrentProcess(),
GetCurrentProcessId(),
hFile,
dumpType,
exceptionPointers != nullptr ? &exceptionInformation : 0,
nullptr,
nullptr);
if (!dumpWriteResult)
_tprintf(_T("MiniDumpWriteDump failed. Error: %u \n"), GetLastError());
else
_tprintf(_T("Minidump created.\n"));
CloseHandle(hFile);
}
else
{
_tprintf(_T("CreateFile failed. Error: %u \n"), GetLastError());
}
int selectedButtonId = MessageBox(nullptr,
_T("Application crashed. Send error report to vendor on application restart?"),
_T("Crash"),
MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1
);
_tprintf(_T("User pushed: %d \n"), selectedButtonId);
if (selectedButtonId == IDNO)
DeleteFile(dumpFileName);
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
Call the code on crash from an app using:
#ifdef JUCE_WINDOWS
SetUnhandledExceptionFilter (createMiniDump);
#endif
In plugins (Windows)
SetUnhandledExceptionFilter and setApplicationCrashHandler is the wrong thing to do in a plugin. It overrides the whole process’s crash handler, which probably includes the DAW.
The safe thing on Windows is to wrap all entry points in __try {… } __except { … } on Windows. I haven’t tried this with a plugin yet, but it ought to be possible. Note these are not the normal C++ try/except things but some MS extension.