Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@
/third_party/linux/sysroot
/third_party/lss/lss
/third_party/gyp/gyp
/third_party/mini_chromium/mini_chromium
/third_party/zlib/zlib
/xcodebuild
tags
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "third_party/mini_chromium/mini_chromium"]
path = third_party/mini_chromium/mini_chromium
url = https://chromium.googlesource.com/chromium/mini_chromium
[submodule "third_party/zlib/zlib"]
path = third_party/zlib/zlib
url = https://chromium.googlesource.com/chromium/src/third_party/zlib
78 changes: 78 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
cmake_minimum_required(VERSION 3.0)
project(crashpad LANGUAGES C CXX)

if(WIN32)
enable_language(ASM_MASM)
else()
enable_language(ASM)
endif()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(LINUX TRUE)
endif()

include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/mini_chromium/mini_chromium")

# These should really be in `compat`, but we want them for the whole project
if(APPLE)
include_directories(SYSTEM "compat/mac")
else()
include_directories(PUBLIC "compat/non_mac")
endif()

if(LINUX OR ANDROID)
include_directories(SYSTEM "compat/linux")
endif()
if(ANDROID)
include_directories(SYSTEM "compat/android")
endif()

if(WIN32)
include_directories(SYSTEM "compat/win")
else()
include_directories(PUBLIC "compat/non_win")
endif()

if(NOT LINUX AND NOT ANDROID)
include_directories(SYSTEM "compat/non_elf")
endif()

if(WIN32)
add_definitions(
/DNOMINMAX
/DUNICODE
/DWIN32_LEAN_AND_MEAN
/D_CRT_SECURE_NO_WARNINGS
/D_HAS_EXCEPTIONS=0
/D_UNICODE
/FS
/W4
/WX
/Zi
/bigobj # Support larger number of sections in obj file.
/wd4100 # Unreferenced formal parameter.
/wd4127 # Conditional expression is constant.
/wd4324 # Structure was padded due to alignment specifier.
/wd4351 # New behavior: elements of array will be default initialized.
/wd4577 # 'noexcept' used with no exception handling mode specified.
/wd4996 # 'X' was declared deprecated.
)
endif()

add_subdirectory(client)
add_subdirectory(compat)
add_subdirectory(handler)
add_subdirectory(minidump)
add_subdirectory(snapshot)
add_subdirectory(tools)
add_subdirectory(util)
add_subdirectory(third_party/mini_chromium)

if(WIN32)
add_subdirectory(third_party/getopt)
add_subdirectory(third_party/zlib)
endif()
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ PATH := $(PWD)/../depot_tools:$(PATH)
all:
echo 'Nothing to do' && exit 1

build:
build-with-gn:
gn gen out/Default
ninja -C out/Default
.PHONY: build
.PHONY: build-with-gn

update:
build-with-cmake:
mkdir -p cmakebuild
cd cmakebuild; cmake ..
cmake --build cmakebuild --parallel
.PHONY: build-with-cmake

update-with-gclient:
gclient sync
.PHONY: update-with-gclient

example:
example: build-with-gn
g++ -g \
-o example example.cpp \
-I. -I./third_party/mini_chromium/mini_chromium \
Expand Down
54 changes: 54 additions & 0 deletions README.getsentry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Sentry Modifications

- File attachments support for MacOS and Windows. Based on changes made in
https://github.com/Youw/crashpad/, distributed with Apache 2.0 License.
- Add `throws` declaration to `memfd_create` for compatibility with different
libc versions.
- Build System Changes Listed Below

# Build System Changes

In order to minimize external dependencies, and to better integrate with
Comment thread
Swatinem marked this conversation as resolved.
`sentry-native`, this fork replaced usage of `depo_tools` with explicit
submodules, and added CMake files for building.

Both submodules and CMake files currently only support building on macOS and
Windows, and do only export the necessary libraries and executables to
integrate the crashpad client.

When updating this fork, make sure to keep the files in sync, as explained
below.

## Submodules

For macOS and Windows support, only `third_party/mini_chromium` and
`third_party/zlib` are needed.

The specific submodule commit hashes can be found in the `./DEPS` file.

## CMake Integration

To allow building crashpad with CMake, the following CMake files were created
by manually translating the `BUILD.gn` files in the same folders (and following
included files):

- `./CMakeLists.txt`
- `./client/CMakeLists.txt`
- `./compat/CMakeLists.txt`
- `./handler/CMakeLists.txt`
- `./minidump/CMakeLists.txt`
- `./snapshot/CMakeLists.txt`
- `./third_party/getopt/CMakeLists.txt`
- `./third_party/mini_chromium/CMakeLists.txt`
- `./third_party/lib/CMakeLists.txt`
- `./tools/CMakeLists.txt`
- `./util/CMakeLists.txt`

