Skip to content

Commit

Permalink
STAFF-120395: add app relaunch on crash (#4)
Browse files Browse the repository at this point in the history
* STAFF-120395: add app relaunch on crash

* STAFF-120395: update to td version of crashpad

* STAFF-120395: add ability to pass argv to crashpad relaunch

* STAFF-120395: add ability to pass argv to crashpad relaunch 2

* STAFF-120395: update crashpad

* STAFF-120395: update crashpad

* STAFF-120395: fix relaunch annotation

* STAFF-120395: update crashpad

* STAFF-120395: update crashpad

* update crashpad

* update crashpad

* update crashpad
  • Loading branch information
nunomluz authored Apr 20, 2021
1 parent 93005cc commit 07b70bc
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
url = https://chromium.googlesource.com/linux-syscall-support
[submodule "external/crashpad"]
path = external/crashpad
url = https://github.com/getsentry/crashpad.git
branch = getsentry
url = https://github.com/mystaff/crashpad.git
branch = timedoctor
2 changes: 1 addition & 1 deletion external/breakpad
Submodule breakpad updated 42 files
+2 −0 .gitignore
+1 −1 DEPS
+48 −0 Makefile.am
+3,858 −2,726 Makefile.in
+3 −3 README.md
+93 −113 aclocal.m4
+132 −103 configure
+3 −2 configure.ac
+1 −1 default.xml
+39 −0 docs/linux_core_handler.md
+14 −7 docs/symbol_files.md
+3 −0 src/client/ios/exception_handler_no_mach.cc
+10 −0 src/client/linux/minidump_writer/linux_core_dumper.cc
+6 −0 src/common/dwarf/dwarf2enums.h
+180 −6 src/common/dwarf/dwarf2reader.cc
+19 −2 src/common/dwarf/dwarf2reader.h
+192 −60 src/common/dwarf/dwarf2reader_die_unittest.cc
+1 −1 src/common/dwarf/dwarf2reader_lineinfo_unittest.cc
+126 −0 src/common/dwarf/dwarf2reader_splitfunctions_unittest.cc
+11 −2 src/common/dwarf/dwarf2reader_test_common.h
+14 −7 src/common/dwarf_cu_to_module.cc
+10 −9 src/common/dwarf_cu_to_module_unittest.cc
+26 −2 src/common/linux/elf_core_dump.cc
+8 −0 src/common/linux/elf_core_dump.h
+6 −6 src/common/linux/elf_symbols_to_module_unittest.cc
+5 −0 src/common/module_unittest.cc
+6 −0 src/config.h.in
+2 −0 src/google_breakpad/processor/stackwalker.h
+1 −0 src/processor/microdump_processor.cc
+1 −1 src/processor/microdump_processor_unittest.cc
+14 −0 src/processor/minidump.cc
+1 −0 src/processor/minidump_processor.cc
+60 −9 src/processor/stackwalker.cc
+1 −0 src/processor/stackwalker_address_list_unittest.cc
+0 −5 src/processor/stackwalker_amd64.cc
+27 −0 src/processor/stackwalker_arm.cc
+5 −0 src/processor/stackwalker_arm.h
+1 −0 src/processor/stackwalker_mips64_unittest.cc
+1 −0 src/processor/stackwalker_mips_unittest.cc
+146 −0 src/tools/linux/core_handler/core_handler.cc
+57 −0 src/tools/linux/pid2md/pid2md.cc
+2 −2 src/tools/windows/dump_syms/dump_syms_unittest.cc
2 changes: 1 addition & 1 deletion external/crashpad
Submodule crashpad updated 63 files
+0 −1 .gitignore
+0 −13 BUILD.gn
+2 −2 DEPS
+5 −0 README.md
+8 −0 README.timedoctor.md
+0 −1 build/ios/setup_ios_gn.py
+2 −1 client/BUILD.gn
+2 −1 client/crashpad_client.h
+5 −4 client/crashpad_client_linux.cc
+1 −24 compat/BUILD.gn
+0 −13 compat/CMakeLists.txt
+4 −1 compat/linux/sys/user.h
+1 −0 handler/BUILD.gn
+6 −0 handler/CMakeLists.txt
+18 −14 handler/handler_main.cc
+3 −0 handler/linux/crash_report_exception_handler.cc
+3 −0 handler/mac/crash_report_exception_handler.cc
+170 −0 handler/relaunch_signal.cc
+13 −0 handler/relaunch_signal.h
+3 −0 handler/win/crash_report_exception_handler.cc
+0 −2 minidump/BUILD.gn
+18 −13 minidump/minidump_exception_writer_test.cc
+32 −33 minidump/minidump_handle_writer_test.cc
+20 −11 minidump/minidump_memory_info_writer_test.cc
+17 −10 minidump/minidump_misc_info_writer_test.cc
+56 −39 minidump/minidump_module_writer_test.cc
+15 −8 minidump/minidump_system_info_writer_test.cc
+28 −20 minidump/minidump_thread_writer_test.cc
+13 −5 minidump/test/minidump_memory_writer_test_util.cc
+2 −2 snapshot/BUILD.gn
+1 −1 snapshot/linux/debug_rendezvous.h
+39 −5 snapshot/linux/debug_rendezvous_test.cc
+11 −212 snapshot/linux/process_reader_linux_test.cc
+262 −0 snapshot/linux/test_modules.cc
+37 −0 snapshot/linux/test_modules.h
+1 −1 snapshot/minidump/process_snapshot_minidump.cc
+2 −0 snapshot/snapshot_test.gyp
+3 −0 test/fuchsia_crashpad_tests.cmx
+2 −2 third_party/edo/BUILD.gn
+0 −1 third_party/googletest/BUILD.gn
+1 −1 third_party/lss/README.crashpad
+13 −0 third_party/mini_chromium/BUILD.gn
+4 −0 third_party/mini_chromium/CMakeLists.txt
+13 −0 third_party/mini_chromium/build/chromeos_buildflags.h
+1 −1 third_party/mini_chromium/mini_chromium
+13 −1 third_party/zlib/CMakeLists.txt
+1 −2 util/BUILD.gn
+33 −2 util/CMakeLists.txt
+8 −6 util/file/file_io.cc
+35 −24 util/ios/exception_processor.mm
+12 −8 util/ios/exception_processor_test.mm
+2 −1 util/linux/initial_signal_dispositions.cc
+57 −53 util/linux/ptrace_broker.cc
+3 −10 util/linux/ptrace_broker.h
+29 −14 util/linux/scoped_ptrace_attach.cc
+18 −0 util/linux/scoped_ptrace_attach.h
+6 −1 util/mach/mig_gen.py
+1 −1 util/net/http_transport_socket.cc
+58 −13 util/posix/scoped_mmap.cc
+5 −1 util/posix/scoped_mmap.h
+1 −1 util/stdlib/aligned_allocator.h
+5 −25 util/stdlib/strlcpy.cc
+2 −16 util/stdlib/strlcpy_test.cc
2 changes: 1 addition & 1 deletion external/libunwindstack-ndk
Submodule libunwindstack-ndk updated 89 files
+55 −0 .github/workflows/build.yml
+2 −0 .gitignore
+269 −106 ArmExidx.cpp
+14 −2 ArmExidx.h
+80 −119 DexFile.cpp
+18 −15 DexFile.h
+36 −42 DexFiles.cpp
+81 −48 DwarfCfa.cpp
+19 −6 DwarfCfa.h
+81 −92 DwarfEhFrameWithHdr.cpp
+28 −20 DwarfEhFrameWithHdr.h
+1 −2 DwarfMemory.cpp
+1,449 −5 DwarfOp.cpp
+2 −1,344 DwarfOp.h
+376 −467 DwarfSection.cpp
+89 −57 Elf.cpp
+304 −202 ElfInterface.cpp
+26 −24 ElfInterfaceArm.cpp
+11 −8 ElfInterfaceArm.h
+99 −0 Global.cpp
+220 −0 JitDebug.cpp
+147 −0 LocalUnwinder.cpp
+2 −0 Log.cpp
+251 −51 MapInfo.cpp
+127 −168 Maps.cpp
+146 −18 Memory.cpp
+57 −0 MemoryBuffer.h
+51 −0 MemoryCache.h
+47 −0 MemoryFileAtOffset.h
+39 −0 MemoryLocal.h
+35 −0 MemoryMte.cpp
+60 −0 MemoryOffline.h
+43 −0 MemoryOfflineBuffer.h
+66 −0 MemoryRange.h
+46 −0 MemoryRemote.h
+59 −16 Regs.cpp
+7 −33 RegsArm.cpp
+57 −13 RegsArm64.cpp
+11 −10 RegsInfo.h
+6 −9 RegsX86.cpp
+9 −12 RegsX86_64.cpp
+96 −65 Symbols.cpp
+21 −19 Symbols.h
+102 −0 ThreadEntry.cpp
+78 −0 ThreadEntry.h
+182 −0 ThreadUnwinder.cpp
+476 −0 Unwinder.cpp
+3 −0 android-base/README.md
+42 −0 android-base/errno_restorer.h
+397 −0 android-base/file.cpp
+125 −0 android-base/file.h
+480 −0 android-base/logging.h
+146 −0 android-base/macros.h
+22 −0 android-base/off64_t.h
+136 −0 android-base/parseint.h
+139 −0 android-base/strings.cpp
+94 −0 android-base/strings.h
+30 −0 android-base/threads.h
+196 −28 android-base/unique_fd.h
+104 −0 android-base/utf8.h
+75 −18 cmake/CMakeLists.txt
+12 −0 compat/string.h
+44 −0 include/unwindstack/Arch.h
+9 −8 include/unwindstack/DexFiles.h
+1 −0 include/unwindstack/DwarfLocation.h
+3 −3 include/unwindstack/DwarfMemory.h
+46 −41 include/unwindstack/DwarfSection.h
+1 −0 include/unwindstack/DwarfStructs.h
+18 −21 include/unwindstack/Elf.h
+81 −83 include/unwindstack/ElfInterface.h
+46 −7 include/unwindstack/Error.h
+63 −0 include/unwindstack/Global.h
+71 −0 include/unwindstack/JitDebug.h
+86 −0 include/unwindstack/LocalUnwinder.h
+1 −0 include/unwindstack/Log.h
+8 −0 include/unwindstack/MachineArm64.h
+68 −15 include/unwindstack/MapInfo.h
+27 −5 include/unwindstack/Maps.h
+10 −117 include/unwindstack/Memory.h
+12 −6 include/unwindstack/Regs.h
+3 −3 include/unwindstack/RegsArm.h
+18 −3 include/unwindstack/RegsArm64.h
+13 −14 include/unwindstack/RegsGetLocal.h
+3 −3 include/unwindstack/RegsX86.h
+3 −3 include/unwindstack/RegsX86_64.h
+207 −0 include/unwindstack/Unwinder.h
+3 −0 procinfo/README.md
+124 −0 procinfo/process.h
+311 −0 procinfo/process_map.h
2 changes: 1 addition & 1 deletion external/third_party/lss
Submodule lss updated from 171a36 to 29f7c7
13 changes: 13 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,19 @@ SENTRY_API void sentry_options_set_release(
*/
SENTRY_API const char *sentry_options_get_release(const sentry_options_t *opts);

/**
* Sets the args passed to the process when relaunching after a crash.
* Args must be in 1 single string separated by |
*/
SENTRY_API void sentry_options_set_relaunch_argv(
sentry_options_t *opts, const char *relaunch_argv);

/**
* Gets the args passsed to the process when relaunching after a crash.
*/
SENTRY_API const char *sentry_options_get_relaunch_argv(
const sentry_options_t *opts);

/**
* Sets the environment.
*/
Expand Down
24 changes: 24 additions & 0 deletions src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ extern "C" {
# pragma warning(pop)
#endif

#if defined(SENTRY_PLATFORM_WINDOWS)
# include <process.h>
static int
td__getpid()
{
return _getpid();
}
#else
# include <unistd.h>
static int
td__getpid()
{
return getpid();
}
#endif

extern "C" {

#ifdef SENTRY_PLATFORM_LINUX
Expand Down Expand Up @@ -192,6 +208,14 @@ sentry__crashpad_backend_startup(
std::map<std::string, std::string> annotations;
std::vector<base::FilePath> attachments;

sentry_path_t *current_exe = sentry__path_current_exe();
if (current_exe && options->relaunch_argv) {
annotations["__td-crashed-pid"] = std::to_string(td__getpid());
annotations["__td-relaunch-path"] = std::string(current_exe->path);
annotations["__td-relaunch-argv"] = std::string(options->relaunch_argv);
sentry__path_free(current_exe);
}

// register attachments
for (sentry_attachment_t *attachment = options->attachments; attachment;
attachment = attachment->next) {
Expand Down
15 changes: 15 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ sentry_options_free(sentry_options_t *opts)
}
sentry__dsn_decref(opts->dsn);
sentry_free(opts->release);
sentry_free(opts->relaunch_argv);
sentry_free(opts->environment);
sentry_free(opts->dist);
sentry_free(opts->http_proxy);
Expand Down Expand Up @@ -155,6 +156,20 @@ sentry_options_get_release(const sentry_options_t *opts)
return opts->release;
}

void
sentry_options_set_relaunch_argv(
sentry_options_t *opts, const char *relaunch_argv)
{
sentry_free(opts->relaunch_argv);
opts->relaunch_argv = sentry__string_clone(relaunch_argv);
}

const char *
sentry_options_get_relaunch_argv(const sentry_options_t *opts)
{
return opts->relaunch_argv;
}

void
sentry_options_set_environment(sentry_options_t *opts, const char *environment)
{
Expand Down
1 change: 1 addition & 0 deletions src/sentry_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef struct sentry_options_s {
char *http_proxy;
char *ca_certs;
char *transport_thread_name;
char *relaunch_argv;
sentry_path_t *database_path;
sentry_path_t *handler_path;
sentry_logger_t logger;
Expand Down

0 comments on commit 07b70bc

Please sign in to comment.