diff options
author | Thanos Doukoudakis <thanos.doukoudakis@isode.com> | 2017-10-16 11:53:42 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2017-10-19 09:22:57 (GMT) |
commit | eb07238e9c1a09a640dae06e8a433d7dba77f490 (patch) | |
tree | 51b618bbdf933bcca2b8deb915e131c48d80d5f7 /3rdParty/Breakpad/src/common/mac/macho_walker.cc | |
parent | 80ef26c165a08d5251d7ee56e0bd07b86fc82f55 (diff) | |
download | swift-eb07238e9c1a09a640dae06e8a433d7dba77f490.zip swift-eb07238e9c1a09a640dae06e8a433d7dba77f490.tar.bz2 |
Upgrade Breakpad to latest
This commit will upgrade breakpad to version 1.0.86
(I9957f27cd134f862b9831e4b1d90f8a014eb37b6) from
https://chromium.googlesource.com/breakpad/breakpad
Added a script(BreakpadSwiftCleanup.sh) that remove files from Breakpad's
repository that are not used by Swift.
This commit also re-applies the changes that were introduced in commit
7f0fe603be200c09c74cf9cc295a972f3c3dbdfd, that change the minidump
filename format to include version and date
Test-Information:
https://travis-ci.org/google/breakpad/builds/283789304
https://ci.appveyor.com/project/vapier/breakpad/build/job/1bu73ysmcfpwg9e4
Tested by adding some code that forces a crash to the client on Windows 10
with VS2015. Verified the name and contents of the generated crash dump.
Change-Id: Ied9e74088e43137845edc09d070c2c27494aeade
Diffstat (limited to '3rdParty/Breakpad/src/common/mac/macho_walker.cc')
-rw-r--r-- | 3rdParty/Breakpad/src/common/mac/macho_walker.cc | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/3rdParty/Breakpad/src/common/mac/macho_walker.cc b/3rdParty/Breakpad/src/common/mac/macho_walker.cc index 92da7b1..1acd866 100644 --- a/3rdParty/Breakpad/src/common/mac/macho_walker.cc +++ b/3rdParty/Breakpad/src/common/mac/macho_walker.cc @@ -35,11 +35,9 @@ -extern "C" { // necessary for Leopard - #include <assert.h> - #include <fcntl.h> - #include <mach-o/arch.h> - #include <mach-o/loader.h> - #include <mach-o/swap.h> - #include <string.h> - #include <unistd.h> -} +#include <assert.h> +#include <fcntl.h> +#include <mach-o/arch.h> +#include <mach-o/fat.h> +#include <mach-o/loader.h> +#include <string.h> +#include <unistd.h> @@ -53,3 +51,3 @@ MachoWalker::MachoWalker(const char *path, LoadCommandCallback callback, void *context) - : file_(0), + : file_(-1), memory_(NULL), @@ -66,3 +64,3 @@ MachoWalker::MachoWalker(void *memory, size_t size, LoadCommandCallback callback, void *context) - : file_(0), + : file_(-1), memory_(memory), @@ -81,4 +79,6 @@ MachoWalker::~MachoWalker() { -int MachoWalker::ValidateCPUType(int cpu_type) { - // If the user didn't specify, use the local architecture. +bool MachoWalker::WalkHeader(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype) { + cpu_type_t valid_cpu_type = cpu_type; + cpu_subtype_t valid_cpu_subtype = cpu_subtype; + // if |cpu_type| is 0, use the native cpu type. if (cpu_type == 0) { @@ -86,12 +86,7 @@ int MachoWalker::ValidateCPUType(int cpu_type) { assert(arch); - cpu_type = arch->cputype; + valid_cpu_type = arch->cputype; + valid_cpu_subtype = CPU_SUBTYPE_MULTIPLE; } - - return cpu_type; -} - -bool MachoWalker::WalkHeader(int cpu_type) { - int valid_cpu_type = ValidateCPUType(cpu_type); off_t offset; - if (FindHeader(valid_cpu_type, offset)) { + if (FindHeader(valid_cpu_type, valid_cpu_subtype, offset)) { if (cpu_type & CPU_ARCH_ABI64) @@ -113,3 +108,3 @@ bool MachoWalker::ReadBytes(void *buffer, size_t size, off_t offset) { return false; - size = memory_size_ - offset; + size = memory_size_ - static_cast<size_t>(offset); result = false; @@ -133,4 +128,5 @@ bool MachoWalker::CurrentHeader(struct mach_header_64 *header, off_t *offset) { -bool MachoWalker::FindHeader(int cpu_type, off_t &offset) { - int valid_cpu_type = ValidateCPUType(cpu_type); +bool MachoWalker::FindHeader(cpu_type_t cpu_type, + cpu_subtype_t cpu_subtype, + off_t &offset) { // Read the magic bytes that's common amongst all mach-o files @@ -155,4 +151,4 @@ bool MachoWalker::FindHeader(int cpu_type, off_t &offset) { // header - cpu_type_t header_cpu_type; - if (!ReadBytes(&header_cpu_type, sizeof(header_cpu_type), offset)) + struct mach_header header; + if (!ReadBytes(&header, sizeof(header), 0)) return false; @@ -160,6 +156,9 @@ bool MachoWalker::FindHeader(int cpu_type, off_t &offset) { if (magic == MH_CIGAM || magic == MH_CIGAM_64) - header_cpu_type = ByteSwap(header_cpu_type); + breakpad_swap_mach_header(&header); - if (valid_cpu_type != header_cpu_type) + if (cpu_type != header.cputype || + (cpu_subtype != CPU_SUBTYPE_MULTIPLE && + cpu_subtype != header.cpusubtype)) { return false; + } @@ -175,3 +174,3 @@ bool MachoWalker::FindHeader(int cpu_type, off_t &offset) { if (NXHostByteOrder() != NX_BigEndian) - swap_fat_header(&fat, NXHostByteOrder()); + breakpad_swap_fat_header(&fat); @@ -186,5 +185,7 @@ bool MachoWalker::FindHeader(int cpu_type, off_t &offset) { if (NXHostByteOrder() != NX_BigEndian) - swap_fat_arch(&arch, 1, NXHostByteOrder()); + breakpad_swap_fat_arch(&arch, 1); - if (arch.cputype == valid_cpu_type) { + if (arch.cputype == cpu_type && + (cpu_subtype == CPU_SUBTYPE_MULTIPLE || + arch.cpusubtype == cpu_subtype)) { offset = arch.offset; @@ -207,3 +208,3 @@ bool MachoWalker::WalkHeaderAtOffset(off_t offset) { if (swap) - swap_mach_header(&header, NXHostByteOrder()); + breakpad_swap_mach_header(&header); @@ -233,3 +234,3 @@ bool MachoWalker::WalkHeader64AtOffset(off_t offset) { if (swap) - breakpad_swap_mach_header_64(&header, NXHostByteOrder()); + breakpad_swap_mach_header_64(&header); @@ -254,3 +255,3 @@ bool MachoWalker::WalkHeaderCore(off_t offset, uint32_t number_of_commands, if (swap) - swap_load_command(&cmd, NXHostByteOrder()); + breakpad_swap_load_command(&cmd); |