The important thing here is to keep the list of source files in sync when
updating.

# How To Update

- Bump the submodules to the commit hashes specified in `./DEPS`
- Go through the changes in `BUILD.gn` files, and apply them to the
corresponding `CMakeLists.txt`. See the list above.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ https://chromium.googlesource.com/crashpad/crashpad.

## Sentry modifications

File attachments support for MacOS and Windows.

Based on changes made in https://github.com/Youw/crashpad/, distributed with Apache 2.0 License.
See [README.getsentry.md](README.getsentry.md) for more information on the
changes, and on maintaining the fork.

Generating patch:

Expand Down
58 changes: 58 additions & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
list(APPEND CLIENT_SOURCES
annotation.cc
annotation.h
annotation_list.cc
annotation_list.h
crash_report_database.cc
crash_report_database.h
crashpad_client.h
crashpad_info.cc
crashpad_info.h
prune_crash_reports.cc
prune_crash_reports.h
settings.cc
settings.h
simple_address_range_bag.h
simple_string_dictionary.h
simulate_crash.h
)

if(APPLE)
list(APPEND CLIENT_SOURCES
crash_report_database_mac.mm
crashpad_client_mac.cc
simulate_crash_mac.cc
simulate_crash_mac.h
)
endif()

if(LINUX OR ANDROID)
list(APPEND CLIENT_SOURCES
crashpad_client_linux.cc
simulate_crash_linux.h
client_argv_handling.cc
client_argv_handling.h
crashpad_info_note.S
crash_report_database_generic.cc
)
endif()

if(WIN32)
list(APPEND CLIENT_SOURCES
crash_report_database_win.cc
crashpad_client_win.cc
simulate_crash_win.h
)
endif()

add_library(crashpad_client STATIC ${CLIENT_SOURCES})
target_link_libraries(crashpad_client
crashpad_compat
crashpad_util
mini_chromium
)

if(WIN32)
target_link_libraries(crashpad_client "rpcrt4")
target_compile_options(crashpad_client PUBLIC "/wd4201")
endif()
89 changes: 89 additions & 0 deletions compat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
list(APPEND COMPAT_SOURCES "")

if(APPLE)
list(APPEND COMPAT_SOURCES
mac/AvailabilityMacros.h
mac/kern/exc_resource.h
mac/mach-o/loader.h
mac/mach/mach.h
mac/sys/resource.h
)
else()
list(APPEND COMPAT_SOURCES
non_mac/mach-o/loader.h
non_mac/mach/mach.h
non_mac/mach/machine.h
non_mac/mach/vm_prot.h
)
endif()

if(LINUX OR ANDROID)
list(APPEND COMPAT_SOURCES
linux/signal.h
linux/sys/mman.cc
linux/sys/mman.h
linux/sys/ptrace.h
linux/sys/user.h
)
endif()

if(ANDROID)
list(APPEND COMPAT_SOURCES
android/android/api-level.cc
android/android/api-level.h
android/dlfcn_internal.cc
android/dlfcn_internal.h
android/elf.h
android/linux/elf.h
android/linux/prctl.h
android/linux/ptrace.h
android/sched.h
android/sys/epoll.cc
android/sys/epoll.h
android/sys/mman.cc
android/sys/mman.h
android/sys/syscall.h
android/sys/user.h
)
endif()

if(WIN32)
list(APPEND COMPAT_SOURCES
win/getopt.h
win/strings.cc
win/strings.h
win/sys/types.h
win/time.cc
win/time.h
win/winbase.h
win/winnt.h
win/winternl.h
)
else()
list(APPEND COMPAT_SOURCES
non_win/dbghelp.h
non_win/minwinbase.h
non_win/timezoneapi.h
non_win/verrsrc.h
non_win/windows.h
non_win/winnt.h
)
endif()

if(NOT LINUX AND NOT ANDROID)
list(APPEND COMPAT_SOURCES
non_elf/elf.h
)
endif()

if(APPLE)
add_library(crashpad_compat INTERFACE)
list(TRANSFORM COMPAT_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
target_sources(crashpad_compat INTERFACE ${COMPAT_SOURCES})
else()
add_library(crashpad_compat STATIC ${COMPAT_SOURCES})
endif()

if(WIN32)
target_link_libraries(crashpad_compat getopt)
endif()
Loading