123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- diff --git a/ports/crashpad/o3de_handler_extensions.patch b/ports/crashpad/o3de_handler_extensions.patch
- new file mode 100644
- index 0000000..6f566f8
- --- /dev/null
- +++ b/ports/crashpad/o3de_handler_extensions.patch
- @@ -0,0 +1,180 @@
- +diff --git a/client/crashpad_client.h b/client/crashpad_client.h
- +index 3c966686..75d01a84 100644
- +--- a/client/crashpad_client.h
- ++++ b/client/crashpad_client.h
- +@@ -12,6 +12,10 @@
- + // See the License for the specific language governing permissions and
- + // limitations under the License.
- +
- ++// Modifications Copyright (c) Contributors to the Open 3D Engine Project.
- ++// SPDX-License-Identifier: Apache-2.0 OR MIT
- ++// (See O3DE tagged section(s) below)
- ++
- + #ifndef CRASHPAD_CLIENT_CRASHPAD_CLIENT_H_
- + #define CRASHPAD_CLIENT_CRASHPAD_CLIENT_H_
- +
- +@@ -771,6 +775,29 @@ class CrashpadClient {
- + static bool DumpAndCrashTargetProcess(HANDLE process,
- + HANDLE blame_thread,
- + DWORD exception_code);
- ++
- ++ // O3DE - Handle giving the user the option to react to a crash
- ++ //! \brief The type for custom handlers installed by clients.
- ++ using FirstChanceHandler = bool (*)(EXCEPTION_POINTERS*);
- ++
- ++ //! \brief Installs a custom crash signal handler which runs before the
- ++ //! currently installed Crashpad handler.
- ++ //!
- ++ //! Handling signals appropriately can be tricky and use of this method
- ++ //! should be avoided, if possible.
- ++ //!
- ++ //! A handler must have already been installed before calling this method.
- ++ //!
- ++ //! The custom handler runs in a signal handler context and must be safe for
- ++ //! that purpose.
- ++ //!
- ++ //! If the custom handler returns `true`, the signal is considered handled and
- ++ //! the signal handler returns. Otherwise, the currently installed Crashpad
- ++ //! signal handler is run.
- ++ //!
- ++ //! \param[in] handler The custom crash signal handler to install.
- ++ static void SetFirstChanceExceptionHandler(FirstChanceHandler handler);
- ++
- + #endif
- +
- + #if BUILDFLAG(IS_APPLE) || DOXYGEN
- +diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc
- +index c10df2b0..71435039 100644
- +--- a/client/crashpad_client_win.cc
- ++++ b/client/crashpad_client_win.cc
- +@@ -12,6 +12,10 @@
- + // See the License for the specific language governing permissions and
- + // limitations under the License.
- +
- ++// Modifications Copyright (c) Contributors to the Open 3D Engine Project.
- ++// SPDX-License-Identifier: Apache-2.0 OR MIT
- ++// (See O3DE tagged section(s) below)
- ++
- + #include "client/crashpad_client.h"
- +
- + #include <windows.h>
- +@@ -84,6 +88,9 @@ WerRegistration g_wer_registration = {WerRegistration::kWerRegistrationVersion,
- + {0},
- + {0}};
- +
- ++// O3DE - Handle storing the crash reaction handler
- ++CrashpadClient::FirstChanceHandler g_first_chance_handler = nullptr;
- ++
- + enum class StartupState : int {
- + kNotReady = 0, // This must be value 0 because it is the initial value of a
- + // global AtomicWord.
- +@@ -134,6 +141,13 @@ LONG WINAPI UnhandledExceptionHandler(EXCEPTION_POINTERS* exception_pointers) {
- + return status;
- + #endif
- +
- ++ // O3DE - User react to a crash
- ++ if (g_first_chance_handler && g_first_chance_handler(exception_pointers))
- ++ {
- ++ SafeTerminateProcess(GetCurrentProcess(), kTerminationCodeCrashNoDump);
- ++ return EXCEPTION_CONTINUE_SEARCH;
- ++ }
- ++
- + if (BlockUntilHandlerStartedOrFailed() == StartupState::kFailed) {
- + // If we know for certain that the handler has failed to start, then abort
- + // here, rather than trying to signal to a handler that will never arrive,
- +@@ -1126,4 +1140,9 @@ bool CrashpadClient::DumpAndCrashTargetProcess(HANDLE process,
- + return result;
- + }
- +
- ++void CrashpadClient::SetFirstChanceExceptionHandler(CrashpadClient::FirstChanceHandler handler)
- ++{
- ++ g_first_chance_handler = handler;
- ++}
- ++
- + } // namespace crashpad
- +diff --git a/handler/crash_report_upload_thread.cc b/handler/crash_report_upload_thread.cc
- +index 5bd2889e..e3cc0341 100644
- +--- a/handler/crash_report_upload_thread.cc
- ++++ b/handler/crash_report_upload_thread.cc
- +@@ -12,6 +12,10 @@
- + // See the License for the specific language governing permissions and
- + // limitations under the License.
- +
- ++// Modifications Copyright (c) Contributors to the Open 3D Engine Project.
- ++// SPDX-License-Identifier: Apache-2.0 OR MIT
- ++// (See O3DE tagged section(s) below)
- ++
- + #include "handler/crash_report_upload_thread.h"
- +
- + #include <errno.h>
- +@@ -48,6 +52,15 @@
- + #include "util/ios/scoped_background_task.h"
- + #endif // BUILDFLAG(IS_IOS)
- +
- ++// O3DE - Handle giving the user the option of whether or not to send the report.
- ++namespace O3de {
- ++ bool CheckConfirmation(const crashpad::CrashReportDatabase::Report& report);
- ++ bool AddAttachments(crashpad::HTTPMultipartBuilder& multipartBuilder);
- ++ bool UpdateHttpTransport(
- ++ std::unique_ptr<crashpad::HTTPTransport>& httpTransport,
- ++ const std::string& baseURL);
- ++} // namespace O3de
- ++
- + namespace crashpad {
- +
- + namespace {
- +@@ -194,6 +207,14 @@ void CrashReportUploadThread::ProcessPendingReport(
- +
- + Settings* const settings = database_->GetSettings();
- +
- ++ // O3DE - Handle giving the user the option of whether or not to send the report.
- ++ if (!O3de::CheckConfirmation(report)) {
- ++ database_->SkipReportUpload(report.uuid,
- ++ Metrics::CrashSkippedReason::kUploadsDisabled);
- ++ database_->DeleteReport(report.uuid);
- ++ return;
- ++ }
- ++
- + bool uploads_enabled;
- + if (!report.upload_explicitly_requested &&
- + (!settings->GetUploadsEnabled(&uploads_enabled) || !uploads_enabled)) {
- +@@ -327,6 +348,9 @@ CrashReportUploadThread::UploadResult CrashReportUploadThread::UploadReport(
- + reader,
- + "application/octet-stream");
- +
- ++ // O3DE
- ++ O3de::AddAttachments(http_multipart_builder);
- ++
- + std::unique_ptr<HTTPTransport> http_transport(HTTPTransport::Create());
- + if (!http_transport) {
- + return UploadResult::kPermanentFailure;
- +@@ -366,6 +390,9 @@ CrashReportUploadThread::UploadResult CrashReportUploadThread::UploadReport(
- + }
- + http_transport->SetURL(url);
- +
- ++ // O3DE
- ++ O3de::UpdateHttpTransport(http_transport, url);
- ++
- + if (!http_transport->ExecuteSynchronously(response_body)) {
- + return UploadResult::kRetry;
- + }
- +diff --git a/tools/BUILD.gn b/tools/BUILD.gn
- +index 157ee929..14ca33d2 100644
- +--- a/tools/BUILD.gn
- ++++ b/tools/BUILD.gn
- +@@ -12,9 +12,14 @@
- + # See the License for the specific language governing permissions and
- + # limitations under the License.
- +
- ++# Modifications Copyright (c) Contributors to the Open 3D Engine Project.
- ++# SPDX-License-Identifier: Apache-2.0 OR MIT
- ++# (See O3DE tagged section(s) below)
- ++
- + import("../build/crashpad_buildconfig.gni")
- +
- +-source_set("tool_support") {
- ++# O3DE - Change the tool_support target type from source set to static library
- ++crashpad_static_library("tool_support") {
- + sources = [
- + "tool_support.cc",
- + "tool_support.h",
- diff --git a/ports/crashpad/portfile.cmake b/ports/crashpad/portfile.cmake
- index 6985a8b..f45bc36 100644
- --- a/ports/crashpad/portfile.cmake
- +++ b/ports/crashpad/portfile.cmake
- @@ -7,6 +7,7 @@ vcpkg_from_git(
- PATCHES
- fix-linux.patch
- fix-lib-name-conflict.patch
- + o3de_handler_extensions.patch
- )
-
- vcpkg_find_acquire_program(PYTHON3)
- @@ -40,41 +41,24 @@ if(NOT EXISTS "${SOURCE_PATH}/third_party/lss/lss/BUILD.gn" AND (VCPKG_TARGET_IS
- file(RENAME "${lss}" "${SOURCE_PATH}/third_party/lss/lss")
- endif()
-
- -function(replace_gn_dependency INPUT_FILE OUTPUT_FILE LIBRARY_NAMES)
- - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
- - unset(_LIBRARY_DEB CACHE)
- - find_library(_LIBRARY_DEB NAMES ${LIBRARY_NAMES}
- - PATHS "${CURRENT_INSTALLED_DIR}/debug/lib"
- - NO_DEFAULT_PATH)
- -
- - if(_LIBRARY_DEB MATCHES "-NOTFOUND")
- - message(FATAL_ERROR "Could not find debug library with names: ${LIBRARY_NAMES}")
- - endif()
- - endif()
- -
- - unset(_LIBRARY_REL CACHE)
- - find_library(_LIBRARY_REL NAMES ${LIBRARY_NAMES}
- - PATHS "${CURRENT_INSTALLED_DIR}/lib"
- - NO_DEFAULT_PATH)
- -
- - if(_LIBRARY_REL MATCHES "-NOTFOUND")
- - message(FATAL_ERROR "Could not find library with names: ${LIBRARY_NAMES}")
- +function(checkout_in_path PATH URL REF)
- + if(EXISTS "${PATH}")
- + return()
- endif()
-
- - if(VCPKG_BUILD_TYPE STREQUAL "release")
- - set(_LIBRARY_DEB ${_LIBRARY_REL})
- - endif()
- -
- - set(_INCLUDE_DIR "${CURRENT_INSTALLED_DIR}/include")
- -
- - file(REMOVE "${OUTPUT_FILE}")
- - configure_file("${INPUT_FILE}" "${OUTPUT_FILE}" @ONLY)
- + vcpkg_from_git(
- + OUT_SOURCE_PATH DEP_SOURCE_PATH
- + URL "${URL}"
- + REF "${REF}"
- + )
- + file(RENAME "${DEP_SOURCE_PATH}" "${PATH}")
- + file(REMOVE_RECURSE "${DEP_SOURCE_PATH}")
- endfunction()
-
- -replace_gn_dependency(
- - "${CMAKE_CURRENT_LIST_DIR}/zlib.gn"
- - "${SOURCE_PATH}/third_party/zlib/BUILD.gn"
- - "z;zlib;zlibd"
- +checkout_in_path(
- + "${SOURCE_PATH}/third_party/zlib/zlib"
- + "https://chromium.googlesource.com/chromium/src/third_party/zlib"
- + "1e85c01b15363d11fab81c46fe2b5c2179113f70"
- )
-
- set(OPTIONS "target_cpu=\"${VCPKG_TARGET_ARCHITECTURE}\"")
- @@ -127,9 +111,14 @@ vcpkg_gn_configure(
- OPTIONS_RELEASE "${OPTIONS_REL}"
- )
-
- +set(TARGET_MODULES client client:common util third_party/mini_chromium/mini_chromium/base handler handler:common util:net tools:tool_support compat minidump:format minidump snapshot:context snapshot)
- +if(VCPKG_TARGET_IS_WINDOWS)
- + list(APPEND TARGET_MODULES third_party/getopt third_party/zlib)
- +endif()
- +
- vcpkg_gn_install(
- SOURCE_PATH "${SOURCE_PATH}"
- - TARGETS client client:common util third_party/mini_chromium/mini_chromium/base handler:crashpad_handler
- + TARGETS ${TARGET_MODULES}
- )
-
- message(STATUS "Installing headers...")
- @@ -138,9 +127,17 @@ function(install_headers DIR)
- file(COPY "${DIR}" DESTINATION "${PACKAGES_INCLUDE_DIR}" FILES_MATCHING PATTERN "*.h")
- endfunction()
- install_headers("${SOURCE_PATH}/client")
- +install_headers("${SOURCE_PATH}/compat")
- +install_headers("${SOURCE_PATH}/handler")
- +install_headers("${SOURCE_PATH}/minidump")
- +install_headers("${SOURCE_PATH}/snapshot")
- +install_headers("${SOURCE_PATH}/third_party/mini_chromium/mini_chromium")
- +install_headers("${SOURCE_PATH}/tools")
- install_headers("${SOURCE_PATH}/util")
- -install_headers("${SOURCE_PATH}/third_party/mini_chromium/mini_chromium/base")
- -install_headers("${SOURCE_PATH}/third_party/mini_chromium/mini_chromium/build")
- +if(VCPKG_TARGET_IS_WINDOWS)
- + install_headers("${SOURCE_PATH}/third_party/getopt")
- + install_headers("${SOURCE_PATH}/third_party/zlib/zlib")
- +endif()
-
- file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen/build/chromeos_buildflags.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}/build")
- file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen/build/chromeos_buildflags.h.flags" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}/build")
- @@ -152,18 +149,6 @@ if(VCPKG_TARGET_IS_OSX)
- file(COPY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/obj/util/libmig_output.a" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
- endif()
-
- -vcpkg_copy_tools(
- - TOOL_NAMES crashpad_handler
- - SEARCH_DIR "${CURRENT_PACKAGES_DIR}/tools")
- -
- -if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_MINGW)
- - file(CHMOD "${CURRENT_PACKAGES_DIR}/tools/crashpad_handler" FILE_PERMISSIONS
- - OWNER_READ OWNER_WRITE OWNER_EXECUTE
- - GROUP_READ GROUP_EXECUTE
- - WORLD_READ WORLD_EXECUTE
- - )
- -endif()
- -
- # remove empty directories
- file(REMOVE_RECURSE
- "${PACKAGES_INCLUDE_DIR}/util/net/testdata"
- diff --git a/ports/crashpad/vcpkg.json b/ports/crashpad/vcpkg.json
- index c2e9cd5..a0d7bcf 100644
- --- a/ports/crashpad/vcpkg.json
- +++ b/ports/crashpad/vcpkg.json
- @@ -27,7 +27,6 @@
- {
- "name": "vcpkg-tool-gn",
- "host": true
- - },
- - "zlib"
- + }
- ]
- }
|