Esempio n. 1
0
void LLApp::setupErrorHandling()
{
	// Error handling is done by starting up an error handling thread, which just sleeps and
	// occasionally checks to see if the app is in an error state, and sees if it needs to be run.

#if LL_WINDOWS
	// Windows doesn't have the same signal handling mechanisms as UNIX, thus APR doesn't provide
	// a signal handling thread implementation.
	// What we do is install an unhandled exception handler, which will try to do the right thing
	// in the case of an error (generate a minidump)

	// Disable this until the viewer gets ported so server crashes can be JIT debugged.
	//LPTOP_LEVEL_EXCEPTION_FILTER prev_filter;
	//prev_filter = SetUnhandledExceptionFilter(default_windows_exception_handler);

	// This sets a callback to handle w32 signals to the console window.
	// The viewer shouldn't be affected, sicne its a windowed app.
	SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ConsoleCtrlHandler, TRUE);

#else
	//
	// Start up signal handling.
	//
	// There are two different classes of signals.  Synchronous signals are delivered to a specific
	// thread, asynchronous signals can be delivered to any thread (in theory)
	//

	setup_signals();

#endif

	startErrorThread();
}
Esempio n. 2
0
LLApp::LLApp() : mThreadErrorp(NULL)
{
	commonCtor();
	startErrorThread();
}
Esempio n. 3
0
void LLApp::setupErrorHandling()
{
	// Error handling is done by starting up an error handling thread, which just sleeps and
	// occasionally checks to see if the app is in an error state, and sees if it needs to be run.

#if LL_WINDOWS
	// This sets a callback to handle w32 signals to the console window.
	// The viewer shouldn't be affected, sicne its a windowed app.
	SetConsoleCtrlHandler( (PHANDLER_ROUTINE) ConsoleCtrlHandler, TRUE);

	// Install the Google Breakpad crash handler for Windows
	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
	//
	// Start up signal handling.
	//
	// There are two different classes of signals.  Synchronous signals are delivered to a specific
	// thread, asynchronous signals can be delivered to any thread (in theory)
	//
	setup_signals();
	
	// Add google breakpad exception handler configured for Darwin/Linux.
	bool installHandler = true;
#ifdef LL_DARWIN
	// For the special case of Darwin, we do not want to install the handler if
	// the process is being debugged as the app will exit with value ABRT (6) if
	// we do.  Unfortunately, the code below which performs that test relies on
	// the structure kinfo_proc which has been tagged by apple as an unstable
	// API.  We disable this test for shipping versions to avoid conflicts with
	// future releases of Darwin.  This test is really only needed for developers
	// starting the app from a debugger anyway.
	#ifndef LL_RELEASE_FOR_DOWNLOAD
    int mib[4];
	mib[0] = CTL_KERN;
	mib[1] = KERN_PROC;
	mib[2] = KERN_PROC_PID;
	mib[3] = getpid();
	
	struct kinfo_proc info;
	memset(&info, 0, sizeof(info));
	
	size_t size = sizeof(info);
	int result = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
	if((result == 0) || (errno == ENOMEM))
	{
		// P_TRACED flag is set, so this process is being debugged; do not install
		// the handler
		if(info.kp_proc.p_flag & P_TRACED) installHandler = false;
	}
	else
	{
		// Failed to discover if the process is being debugged; default to
		// installing the handler.
		installHandler = true;
	}
	#endif
#endif
	if(installHandler && (mExceptionHandler == 0))
	{
		std::string dumpPath = "/tmp/";
		mExceptionHandler = new google_breakpad::ExceptionHandler(dumpPath, 0, &unix_post_minidump_callback, 0, true);
	}
#endif

	startErrorThread();
}