Skip to content

Commit

Permalink
Update breakpad to the latest version to fix symbol generation
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Sep 7, 2024
1 parent a2ced6e commit 3431f30
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 24 deletions.
3 changes: 0 additions & 3 deletions breakpad-9bcfabca.zip

This file was deleted.

3 changes: 3 additions & 0 deletions breakpad-e92bea3.zip
Git LFS file not shown
29 changes: 11 additions & 18 deletions build_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ def build_breakpad(build_dir, include_dir, lib_dir, licenses_dir):

print("Uncompressing breakpad")
breakpad_dir = build_dir.joinpath("breakpad")
shutil.unpack_archive("breakpad-9bcfabca.zip", str(breakpad_dir))

gyp_dir = build_dir.joinpath("gyp_dir")
shutil.unpack_archive("gyp-e87d37d.tar.gz", str(gyp_dir))
shutil.unpack_archive("breakpad-e92bea3.zip", str(breakpad_dir))

src_dir = breakpad_dir.joinpath("src")

def build(build_type):
def build(build_type, copy_binaries):
print(f"Building with CMAKE_BUILD_TYPE={build_type}")
cmake_build_dir = build_dir.joinpath("crash_reporting_" + build_type.lower())
shutil.copytree("crash_reporting", cmake_build_dir)
Expand All @@ -152,23 +149,19 @@ def build(build_type):
for f in cmake_build_dir.glob("*.pdb"):
shutil.copy(f, lib_dir)

build("DEBUG")
build("RELWITHDEBINFO")
# Only copy binaries for release
if copy_binaries:
bin_dir = build_dir.joinpath("dependencies/bin")
bin_dir.mkdir(exist_ok=True)
for f in cmake_build_dir.glob("*.exe"):
shutil.copy(f, bin_dir)

build("DEBUG", False)
build("RELWITHDEBINFO", True)

shutil.copy(breakpad_dir.joinpath("LICENSE"), licenses_dir.joinpath("breakpad.txt"))
shutil.copy("crash_reporting/crash_reporting.h", include_dir)

# we rebuild the binaries to make use of the DIA SDK included in our version of visual studio
tools_dir = breakpad_dir.joinpath("src/tools/windows")
subprocess.run([str(gyp_dir.joinpath("gyp")), "tools_windows.gyp"], shell=True, check=True, cwd=str(tools_dir))
# We are not using check=True here because this build will fail currently due to broken googletest dependencies
subprocess.run(["devenv", "tools_windows.sln", "/build", "Release|Win32"], check=False, cwd=str(tools_dir))

bin_dir = build_dir.joinpath("dependencies/bin")
bin_dir.mkdir(exist_ok=True)
for bin_file in breakpad_dir.glob("src/tools/windows/binaries/*.exe"):
shutil.copy(bin_file, bin_dir)

def build_minhook(build_dir, include_dir, lib_dir, licenses_dir):
print("Building minhook")
shutil.unpack_archive("minhook-1.3.3.tar.gz", str(build_dir))
Expand Down
18 changes: 18 additions & 0 deletions crash_reporting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
project(crash_reporting)
cmake_minimum_required(VERSION 3.9)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

set(BREAKPAD_DIR breakpad/src CACHE PATH "Path to breakpad source directory")

set(BREAKPAD_SOURCES
Expand All @@ -23,3 +25,19 @@ add_library(crash_reporting STATIC ${SOURCES} ${BREAKPAD_SOURCES})
set_target_properties(crash_reporting PROPERTIES COMPILE_PDB_NAME crash_reporting COMPILE_PDB_NAME_DEBUG crash_reporting_d)
add_definitions(-DUNICODE)
include_directories(${BREAKPAD_DIR})

find_package(DiaSDK REQUIRED) # Used for constants and declarations.

set(DUMP_SYMS_SRC
${BREAKPAD_DIR}/tools/windows/dump_syms/dump_syms.cc
${BREAKPAD_DIR}/common/windows/dia_util.cc
${BREAKPAD_DIR}/common/windows/guid_string.cc
${BREAKPAD_DIR}/common/windows/omap.cc
${BREAKPAD_DIR}/common/windows/pdb_source_line_writer.cc
${BREAKPAD_DIR}/common/windows/pe_source_line_writer.cc
${BREAKPAD_DIR}/common/windows/string_utils.cc
${BREAKPAD_DIR}/common/windows/pe_util.cc
)
add_executable(dump_syms ${DUMP_SYMS_SRC})
target_include_directories(dump_syms PRIVATE ${DIASDK_INCLUDE_DIRS})
target_link_libraries(dump_syms PRIVATE ${LIBRARIES} ${DIASDK_LIBRARIES} Imagehlp.lib Dbghelp.lib)
50 changes: 50 additions & 0 deletions crash_reporting/FindDiaSDK.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# https://raw.githubusercontent.com/microsoft/DirectXShaderCompiler/main/cmake/modules/FindDiaSDK.cmake
# Find the DIA SDK path.
# It will typically look something like this:
# C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\include

# CMAKE_GENERATOR_INSTANCE has the location of Visual Studio used
# i.e. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community
set(VS_PATH ${CMAKE_GENERATOR_INSTANCE})
get_filename_component(VS_DIA_INC_PATH "${VS_PATH}/DIA SDK/include" ABSOLUTE CACHE)

# Starting in VS 15.2, vswhere is included.
# Unclear what the right component to search for is, might be Microsoft.VisualStudio.Component.VC.DiagnosticTools
# (although the friendly name of that is C++ profiling tools). The toolset is the most likely target.
set(PROGRAMFILES_X86 "ProgramFiles(x86)")
execute_process(
COMMAND "$ENV{${PROGRAMFILES_X86}}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
OUTPUT_VARIABLE VSWHERE_LATEST
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

find_path(DIASDK_INCLUDE_DIR # Set variable DIASDK_INCLUDE_DIR
dia2.h # Find a path with dia2.h
HINTS "${VS_DIA_INC_PATH}"
HINTS "${VSWHERE_LATEST}/DIA SDK/include"
HINTS "${MSVC_DIA_SDK_DIR}/include"
DOC "path to DIA SDK header files"
)


if ((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x64"))
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib/amd64 )
elseif ((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM"))
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib/arm )
elseif ((CMAKE_GENERATOR_PLATFORM MATCHES "ARM64.*") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARM64.*"))
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib/arm64 )
else ((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x64"))
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib )
endif((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x64"))

set(DIASDK_LIBRARIES ${DIASDK_GUIDS_LIBRARY})
set(DIASDK_INCLUDE_DIRS ${DIASDK_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set DIASDK_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(DiaSDK DEFAULT_MSG
DIASDK_LIBRARIES DIASDK_INCLUDE_DIR)

mark_as_advanced(DIASDK_INCLUDE_DIRS DIASDK_LIBRARIES)
3 changes: 0 additions & 3 deletions gyp-e87d37d.tar.gz

This file was deleted.

0 comments on commit 3431f30

Please sign in to comment.