Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
if(NOT PAL_TRAIT_BUILD_HOST_TOOLS)
return()
endif()
ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME})
include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
if(NOT PAL_TRAIT_BUILD_CRASH_HANDLER_SUPPORTED)
return()
endif()
add_subdirectory(Support)
ly_add_target(
NAME CrashHandler STATIC
NAMESPACE AZ
FILES_CMAKE
crash_handler_files.cmake
${pal_dir}/crash_handler_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Shared
PRIVATE
${pal_dir}
BUILD_DEPENDENCIES
PRIVATE
3rdParty::Crashpad
AZ::AzCore
AZ::AzFramework
AZ::CrashSupport
)
string(REPLACE "." ";" version_list "${LY_VERSION_STRING}")
list(GET version_list 0 EXE_VERSION_INFO_0)
list(GET version_list 1 EXE_VERSION_INFO_1)
list(GET version_list 2 EXE_VERSION_INFO_2)
list(GET version_list 3 EXE_VERSION_INFO_3)
ly_add_source_properties(
SOURCES Shared/CrashHandler.cpp
PROPERTY COMPILE_DEFINITIONS
VALUES
LY_BUILD=${LY_VERSION_BUILD_NUMBER}
EXE_VERSION_INFO_0=${EXE_VERSION_INFO_0}
EXE_VERSION_INFO_1=${EXE_VERSION_INFO_1}
EXE_VERSION_INFO_2=${EXE_VERSION_INFO_2}
EXE_VERSION_INFO_3=${EXE_VERSION_INFO_3}
)
ly_add_target(
NAME CrashUploaderSupport STATIC
NAMESPACE AZ
FILES_CMAKE
crash_uploader_support_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Uploader/include
PRIVATE
Uploader/include/Uploader
BUILD_DEPENDENCIES
PRIVATE
3rdParty::Crashpad::Handler
AZ::AzCore
AZ::CrashSupport
)
add_subdirectory(Tools)
@@ -0,0 +1,15 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS 0
#define AZ_TRAIT_CRASHHANDLER_WAIT_FOR_COMPLETED_HANDLER_LAUNCH 0
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <CrashHandler_Traits_Android.h>
@@ -0,0 +1,12 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(PAL_TRAIT_BUILD_CRASH_HANDLER_SUPPORTED FALSE)
@@ -0,0 +1,36 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Base Crashpad Mac implementation
#include <CrashHandler.h>
#include <AzCore/PlatformIncl.h>
#include <AzCore/IO/SystemFile.h>
#include <mach-o/dyld.h>
namespace CrashHandler
{
const char* crashHandlerPath = "ToolsCrashUploader";
const char* CrashHandlerBase::GetCrashHandlerExecutableName() const
{
return crashHandlerPath;
}
void CrashHandlerBase::GetOSAnnotations(CrashHandlerAnnotations& annotations) const
{
annotations["os"] = "mac";
}
}
@@ -0,0 +1,91 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Base Crashpad Windows implementation
#include <CrashHandler.h>
#include <AzCore/PlatformIncl.h>
namespace CrashHandler
{
const char* crashHandlerPath = "ToolsCrashUploader.exe";
const char* CrashHandlerBase::GetCrashHandlerExecutableName() const
{
return crashHandlerPath;
}
void CrashHandlerBase::GetOSAnnotations(CrashHandlerAnnotations& annotations) const
{
annotations["os"] = "windows";
// Disable warning about GetVersion deprecation
// Windows now encourages users to check for the specific capability they need rather
// than relying on a version ID due to badly written/lazy code (If buildID >= NUM then I certainly can do x...)
// In this case we really just want a build ID to report
AZ_PUSH_DISABLE_WARNING(4996, "-Wdeprecated-declarations")
DWORD winVersion = GetVersion();
AZ_POP_DISABLE_WARNING
// VersionMajor lives in the low byte of the low word
int versionMajor = winVersion & 0xFF;
// VersionMinor lives in the high byte of the low word
int versionMinor = (winVersion & (0xFF << 8)) >> 8;
int osBuild = 0;
if (winVersion < 0x80000000)
{
// BuildID lives in the high word
osBuild = (winVersion & (0xFFFF << 16)) >> 16;
}
std::string annotationBuf;
annotationBuf = std::to_string(versionMajor) + "." + std::to_string(versionMinor);
annotations["os.version"] = annotationBuf;
annotationBuf = std::to_string(osBuild);
annotations["os.build"] = annotationBuf;
const size_t kbSize = 1024;
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
annotationBuf = std::to_string(statex.dwMemoryLoad);
annotations["vm.used"] = annotationBuf;
annotationBuf = std::to_string(statex.ullTotalPhys / kbSize);
annotations["vm.total"] = annotationBuf;
annotationBuf = std::to_string(statex.ullAvailPhys / kbSize);
annotations["vm.free"] = annotationBuf;
annotationBuf = std::to_string(statex.ullTotalPageFile / kbSize);
annotations["vm.swap.size"] = annotationBuf;
RECT desktopRect;
const HWND desktopWind = GetDesktopWindow();
GetWindowRect(desktopWind, &desktopRect);
annotationBuf = std::to_string(desktopRect.right) + "x" + std::to_string(desktopRect.bottom);
annotations["resolution"] = annotationBuf;
ULARGE_INTEGER freeBytes;
auto queryResult = GetDiskFreeSpaceExA(".", &freeBytes, nullptr, nullptr);
if (queryResult)
{
annotationBuf = std::to_string(freeBytes.QuadPart);
annotations["disk_free"] = annotationBuf;
}
else
{
annotations["disk_free"] = "error";
}
}
}
@@ -0,0 +1,15 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS 0
#define AZ_TRAIT_CRASHHANDLER_WAIT_FOR_COMPLETED_HANDLER_LAUNCH 0
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <CrashHandler_Traits_Linux.h>
@@ -0,0 +1,12 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(PAL_TRAIT_BUILD_CRASH_HANDLER_SUPPORTED FALSE)
@@ -0,0 +1,15 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS 0
#define AZ_TRAIT_CRASHHANDLER_WAIT_FOR_COMPLETED_HANDLER_LAUNCH 0
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <CrashHandler_Traits_Mac.h>
@@ -0,0 +1,12 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(PAL_TRAIT_BUILD_CRASH_HANDLER_SUPPORTED FALSE)
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <CrashHandler_Traits_Windows.h>
@@ -0,0 +1,15 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS 1
#define AZ_TRAIT_CRASHHANDLER_WAIT_FOR_COMPLETED_HANDLER_LAUNCH 1
@@ -0,0 +1,12 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(PAL_TRAIT_BUILD_CRASH_HANDLER_SUPPORTED TRUE)
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
../CrashHandler_win.cpp
)
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
CrashHandler_Traits_Platform.h
CrashHandler_Traits_Windows.h
)
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <CrashHandler_Traits_iOS.h>
@@ -0,0 +1,15 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS 0
#define AZ_TRAIT_CRASHHANDLER_WAIT_FOR_COMPLETED_HANDLER_LAUNCH 0
@@ -0,0 +1,12 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(PAL_TRAIT_BUILD_CRASH_HANDLER_SUPPORTED FALSE)
@@ -0,0 +1,290 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Base Crashpad Hook
#include <AzCore/PlatformIncl.h>
#include <client/crashpad_client.h>
#include <client/crash_report_database.h>
#include <client/settings.h>
#include <client/crashpad_info.h>
#include <fstream>
#include <CrashHandler.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/SystemFile.h>
#include <CrashSupport.h>
#include <AzCore/Module/Environment.h>
#include <CrashHandler_Traits_Platform.h>
namespace CrashHandler
{
static const char* disableFile = "disable";
static const char* crashHandlerEnvVar = "ExceptionHandlerIsSet";
static const char* crashHandlerAnnotationEnvVar = "CrashHandlerAnnotations";
static const char* crashSettingsFile = "crashSettings.cfg";
void CrashHandlerBase::InitCrashHandler(const std::string& moduleTag, const std::string& devRoot, const std::string& crashUrl, const std::string& crashToken, const std::string& handlerFolder, const CrashHandlerAnnotations& baseAnnotations, const CrashHandlerArguments& arguments )
{
CrashHandlerBase crashHandler;
crashHandler.Initialize( moduleTag, devRoot, crashUrl, crashToken, handlerFolder, baseAnnotations, arguments);
}
std::string CrashHandlerBase::GetCrashReportFolder(const std::string& devRoot) const
{
std::string returnFolder{ devRoot };
returnFolder.append(GetDefaultCrashFolder());
return returnFolder;
}
std::string CrashHandlerBase::GetCrashHandlerPath(const std::string& handlerBasePath) const
{
std::string returnPath;
if (handlerBasePath.length())
{
returnPath = handlerBasePath;
}
else
{
GetExecutableFolder(returnPath);
}
returnPath.append(GetCrashHandlerExecutableName());
return returnPath;
}
std::string CrashHandlerBase::GetAppRootFromCWD() const
{
std::string returnPath{ "./" };
return returnPath;
}
std::string CrashHandlerBase::DetermineAppPath() const
{
return GetAppRootFromCWD();
}
void CrashHandlerBase::Initialize(const std::string& moduleTag, const std::string& devRoot)
{
Initialize(moduleTag, devRoot, GetCrashSubmissionURL(), GetCrashSubmissionToken());
}
void CrashHandlerBase::GetBuildAnnotations(CrashHandlerAnnotations& annotations) const
{
annotations["product"] = GetProductName();
annotations["build_tag"] = MAKE_DEFINE_STRING(EXTERNAL_CRASH_REPORTING);
std::string versionString = std::to_string(EXE_VERSION_INFO_0) + "." + std::to_string(EXE_VERSION_INFO_1) + "." + std::to_string(EXE_VERSION_INFO_2) + "." + std::to_string(EXE_VERSION_INFO_3);
annotations["version"] = versionString;
versionString = std::to_string(LY_BUILD);
annotations["ly_build"] = versionString;
#if defined(_MSC_VER)
versionString = std::to_string(_MSC_VER);
annotations["msc_ver"] = versionString;
#endif
}
bool CrashHandlerBase::CreateCrashHandlerDB(const std::string& reportPath) const
{
AZ_TracePrintf("CrashReporting", "Creating new crash dump db at %s", reportPath.c_str());
#if AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS
wchar_t pathStr[AZ_MAX_PATH_LEN];
size_t chars_converted{ 0 };
mbstowcs_s(&chars_converted, pathStr, reportPath.c_str(), reportPath.length());
base::FilePath db{ pathStr };
#else
base::FilePath db{ reportPath };
#endif
std::unique_ptr<crashpad::CrashReportDatabase> crashDb = crashpad::CrashReportDatabase::Initialize(db);
if (crashDb)
{
return crashDb->GetSettings()->SetUploadsEnabled(true);
}
return false;
}
void CrashHandlerBase::AppendSep(std::string& pathStr)
{
if (pathStr.length() && pathStr[pathStr.length() - 1] != '/' && pathStr[pathStr.length() - 1] != '\\')
{
pathStr.append("/");
}
}
void CrashHandlerBase::ReadConfigFile()
{
std::string filePath;
GetExecutableFolder(filePath);
filePath += crashSettingsFile;
std::ifstream inputFile(filePath);
if (!inputFile.is_open())
{
return;
}
std::string inputString;
while (std::getline(inputFile, inputString))
{
size_t equalPos = inputString.find_first_of('=');
if (equalPos != std::string::npos && equalPos != inputString.length() - 1)
{
std::string tokenStr = inputString.substr(0, equalPos);
std::string valueStr = inputString.substr(equalPos + 1);
if (tokenStr == "SubmissionToken")
{
m_submissionToken = valueStr;
}
}
}
}
const std::string& CrashHandlerBase::GetConfigSubmissionToken() const
{
return m_submissionToken;
}
void CrashHandlerBase::Initialize(const std::string& moduleTag, const std::string& appRoot, const std::string& crashUrl, const std::string& crashToken, const std::string& handlerFolder, const CrashHandlerAnnotations& baseAnnotations, const CrashHandlerArguments& arguments)
{
ReadConfigFile();
const std::string url{ crashUrl.length() ? crashUrl : GetCrashSubmissionURL() };
const std::string token{ crashToken.length() ? crashToken : GetCrashSubmissionToken() };
std::string lyAppRoot{ appRoot };
AppendSep(lyAppRoot);
if (!lyAppRoot.length())
{
lyAppRoot = DetermineAppPath();
if(!lyAppRoot.length())
{
AZ_Warning("CrashReporting", false, "Could not determine app root");
return;
}
AppendSep(lyAppRoot);
}
std::string dbPath = GetCrashReportFolder(lyAppRoot);
std::string disableFilePath{ dbPath + disableFile };
if (AZ::IO::SystemFile::Exists(disableFilePath.c_str()))
{
AZ_TracePrintf("CrashReporting", "Disabling crash reporting - disable file found at %s", disableFilePath.c_str());
return;
}
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
#if AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS
wchar_t pathStr[AZ_MAX_PATH_LEN];
size_t chars_converted{ 0 };
mbstowcs_s(&chars_converted, pathStr, dbPath.c_str(), dbPath.length());
base::FilePath db{ pathStr };
#else
base::FilePath db{ dbPath };
#endif
if (!CreateCrashHandlerDB(dbPath))
{
AZ_Warning("CrashReporting", false, "Failed to create crash dump path.");
}
std::string crashHandlerPath = GetCrashHandlerPath(handlerFolder);
#if AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS
mbstowcs_s(&chars_converted, pathStr, crashHandlerPath.c_str(), crashHandlerPath.length());
base::FilePath handler{ pathStr };
#else
base::FilePath handler{ crashHandlerPath };
#endif
CrashHandlerAnnotations defaultAnnotations{ baseAnnotations };
defaultAnnotations["executable"] = moduleTag;
GetBuildAnnotations(defaultAnnotations);
// User specific OS info
GetOSAnnotations(defaultAnnotations);
GetUserAnnotations(defaultAnnotations);
// Credentials for crash upload
defaultAnnotations["token"] = token;
defaultAnnotations["format"] = "minidump";
// Our 3rd party provider handles "bad actors" sending too many crash reports, so this should be turned off so we aren't
// arbitrarily throwing out potentially valid crashes (Default rate limit is 1 hour)
CrashHandlerArguments argumentList{ arguments };
argumentList.push_back("--no-rate-limit");
std::string submissionToken{ "--submission-token=" };
submissionToken += token;
argumentList.push_back(submissionToken);
std::string executableName;
GetExecutableBaseName(executableName);
executableName = "--executable-name=" + executableName;
argumentList.push_back(executableName);
crashpad::CrashpadClient client;
// Initialize automatic crashpad handling.
bool rc = client.StartHandler(handler,
db,
db,
url,
defaultAnnotations,
argumentList,
true,
true);
if (rc == false)
{
AZ_Warning("CrashReporting", false, "Failed to start crash handler");
return;
}
#if AZ_TRAIT_CRASHHANDLER_WAIT_FOR_COMPLETED_HANDLER_LAUNCH
rc = client.WaitForHandlerStart(INFINITE);
#endif
if (rc == false)
{
AZ_Warning("CrashReporting", false, "Failed to wait for handler to start");
return;
}
static AZ::EnvironmentVariable<bool> envVar = AZ::Environment::CreateVariable<bool>(crashHandlerEnvVar, true);
AZ_TracePrintf("CrashReporting", "Initialized Crash Handler Successfully. Crash dumps written to %s. Handler at %s.", dbPath.c_str(), crashHandlerPath.c_str());
}
void CrashHandlerBase::AddAnnotation(const std::string& keyName, const std::string& valueStr)
{
AZ::EnvironmentVariable<crashpad::SimpleStringDictionary> annotationVar = AZ::Environment::FindVariable<crashpad::SimpleStringDictionary>(crashHandlerAnnotationEnvVar);
if (!annotationVar)
{
static AZ::EnvironmentVariable<crashpad::SimpleStringDictionary> createAnnotationVar = AZ::Environment::CreateVariable<crashpad::SimpleStringDictionary>(crashHandlerAnnotationEnvVar);
crashpad::CrashpadInfo* crashpad_info = crashpad::CrashpadInfo::GetCrashpadInfo();
crashpad_info->set_simple_annotations(&createAnnotationVar.Get());
annotationVar = createAnnotationVar;
}
if (annotationVar)
{
annotationVar->SetKeyValue(keyName.c_str(), valueStr.c_str());
}
}
}
@@ -0,0 +1,72 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Crashpad Hook
#pragma once
#include <map>
#include <string>
#include <vector>
namespace CrashHandler
{
static const char* defaultCrashFolder = "CrashDB/";
static const char* lumberyardProductName = "lumberyard";
using CrashHandlerAnnotations = std::map<std::string, std::string>;
using CrashHandlerArguments = std::vector<std::string>;
class CrashHandlerBase
{
public:
CrashHandlerBase() = default;
virtual ~CrashHandlerBase() = default;
static void InitCrashHandler(const std::string& moduleTag, const std::string& devRoot, const std::string& crashUrl = {}, const std::string& crashToken = {}, const std::string& handlerFolder = {}, const CrashHandlerAnnotations& baseAnnotations = CrashHandlerAnnotations(), const CrashHandlerArguments& argumentVec = CrashHandlerArguments());
void Initialize(const std::string& moduleTag, const std::string& devRoot);
void Initialize(const std::string& moduleTag, const std::string& devRoot, const std::string& crashUrl, const std::string& crashToken, const std::string& handlerFolder = {}, const CrashHandlerAnnotations& baseAnnotations = CrashHandlerAnnotations(), const CrashHandlerArguments& argumentVec = CrashHandlerArguments());
// Helper to add an annotation after initialization - must have already called InitCrashHandler
static void AddAnnotation(const std::string& keyName, const std::string& valueStr);
protected:
virtual std::string GetCrashReportFolder(const std::string& lyAppRoot) const;
virtual const char* GetDefaultCrashFolder() const { return defaultCrashFolder; }
virtual std::string GetCrashHandlerPath(const std::string& lyAppRoot = {}) const;
virtual const char* GetCrashHandlerExecutableName() const;
virtual std::string DetermineAppPath() const;
virtual const char* GetProductName() const { return lumberyardProductName; }
virtual bool CreateCrashHandlerDB(const std::string& reportPath) const;
virtual std::string GetCrashSubmissionURL() const { return{}; }
virtual std::string GetCrashSubmissionToken() const { return{}; }
static void AppendSep(std::string& lyAppRoot);
virtual void GetBuildAnnotations(CrashHandlerAnnotations& annotations) const;
virtual void GetUserAnnotations(CrashHandlerAnnotations& ) const {};
// OS Dependent
virtual std::string GetAppRootFromCWD() const;
virtual void GetOSAnnotations(CrashHandlerAnnotations& annotations) const;
const std::string& GetConfigSubmissionToken() const;
private:
void ReadConfigFile();
std::string m_submissionToken;
};
}
@@ -0,0 +1,24 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_add_target(
NAME CrashSupport STATIC
NAMESPACE AZ
FILES_CMAKE
crash_handler_support_files.cmake
Platform/${PAL_PLATFORM_NAME}/crash_handler_support_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
include
BUILD_DEPENDENCIES
PRIVATE
AZ::AzCore
)
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
include/CrashSupport.h
src/CrashSupport.cpp
)
@@ -0,0 +1,85 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Crash Handler shared support
#pragma once
#include <AzCore/PlatformDef.h>
#include <algorithm>
#include <string>
#define CRASH_HANDLER_MAX_PATH_LEN 1024
#define _MAKE_DEFINE_STRING(x) #x
#define MAKE_DEFINE_STRING(x) _MAKE_DEFINE_STRING(x)
namespace CrashHandler
{
std::string GetTimeString();
void GetExecutablePathA(char* pathBuffer, int& bufferSize);
void GetExecutablePathW(wchar_t* pathBuffer, int& bufferSize);
void GetTimeInfo(tm& curTime);
template <typename T>
inline void GetExecutablePath(T& returnPath)
{
char currentFileName[CRASH_HANDLER_MAX_PATH_LEN] = { 0 };
int bufferLen{ CRASH_HANDLER_MAX_PATH_LEN };
GetExecutablePathA(currentFileName, bufferLen);
returnPath = currentFileName;
std::replace(returnPath.begin(), returnPath.end(), '\\', '/');
}
template <>
inline void GetExecutablePath<std::wstring>(std::wstring& returnPath)
{
wchar_t currentFileName[CRASH_HANDLER_MAX_PATH_LEN] = { 0 };
int bufferLen{ CRASH_HANDLER_MAX_PATH_LEN };
GetExecutablePathW(currentFileName, bufferLen);
returnPath = currentFileName;
std::replace(returnPath.begin(), returnPath.end(), '\\', '/');
}
template<typename T>
inline void GetExecutableFolder(T& returnPath)
{
GetExecutablePath(returnPath);
auto lastPos = returnPath.find_last_of('/');
if (lastPos != T::npos)
{
returnPath = returnPath.substr(0, lastPos + 1);
}
}
template<typename T>
inline void GetExecutableBaseName(T& returnPath)
{
GetExecutablePath(returnPath);
auto lastPos = returnPath.find_last_of('/');
if (lastPos != T::npos)
{
returnPath = returnPath.substr(lastPos + 1, returnPath.length());
}
auto extPos = returnPath.find_last_of('.');
if (extPos != T::npos)
{
returnPath = returnPath.substr(0, extPos);
}
}
}
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
../../Platform/win/CrashSupport_win.cpp
)
@@ -0,0 +1,38 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <CrashSupport.h>
#include <mach-o/dyld.h> // Needed for _NSGetExecutablePath
#include <time.h>
namespace CrashHandler
{
void GetExecutablePathA(char* pathBuffer, int& bufferSize)
{
unsigned int localBufferSize{static_cast<unsigned int>(bufferSize)};
_NSGetExecutablePath(pathBuffer, &localBufferSize);
}
void GetExecutablePathW(wchar_t* pathBuffer, int& bufferSize)
{
// Windows only
}
void GetTimeInfo(tm& timeInfo)
{
time_t rawtime;
time(&rawtime);
localtime_r(&rawtime, &timeInfo);
}
}
@@ -0,0 +1,38 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <CrashSupport.h>
#include <algorithm>
#include <AzCore/PlatformIncl.h>
#include <time.h>
namespace CrashHandler
{
void GetExecutablePathA(char* pathBuffer, int& bufferSize)
{
GetModuleFileNameA(nullptr, pathBuffer, bufferSize);
}
void GetExecutablePathW(wchar_t* pathBuffer, int& bufferSize)
{
GetModuleFileNameW(nullptr, pathBuffer, bufferSize);
}
void GetTimeInfo(tm& timeInfo)
{
time_t rawtime;
time(&rawtime);
localtime_s(&timeInfo, &rawtime);
}
}
@@ -0,0 +1,34 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Crash Handler shared support
#include <CrashSupport.h>
#include <time.h>
namespace CrashHandler
{
std::string GetTimeString()
{
const int bufLen = 100;
char buffer[bufLen];
struct tm timeinfo;
GetTimeInfo(timeinfo);
strftime(buffer, bufLen, "%Y-%m-%dT%H:%M:%S", &timeinfo);
return buffer;
}
}
@@ -0,0 +1,54 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_add_target(
NAME ToolsCrashHandler STATIC
NAMESPACE AZ
AUTOMOC
FILES_CMAKE
tools_crash_handler_files.cmake
Platform/${PAL_PLATFORM_NAME}/tools_crash_handler_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
BUILD_DEPENDENCIES
PRIVATE
3rdParty::Qt::Core
AZ::CrashHandler
AZ::CrashSupport
AZ::AzToolsFramework
)
ly_add_target(
NAME ToolsCrashUploader APPLICATION
NAMESPACE AZ
AUTOMOC
AUTOUIC
FILES_CMAKE
tools_crash_uploader_files.cmake
Platform/${PAL_PLATFORM_NAME}/tools_crash_uploader_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
.
Uploader
BUILD_DEPENDENCIES
PRIVATE
3rdParty::Qt::Core
3rdParty::Qt::Gui
3rdParty::Qt::Widgets
3rdParty::Crashpad
3rdParty::Crashpad::Handler
AZ::CrashUploaderSupport
AZ::AzQtComponents
AZ::CrashSupport
TARGET_PROPERTIES
Qt5_NO_LINK_QTMAIN TRUE
)
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
../../ToolsCrashHandler_win.cpp
)
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
../../Uploader/platforms/win/main.cpp
)
@@ -0,0 +1,81 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Crashpad Hook
#include <ToolsCrashHandler.h>
#include <CrashSupport.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/PlatformIncl.h>
#include <AzCore/IO/SystemFile.h>
#include <QOperatingSystemVersion>
#include <QString>
namespace CrashHandler
{
void ToolsCrashHandler::InitCrashHandler(const std::string& moduleTag, const std::string& devRoot, const std::string& crashUrl, const std::string& crashToken, const std::string& handlerFolder, const CrashHandlerAnnotations& baseAnnotations, const CrashHandlerArguments& arguments)
{
ToolsCrashHandler crashHandler;
crashHandler.Initialize( moduleTag, devRoot, crashUrl, crashToken, handlerFolder, baseAnnotations, arguments);
}
std::string ToolsCrashHandler::GetCrashSubmissionURL() const
{
#if defined(CRASH_HANDLER_URL)
return MAKE_DEFINE_STRING(CRASH_HANDLER_URL);
#else
return "https://lumberyard.sp.backtrace.io:8443/";
#endif
}
std::string ToolsCrashHandler::GetCrashSubmissionToken() const
{
std::string configToken = GetConfigSubmissionToken();
if (configToken.length())
{
return configToken;
}
#if defined(CRASH_HANDLER_TOKEN)
return MAKE_DEFINE_STRING(CRASH_HANDLER_TOKEN);
#else
return "8f562f6bf0ecb674e5f64344d76e6afeccb3244b4a9ea191ee61dc4e3528c5bd";
#endif
}
std::string ToolsCrashHandler::DetermineAppPath() const
{
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
if (fileIO)
{
// If our devroot alias is available, use that
const char* devAlias = fileIO->GetAlias("@devroot@");
if (devAlias)
{
return devAlias;
}
}
return GetAppRootFromCWD();
}
void ToolsCrashHandler::GetOSAnnotations(CrashHandlerAnnotations& annotations) const
{
CrashHandlerBase::GetOSAnnotations(annotations);
std::string annotationBuf = QOperatingSystemVersion::current().name().toUtf8().data();
annotations["os.qtversion"] = annotationBuf;
}
}
@@ -0,0 +1,40 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Crashpad Hook
#pragma once
#include <CrashHandler.h>
namespace CrashHandler
{
class ToolsCrashHandler : public CrashHandler::CrashHandlerBase
{
public:
ToolsCrashHandler() = default;
virtual ~ToolsCrashHandler() = default;
static void InitCrashHandler(const std::string& moduleTag, const std::string& devRoot, const std::string& crashUrl = {}, const std::string& crashToken = {}, const std::string& handlerFolder = {}, const CrashHandlerAnnotations& baseAnnotations = CrashHandlerAnnotations(), const CrashHandlerArguments& arguments = CrashHandlerArguments());
protected:
virtual std::string DetermineAppPath() const override;
virtual std::string GetCrashSubmissionURL() const override;
virtual std::string GetCrashSubmissionToken() const override;
// OS Dependent
virtual std::string GetAppRootFromCWD() const override;
virtual void GetOSAnnotations(CrashHandlerAnnotations& annotations) const override;
};
}
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Tools Crash Handler support for Mac
#include <ToolsCrashHandler.h>
#include <AzCore/PlatformIncl.h>
#include <AzCore/IO/SystemFile.h>
#include <CrashSupport.h>
namespace CrashHandler
{
std::string ToolsCrashHandler::GetAppRootFromCWD() const
{
std::string returnPath;
GetExecutableFolder(returnPath);
std::string devRoot{ "/dev/" };
auto devpos = returnPath.rfind(devRoot);
if (devpos != std::string::npos)
{
/* Cut off everything beyond \\dev\\ */
returnPath.erase(devpos + devRoot.length());
}
return returnPath;
}
}
@@ -0,0 +1,36 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Crashpad Hook - Windows
#include <ToolsCrashHandler.h>
#include <AzCore/PlatformIncl.h>
#include <CrashSupport.h>
namespace CrashHandler
{
std::string ToolsCrashHandler::GetAppRootFromCWD() const
{
std::string returnPath;
GetExecutableFolder(returnPath);
std::string devRoot{ "/dev/" };
auto devpos = returnPath.rfind(devRoot);
if (devpos != std::string::npos)
{
/* Cut off everything beyond \\dev\\ */
returnPath.erase(devpos + devRoot.length());
}
return returnPath;
}
}
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/Icons">
<file>lyeditor.ico</file>
</qresource>
</RCC>
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2c9a6ddbfc423c717a03dacab45e134166a1b06030b4caf418d0a6a69c2d82d2
size 114333
@@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SendReportDialog</class>
<widget class="QDialog" name="SendReportDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>220</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>220</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>220</height>
</size>
</property>
<property name="windowTitle">
<string>Send Error Report</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>lyeditoricon.ico</normaloff>lyeditoricon.ico</iconset>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="modal">
<bool>true</bool>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>210</x>
<y>186</y>
<width>175</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>0</x>
<y>168</y>
<width>391</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>6</x>
<y>6</y>
<width>385</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Lumberyard has encountered a fatal error. We're sorry for the inconvenience.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>6</x>
<y>36</y>
<width>385</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>A Lumberyard Editor crash debugging file has been created at:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="dump_label">
<property name="geometry">
<rect>
<x>6</x>
<y>66</y>
<width>391</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>6</x>
<y>96</y>
<width>385</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>If you are willing to submit this file to Amazon it will help us improve the Lumberyard experience. We will treat this report as confidential.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>6</x>
<y>138</y>
<width>331</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Would you like to send the error report?</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</widget>
<resources>
<include location="../../../../Sandbox/Editor/MainWindow.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SendReportDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SendReportDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -0,0 +1,41 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "SendReportDialog.h"
#include "UI/ui_submit_report.h"
namespace CrashUploader
{
SendReportDialog::SendReportDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::SendReportDialog)
{
ui->setupUi(this);
}
SendReportDialog::~SendReportDialog()
{
}
void SendReportDialog::SetReportText(const char* reportText)
{
ui->dump_label->setText(reportText);
}
void SendReportDialog::SetApplicationName(const char* applicationName)
{
QString errorString{ applicationName };
errorString += " has encountered a fatal error. We're sorry for the inconvenience.";
ui->label->setText(errorString);
}
}
@@ -0,0 +1,40 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QDialog>
#include <QScopedPointer>
#endif
namespace Ui {
class SendReportDialog;
}
namespace CrashUploader
{
class SendReportDialog : public QDialog
{
Q_OBJECT // AUTOMOC
public:
explicit SendReportDialog(QWidget* parent = nullptr);
~SendReportDialog() override;
void SetReportText(const char* reportPath);
void SetApplicationName(const char* appName);
private:
QScopedPointer<Ui::SendReportDialog> ui;
};
}
@@ -0,0 +1,111 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Crashpad Upload Handler Extension
#include <ToolsCrashUploader.h>
#include <SendReportDialog.h>
#include <CrashSupport.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzCore/PlatformDef.h>
#include <AzCore/std/typetraits/underlying_type.h>
#include <QString>
#include <QApplication>
#include <memory>
#include "UI/ui_submit_report.h"
namespace Lumberyard
{
void InstallCrashUploader(int& argc, char* argv[])
{
Lumberyard::CrashUploader::SetCrashUploader(std::make_shared<Lumberyard::ToolsCrashUploader>(argc, argv));
}
QString GetReportString(const std::wstring& reportPath)
{
return QString::fromStdWString(reportPath);
}
QString GetReportString(const std::string& reportPath)
{
return QString::fromStdString( reportPath );
}
ToolsCrashUploader::ToolsCrashUploader(int& argCount, char** argv) :
CrashUploader(argCount, argv)
{
}
std::string ToolsCrashUploader::GetRootFolder()
{
std::string returnPath;
::CrashHandler::GetExecutableFolder(returnPath);
std::string devRoot{ "/dev/" };
auto devpos = returnPath.rfind(devRoot);
if (devpos != std::string::npos)
{
/* Cut off everything beyond \\dev\\ */
returnPath.erase(devpos + devRoot.length());
}
return returnPath;
}
bool ToolsCrashUploader::CheckConfirmation(const crashpad::CrashReportDatabase::Report& report)
{
if (m_noConfirmation)
{
return true;
}
#if !AZ_TRAIT_OS_PLATFORM_APPLE
AZ_PUSH_DISABLE_WARNING(4996, "-Wunknown-warning-option")
const char* noConfirmation = getenv("LY_NO_CONFIRM");
AZ_POP_DISABLE_WARNING
if (noConfirmation == nullptr)
{
int argCount = 0;
AzQtComponents::StyleManager styleManager{ nullptr };
QApplication app{ argCount, nullptr };
styleManager.Initialize(&app);
QString reportPath{ GetReportString(report.file_path.value()) };
QString reportString{ GetReportString(report.file_path.value()).toStdString().c_str() };
QAtomicInt dialogResult{ -1 };
::CrashUploader::SendReportDialog confirmDialog{ nullptr };
confirmDialog.SetApplicationName(m_executableName.c_str());
confirmDialog.setWindowIcon(QIcon(":/Icons/editor_icon.ico"));
confirmDialog.SetReportText(reportString.toStdString().c_str());
confirmDialog.setWindowFlags((confirmDialog.windowFlags() | Qt::WindowStaysOnTopHint) & ~Qt::WindowContextHelpButtonHint);
confirmDialog.exec();
while (dialogResult == -1)
{
app.processEvents();
dialogResult = confirmDialog.result();
}
return dialogResult == QDialog::Accepted;
}
#endif
return true;
}
}
@@ -0,0 +1,29 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Crashpad Upload Handler Extension
#pragma once
#include <Uploader/CrashUploader.h>
namespace Lumberyard
{
class ToolsCrashUploader : public CrashUploader
{
public:
ToolsCrashUploader(int& argcount, char** argv);
virtual bool CheckConfirmation(const crashpad::CrashReportDatabase::Report& report) override;
static std::string GetRootFolder();
};
}
@@ -0,0 +1,24 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Crashpad Upload Handler - Mac
#include <handler/handler_main.h>
#include <Uploader/CrashUploader.h>
int main(int argc, char** argv)
{
Lumberyard::InstallCrashUploader(argc, argv);
LOG(ERROR) << "Initializing posix crash uploader";
return crashpad::HandlerMain(argc, argv, Lumberyard::CrashUploader::GetCrashUploader()->GetUserStreamSources());
}
@@ -0,0 +1,38 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// LY Editor Crashpad Upload Handler Extension
#include <handler/handler_main.h>
#include <tools/tool_support.h>
#include <Uploader/CrashUploader.h>
#include <windows.h>
namespace
{
int HandlerMain(int argc, char* argv[])
{
Lumberyard::InstallCrashUploader(argc, argv);
LOG(ERROR) << "Initializing windows crash uploader";
int resultCode = crashpad::HandlerMain(argc, argv, Lumberyard::CrashUploader::GetCrashUploader()->GetUserStreamSources());
return resultCode;
}
}
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, [[maybe_unused]] wchar_t* lpCmdLine, int)
{
return crashpad::ToolSupport::Wmain(__argc, __wargv, HandlerMain);
}
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
ToolsCrashHandler.h
ToolsCrashHandler.cpp
)
@@ -0,0 +1,20 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Uploader/ToolsCrashUploader.h
Uploader/ToolsCrashUploader.cpp
Uploader/SendReportDialog.h
Uploader/SendReportDialog.cpp
UI/submit_report.ui
UI/lyeditor.ico
UI/ToolsCrashHandler.qrc
)
@@ -0,0 +1,36 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <minidump/minidump_user_extension_stream_data_source.h>
#include <vector>
namespace Lumberyard
{
class BufferedDataStream : public crashpad::MinidumpUserExtensionStreamDataSource
{
public:
BufferedDataStream(uint32_t stream_type, const void* data, size_t data_size);
size_t StreamDataSize() override;
bool ReadStreamData(Delegate* delegate) override;
private:
std::vector<uint8_t> data_;
BufferedDataStream(const BufferedDataStream& rhs) = delete;
BufferedDataStream& operator=(const BufferedDataStream& rhs) = delete;
};
}
@@ -0,0 +1,75 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <client/crash_report_database.h>
#include <util/net/http_multipart_builder.h>
#include <util/net/http_transport.h>
#include <handler/user_stream_data_source.h>
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#include <base/logging.h>
#include <string>
namespace Lumberyard
{
bool CheckConfirmation(const crashpad::CrashReportDatabase::Report& report);
void InstallCrashUploader(int& argc, char* argv[]);
bool AddAttachments(crashpad::HTTPMultipartBuilder& builder);
bool UpdateHttpTransport(std::unique_ptr<crashpad::HTTPTransport>& httpTransport, const std::string& baseURL);
class CrashUploader
{
public:
CrashUploader(int& argc, char** argv);
virtual ~CrashUploader();
static void SetCrashUploader(std::shared_ptr<CrashUploader> uploader);
static std::shared_ptr<CrashUploader> GetCrashUploader();
virtual bool CheckConfirmation(const crashpad::CrashReportDatabase::Report& report);
virtual void InstallLogHandler() const;
virtual bool AddAttachments(crashpad::HTTPMultipartBuilder& builder);
virtual bool UpdateHttpTransport(std::unique_ptr<crashpad::HTTPTransport>& httpTransport, const std::string& baseURL);
static const char* GetLogFileName() { return "CrashUploaderLog.txt"; }
// base/logging.h::LogMessageHandlerFunction
static bool DoLogging(logging::LogSeverity severity,
const char* file_poath,
int line,
size_t message_start,
const std::string& string);
// We parse out our arguments from the list and let the rest pass through to crashpad
virtual void ParseArguments(int& argc, char** argv);
virtual crashpad::UserStreamDataSources* GetUserStreamSources();
protected:
// Skip confirmation dialog by argument
bool m_noConfirmation{ false };
// Log paths to uploadas user streams with the minidump
std::vector<base::FilePath> m_uploadPaths;
crashpad::UserStreamDataSources m_userStreams;
static std::shared_ptr<CrashUploader> s_uploader;
std::string m_submissionToken;
std::string m_executableName;
};
}
@@ -0,0 +1,34 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <handler/user_stream_data_source.h>
#include "base/files/file_path.h"
namespace Lumberyard
{
class FileStreamDataSource : public crashpad::UserStreamDataSource
{
public:
FileStreamDataSource(const base::FilePath& filePath);
std::unique_ptr<crashpad::MinidumpUserExtensionStreamDataSource> ProduceStreamData(crashpad::ProcessSnapshot* process_snapshot) override;
private:
FileStreamDataSource(const FileStreamDataSource& rhs) = delete;
FileStreamDataSource& operator=(const FileStreamDataSource& rhs) = delete;
base::FilePath m_filePath;
};
}
@@ -0,0 +1,38 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <BufferedDataStream.h>
namespace Lumberyard
{
BufferedDataStream::BufferedDataStream(uint32_t stream_type, const void* data, size_t data_size)
: crashpad::MinidumpUserExtensionStreamDataSource(stream_type)
{
data_.resize(data_size);
if (data_size)
{
memcpy(data_.data(), data, data_size);
}
}
size_t BufferedDataStream::StreamDataSize()
{
return data_.size();
}
bool BufferedDataStream::ReadStreamData(Delegate* delegate)
{
return delegate->ExtensionStreamDataSourceRead(data_.size() ? data_.data() : nullptr, data_.size());
}
}
@@ -0,0 +1,249 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <CrashUploader.h>
#include <CrashSupport.h>
#include <AzCore/PlatformDef.h>
#include <getopt.h>
#include <util/file/file_reader.h>
#include <util/string/split_string.h>
#include <tools/tool_support.h>
#include <base/strings/utf_string_conversions.h>
#include <fstream>
#include <memory>
namespace Lumberyard
{
using namespace crashpad;
std::shared_ptr<CrashUploader> CrashUploader::s_uploader = nullptr;
bool CheckConfirmation(const crashpad::CrashReportDatabase::Report& report)
{
return CrashUploader::GetCrashUploader()->CheckConfirmation(report);
}
bool AddAttachments(HTTPMultipartBuilder& builder)
{
return CrashUploader::GetCrashUploader()->AddAttachments(builder);
}
bool UpdateHttpTransport(std::unique_ptr<crashpad::HTTPTransport>& httpTransport, const std::string& baseURL)
{
return CrashUploader::GetCrashUploader()->UpdateHttpTransport(httpTransport, baseURL);
}
CrashUploader::CrashUploader(int& argc, char** argv)
{
ParseArguments(argc, argv);
}
CrashUploader::~CrashUploader()
{
}
bool CrashUploader::DoLogging([[maybe_unused]] logging::LogSeverity severity,
[[maybe_unused]] const char* file_path,
[[maybe_unused]] int line,
[[maybe_unused]] size_t message_start,
const std::string& string)
{
const char* crashLog = GetLogFileName();
std::ofstream outFile(crashLog, std::ofstream::out | std::ofstream::app);
outFile << "[" << CrashHandler::GetTimeString() << "] " << string;
outFile.close();
return true;
}
void CrashUploader::InstallLogHandler() const
{
logging::SetLogMessageHandler(&CrashUploader::DoLogging);
}
void CrashUploader::SetCrashUploader(std::shared_ptr<CrashUploader> uploader)
{
s_uploader = uploader;
if (uploader)
{
uploader->InstallLogHandler();
}
else
{
logging::SetLogMessageHandler(nullptr);
}
}
std::shared_ptr<CrashUploader> CrashUploader::GetCrashUploader()
{
if (!s_uploader)
{
int noArgCount{ 0 };
s_uploader = std::make_shared<CrashUploader>(noArgCount, nullptr);
}
return s_uploader;
}
crashpad::UserStreamDataSources* CrashUploader::GetUserStreamSources()
{
return &m_userStreams;
}
bool CrashUploader::CheckConfirmation([[maybe_unused]] const crashpad::CrashReportDatabase::Report& report)
{
return !m_noConfirmation;
}
bool CrashUploader::UpdateHttpTransport(std::unique_ptr<crashpad::HTTPTransport>& httpTransport, const std::string& baseURL)
{
std::string newURL{ baseURL };
// Are there already query parameters
auto findPos = baseURL.find('?');
if (findPos == std::string::npos)
{
newURL += "?";
}
else
{
newURL += "&";
}
newURL += "token=" + m_submissionToken;
httpTransport->SetURL(newURL);
return true;
}
bool CrashUploader::AddAttachments(crashpad::HTTPMultipartBuilder& builder)
{
int attachmentCount = 0;
for(auto thisFile : m_uploadPaths)
{
static std::vector<std::unique_ptr<crashpad::FileReader>> logFileReaders;
logFileReaders.push_back(std::make_unique<crashpad::FileReader>());
crashpad::FileReader* logFileReader = logFileReaders.back().get();
if (!logFileReader->Open(thisFile))
{
#if defined(AZ_PLATFORM_WINDOWS)
LOG(ERROR) << "Failed to open " << base::UTF16ToUTF8(thisFile.BaseName().value());
#else
LOG(ERROR) << "Failed to open " << thisFile.BaseName().value();
#endif
continue;
}
FileOffset start_offset = logFileReader->SeekGet();
if (start_offset < 0)
{
#if defined(AZ_PLATFORM_WINDOWS)
LOG(ERROR) << "Failed to get offset for " << base::UTF16ToUTF8(thisFile.BaseName().value());
#else
LOG(ERROR) << "Failed to get offset for " << thisFile.BaseName().value();
#endif
continue;
}
++attachmentCount;
std::string attachmentKey{ "attachment_" };
attachmentKey += std::to_string(attachmentCount);
std::string fileNameKey{ "attachment_" };
#if defined(AZ_PLATFORM_WINDOWS)
fileNameKey += base::UTF16ToUTF8(thisFile.BaseName().value());
#else
fileNameKey += thisFile.BaseName().value();
#endif
attachmentKey = fileNameKey;
builder.SetFileAttachment(
attachmentKey,
fileNameKey,
logFileReader,
"");
}
return true;
}
void CrashUploader::ParseArguments(int& argc, char** argv)
{
if (!argc)
{
return;
}
enum ParsedFlags
{
NoConfirmation,
UploadPath,
UserStream,
SubmissionToken,
ExecutableName,
EndFlags
};
static constexpr option options_list[] = {
{"noconfirmation", no_argument, nullptr, NoConfirmation},
{"uploadpath", required_argument, nullptr, UploadPath},
{"userstream", required_argument, nullptr, UserStream },
{"submission-token", required_argument, nullptr, SubmissionToken },
{"executable-name", required_argument, nullptr, ExecutableName },
{nullptr, no_argument, nullptr, EndFlags}
};
int opt{ 0 };
while ((opt = getopt_long(argc, argv, "", options_list, nullptr)) != -1)
{
switch (opt)
{
case NoConfirmation:
{
m_noConfirmation = true;
argv[--optind] = argv[--argc];
break;
}
case UploadPath:
{
m_uploadPaths.push_back(base::FilePath(crashpad::ToolSupport::CommandLineArgumentToFilePathStringType(optarg)));
argv[--optind] = argv[--argc];
break;
}
case UserStream:
{
argv[--optind] = argv[--argc];
break;
}
case SubmissionToken:
{
m_submissionToken = optarg;
argv[--optind] = argv[--argc];
break;
}
case ExecutableName:
{
m_executableName = optarg;
argv[--optind] = argv[--argc];
break;
}
default:
{
// Likely an argument for crashpad - passthrough
}
}
}
// Reset so we can loop again inside crashpad
optind = 0;
}
}
@@ -0,0 +1,33 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <FileStreamDataSource.h>
#include <BufferedDataStream.h>
#include <memory>
namespace Lumberyard
{
FileStreamDataSource::FileStreamDataSource(const base::FilePath& filePath) :
m_filePath{ filePath }
{
}
std::unique_ptr<crashpad::MinidumpUserExtensionStreamDataSource> FileStreamDataSource::ProduceStreamData(crashpad::ProcessSnapshot* process_snapshot)
{
static constexpr char testBuffer[] = "Test Data From buffer.";
return std::make_unique<BufferedDataStream>( 0xCAFEBABE, testBuffer, sizeof(testBuffer));
}
}
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Shared/CrashHandler.h
Shared/CrashHandler.cpp
)
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Uploader/include/Uploader/CrashUploader.h
Uploader/src/CrashUploader.cpp
)