windows breakpad

This commit is contained in:
Green Sky 2024-11-12 16:23:02 +01:00
parent 3fbbf80e8c
commit 1cd1390901
No known key found for this signature in database
4 changed files with 67 additions and 14 deletions

View File

@ -166,7 +166,7 @@ jobs:
#- uses: ilammy/setup-nasm@v1 #- uses: ilammy/setup-nasm@v1
- name: Configure CMake - name: Configure CMake
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDLIMAGE_VENDORED=ON -DSDLIMAGE_DEPS_SHARED=ON -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe -DTOMATO_TOX_AV=ON run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDLIMAGE_VENDORED=ON -DSDLIMAGE_DEPS_SHARED=ON -DSDLIMAGE_JXL=OFF -DSDLIMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe -DTOMATO_BREAKPAD=ON -DTOMATO_TOX_AV=ON
- name: Build - name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tomato run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tomato

View File

@ -39,7 +39,6 @@ if (NOT TARGET breakpad_client)
if(NOT breakpad_POPULATED) if(NOT breakpad_POPULATED)
FetchContent_Populate(breakpad) FetchContent_Populate(breakpad)
enable_language(ASM)
add_library(breakpad_common STATIC add_library(breakpad_common STATIC
${breakpad_SOURCE_DIR}/src/common/convert_UTF.h ${breakpad_SOURCE_DIR}/src/common/convert_UTF.h
${breakpad_SOURCE_DIR}/src/common/convert_UTF.cc ${breakpad_SOURCE_DIR}/src/common/convert_UTF.cc
@ -51,7 +50,10 @@ if (NOT TARGET breakpad_client)
target_include_directories(breakpad_common PUBLIC "${breakpad_SOURCE_DIR}/src") target_include_directories(breakpad_common PUBLIC "${breakpad_SOURCE_DIR}/src")
if (WIN32) if (WIN32)
# TODO: common target_sources(breakpad_common PUBLIC
${breakpad_SOURCE_DIR}/src/common/windows/guid_string.h
${breakpad_SOURCE_DIR}/src/common/windows/guid_string.cc
)
add_library(breakpad_client STATIC) add_library(breakpad_client STATIC)
target_sources(breakpad_client target_sources(breakpad_client
@ -59,11 +61,16 @@ if (NOT TARGET breakpad_client)
${breakpad_SOURCE_DIR}/src/client/windows/handler/exception_handler.h ${breakpad_SOURCE_DIR}/src/client/windows/handler/exception_handler.h
${breakpad_SOURCE_DIR}/src/client/windows/common/ipc_protocol.h ${breakpad_SOURCE_DIR}/src/client/windows/common/ipc_protocol.h
${breakpad_SOURCE_DIR}/src/client/windows/crash_generation/crash_generation_client.h ${breakpad_SOURCE_DIR}/src/client/windows/crash_generation/crash_generation_client.h
${breakpad_SOURCE_DIR}/src/client/windows/crash_generation/minidump_generator.h
PRIVATE PRIVATE
${breakpad_SOURCE_DIR}/src/client/windows/handler/exception_handler.cc ${breakpad_SOURCE_DIR}/src/client/windows/handler/exception_handler.cc
${breakpad_SOURCE_DIR}/src/client/windows/crash_generation/crash_generation_client.cc
${breakpad_SOURCE_DIR}/src/client/windows/crash_generation/minidump_generator.cc
) )
target_compile_definitions(breakpad_client PRIVATE UNICODE)
#elseif() # TODO: mac, ios and any other platform #elseif() # TODO: mac, ios and any other platform
else() # assume linux else() # assume linux
enable_language(ASM) # mostly to document, needs to be set in parent
target_sources(breakpad_common PUBLIC target_sources(breakpad_common PUBLIC
${breakpad_SOURCE_DIR}/src/common/linux/elf_core_dump.cc ${breakpad_SOURCE_DIR}/src/common/linux/elf_core_dump.cc
${breakpad_SOURCE_DIR}/src/common/linux/elfutils.h ${breakpad_SOURCE_DIR}/src/common/linux/elfutils.h
@ -115,11 +122,13 @@ if (NOT TARGET breakpad_client)
endif() endif()
if (TARGET breakpad_client) if (TARGET breakpad_client)
if (NOT WIN32)
target_sources(breakpad_client PUBLIC target_sources(breakpad_client PUBLIC
${breakpad_SOURCE_DIR}/src/client/minidump_file_writer-inl.h ${breakpad_SOURCE_DIR}/src/client/minidump_file_writer-inl.h
${breakpad_SOURCE_DIR}/src/client/minidump_file_writer.h ${breakpad_SOURCE_DIR}/src/client/minidump_file_writer.h
${breakpad_SOURCE_DIR}/src/client/minidump_file_writer.cc ${breakpad_SOURCE_DIR}/src/client/minidump_file_writer.cc
) )
endif()
target_link_libraries(breakpad_client PUBLIC breakpad_common) target_link_libraries(breakpad_client PUBLIC breakpad_common)
target_include_directories(breakpad_client PUBLIC "${breakpad_SOURCE_DIR}/src") target_include_directories(breakpad_client PUBLIC "${breakpad_SOURCE_DIR}/src")
target_compile_features(breakpad_client PUBLIC cxx_std_11) target_compile_features(breakpad_client PUBLIC cxx_std_11)

View File

@ -1,10 +1,38 @@
#include "./breakpad_client.hpp" #include "./breakpad_client.hpp"
// if linux #ifdef WIN32
bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void*, bool succeeded) { bool dumpCallback(const wchar_t* dump_path, const wchar_t* minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool succeeded) {
fprintf(stderr, "Crash detected, MiniDump written to: %s\n", descriptor.path()); //TCHAR* text = new TCHAR[kMaximumLineLength];
//text[0] = _T('\0');
//int result = swprintf_s(text,
// kMaximumLineLength,
// TEXT("Dump generation request %s\r\n"),
// succeeded ? TEXT("succeeded") : TEXT("failed"));
//if (result == -1) {
// delete [] text;
//}
//QueueUserWorkItem(AppendTextWorker, text, WT_EXECUTEDEFAULT);
if (succeeded) {
fprintf(stderr, "Crash detected, MiniDump written to: %ls\n", dump_path);
} else {
fprintf(stderr, "Crash detected, failed to write MiniDump. (path: %ls)\n", dump_path);
}
return succeeded; return succeeded;
} }
// endif linux #else
// linux
bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void*, bool succeeded) {
if (succeeded) {
fprintf(stderr, "Crash detected, MiniDump written to: %s\n", descriptor.path());
} else {
fprintf(stderr, "Crash detected, failed to write MiniDump. (path: %s)\n", descriptor.path());
}
return succeeded;
}
#endif

View File

@ -1,6 +1,22 @@
#pragma once #pragma once
// TODO: if linux/android // TODO: require msvc
#ifdef WIN32
#include <client/windows/handler/exception_handler.h>
bool dumpCallback(const wchar_t* dump_path, const wchar_t* minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool succeeded);
#define BREAKPAD_MAIN_INIT \
google_breakpad::ExceptionHandler bp_eh{ \
L".\\", /* path */ \
nullptr, \
dumpCallback, \
nullptr, \
google_breakpad::ExceptionHandler::HANDLER_ALL, \
}
#else
#include <client/linux/handler/exception_handler.h> #include <client/linux/handler/exception_handler.h>
@ -19,4 +35,4 @@ bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void*,
-1, /* dump in-process (OOP would be better) */ \ -1, /* dump in-process (OOP would be better) */ \
} }
// endif linux #endif