Skip to content
Snippets Groups Projects
Commit 1077ab49 authored by Andrew A. de Laix's avatar Andrew A. de Laix
Browse files

Just enough hackery to get minidumps into Wind'ohs crash reports. Code clean up needed.

parent 168fbc9b
No related branches found
No related tags found
No related merge requests found
# -*- cmake -*- # -*- cmake -*-
include(Prebuilt) include(Prebuilt)
if (STANDALONE) if (STANDALONE)
MESSAGE(FATAL_ERROR "*TODO standalone support for google breakad is unimplemented") MESSAGE(FATAL_ERROR "*TODO standalone support for google breakad is unimplemented")
# *TODO - implement this include(FindGoogleBreakpad) # *TODO - implement this include(FindGoogleBreakpad)
else (STANDALONE) else (STANDALONE)
use_prebuilt_binary(google_breakpad) use_prebuilt_binary(google_breakpad)
set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES exception_handler crash_generation_client common) set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES exception_handler)
if (LINUX) if(WINDOWS)
set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES breakpad_client) list(APPEND BREAKPAD_EXCEPTION_HANDLER_LIBRARIES crash_generation_client common)
endif (LINUX) endif(WINDOWS)
endif (STANDALONE) if (LINUX)
set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES breakpad_client)
endif (LINUX)
endif (STANDALONE)
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
#include <cstdlib>
#include "linden_common.h" #include "linden_common.h"
#include "llapp.h" #include "llapp.h"
...@@ -43,6 +45,8 @@ ...@@ -43,6 +45,8 @@
#include "llstl.h" // for DeletePointer() #include "llstl.h" // for DeletePointer()
#include "lleventtimer.h" #include "lleventtimer.h"
#include "google_breakpad/exception_handler.h"
// //
// Signal handling // Signal handling
// //
...@@ -51,6 +55,12 @@ ...@@ -51,6 +55,12 @@
#if LL_WINDOWS #if LL_WINDOWS
LONG WINAPI default_windows_exception_handler(struct _EXCEPTION_POINTERS *exception_infop); LONG WINAPI default_windows_exception_handler(struct _EXCEPTION_POINTERS *exception_infop);
BOOL ConsoleCtrlHandler(DWORD fdwCtrlType); BOOL ConsoleCtrlHandler(DWORD fdwCtrlType);
bool windows_post_minidump_callback(const wchar_t* dump_path,
const wchar_t* minidump_id,
void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion,
bool succeeded);
#else #else
# include <signal.h> # include <signal.h>
# include <unistd.h> // for fork() # include <unistd.h> // for fork()
...@@ -285,6 +295,13 @@ void LLApp::setupErrorHandling() ...@@ -285,6 +295,13 @@ void LLApp::setupErrorHandling()
// The viewer shouldn't be affected, sicne its a windowed app. // The viewer shouldn't be affected, sicne its a windowed app.
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ConsoleCtrlHandler, TRUE); SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ConsoleCtrlHandler, TRUE);
if(mExceptionHandler == 0)
{
llwarns << "adding breakpad exception handler" << llendl;
mExceptionHandler = new google_breakpad::ExceptionHandler(
L"C:\\Temp\\", 0, windows_post_minidump_callback, 0, google_breakpad::ExceptionHandler::HANDLER_ALL);
}
#else #else
// //
// Start up signal handling. // Start up signal handling.
...@@ -815,3 +832,53 @@ bool darwin_post_minidump_callback(const char *dump_dir, ...@@ -815,3 +832,53 @@ bool darwin_post_minidump_callback(const char *dump_dir,
LLApp::runErrorHandler(); LLApp::runErrorHandler();
return true; return true;
} }
bool windows_post_minidump_callback(const wchar_t* dump_path,
const wchar_t* minidump_id,
void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion,
bool succeeded)
{
char * path = LLApp::instance()->minidump_path;
S32 remaining = LLApp::MAX_MINDUMP_PATH_LENGTH;
size_t bytesUsed;
bytesUsed = wcstombs(path, dump_path, static_cast<size_t>(remaining));
remaining -= bytesUsed;
path += bytesUsed;
if(remaining > 0)
{
bytesUsed = wcstombs(path, minidump_id, static_cast<size_t>(remaining));
remaining -= bytesUsed;
path += bytesUsed;
}
if(remaining > 0)
{
strncpy(path, ".dmp", remaining);
}
llinfos << "generated minidump: " << LLApp::instance()->minidump_path << llendl;
// *NOTE:Mani - this code is stolen from LLApp, where its never actually used.
//OSMessageBox("Attach Debugger Now", "Error", OSMB_OK);
// *TODO: Translate the signals/exceptions into cross-platform stuff
// Windows implementation
llinfos << "Entering Windows Exception Handler..." << llendl;
if (LLApp::isError())
{
llwarns << "Got another fatal signal while in the error handler, die now!" << llendl;
}
// Flag status to error, so thread_error starts its work
LLApp::setError();
// Block in the exception handler until the app has stopped
// This is pretty sketchy, but appears to work just fine
while (!LLApp::isStopped())
{
ms_sleep(10);
}
return true;
}
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
#include "llsd.h" #include "llsd.h"
#include "lloptioninterface.h" #include "lloptioninterface.h"
#include "google_breakpad/exception_handler.h"
// Forward declarations // Forward declarations
template <typename Type> class LLAtomic32; template <typename Type> class LLAtomic32;
typedef LLAtomic32<U32> LLAtomicU32; typedef LLAtomic32<U32> LLAtomicU32;
...@@ -68,6 +66,10 @@ class LLChildInfo ...@@ -68,6 +66,10 @@ class LLChildInfo
}; };
#endif #endif
namespace google_breakpad {
class ExceptionHandler; // See exception_handler.h
}
class LL_COMMON_API LLApp : public LLOptionInterface class LL_COMMON_API LLApp : public LLOptionInterface
{ {
friend class LLErrorThread; friend class LLErrorThread;
......
...@@ -529,8 +529,9 @@ bool LLAppViewerWin32::initParseCommandLine(LLCommandLineParser& clp) ...@@ -529,8 +529,9 @@ bool LLAppViewerWin32::initParseCommandLine(LLCommandLineParser& clp)
} }
bool LLAppViewerWin32::restoreErrorTrap() bool LLAppViewerWin32::restoreErrorTrap()
{ {
return LLWinDebug::checkExceptionHandler(); return true;
//return LLWinDebug::checkExceptionHandler();
} }
void LLAppViewerWin32::handleSyncCrashTrace() void LLAppViewerWin32::handleSyncCrashTrace()
......
...@@ -718,7 +718,8 @@ BOOL PreventSetUnhandledExceptionFilter() ...@@ -718,7 +718,8 @@ BOOL PreventSetUnhandledExceptionFilter()
// static // static
void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func) void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func)
{ {
return;
#if 0
static bool s_first_run = true; static bool s_first_run = true;
// Load the dbghelp dll now, instead of waiting for the crash. // Load the dbghelp dll now, instead of waiting for the crash.
// Less potential for stack mangling // Less potential for stack mangling
...@@ -762,34 +763,27 @@ void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func) ...@@ -762,34 +763,27 @@ void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func)
Module32First_ = (MODULE32_FIRST)GetProcAddress(hKernel32, "Module32FirstW"); Module32First_ = (MODULE32_FIRST)GetProcAddress(hKernel32, "Module32FirstW");
Module32Next_ = (MODULE32_NEST)GetProcAddress(hKernel32, "Module32NextW"); Module32Next_ = (MODULE32_NEST)GetProcAddress(hKernel32, "Module32NextW");
LPTOP_LEVEL_EXCEPTION_FILTER prev_filter; PVOID added_filter =
prev_filter = SetUnhandledExceptionFilter(filter_func); AddVectoredExceptionHandler(0, filter_func);
// *REMOVE:Mani
//PreventSetUnhandledExceptionFilter();
if(prev_filter != gFilterFunc) if(added_filter == 0)
{ {
LL_WARNS("AppInit") LL_WARNS("AppInit")
<< "Replacing unknown exception (" << (void *)prev_filter << ") with (" << (void *)filter_func << ") !" << LL_ENDL; << "Failed to add exception handler (" << added_filter << ") !" << LL_ENDL;
} }
gFilterFunc = filter_func; gFilterFunc = filter_func;
#endif
} }
bool LLWinDebug::checkExceptionHandler() bool LLWinDebug::checkExceptionHandler()
{ {
bool ok = true; bool ok = true;
LPTOP_LEVEL_EXCEPTION_FILTER prev_filter;
prev_filter = SetUnhandledExceptionFilter(gFilterFunc);
if (prev_filter != gFilterFunc) RemoveVectoredExceptionHandler(gFilterFunc);
{ PVOID filter = AddVectoredExceptionHandler(0, gFilterFunc);
LL_WARNS("AppInit") << "Our exception handler (" << (void *)gFilterFunc << ") replaced with " << prev_filter << "!" << LL_ENDL;
ok = false;
}
if (prev_filter == NULL) if (filter == NULL)
{ {
ok = FALSE; ok = FALSE;
if (gFilterFunc == NULL) if (gFilterFunc == NULL)
...@@ -798,7 +792,7 @@ bool LLWinDebug::checkExceptionHandler() ...@@ -798,7 +792,7 @@ bool LLWinDebug::checkExceptionHandler()
} }
else else
{ {
LL_WARNS("AppInit") << "Our exception handler (" << (void *)gFilterFunc << ") replaced with NULL!" << LL_ENDL; LL_WARNS("AppInit") << "Failed to add exception handler (" << (void *)gFilterFunc << ")!" << LL_ENDL;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment