Example #1
0
LONG WINAPI WindowsExceptionHandler(struct _EXCEPTION_POINTERS *exceptionInfo)
{
	LD_UNUSED_PARAMETER(exceptionInfo);

	LD_LOG(Platform, Error, "~~~~~~~~~~~~ UNHANDLED EXCEPTION OCCURRED ~~~~~~~~~~~");
	LD_LOG(Platform, Error, "Stack Trace:");

	StackTrace Trace;
	if (StackTrace::Generate(Trace, (void*)exceptionInfo).Failed())
	{
		LD_LOG(Platform, Error, "Failed to generate stack trace.");
		return 0;
	}
	else
	{
		for (int i = 0; i < Trace.FrameCount(); i++)
		{
			StackFrame Frame = Trace.GetFrame(i);
			if (Frame.Resolve().Failed())
			{
				LD_LOGF(Platform, Error, "[%i] 0x%p (Symbols Unresolved)", i, Frame.Address);
			}
			else
			{
				LD_LOGF(Platform, Error, "[%i] (%s:%i) %s", i, Frame.File.Data(), Frame.Line, Frame.Function.Data());
			}
		}
	}

	return EXCEPTION_EXECUTE_HANDLER;
}