|
|
|
|
@ -6,14 +6,25 @@
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AzCore/Debug/TraceMessageBus.h>
|
|
|
|
|
#include <AzCore/IO/SystemFile.h>
|
|
|
|
|
#include <AzCore/std/string/string_view.h>
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <execinfo.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
namespace AZ::Debug::Platform
|
|
|
|
|
namespace AZ::Debug
|
|
|
|
|
{
|
|
|
|
|
#if defined(AZ_ENABLE_DEBUG_TOOLS)
|
|
|
|
|
void ExceptionHandler(int signal);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
constexpr int MaxMessageLength = 4096;
|
|
|
|
|
constexpr int MaxStackLines = 100;
|
|
|
|
|
|
|
|
|
|
namespace Platform
|
|
|
|
|
{
|
|
|
|
|
#if defined(AZ_ENABLE_DEBUG_TOOLS)
|
|
|
|
|
bool performDebuggerDetection()
|
|
|
|
|
@ -63,8 +74,25 @@ namespace AZ::Debug::Platform
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HandleExceptions(bool)
|
|
|
|
|
{}
|
|
|
|
|
void SignalHandler(int handler)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HandleExceptions(bool isEnabled)
|
|
|
|
|
{
|
|
|
|
|
if (isEnabled)
|
|
|
|
|
{
|
|
|
|
|
signal(SIGSEGV, ExceptionHandler);
|
|
|
|
|
signal(SIGTRAP, ExceptionHandler);
|
|
|
|
|
signal(SIGILL, ExceptionHandler);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
signal(SIGSEGV, SIG_DFL);
|
|
|
|
|
signal(SIGTRAP, SIG_DFL);
|
|
|
|
|
signal(SIGILL, SIG_DFL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebugBreak()
|
|
|
|
|
{
|
|
|
|
|
@ -76,4 +104,31 @@ namespace AZ::Debug::Platform
|
|
|
|
|
{
|
|
|
|
|
_exit(exitCode);
|
|
|
|
|
}
|
|
|
|
|
} // namespace AZ::Debug::Platform
|
|
|
|
|
} // namespace Platform
|
|
|
|
|
|
|
|
|
|
#if defined(AZ_ENABLE_DEBUG_TOOLS)
|
|
|
|
|
void ExceptionHandler(int signal)
|
|
|
|
|
{
|
|
|
|
|
char message[MaxMessageLength];
|
|
|
|
|
Debug::Trace::Instance().Output(nullptr, "==================================================================\n");
|
|
|
|
|
azsnprintf(message, MaxMessageLength, "Error: signal %s: \n", strsignal(signal));
|
|
|
|
|
Debug::Trace::Instance().Output(nullptr, message);
|
|
|
|
|
|
|
|
|
|
void* buffers[MaxStackLines];
|
|
|
|
|
int numberBacktraceStrings = backtrace(buffers, MaxStackLines);
|
|
|
|
|
char** backtraceResults = backtrace_symbols(buffers, numberBacktraceStrings);
|
|
|
|
|
if (backtraceResults == nullptr)
|
|
|
|
|
{
|
|
|
|
|
Debug::Trace::Instance().Output(nullptr, "==================================================================\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (int j = 0; j < numberBacktraceStrings; j++)
|
|
|
|
|
{
|
|
|
|
|
Debug::Trace::Instance().Output(nullptr, backtraceResults[j]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Debug::Trace::Instance().Output(nullptr, "==================================================================\n");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
} // namespace AZ::Debug
|
|
|
|
|
|