You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
2.8 KiB
C++
115 lines
2.8 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
#include <Launcher.h>
|
|
#include <../Common/UnixLike/Launcher_UnixLike.h>
|
|
|
|
#include <AzCore/Debug/StackTracer.h>
|
|
#include <AzCore/IO/SystemFile.h> // for AZ_MAX_PATH_LEN
|
|
#include <AzCore/Math/Vector2.h>
|
|
|
|
#include <CryLibrary.h>
|
|
|
|
#include <execinfo.h>
|
|
#include <libgen.h>
|
|
#include <netdb.h>
|
|
#include <sys/prctl.h>
|
|
#include <sys/resource.h>
|
|
#include <sys/types.h>
|
|
|
|
namespace
|
|
{
|
|
void SignalHandler(int sig, siginfo_t* info, void* secret)
|
|
{
|
|
FILE* ftrace = fopen("backtrace.log", "w");
|
|
if (!ftrace)
|
|
{
|
|
ftrace = stderr;
|
|
}
|
|
|
|
AZ::Debug::StackFrame frames[25];
|
|
unsigned int frameCount = AZ_ARRAY_SIZE(frames);
|
|
frameCount = AZ::Debug::StackRecorder::Record(frames, frameCount);
|
|
AZ::Debug::SymbolStorage::StackLine lines[25];
|
|
AZ::Debug::SymbolStorage::DecodeFrames(frames, frameCount, lines);
|
|
|
|
for (unsigned int frame = 0; frame < frameCount; ++frame)
|
|
{
|
|
fprintf(ftrace, "%s", lines[frame]);
|
|
}
|
|
|
|
if (ftrace != stderr)
|
|
{
|
|
fclose(ftrace);
|
|
}
|
|
|
|
abort();
|
|
}
|
|
|
|
void InitStackTracer()
|
|
{
|
|
struct sigaction sa;
|
|
sa.sa_sigaction = SignalHandler;
|
|
sigemptyset(&sa.sa_mask);
|
|
sa.sa_flags = SA_RESTART | SA_SIGINFO;
|
|
sigaction(SIGSEGV, &sa, 0);
|
|
sigaction(SIGBUS, &sa, 0);
|
|
sigaction(SIGILL, &sa, 0);
|
|
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
bool waitForDebugger = false;
|
|
for (int i = 1; i < argc; ++i)
|
|
{
|
|
if (!strcmp(argv[i], "-wait"))
|
|
{
|
|
waitForDebugger = true;
|
|
break;
|
|
}
|
|
}
|
|
if (waitForDebugger)
|
|
{
|
|
while(!AZ::Debug::Trace::IsDebuggerPresent())
|
|
{
|
|
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(50));
|
|
}
|
|
}
|
|
|
|
InitStackTracer();
|
|
|
|
using namespace O3DELauncher;
|
|
|
|
#if !defined(AZ_MONOLITHIC_BUILD)
|
|
char exePath[AZ_MAX_PATH_LEN] = { 0 };
|
|
if (readlink("/proc/self/exe", exePath, AZ_MAX_PATH_LEN) == -1)
|
|
{
|
|
return static_cast<int>(ReturnCode::ErrExePath);
|
|
}
|
|
|
|
char* runDir = dirname(exePath);
|
|
SetModulePath(runDir);
|
|
#endif // !defined(AZ_MONOLITHIC_BUILD)
|
|
|
|
PlatformMainInfo mainInfo;
|
|
|
|
mainInfo.m_updateResourceLimits = IncreaseResourceLimits;
|
|
|
|
bool ret = mainInfo.CopyCommandLine(argc, argv);
|
|
|
|
// run the Lumberyard application
|
|
ReturnCode status = ret ?
|
|
Run(mainInfo) :
|
|
ReturnCode::ErrCommandLine;
|
|
|
|
return static_cast<int>(status);
|
|
}
|
|
|
|
void CVar_OnViewportPosition([[maybe_unused]] const AZ::Vector2& value) {}
|