diff options
35 files changed, 780 insertions, 398 deletions
diff --git a/build/secondary/third_party/crashpad/crashpad/snapshot/BUILD.gn b/build/secondary/third_party/crashpad/crashpad/snapshot/BUILD.gn index 0e77d40..a2eeafa 100644 --- a/build/secondary/third_party/crashpad/crashpad/snapshot/BUILD.gn +++ b/build/secondary/third_party/crashpad/crashpad/snapshot/BUILD.gn @@ -18,6 +18,8 @@ source_set("snapshot") { } sources = [ + "capture_memory.cc", + "capture_memory.h", "cpu_architecture.h", "cpu_context.cc", "cpu_context.h", @@ -77,8 +79,8 @@ source_set("snapshot") { "process_snapshot.h", "system_snapshot.h", "thread_snapshot.h", - "win/capture_context_memory.cc", - "win/capture_context_memory.h", + "win/capture_memory_delegate_win.cc", + "win/capture_memory_delegate_win.h", "win/cpu_context_win.cc", "win/cpu_context_win.h", "win/exception_snapshot_win.cc", diff --git a/third_party/crashpad/README.chromium b/third_party/crashpad/README.chromium index b681fe1..a6d230a 100644 --- a/third_party/crashpad/README.chromium +++ b/third_party/crashpad/README.chromium @@ -2,7 +2,7 @@ Name: Crashpad Short Name: crashpad URL: https://crashpad.chromium.org/ Version: unknown -Revision: 4794225f22583a08732cb9ad4356106013a220f3 +Revision: a392a2c3ed480cd80b2608ca9349a4e28ad7a6dd License: Apache 2.0 License File: crashpad/LICENSE Security Critical: yes diff --git a/third_party/crashpad/crashpad/DEPS b/third_party/crashpad/crashpad/DEPS index 902915c..829ae27 100644 --- a/third_party/crashpad/crashpad/DEPS +++ b/third_party/crashpad/crashpad/DEPS @@ -25,7 +25,7 @@ deps = { '01528c7244837168a1c80f06ff60fa5a9793c824', 'crashpad/third_party/mini_chromium/mini_chromium': Var('chromium_git') + '/chromium/mini_chromium@' + - 'a43fee120b10ed71df4e55a370948ca461d78232', + '7c5b0c1ab44a4264b02f4c825a5b73d9173253e4', 'buildtools': Var('chromium_git') + '/chromium/buildtools.git@' + 'c2f259809d5ede3275df5ea0842f0431990c4f98', diff --git a/third_party/crashpad/crashpad/build/crashpad_dependencies.gypi b/third_party/crashpad/crashpad/build/crashpad_dependencies.gypi new file mode 100644 index 0000000..417d462 --- /dev/null +++ b/third_party/crashpad/crashpad/build/crashpad_dependencies.gypi @@ -0,0 +1,42 @@ +# Copyright 2015 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{ + # Crashpad can obtain dependencies in three different ways, directed by the + # crashpad_standalone GYP variable. It may have these values: + # standalone + # A “standalone” Crashpad build, where the dependencies are in the + # Crashpad tree. third_party/mini_chromium and third_party/gtest provide + # the base and gtest libraries. + # chromium + # An in-Chromium build, where Crashpad is within the Chromium tree. + # Chromium provides its own base library and its copy of the gtest + # library. + # external + # A build with external dependencies. mini_chromium provides the base + # library, but it’s located outside of the Crashpad tree, as is gtest. + # + # In order for Crashpad’s .gyp files to reference the correct versions + # depending on how dependencies are being provided, include this .gypi file + # and reference the crashpad_dependencies variable. + + 'variables': { + # When building as a standalone project or with external dependencies, + # build/gyp_crashpad.py sets crashpad_dependencies to "standalone" or + # "external", and this % assignment will not override it. The variable will + # not be set by anything else when building as part of Chromium, so in that + # case, this will define it with value "chromium". + 'crashpad_dependencies%': 'chromium', + }, +} diff --git a/third_party/crashpad/crashpad/build/crashpad_in_chromium.gypi b/third_party/crashpad/crashpad/build/crashpad_in_chromium.gypi deleted file mode 100644 index 0f64637..0000000 --- a/third_party/crashpad/crashpad/build/crashpad_in_chromium.gypi +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2015 The Crashpad Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -{ - # Crashpad can build as a standalone project or as part of Chromium. When - # building as a standalone project, it uses mini_chromium to provide the base - # library, and uses its own copy of gtest in third_party. When building as - # part of Chromium, it uses Chromium’s base library and copy of gtest. In - # order for Crashpad’s .gyp files to reference the correct versions depending - # on whether building standalone or as a part of Chromium, include this .gypi - # file and reference the crashpad_in_chromium variable. - - 'variables': { - 'variables': { - # When building as a standalone project, build/gyp_crashpad.py sets - # crashpad_standalone to 1, and this % assignment will not override it. - # The variable will not be set when building as part of Chromium, so in - # that case, this will define it with value 0. - 'crashpad_standalone%': 0, - }, - - 'conditions': [ - ['crashpad_standalone!=0', { - 'crashpad_in_chromium': 0, - }, { - 'crashpad_in_chromium': 1, - }], - ], - - 'crashpad_in_chromium': '<(crashpad_in_chromium)', - }, -} diff --git a/third_party/crashpad/crashpad/build/gyp_crashpad.py b/third_party/crashpad/crashpad/build/gyp_crashpad.py index 42818ec..741c812 100755 --- a/third_party/crashpad/crashpad/build/gyp_crashpad.py +++ b/third_party/crashpad/crashpad/build/gyp_crashpad.py @@ -17,10 +17,38 @@ import os import sys + +def ChooseDependencyPath(local_path, external_path): + """Chooses between a dependency located at local path and an external path. + + The local path, used in standalone builds, is preferred. If it is not present + but the external path is, the external path will be used. If neither path is + present, the local path will be used, so that error messages uniformly refer + to the local path. + + Args: + local_path: The preferred local path to use for a standalone build. + external_path: The external path to fall back to. + + Returns: + A 2-tuple. The first element is 'standalone' or 'external', depending on + whether local_path or external_path was chosen. The second element is the + chosen path. + """ + if os.path.exists(local_path) or not os.path.exists(external_path): + return ('standalone', local_path) + return ('external', external_path) + + script_dir = os.path.dirname(__file__) -crashpad_dir = os.path.dirname(script_dir) if script_dir is not '' else '..' -sys.path.insert( - 0, os.path.join(crashpad_dir, 'third_party', 'gyp', 'gyp', 'pylib')) +crashpad_dir = (os.path.dirname(script_dir) if script_dir not in ('', os.curdir) + else os.pardir) + +sys.path.insert(0, + ChooseDependencyPath(os.path.join(crashpad_dir, 'third_party', 'gyp', 'gyp', + 'pylib'), + os.path.join(crashpad_dir, os.pardir, os.pardir, 'gyp', + 'pylib'))[1]) import gyp @@ -29,12 +57,15 @@ def main(args): if 'GYP_GENERATORS' not in os.environ: os.environ['GYP_GENERATORS'] = 'ninja' - crashpad_dir_or_dot = crashpad_dir if crashpad_dir is not '' else '.' + crashpad_dir_or_dot = crashpad_dir if crashpad_dir is not '' else os.curdir - args.extend(['-D', 'crashpad_standalone=1']) - args.extend(['--include', - os.path.join(crashpad_dir, 'third_party', 'mini_chromium', - 'mini_chromium', 'build', 'common.gypi')]) + (dependencies, mini_chromium_dir) = (ChooseDependencyPath( + os.path.join(crashpad_dir, 'third_party', 'mini_chromium', + 'mini_chromium', 'build', 'common.gypi'), + os.path.join(crashpad_dir, os.pardir, os.pardir, 'mini_chromium', + 'mini_chromium', 'build', 'common.gypi'))) + args.extend(['-D', 'crashpad_dependencies=%s' % dependencies]) + args.extend(['--include', mini_chromium_dir]) args.extend(['--depth', crashpad_dir_or_dot]) args.append(os.path.join(crashpad_dir, 'crashpad.gyp')) diff --git a/third_party/crashpad/crashpad/client/crashpad_info.cc b/third_party/crashpad/crashpad/client/crashpad_info.cc index 596f349..46e7321 100644 --- a/third_party/crashpad/crashpad/client/crashpad_info.cc +++ b/third_party/crashpad/crashpad/client/crashpad_info.cc @@ -98,6 +98,7 @@ CrashpadInfo::CrashpadInfo() version_(kCrashpadInfoVersion), crashpad_handler_behavior_(TriState::kUnset), system_crash_reporter_forwarding_(TriState::kUnset), + gather_indirectly_referenced_memory_(TriState::kUnset), padding_0_(0), simple_annotations_(nullptr) #if !defined(NDEBUG) && defined(OS_WIN) diff --git a/third_party/crashpad/crashpad/client/crashpad_info.h b/third_party/crashpad/crashpad/client/crashpad_info.h index 1c4997a..377d194 100644 --- a/third_party/crashpad/crashpad/client/crashpad_info.h +++ b/third_party/crashpad/crashpad/client/crashpad_info.h @@ -97,6 +97,22 @@ struct CrashpadInfo { system_crash_reporter_forwarding_ = system_crash_reporter_forwarding; } + //! \brief Enables or disables Crashpad capturing indirectly referenced memory + //! in the minidump. + //! + //! When handling an exception, the Crashpad handler will scan all modules in + //! a process. The first one that has a CrashpadInfo structure populated with + //! a value other than #kUnset for this field will dictate whether the extra + //! memory is captured. + //! + //! This causes Crashpad to include pages of data referenced by locals or + //! other stack memory. Turning this on can increase the size of the minidump + //! significantly. + void set_gather_indirectly_referenced_memory( + TriState gather_indirectly_referenced_memory) { + gather_indirectly_referenced_memory_ = gather_indirectly_referenced_memory; + } + enum : uint32_t { kSignature = 'CPad', }; @@ -117,7 +133,8 @@ struct CrashpadInfo { uint32_t version_; // kVersion TriState crashpad_handler_behavior_; TriState system_crash_reporter_forwarding_; - uint16_t padding_0_; + TriState gather_indirectly_referenced_memory_; + uint8_t padding_0_; SimpleStringDictionary* simple_annotations_; // weak #if !defined(NDEBUG) && defined(OS_WIN) diff --git a/third_party/crashpad/crashpad/codereview.settings b/third_party/crashpad/crashpad/codereview.settings index 3878422..685c904 100644 --- a/third_party/crashpad/crashpad/codereview.settings +++ b/third_party/crashpad/crashpad/codereview.settings @@ -13,6 +13,7 @@ # limitations under the License. GERRIT_HOST: True +GERRIT_SQUASH_UPLOADS: True CODE_REVIEW_SERVER: https://canary-chromium-review.googlesource.com/ VIEW_VC: https://chromium.googlesource.com/crashpad/crashpad/+/ PROJECT: crashpad diff --git a/third_party/crashpad/crashpad/handler/handler.gyp b/third_party/crashpad/crashpad/handler/handler.gyp index 9a520a2..40d5977 100644 --- a/third_party/crashpad/crashpad/handler/handler.gyp +++ b/third_party/crashpad/crashpad/handler/handler.gyp @@ -15,7 +15,7 @@ { 'includes': [ '../build/crashpad.gypi', - '../build/crashpad_in_chromium.gypi', + '../build/crashpad_dependencies.gypi', ], 'targets': [ { @@ -78,7 +78,7 @@ 'component%': 'static_library', }, 'conditions': [ - ['crashpad_in_chromium!=0 and component=="shared_library"', { + ['crashpad_dependencies=="chromium" and component=="shared_library"', { 'xcode_settings': { 'LD_RUNPATH_SEARCH_PATHS': [ # -Wl,-rpath # Get back from diff --git a/third_party/crashpad/crashpad/handler/win/crashy_test_program.cc b/third_party/crashpad/crashpad/handler/win/crashy_test_program.cc index 6fbd514..f9e8501 100644 --- a/third_party/crashpad/crashpad/handler/win/crashy_test_program.cc +++ b/third_party/crashpad/crashpad/handler/win/crashy_test_program.cc @@ -28,6 +28,7 @@ #include "base/macros.h" #include "build/build_config.h" #include "client/crashpad_client.h" +#include "client/crashpad_info.h" #include "util/win/critical_section_with_debug_info.h" #include "util/win/get_function.h" @@ -164,6 +165,18 @@ int CrashyMain(int argc, wchar_t* argv[]) { return EXIT_FAILURE; } + // Make sure data pointed to by the stack is captured. + const int kDataSize = 512; + int* pointed_to_data = new int[kDataSize]; + for (int i = 0; i < kDataSize; ++i) + pointed_to_data[i] = i | ((i % 2 == 0) ? 0x80000000 : 0); + int* offset_pointer = &pointed_to_data[128]; + // Encourage the compiler to keep this variable around. + printf("%p, %p\n", offset_pointer, &offset_pointer); + + crashpad::CrashpadInfo::GetCrashpadInfo() + ->set_gather_indirectly_referenced_memory(TriState::kEnabled); + AllocateMemoryOfVariousProtections(); if (InitializeCriticalSectionWithDebugInfoIfPossible( diff --git a/third_party/crashpad/crashpad/snapshot/capture_memory.cc b/third_party/crashpad/crashpad/snapshot/capture_memory.cc new file mode 100644 index 0000000..c692798 --- /dev/null +++ b/third_party/crashpad/crashpad/snapshot/capture_memory.cc @@ -0,0 +1,128 @@ +// Copyright 2016 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "snapshot/capture_memory.h" + +#include <stdint.h> + +#include <limits> + +#include "base/memory/scoped_ptr.h" +#include "snapshot/memory_snapshot.h" + +namespace crashpad { +namespace internal { + +namespace { + +void MaybeCaptureMemoryAround(CaptureMemory::Delegate* delegate, + uint64_t address) { + const uint64_t non_address_offset = 0x10000; + if (address < non_address_offset) + return; + + const uint64_t max_address = delegate->Is64Bit() ? + std::numeric_limits<uint64_t>::max() : + std::numeric_limits<uint32_t>::max(); + if (address > max_address - non_address_offset) + return; + + const uint64_t kRegisterByteOffset = 256; + const uint64_t target = address - kRegisterByteOffset; + const uint64_t size = 1024; + static_assert(kRegisterByteOffset <= size / 2, + "negative offset too large"); + auto ranges = + delegate->GetReadableRanges(CheckedRange<uint64_t>(target, size)); + for (const auto& range : ranges) { + delegate->AddNewMemorySnapshot(range); + } +} + +template <class T> +void CaptureAtPointersInRange(uint8_t* buffer, + uint64_t buffer_size, + CaptureMemory::Delegate* delegate) { + for (uint64_t address_offset = 0; address_offset < buffer_size; + address_offset += sizeof(T)) { + uint64_t target_address = *reinterpret_cast<T*>(&buffer[address_offset]); + MaybeCaptureMemoryAround(delegate, target_address); + } +} + +} // namespace + +// static +void CaptureMemory::PointedToByContext(const CPUContext& context, + Delegate* delegate) { +#if defined(ARCH_CPU_X86_FAMILY) + if (context.architecture == kCPUArchitectureX86_64) { + MaybeCaptureMemoryAround(delegate, context.x86_64->rax); + MaybeCaptureMemoryAround(delegate, context.x86_64->rbx); + MaybeCaptureMemoryAround(delegate, context.x86_64->rcx); + MaybeCaptureMemoryAround(delegate, context.x86_64->rdx); + MaybeCaptureMemoryAround(delegate, context.x86_64->rdi); + MaybeCaptureMemoryAround(delegate, context.x86_64->rsi); + MaybeCaptureMemoryAround(delegate, context.x86_64->rbp); + MaybeCaptureMemoryAround(delegate, context.x86_64->r8); + MaybeCaptureMemoryAround(delegate, context.x86_64->r9); + MaybeCaptureMemoryAround(delegate, context.x86_64->r10); + MaybeCaptureMemoryAround(delegate, context.x86_64->r11); + MaybeCaptureMemoryAround(delegate, context.x86_64->r12); + MaybeCaptureMemoryAround(delegate, context.x86_64->r13); + MaybeCaptureMemoryAround(delegate, context.x86_64->r14); + MaybeCaptureMemoryAround(delegate, context.x86_64->r15); + MaybeCaptureMemoryAround(delegate, context.x86_64->rip); + } else { + MaybeCaptureMemoryAround(delegate, context.x86->eax); + MaybeCaptureMemoryAround(delegate, context.x86->ebx); + MaybeCaptureMemoryAround(delegate, context.x86->ecx); + MaybeCaptureMemoryAround(delegate, context.x86->edx); + MaybeCaptureMemoryAround(delegate, context.x86->edi); + MaybeCaptureMemoryAround(delegate, context.x86->esi); + MaybeCaptureMemoryAround(delegate, context.x86->ebp); + MaybeCaptureMemoryAround(delegate, context.x86->eip); + } +#else +#error non-x86 +#endif +} + +// static +void CaptureMemory::PointedToByMemoryRange(const MemorySnapshot& memory, + Delegate* delegate) { + if (memory.Size() == 0) + return; + + const size_t alignment = + delegate->Is64Bit() ? sizeof(uint64_t) : sizeof(uint32_t); + if (memory.Address() % alignment != 0 || memory.Size() % alignment != 0) { + LOG(ERROR) << "unaligned range"; + return; + } + + scoped_ptr<uint8_t[]> buffer(new uint8_t[memory.Size()]); + if (!delegate->ReadMemory(memory.Address(), memory.Size(), buffer.get())) { + LOG(ERROR) << "ReadMemory"; + return; + } + + if (delegate->Is64Bit()) + CaptureAtPointersInRange<uint64_t>(buffer.get(), memory.Size(), delegate); + else + CaptureAtPointersInRange<uint32_t>(buffer.get(), memory.Size(), delegate); +} + +} // namespace internal +} // namespace crashpad diff --git a/third_party/crashpad/crashpad/snapshot/capture_memory.h b/third_party/crashpad/crashpad/snapshot/capture_memory.h new file mode 100644 index 0000000..ef5f4ed --- /dev/null +++ b/third_party/crashpad/crashpad/snapshot/capture_memory.h @@ -0,0 +1,98 @@ +// Copyright 2016 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CRASHPAD_SNAPSHOT_CAPTURE_MEMORY_H_ +#define CRASHPAD_SNAPSHOT_CAPTURE_MEMORY_H_ + +#include <stdint.h> + +#include <vector> + +#include "snapshot/cpu_context.h" +#include "util/numeric/checked_range.h" + +namespace crashpad { + +class MemorySnapshot; + +namespace internal { + +class CaptureMemory { + public: + //! \brief An interface to a platform-specific process reader. + class Delegate { + public: + virtual ~Delegate() {} + + //! \return `true` if the target process is a 64-bit process. + virtual bool Is64Bit() const = 0; + + //! \brief Attempts to read \a num_bytes bytes from the target process + //! starting at address \a at into \a into. + //! + //! \return `true` if the entire region could be read, or `false` with an + //! error logged. + virtual bool ReadMemory(uint64_t at, + uint64_t num_bytes, + void* into) const = 0; + + //! \brief Given a range to be read from the target process, returns a + //! vector + //! of ranges, representing the readable portions of the original range. + //! + //! \param[in] range The range being identified. + //! + //! \return A vector of ranges corresponding to the portion of \a range that + //! is readable. + virtual std::vector<CheckedRange<uint64_t>> GetReadableRanges( + const CheckedRange<uint64_t, uint64_t>& range) const = 0; + + //! \brief Adds the given range representing a memory snapshot in the target + //! process to the result. + virtual void AddNewMemorySnapshot( + const CheckedRange<uint64_t, uint64_t>& range) = 0; + }; + + //! \brief For all registers that appear to be pointer-like in \a context, + //! captures a small amount of memory near their pointed to location. + //! + //! "Pointer-like" in this context means not too close to zero (signed or + //! unsigned) so that there's a reasonable chance that the value is a pointer. + //! + //! \param[in] context The context to inspect. + //! \param[in] process_reader A MemoryCaptureProcessReader to read from the + //! target process, and that handles adding new ranges. + static void PointedToByContext(const CPUContext& context, Delegate* delegate); + + //! \brief For all pointer-like values in a memory range of the target + //! process, + //! captures a small amount of memory near the pointed to location. + //! + //! \param[in] memory An existing MemorySnapshot of the range to search. The + //! base address and size must be pointer-aligned and an integral number + //! of + //! pointers long. + //! \param[in] process_reader A MemoryCaptureProcessReader to read from the + //! target process, and that handles adding new ranges. + static void PointedToByMemoryRange(const MemorySnapshot& memory, + Delegate* delegate); + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureMemory); +}; + +} // namespace internal +} // namespace crashpad + +#endif // CRASHPAD_SNAPSHOT_CAPTURE_MEMORY_H_ diff --git a/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.cc b/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.cc index e19b021..4a89d84 100644 --- a/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.cc +++ b/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.cc @@ -38,7 +38,8 @@ TriState CrashpadInfoClientOptions::TriStateFromCrashpadInfo( CrashpadInfoClientOptions::CrashpadInfoClientOptions() : crashpad_handler_behavior(TriState::kUnset), - system_crash_reporter_forwarding(TriState::kUnset) { + system_crash_reporter_forwarding(TriState::kUnset), + gather_indirectly_referenced_memory(TriState::kUnset) { } } // namespace crashpad diff --git a/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.h b/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.h index 3f9e03d..eeb1904 100644 --- a/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.h +++ b/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options.h @@ -59,6 +59,9 @@ struct CrashpadInfoClientOptions { //! \sa CrashpadInfo::set_system_crash_reporter_forwarding() TriState system_crash_reporter_forwarding; + + //! \sa CrashpadInfo::set_gather_indirectly_referenced_memory() + TriState gather_indirectly_referenced_memory; }; } // namespace crashpad diff --git a/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options_test.cc b/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options_test.cc index 9c1f88b..50ba631 100644 --- a/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options_test.cc +++ b/third_party/crashpad/crashpad/snapshot/crashpad_info_client_options_test.cc @@ -61,6 +61,7 @@ class ScopedUnsetCrashpadInfoOptions { ~ScopedUnsetCrashpadInfoOptions() { crashpad_info_->set_crashpad_handler_behavior(TriState::kUnset); crashpad_info_->set_system_crash_reporter_forwarding(TriState::kUnset); + crashpad_info_->set_gather_indirectly_referenced_memory(TriState::kUnset); } private: @@ -69,14 +70,13 @@ class ScopedUnsetCrashpadInfoOptions { DISALLOW_COPY_AND_ASSIGN(ScopedUnsetCrashpadInfoOptions); }; -TEST(CrashpadInfoClientOptions, OneModule) { - // Make sure that the initial state has all values unset. +CrashpadInfoClientOptions SelfProcessSnapshotAndGetCrashpadOptions() { #if defined(OS_MACOSX) ProcessSnapshotMac process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(mach_task_self())); + EXPECT_TRUE(process_snapshot.Initialize(mach_task_self())); #elif defined(OS_WIN) ProcessSnapshotWin process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize( + EXPECT_TRUE(process_snapshot.Initialize( GetCurrentProcess(), ProcessSuspensionState::kRunning, 0)); #else #error Port. @@ -84,9 +84,16 @@ TEST(CrashpadInfoClientOptions, OneModule) { CrashpadInfoClientOptions options; process_snapshot.GetCrashpadOptions(&options); + return options; +} + +TEST(CrashpadInfoClientOptions, OneModule) { + // Make sure that the initial state has all values unset. + auto options = SelfProcessSnapshotAndGetCrashpadOptions(); EXPECT_EQ(TriState::kUnset, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kUnset, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); CrashpadInfo* crashpad_info = CrashpadInfo::GetCrashpadInfo(); ASSERT_TRUE(crashpad_info); @@ -96,9 +103,10 @@ TEST(CrashpadInfoClientOptions, OneModule) { crashpad_info->set_crashpad_handler_behavior(TriState::kEnabled); - process_snapshot.GetCrashpadOptions(&options); + options = SelfProcessSnapshotAndGetCrashpadOptions(); EXPECT_EQ(TriState::kEnabled, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kUnset, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); } { @@ -106,9 +114,21 @@ TEST(CrashpadInfoClientOptions, OneModule) { crashpad_info->set_system_crash_reporter_forwarding(TriState::kDisabled); - process_snapshot.GetCrashpadOptions(&options); + options = SelfProcessSnapshotAndGetCrashpadOptions(); EXPECT_EQ(TriState::kUnset, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kDisabled, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); + } + + { + ScopedUnsetCrashpadInfoOptions unset(crashpad_info); + + crashpad_info->set_gather_indirectly_referenced_memory(TriState::kEnabled); + + options = SelfProcessSnapshotAndGetCrashpadOptions(); + EXPECT_EQ(TriState::kUnset, options.crashpad_handler_behavior); + EXPECT_EQ(TriState::kUnset, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kEnabled, options.gather_indirectly_referenced_memory); } } @@ -184,23 +204,12 @@ TEST(CrashpadInfoClientOptions, TwoModules) { dl_handle.LookUpSymbol<CrashpadInfo* (*)()>("TestModule_GetCrashpadInfo"); ASSERT_TRUE(TestModule_GetCrashpadInfo); - // Make sure that the initial state has all values unset. -#if defined(OS_MACOSX) - ProcessSnapshotMac process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize(mach_task_self())); -#elif defined(OS_WIN) - ProcessSnapshotWin process_snapshot; - ASSERT_TRUE(process_snapshot.Initialize( - GetCurrentProcess(), ProcessSuspensionState::kRunning, 0)); -#else -#error Port. -#endif // OS_MACOSX - - CrashpadInfoClientOptions options; - process_snapshot.GetCrashpadOptions(&options); + auto options = SelfProcessSnapshotAndGetCrashpadOptions(); + // Make sure that the initial state has all values unset. EXPECT_EQ(TriState::kUnset, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kUnset, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); // Get both CrashpadInfo structures. CrashpadInfo* local_crashpad_info = CrashpadInfo::GetCrashpadInfo(); @@ -216,18 +225,20 @@ TEST(CrashpadInfoClientOptions, TwoModules) { // When only one module sets a value, it applies to the entire process. remote_crashpad_info->set_crashpad_handler_behavior(TriState::kEnabled); - process_snapshot.GetCrashpadOptions(&options); + options = SelfProcessSnapshotAndGetCrashpadOptions(); EXPECT_EQ(TriState::kEnabled, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kUnset, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); // When more than one module sets a value, the first one in the module list // applies to the process. The local module should appear before the remote // module, because the local module loaded the remote module. local_crashpad_info->set_crashpad_handler_behavior(TriState::kDisabled); - process_snapshot.GetCrashpadOptions(&options); + options = SelfProcessSnapshotAndGetCrashpadOptions(); EXPECT_EQ(TriState::kDisabled, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kUnset, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); } { @@ -238,9 +249,10 @@ TEST(CrashpadInfoClientOptions, TwoModules) { remote_crashpad_info->set_system_crash_reporter_forwarding( TriState::kDisabled); - process_snapshot.GetCrashpadOptions(&options); + options = SelfProcessSnapshotAndGetCrashpadOptions(); EXPECT_EQ(TriState::kUnset, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kDisabled, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); // When more than one module sets a value, the first one in the module list // applies to the process. The local module should appear before the remote @@ -248,9 +260,10 @@ TEST(CrashpadInfoClientOptions, TwoModules) { local_crashpad_info->set_system_crash_reporter_forwarding( TriState::kEnabled); - process_snapshot.GetCrashpadOptions(&options); + options = SelfProcessSnapshotAndGetCrashpadOptions(); EXPECT_EQ(TriState::kUnset, options.crashpad_handler_behavior); EXPECT_EQ(TriState::kEnabled, options.system_crash_reporter_forwarding); + EXPECT_EQ(TriState::kUnset, options.gather_indirectly_referenced_memory); } } diff --git a/third_party/crashpad/crashpad/snapshot/mac/module_snapshot_mac.cc b/third_party/crashpad/crashpad/snapshot/mac/module_snapshot_mac.cc index 64f04dc..dd9e809 100644 --- a/third_party/crashpad/crashpad/snapshot/mac/module_snapshot_mac.cc +++ b/third_party/crashpad/crashpad/snapshot/mac/module_snapshot_mac.cc @@ -64,6 +64,7 @@ void ModuleSnapshotMac::GetCrashpadOptions(CrashpadInfoClientOptions* options) { if (!mach_o_image_reader_->GetCrashpadInfo(&crashpad_info)) { options->crashpad_handler_behavior = TriState::kUnset; options->system_crash_reporter_forwarding = TriState::kUnset; + options->gather_indirectly_referenced_memory = TriState::kUnset; return; } @@ -74,6 +75,10 @@ void ModuleSnapshotMac::GetCrashpadOptions(CrashpadInfoClientOptions* options) { options->system_crash_reporter_forwarding = CrashpadInfoClientOptions::TriStateFromCrashpadInfo( crashpad_info.system_crash_reporter_forwarding); + + options->gather_indirectly_referenced_memory = + CrashpadInfoClientOptions::TriStateFromCrashpadInfo( + crashpad_info.gather_indirectly_referenced_memory); } std::string ModuleSnapshotMac::Name() const { diff --git a/third_party/crashpad/crashpad/snapshot/mac/process_snapshot_mac.cc b/third_party/crashpad/crashpad/snapshot/mac/process_snapshot_mac.cc index b37123c..3d44e93 100644 --- a/third_party/crashpad/crashpad/snapshot/mac/process_snapshot_mac.cc +++ b/third_party/crashpad/crashpad/snapshot/mac/process_snapshot_mac.cc @@ -104,11 +104,16 @@ void ProcessSnapshotMac::GetCrashpadOptions( local_options.system_crash_reporter_forwarding = module_options.system_crash_reporter_forwarding; } + if (local_options.gather_indirectly_referenced_memory == TriState::kUnset) { + local_options.gather_indirectly_referenced_memory = + module_options.gather_indirectly_referenced_memory; + } // If non-default values have been found for all options, the loop can end // early. if (local_options.crashpad_handler_behavior != TriState::kUnset && - local_options.system_crash_reporter_forwarding != TriState::kUnset) { + local_options.system_crash_reporter_forwarding != TriState::kUnset && + local_options.gather_indirectly_referenced_memory != TriState::kUnset) { break; } } diff --git a/third_party/crashpad/crashpad/snapshot/mac/process_types/crashpad_info.proctype b/third_party/crashpad/crashpad/snapshot/mac/process_types/crashpad_info.proctype index cdc8247..af30d95 100644 --- a/third_party/crashpad/crashpad/snapshot/mac/process_types/crashpad_info.proctype +++ b/third_party/crashpad/crashpad/snapshot/mac/process_types/crashpad_info.proctype @@ -32,7 +32,10 @@ PROCESS_TYPE_STRUCT_BEGIN(CrashpadInfo) // TriState PROCESS_TYPE_STRUCT_MEMBER(uint8_t, system_crash_reporter_forwarding) - PROCESS_TYPE_STRUCT_MEMBER(uint16_t, padding_0) + // TriState + PROCESS_TYPE_STRUCT_MEMBER(uint8_t, gather_indirectly_referenced_memory) + + PROCESS_TYPE_STRUCT_MEMBER(uint8_t, padding_0) // SimpleStringDictionary* PROCESS_TYPE_STRUCT_MEMBER(Pointer, simple_annotations) diff --git a/third_party/crashpad/crashpad/snapshot/snapshot.gyp b/third_party/crashpad/crashpad/snapshot/snapshot.gyp index 0154495..d001152 100644 --- a/third_party/crashpad/crashpad/snapshot/snapshot.gyp +++ b/third_party/crashpad/crashpad/snapshot/snapshot.gyp @@ -30,6 +30,8 @@ '..', ], 'sources': [ + 'capture_memory.cc', + 'capture_memory.h', 'cpu_architecture.h', 'cpu_context.cc', 'cpu_context.h', @@ -89,12 +91,12 @@ 'process_snapshot.h', 'system_snapshot.h', 'thread_snapshot.h', - 'win/capture_context_memory.cc', - 'win/capture_context_memory.h', 'win/cpu_context_win.cc', 'win/cpu_context_win.h', 'win/exception_snapshot_win.cc', 'win/exception_snapshot_win.h', + 'win/capture_memory_delegate_win.cc', + 'win/capture_memory_delegate_win.h', 'win/memory_map_region_snapshot_win.cc', 'win/memory_map_region_snapshot_win.h', 'win/memory_snapshot_win.cc', diff --git a/third_party/crashpad/crashpad/snapshot/win/capture_context_memory.cc b/third_party/crashpad/crashpad/snapshot/win/capture_context_memory.cc deleted file mode 100644 index e446900..0000000 --- a/third_party/crashpad/crashpad/snapshot/win/capture_context_memory.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2016 The Crashpad Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "snapshot/win/capture_context_memory.h" - -#include <stdint.h> - -#include <limits> - -#include "snapshot/win/memory_snapshot_win.h" -#include "snapshot/win/process_reader_win.h" - -namespace crashpad { -namespace internal { - -namespace { - -void MaybeCaptureMemoryAround(ProcessReaderWin* process_reader, - WinVMAddress address, - PointerVector<MemorySnapshotWin>* into) { - const WinVMAddress non_address_offset = 0x10000; - if (address < non_address_offset) - return; - if (process_reader->Is64Bit()) { - if (address >= std::numeric_limits<uint64_t>::max() - non_address_offset) - return; - } else { - if (address >= std::numeric_limits<uint32_t>::max() - non_address_offset) - return; - } - - const WinVMSize kRegisterByteOffset = 32; - const WinVMAddress target = address - kRegisterByteOffset; - const WinVMSize size = 128; - auto ranges = process_reader->GetProcessInfo().GetReadableRanges( - CheckedRange<WinVMAddress, WinVMSize>(target, size)); - for (const auto& range : ranges) { - internal::MemorySnapshotWin* snapshot = new internal::MemorySnapshotWin(); - snapshot->Initialize(process_reader, range.base(), range.size()); - into->push_back(snapshot); - } -} - -} // namespace - -void CaptureMemoryPointedToByContext(const CPUContext& context, - ProcessReaderWin* process_reader, - const ProcessReaderWin::Thread& thread, - PointerVector<MemorySnapshotWin>* into) { -#if defined(ARCH_CPU_X86_64) - if (context.architecture == kCPUArchitectureX86_64) { - MaybeCaptureMemoryAround(process_reader, context.x86_64->rax, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->rbx, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->rcx, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->rdx, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->rdi, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->rsi, into); - if (context.x86_64->rbp < thread.stack_region_address || - context.x86_64->rbp >= - thread.stack_region_address + thread.stack_region_size) { - MaybeCaptureMemoryAround(process_reader, context.x86_64->rbp, into); - } - MaybeCaptureMemoryAround(process_reader, context.x86_64->r8, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->r9, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->r10, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->r11, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->r12, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->r13, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->r14, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->r15, into); - MaybeCaptureMemoryAround(process_reader, context.x86_64->rip, into); - } else { -#endif - MaybeCaptureMemoryAround(process_reader, context.x86->eax, into); - MaybeCaptureMemoryAround(process_reader, context.x86->ebx, into); - MaybeCaptureMemoryAround(process_reader, context.x86->ecx, into); - MaybeCaptureMemoryAround(process_reader, context.x86->edx, into); - MaybeCaptureMemoryAround(process_reader, context.x86->edi, into); - MaybeCaptureMemoryAround(process_reader, context.x86->esi, into); - if (context.x86->ebp < thread.stack_region_address || - context.x86->ebp >= - thread.stack_region_address + thread.stack_region_size) { - MaybeCaptureMemoryAround(process_reader, context.x86->ebp, into); - } - MaybeCaptureMemoryAround(process_reader, context.x86->eip, into); -#if defined(ARCH_CPU_X86_64) - } -#endif -} - -} // namespace internal -} // namespace crashpad diff --git a/third_party/crashpad/crashpad/snapshot/win/capture_context_memory.h b/third_party/crashpad/crashpad/snapshot/win/capture_context_memory.h deleted file mode 100644 index d4f4e03..0000000 --- a/third_party/crashpad/crashpad/snapshot/win/capture_context_memory.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Crashpad Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRASHPAD_SNAPSHOT_WIN_CAPTURE_CONTEXT_MEMORY_H_ -#define CRASHPAD_SNAPSHOT_WIN_CAPTURE_CONTEXT_MEMORY_H_ - -#include "snapshot/cpu_context.h" -#include "snapshot/win/process_reader_win.h" -#include "util/stdlib/pointer_container.h" - -namespace crashpad { -namespace internal { - -class MemorySnapshotWin; - -//! \brief For all registers that appear to be pointer-like in \a context, -//! captures a small amount of memory near their pointed to location. -//! -//! \param[in] context The context to inspect. -//! \param[in] process_reader A ProcessReaderWin to read from the target -//! process. -//! \param[in] thread The thread to which the context belongs. -//! \param[out] into A vector of pointers to append new ranges to. -void CaptureMemoryPointedToByContext(const CPUContext& context, - ProcessReaderWin* process_reader, - const ProcessReaderWin::Thread& thread, - PointerVector<MemorySnapshotWin>* into); - -} // namespace internal -} // namespace crashpad - -#endif // CRASHPAD_SNAPSHOT_WIN_CAPTURE_CONTEXT_MEMORY_H_ diff --git a/third_party/crashpad/crashpad/snapshot/win/capture_memory_delegate_win.cc b/third_party/crashpad/crashpad/snapshot/win/capture_memory_delegate_win.cc new file mode 100644 index 0000000..1eaa425 --- /dev/null +++ b/third_party/crashpad/crashpad/snapshot/win/capture_memory_delegate_win.cc @@ -0,0 +1,56 @@ +// Copyright 2016 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "snapshot/win/capture_memory_delegate_win.h" + +#include "snapshot/win/memory_snapshot_win.h" + +namespace crashpad { +namespace internal { + +CaptureMemoryDelegateWin::CaptureMemoryDelegateWin( + ProcessReaderWin* process_reader, + const ProcessReaderWin::Thread& thread, + PointerVector<MemorySnapshotWin>* snapshots) + : stack_(thread.stack_region_address, thread.stack_region_size), + process_reader_(process_reader), + snapshots_(snapshots) {} + +bool CaptureMemoryDelegateWin::Is64Bit() const { + return process_reader_->Is64Bit(); +} + +bool CaptureMemoryDelegateWin::ReadMemory(uint64_t at, + uint64_t num_bytes, + void* into) const { + return process_reader_->ReadMemory(at, num_bytes, into); +} + +std::vector<CheckedRange<uint64_t>> CaptureMemoryDelegateWin::GetReadableRanges( + const CheckedRange<uint64_t, uint64_t>& range) const { + return process_reader_->GetProcessInfo().GetReadableRanges(range); +} + +void CaptureMemoryDelegateWin::AddNewMemorySnapshot( + const CheckedRange<uint64_t, uint64_t>& range) { + // Don't bother storing this memory if it points back into the stack. + if (stack_.ContainsRange(range)) + return; + internal::MemorySnapshotWin* snapshot = new internal::MemorySnapshotWin(); + snapshot->Initialize(process_reader_, range.base(), range.size()); + snapshots_->push_back(snapshot); +} + +} // namespace internal +} // namespace crashpad diff --git a/third_party/crashpad/crashpad/snapshot/win/capture_memory_delegate_win.h b/third_party/crashpad/crashpad/snapshot/win/capture_memory_delegate_win.h new file mode 100644 index 0000000..e408e54 --- /dev/null +++ b/third_party/crashpad/crashpad/snapshot/win/capture_memory_delegate_win.h @@ -0,0 +1,58 @@ + // Copyright 2016 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CRASHPAD_SNAPSHOT_WIN_CAPTURE_MEMORY_DELEGATE_WIN_H_ +#define CRASHPAD_SNAPSHOT_WIN_CAPTURE_MEMORY_DELEGATE_WIN_H_ + +#include "snapshot/capture_memory.h" + +#include "snapshot/win/process_reader_win.h" +#include "util/stdlib/pointer_container.h" + +namespace crashpad { +namespace internal { + +class MemorySnapshotWin; + +class CaptureMemoryDelegateWin : public CaptureMemory::Delegate { + public: + //! \brief A MemoryCaptureDelegate for Windows. + //! + //! \param[in] process_reader A ProcessReaderWin for the target process. + //! \param[in] thread The thread being inspected. Memory ranges overlapping + //! this thread's stack will be ignored on the assumption that they're + //! already captured elsewhere. + //! \param[in] snapshots A vector of MemorySnapshotWin to which the captured + //! memory will be added. + CaptureMemoryDelegateWin(ProcessReaderWin* process_reader, + const ProcessReaderWin::Thread& thread, + PointerVector<MemorySnapshotWin>* snapshots); + + // MemoryCaptureDelegate: + bool Is64Bit() const override; + bool ReadMemory(uint64_t at, uint64_t num_bytes, void* into) const override; + std::vector<CheckedRange<uint64_t>> GetReadableRanges( + const CheckedRange<uint64_t, uint64_t>& range) const override; + void AddNewMemorySnapshot(const CheckedRange<uint64_t, uint64_t>& range); + + private: + CheckedRange<uint64_t, uint64_t> stack_; + ProcessReaderWin* process_reader_; + PointerVector<MemorySnapshotWin>* snapshots_; +}; + +} // namespace internal +} // namespace crashpad + +#endif // CRASHPAD_SNAPSHOT_WIN_CAPTURE_MEMORY_DELEGATE_WIN_H_ diff --git a/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py b/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py index 34343ba..bf4f303 100755 --- a/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py +++ b/third_party/crashpad/crashpad/snapshot/win/end_to_end_test.py @@ -247,10 +247,22 @@ def RunTests(cdb_path, r'FreeOwnStackAndBreak.*\nquit:', 'at correct location, no additional stack entries') + # Switch to the other thread after jumping to the exception, and examine + # memory. out = CdbRun(cdb_path, dump_path, '.ecxr; ~1s; db /c14 edi') out.Check(r'63 62 61 60 5f 5e 5d 5c-5b 5a 59 58 57 56 55 54 53 52 51 50', 'data pointed to by registers captured') + # Move up one stack frame after jumping to the exception, and examine memory. + out = CdbRun(cdb_path, dump_path, + '.ecxr; .f+; dd /c100 poi(offset_pointer)-20') + out.Check(r'80000078 00000079 8000007a 0000007b 8000007c 0000007d 8000007e ' + r'0000007f 80000080 00000081 80000082 00000083 80000084 00000085 ' + r'80000086 00000087 80000088 00000089 8000008a 0000008b 8000008c ' + r'0000008d 8000008e 0000008f 80000090 00000091 80000092 00000093 ' + r'80000094 00000095 80000096 00000097', + 'data pointed to by stack captured') + if z7_dump_path: out = CdbRun(cdb_path, z7_dump_path, '.ecxr;lm') out.Check('This dump file has an exception of interest stored in it', diff --git a/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc b/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc index 9ec16f6..ea44f0f 100644 --- a/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc +++ b/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc @@ -14,9 +14,10 @@ #include "snapshot/win/exception_snapshot_win.h" +#include "snapshot/capture_memory.h" #include "snapshot/memory_snapshot.h" -#include "snapshot/win/capture_context_memory.h" #include "snapshot/win/cpu_context_win.h" +#include "snapshot/win/capture_memory_delegate_win.h" #include "snapshot/win/memory_snapshot_win.h" #include "snapshot/win/process_reader_win.h" #include "util/win/nt_internals.h" @@ -89,8 +90,9 @@ bool ExceptionSnapshotWin::Initialize(ProcessReaderWin* process_reader, InitializeX86Context(context_record, context_.x86); } - CaptureMemoryPointedToByContext( - context_, process_reader, *thread, &extra_memory_); + CaptureMemoryDelegateWin capture_memory_delegate( + process_reader, *thread, &extra_memory_); + CaptureMemory::PointedToByContext(context_, &capture_memory_delegate); INITIALIZATION_STATE_SET_VALID(initialized_); return true; diff --git a/third_party/crashpad/crashpad/snapshot/win/module_snapshot_win.cc b/third_party/crashpad/crashpad/snapshot/win/module_snapshot_win.cc index 0553f35..8948b2a 100644 --- a/third_party/crashpad/crashpad/snapshot/win/module_snapshot_win.cc +++ b/third_party/crashpad/crashpad/snapshot/win/module_snapshot_win.cc @@ -202,6 +202,10 @@ void ModuleSnapshotWin::GetCrashpadOptionsInternal( options->system_crash_reporter_forwarding = CrashpadInfoClientOptions::TriStateFromCrashpadInfo( crashpad_info.system_crash_reporter_forwarding); + + options->gather_indirectly_referenced_memory = + CrashpadInfoClientOptions::TriStateFromCrashpadInfo( + crashpad_info.gather_indirectly_referenced_memory); } const VS_FIXEDFILEINFO* ModuleSnapshotWin::VSFixedFileInfo() const { diff --git a/third_party/crashpad/crashpad/snapshot/win/pe_image_reader.h b/third_party/crashpad/crashpad/snapshot/win/pe_image_reader.h index 4e9516b..feffa8a 100644 --- a/third_party/crashpad/crashpad/snapshot/win/pe_image_reader.h +++ b/third_party/crashpad/crashpad/snapshot/win/pe_image_reader.h @@ -41,7 +41,8 @@ struct CrashpadInfo { uint32_t version; uint8_t crashpad_handler_behavior; // TriState. uint8_t system_crash_reporter_forwarding; // TriState. - uint16_t padding_0; + uint8_t gather_indirectly_referenced_memory; // TriState. + uint8_t padding_0; typename Traits::Pointer simple_annotations; }; diff --git a/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.cc b/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.cc index 8c184c2..535c9a7 100644 --- a/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.cc +++ b/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.cc @@ -38,6 +38,7 @@ ProcessSnapshotWin::ProcessSnapshotWin() client_id_(), annotations_simple_map_(), snapshot_time_(), + options_(), initialized_() { } @@ -65,9 +66,13 @@ bool ProcessSnapshotWin::Initialize( debug_critical_section_address); } - InitializeThreads(); InitializeModules(); + GetCrashpadOptionsInternal(&options_); + + InitializeThreads(options_.gather_indirectly_referenced_memory == + TriState::kEnabled); + for (const MEMORY_BASIC_INFORMATION64& mbi : process_reader_.GetProcessInfo().MemoryInfo()) { memory_map_.push_back(new internal::MemoryMapRegionSnapshotWin(mbi)); @@ -104,31 +109,7 @@ bool ProcessSnapshotWin::InitializeException( void ProcessSnapshotWin::GetCrashpadOptions( CrashpadInfoClientOptions* options) { INITIALIZATION_STATE_DCHECK_VALID(initialized_); - - CrashpadInfoClientOptions local_options; - - for (internal::ModuleSnapshotWin* module : modules_) { - CrashpadInfoClientOptions module_options; - module->GetCrashpadOptions(&module_options); - - if (local_options.crashpad_handler_behavior == TriState::kUnset) { - local_options.crashpad_handler_behavior = - module_options.crashpad_handler_behavior; - } - if (local_options.system_crash_reporter_forwarding == TriState::kUnset) { - local_options.system_crash_reporter_forwarding = - module_options.system_crash_reporter_forwarding; - } - - // If non-default values have been found for all options, the loop can end - // early. - if (local_options.crashpad_handler_behavior != TriState::kUnset && - local_options.system_crash_reporter_forwarding != TriState::kUnset) { - break; - } - } - - *options = local_options; + *options = options_; } pid_t ProcessSnapshotWin::ProcessID() const { @@ -234,13 +215,16 @@ std::vector<const MemorySnapshot*> ProcessSnapshotWin::ExtraMemory() const { return extra_memory; } -void ProcessSnapshotWin::InitializeThreads() { +void ProcessSnapshotWin::InitializeThreads( + bool gather_indirectly_referenced_memory) { const std::vector<ProcessReaderWin::Thread>& process_reader_threads = process_reader_.Threads(); for (const ProcessReaderWin::Thread& process_reader_thread : process_reader_threads) { auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin()); - if (thread->Initialize(&process_reader_, process_reader_thread)) { + if (thread->Initialize(&process_reader_, + process_reader_thread, + gather_indirectly_referenced_memory)) { threads_.push_back(thread.release()); } } @@ -258,6 +242,38 @@ void ProcessSnapshotWin::InitializeModules() { } } +void ProcessSnapshotWin::GetCrashpadOptionsInternal( + CrashpadInfoClientOptions* options) { + CrashpadInfoClientOptions local_options; + + for (internal::ModuleSnapshotWin* module : modules_) { + CrashpadInfoClientOptions module_options; + module->GetCrashpadOptions(&module_options); + + if (local_options.crashpad_handler_behavior == TriState::kUnset) { + local_options.crashpad_handler_behavior = + module_options.crashpad_handler_behavior; + } + if (local_options.system_crash_reporter_forwarding == TriState::kUnset) { + local_options.system_crash_reporter_forwarding = + module_options.system_crash_reporter_forwarding; + } + if (local_options.gather_indirectly_referenced_memory == TriState::kUnset) { + local_options.gather_indirectly_referenced_memory = + module_options.gather_indirectly_referenced_memory; + } + + // If non-default values have been found for all options, the loop can end + // early. + if (local_options.crashpad_handler_behavior != TriState::kUnset && + local_options.system_crash_reporter_forwarding != TriState::kUnset) { + break; + } + } + + *options = local_options; +} + template <class Traits> void ProcessSnapshotWin::InitializePebData( WinVMAddress debug_critical_section_address) { diff --git a/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.h b/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.h index 64e73da..c2307be 100644 --- a/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.h +++ b/third_party/crashpad/crashpad/snapshot/win/process_snapshot_win.h @@ -141,11 +141,14 @@ class ProcessSnapshotWin final : public ProcessSnapshot { private: // Initializes threads_ on behalf of Initialize(). - void InitializeThreads(); + void InitializeThreads(bool gather_indirectly_referenced_memory); // Initializes modules_ on behalf of Initialize(). void InitializeModules(); + // Initializes options_ on behalf of Initialize(). + void GetCrashpadOptionsInternal(CrashpadInfoClientOptions* options); + // Initializes various memory blocks reachable from the PEB on behalf of // Initialize(). template <class Traits> @@ -186,6 +189,7 @@ class ProcessSnapshotWin final : public ProcessSnapshot { UUID client_id_; std::map<std::string, std::string> annotations_simple_map_; timeval snapshot_time_; + CrashpadInfoClientOptions options_; InitializationStateDcheck initialized_; DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotWin); diff --git a/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.cc b/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.cc index f3446e9..a240eb2 100644 --- a/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.cc +++ b/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.cc @@ -17,8 +17,9 @@ #include <vector> #include "base/logging.h" -#include "snapshot/win/capture_context_memory.h" +#include "snapshot/capture_memory.h" #include "snapshot/win/cpu_context_win.h" +#include "snapshot/win/capture_memory_delegate_win.h" #include "snapshot/win/process_reader_win.h" namespace crashpad { @@ -38,7 +39,8 @@ ThreadSnapshotWin::~ThreadSnapshotWin() { bool ThreadSnapshotWin::Initialize( ProcessReaderWin* process_reader, - const ProcessReaderWin::Thread& process_reader_thread) { + const ProcessReaderWin::Thread& process_reader_thread, + bool gather_indirectly_referenced_memory) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); thread_ = process_reader_thread; @@ -76,8 +78,11 @@ bool ThreadSnapshotWin::Initialize( InitializeX86Context(process_reader_thread.context.native, context_.x86); #endif // ARCH_CPU_X86_64 - CaptureMemoryPointedToByContext( - context_, process_reader, thread_, &pointed_to_memory_); + CaptureMemoryDelegateWin capture_memory_delegate( + process_reader, thread_, &pointed_to_memory_); + CaptureMemory::PointedToByContext(context_, &capture_memory_delegate); + if (gather_indirectly_referenced_memory) + CaptureMemory::PointedToByMemoryRange(stack_, &capture_memory_delegate); INITIALIZATION_STATE_SET_VALID(initialized_); return true; diff --git a/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.h b/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.h index 74e6bc6..d746ddb 100644 --- a/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.h +++ b/third_party/crashpad/crashpad/snapshot/win/thread_snapshot_win.h @@ -48,11 +48,14 @@ class ThreadSnapshotWin final : public ThreadSnapshot { //! the thread. //! \param[in] process_reader_thread The thread within the ProcessReaderWin //! for which the snapshot should be created. + //! \param[in] gather_indirectly_referenced_memory If `true`, adds extra + //! memory regions to the snapshot pointed to by the thread's stack. //! //! \return `true` if the snapshot could be created, `false` otherwise with //! an appropriate message logged. bool Initialize(ProcessReaderWin* process_reader, - const ProcessReaderWin::Thread& process_reader_thread); + const ProcessReaderWin::Thread& process_reader_thread, + bool gather_indirectly_referenced_memory); // ThreadSnapshot: diff --git a/third_party/crashpad/crashpad/third_party/gtest/gmock.gyp b/third_party/crashpad/crashpad/third_party/gtest/gmock.gyp index d553bcf..683b89e 100644 --- a/third_party/crashpad/crashpad/third_party/gtest/gmock.gyp +++ b/third_party/crashpad/crashpad/third_party/gtest/gmock.gyp @@ -14,10 +14,19 @@ { 'includes': [ - '../../build/crashpad_in_chromium.gypi', + '../../build/crashpad_dependencies.gypi', ], 'conditions': [ - ['crashpad_in_chromium==0', { + ['crashpad_dependencies!="chromium"', { + 'variables': { + 'conditions': [ + ['crashpad_dependencies=="standalone"', { + 'gmock_dir': 'gtest/googlemock', + }, { + 'gmock_dir': '../../../../gmock', + }], + ], + }, 'target_defaults': { # gmock relies heavily on objects with static storage duration. 'xcode_settings': { @@ -38,41 +47,41 @@ 'gtest.gyp:gtest', ], 'include_dirs': [ - 'gtest/googlemock', - 'gtest/googlemock/include', + '<(gmock_dir)', + '<(gmock_dir)/include', ], 'sources': [ - 'gtest/googlemock/include/gmock/gmock-actions.h', - 'gtest/googlemock/include/gmock/gmock-cardinalities.h', - 'gtest/googlemock/include/gmock/gmock-generated-actions.h', - 'gtest/googlemock/include/gmock/gmock-generated-function-mockers.h', - 'gtest/googlemock/include/gmock/gmock-generated-matchers.h', - 'gtest/googlemock/include/gmock/gmock-generated-nice-strict.h', - 'gtest/googlemock/include/gmock/gmock-matchers.h', - 'gtest/googlemock/include/gmock/gmock-more-actions.h', - 'gtest/googlemock/include/gmock/gmock-more-matchers.h', - 'gtest/googlemock/include/gmock/gmock-spec-builders.h', - 'gtest/googlemock/include/gmock/gmock.h', - 'gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h', - 'gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h', - 'gtest/googlemock/include/gmock/internal/custom/gmock-port.h', - 'gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h', - 'gtest/googlemock/include/gmock/internal/gmock-internal-utils.h', - 'gtest/googlemock/include/gmock/internal/gmock-port.h', - 'gtest/googlemock/src/gmock-all.cc', - 'gtest/googlemock/src/gmock-cardinalities.cc', - 'gtest/googlemock/src/gmock-internal-utils.cc', - 'gtest/googlemock/src/gmock-matchers.cc', - 'gtest/googlemock/src/gmock-spec-builders.cc', - 'gtest/googlemock/src/gmock.cc', + '<(gmock_dir)/include/gmock/gmock-actions.h', + '<(gmock_dir)/include/gmock/gmock-cardinalities.h', + '<(gmock_dir)/include/gmock/gmock-generated-actions.h', + '<(gmock_dir)/include/gmock/gmock-generated-function-mockers.h', + '<(gmock_dir)/include/gmock/gmock-generated-matchers.h', + '<(gmock_dir)/include/gmock/gmock-generated-nice-strict.h', + '<(gmock_dir)/include/gmock/gmock-matchers.h', + '<(gmock_dir)/include/gmock/gmock-more-actions.h', + '<(gmock_dir)/include/gmock/gmock-more-matchers.h', + '<(gmock_dir)/include/gmock/gmock-spec-builders.h', + '<(gmock_dir)/include/gmock/gmock.h', + '<(gmock_dir)/include/gmock/internal/custom/gmock-generated-actions.h', + '<(gmock_dir)/include/gmock/internal/custom/gmock-matchers.h', + '<(gmock_dir)/include/gmock/internal/custom/gmock-port.h', + '<(gmock_dir)/include/gmock/internal/gmock-generated-internal-utils.h', + '<(gmock_dir)/include/gmock/internal/gmock-internal-utils.h', + '<(gmock_dir)/include/gmock/internal/gmock-port.h', + '<(gmock_dir)/src/gmock-all.cc', + '<(gmock_dir)/src/gmock-cardinalities.cc', + '<(gmock_dir)/src/gmock-internal-utils.cc', + '<(gmock_dir)/src/gmock-matchers.cc', + '<(gmock_dir)/src/gmock-spec-builders.cc', + '<(gmock_dir)/src/gmock.cc', ], 'sources!': [ - 'gtest/googlemock/src/gmock-all.cc', + '<(gmock_dir)/src/gmock-all.cc', ], 'direct_dependent_settings': { 'include_dirs': [ - 'gtest/googlemock/include', + '<(gmock_dir)/include', ], 'conditions': [ ['clang!=0', { @@ -114,7 +123,7 @@ 'gtest.gyp:gtest', ], 'sources': [ - 'gtest/googlemock/src/gmock_main.cc', + '<(gmock_dir)/src/gmock_main.cc', ], }, { @@ -127,7 +136,7 @@ 'direct_dependent_settings': { 'type': 'executable', 'include_dirs': [ - 'gtest/googlemock', + '<(gmock_dir)', ], }, 'export_dependent_settings': [ @@ -145,19 +154,19 @@ 'gtest/googletest', ], 'sources': [ - 'gtest/googlemock/test/gmock-actions_test.cc', - 'gtest/googlemock/test/gmock-cardinalities_test.cc', - 'gtest/googlemock/test/gmock-generated-actions_test.cc', - 'gtest/googlemock/test/gmock-generated-function-mockers_test.cc', - 'gtest/googlemock/test/gmock-generated-internal-utils_test.cc', - 'gtest/googlemock/test/gmock-generated-matchers_test.cc', - 'gtest/googlemock/test/gmock-internal-utils_test.cc', - 'gtest/googlemock/test/gmock-matchers_test.cc', - 'gtest/googlemock/test/gmock-more-actions_test.cc', - 'gtest/googlemock/test/gmock-nice-strict_test.cc', - 'gtest/googlemock/test/gmock-port_test.cc', - 'gtest/googlemock/test/gmock-spec-builders_test.cc', - 'gtest/googlemock/test/gmock_test.cc', + '<(gmock_dir)/test/gmock-actions_test.cc', + '<(gmock_dir)/test/gmock-cardinalities_test.cc', + '<(gmock_dir)/test/gmock-generated-actions_test.cc', + '<(gmock_dir)/test/gmock-generated-function-mockers_test.cc', + '<(gmock_dir)/test/gmock-generated-internal-utils_test.cc', + '<(gmock_dir)/test/gmock-generated-matchers_test.cc', + '<(gmock_dir)/test/gmock-internal-utils_test.cc', + '<(gmock_dir)/test/gmock-matchers_test.cc', + '<(gmock_dir)/test/gmock-more-actions_test.cc', + '<(gmock_dir)/test/gmock-nice-strict_test.cc', + '<(gmock_dir)/test/gmock-port_test.cc', + '<(gmock_dir)/test/gmock-spec-builders_test.cc', + '<(gmock_dir)/test/gmock_test.cc', ], }, { @@ -167,9 +176,9 @@ 'gmock_main', ], 'sources': [ - 'gtest/googlemock/test/gmock_link_test.cc', - 'gtest/googlemock/test/gmock_link_test.h', - 'gtest/googlemock/test/gmock_link2_test.cc', + '<(gmock_dir)/test/gmock_link_test.cc', + '<(gmock_dir)/test/gmock_link_test.h', + '<(gmock_dir)/test/gmock_link2_test.cc', ], }, { @@ -178,7 +187,7 @@ 'gmock_test_executable', ], 'sources': [ - 'gtest/googlemock/test/gmock_stress_test.cc', + '<(gmock_dir)/test/gmock_stress_test.cc', ], }, { @@ -191,7 +200,7 @@ ], }, ], - }, { # else: crashpad_in_chromium!=0 + }, { # else: crashpad_dependencies=="chromium" 'targets': [ { 'target_name': 'gmock', diff --git a/third_party/crashpad/crashpad/third_party/gtest/gtest.gyp b/third_party/crashpad/crashpad/third_party/gtest/gtest.gyp index 2ac6ca2..e01adaf 100644 --- a/third_party/crashpad/crashpad/third_party/gtest/gtest.gyp +++ b/third_party/crashpad/crashpad/third_party/gtest/gtest.gyp @@ -14,10 +14,19 @@ { 'includes': [ - '../../build/crashpad_in_chromium.gypi', + '../../build/crashpad_dependencies.gypi', ], 'conditions': [ - ['crashpad_in_chromium==0', { + ['crashpad_dependencies!="chromium"', { + 'variables': { + 'conditions': [ + ['crashpad_dependencies=="standalone"', { + 'gtest_dir': 'gtest/googletest', + }, { + 'gtest_dir': '../../../../gtest', + }], + ], + }, 'target_defaults': { # gtest relies heavily on objects with static storage duration. 'xcode_settings': { @@ -35,53 +44,70 @@ 'target_name': 'gtest', 'type': 'static_library', 'include_dirs': [ - 'gtest/googletest', - 'gtest/googletest/include', + '<(gtest_dir)', + '<(gtest_dir)/include', ], 'sources': [ - 'gtest/googletest/include/gtest/gtest-death-test.h', - 'gtest/googletest/include/gtest/gtest-message.h', - 'gtest/googletest/include/gtest/gtest-param-test.h', - 'gtest/googletest/include/gtest/gtest-printers.h', - 'gtest/googletest/include/gtest/gtest-spi.h', - 'gtest/googletest/include/gtest/gtest-test-part.h', - 'gtest/googletest/include/gtest/gtest-typed-test.h', - 'gtest/googletest/include/gtest/gtest.h', - 'gtest/googletest/include/gtest/gtest_pred_impl.h', - 'gtest/googletest/include/gtest/gtest_prod.h', - 'gtest/googletest/include/gtest/internal/custom/gtest-port.h', - 'gtest/googletest/include/gtest/internal/custom/gtest-printers.h', - 'gtest/googletest/include/gtest/internal/custom/gtest.h', - 'gtest/googletest/include/gtest/internal/gtest-death-test-internal.h', - 'gtest/googletest/include/gtest/internal/gtest-filepath.h', - 'gtest/googletest/include/gtest/internal/gtest-internal.h', - 'gtest/googletest/include/gtest/internal/gtest-linked_ptr.h', - 'gtest/googletest/include/gtest/internal/gtest-param-util-generated.h', - 'gtest/googletest/include/gtest/internal/gtest-param-util.h', - 'gtest/googletest/include/gtest/internal/gtest-port-arch.h', - 'gtest/googletest/include/gtest/internal/gtest-port.h', - 'gtest/googletest/include/gtest/internal/gtest-string.h', - 'gtest/googletest/include/gtest/internal/gtest-tuple.h', - 'gtest/googletest/include/gtest/internal/gtest-type-util.h', - 'gtest/googletest/src/gtest-all.cc', - 'gtest/googletest/src/gtest-death-test.cc', - 'gtest/googletest/src/gtest-filepath.cc', - 'gtest/googletest/src/gtest-internal-inl.h', - 'gtest/googletest/src/gtest-port.cc', - 'gtest/googletest/src/gtest-printers.cc', - 'gtest/googletest/src/gtest-test-part.cc', - 'gtest/googletest/src/gtest-typed-test.cc', - 'gtest/googletest/src/gtest.cc', + '<(gtest_dir)/include/gtest/gtest-death-test.h', + '<(gtest_dir)/include/gtest/gtest-message.h', + '<(gtest_dir)/include/gtest/gtest-param-test.h', + '<(gtest_dir)/include/gtest/gtest-printers.h', + '<(gtest_dir)/include/gtest/gtest-spi.h', + '<(gtest_dir)/include/gtest/gtest-test-part.h', + '<(gtest_dir)/include/gtest/gtest-typed-test.h', + '<(gtest_dir)/include/gtest/gtest.h', + '<(gtest_dir)/include/gtest/gtest_pred_impl.h', + '<(gtest_dir)/include/gtest/gtest_prod.h', + '<(gtest_dir)/include/gtest/internal/custom/gtest-port.h', + '<(gtest_dir)/include/gtest/internal/custom/gtest-printers.h', + '<(gtest_dir)/include/gtest/internal/custom/gtest.h', + '<(gtest_dir)/include/gtest/internal/gtest-death-test-internal.h', + '<(gtest_dir)/include/gtest/internal/gtest-filepath.h', + '<(gtest_dir)/include/gtest/internal/gtest-internal.h', + '<(gtest_dir)/include/gtest/internal/gtest-linked_ptr.h', + '<(gtest_dir)/include/gtest/internal/gtest-param-util-generated.h', + '<(gtest_dir)/include/gtest/internal/gtest-param-util.h', + '<(gtest_dir)/include/gtest/internal/gtest-port-arch.h', + '<(gtest_dir)/include/gtest/internal/gtest-port.h', + '<(gtest_dir)/include/gtest/internal/gtest-string.h', + '<(gtest_dir)/include/gtest/internal/gtest-tuple.h', + '<(gtest_dir)/include/gtest/internal/gtest-type-util.h', + '<(gtest_dir)/src/gtest-all.cc', + '<(gtest_dir)/src/gtest-death-test.cc', + '<(gtest_dir)/src/gtest-filepath.cc', + '<(gtest_dir)/src/gtest-internal-inl.h', + '<(gtest_dir)/src/gtest-port.cc', + '<(gtest_dir)/src/gtest-printers.cc', + '<(gtest_dir)/src/gtest-test-part.cc', + '<(gtest_dir)/src/gtest-typed-test.cc', + '<(gtest_dir)/src/gtest.cc', ], 'sources!': [ - 'gtest/googletest/src/gtest-all.cc', + '<(gtest_dir)/src/gtest-all.cc', ], - 'direct_dependent_settings': { 'include_dirs': [ - 'gtest/googletest/include', + '<(gtest_dir)/include', ], }, + 'conditions': [ + ['crashpad_dependencies=="external"', { + 'include_dirs': [ + '<(gtest_dir)/../..', + ], + 'defines': [ + 'GUNIT_NO_GOOGLE3=1', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + '<(gtest_dir)/../..', + ], + 'defines': [ + 'GUNIT_NO_GOOGLE3=1', + ], + }, + }], + ], }, { 'target_name': 'gtest_main', @@ -90,7 +116,7 @@ 'gtest', ], 'sources': [ - 'gtest/googletest/src/gtest_main.cc', + '<(gtest_dir)/src/gtest_main.cc', ], }, { @@ -102,7 +128,7 @@ 'direct_dependent_settings': { 'type': 'executable', 'include_dirs': [ - 'gtest/googletest', + '<(gtest_dir)', ], }, 'export_dependent_settings': [ @@ -116,23 +142,23 @@ 'gtest_main', ], 'sources': [ - 'gtest/googletest/test/gtest-death-test_test.cc', - 'gtest/googletest/test/gtest-filepath_test.cc', - 'gtest/googletest/test/gtest-linked_ptr_test.cc', - 'gtest/googletest/test/gtest-message_test.cc', - 'gtest/googletest/test/gtest-options_test.cc', - 'gtest/googletest/test/gtest-port_test.cc', - 'gtest/googletest/test/gtest-printers_test.cc', - 'gtest/googletest/test/gtest-test-part_test.cc', - 'gtest/googletest/test/gtest-typed-test2_test.cc', - 'gtest/googletest/test/gtest-typed-test_test.cc', - 'gtest/googletest/test/gtest-typed-test_test.h', - 'gtest/googletest/test/gtest_main_unittest.cc', - 'gtest/googletest/test/gtest_pred_impl_unittest.cc', - 'gtest/googletest/test/gtest_prod_test.cc', - 'gtest/googletest/test/gtest_unittest.cc', - 'gtest/googletest/test/production.cc', - 'gtest/googletest/test/production.h', + '<(gtest_dir)/test/gtest-death-test_test.cc', + '<(gtest_dir)/test/gtest-filepath_test.cc', + '<(gtest_dir)/test/gtest-linked_ptr_test.cc', + '<(gtest_dir)/test/gtest-message_test.cc', + '<(gtest_dir)/test/gtest-options_test.cc', + '<(gtest_dir)/test/gtest-port_test.cc', + '<(gtest_dir)/test/gtest-printers_test.cc', + '<(gtest_dir)/test/gtest-test-part_test.cc', + '<(gtest_dir)/test/gtest-typed-test2_test.cc', + '<(gtest_dir)/test/gtest-typed-test_test.cc', + '<(gtest_dir)/test/gtest-typed-test_test.h', + '<(gtest_dir)/test/gtest_main_unittest.cc', + '<(gtest_dir)/test/gtest_pred_impl_unittest.cc', + '<(gtest_dir)/test/gtest_prod_test.cc', + '<(gtest_dir)/test/gtest_unittest.cc', + '<(gtest_dir)/test/production.cc', + '<(gtest_dir)/test/production.h', ], }, { @@ -141,7 +167,7 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest_environment_test.cc', + '<(gtest_dir)/test/gtest_environment_test.cc', ], }, { @@ -150,7 +176,7 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest-listener_test.cc', + '<(gtest_dir)/test/gtest-listener_test.cc', ], }, { @@ -159,7 +185,7 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest_no_test_unittest.cc', + '<(gtest_dir)/test/gtest_no_test_unittest.cc', ], }, { @@ -168,9 +194,9 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest-param-test2_test.cc', - 'gtest/googletest/test/gtest-param-test_test.cc', - 'gtest/googletest/test/gtest-param-test_test.h', + '<(gtest_dir)/test/gtest-param-test2_test.cc', + '<(gtest_dir)/test/gtest-param-test_test.cc', + '<(gtest_dir)/test/gtest-param-test_test.h', ], }, { @@ -179,7 +205,7 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest_premature_exit_test.cc', + '<(gtest_dir)/test/gtest_premature_exit_test.cc', ], }, { @@ -188,7 +214,7 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest_repeat_test.cc', + '<(gtest_dir)/test/gtest_repeat_test.cc', ], }, { @@ -198,7 +224,7 @@ 'gtest_main', ], 'sources': [ - 'gtest/googletest/test/gtest_sole_header_test.cc', + '<(gtest_dir)/test/gtest_sole_header_test.cc', ], }, { @@ -207,7 +233,7 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest_stress_test.cc', + '<(gtest_dir)/test/gtest_stress_test.cc', ], }, { @@ -216,7 +242,7 @@ 'gtest_test_executable', ], 'sources': [ - 'gtest/googletest/test/gtest-unittest-api_test.cc', + '<(gtest_dir)/test/gtest-unittest-api_test.cc', ], }, { @@ -236,7 +262,7 @@ ], }, ], - }, { # else: crashpad_in_chromium!=0 + }, { # else: crashpad_dependencies=="chromium" 'targets': [ { 'target_name': 'gtest', diff --git a/third_party/crashpad/crashpad/third_party/mini_chromium/mini_chromium.gyp b/third_party/crashpad/crashpad/third_party/mini_chromium/mini_chromium.gyp index 56f897d..f063dd0 100644 --- a/third_party/crashpad/crashpad/third_party/mini_chromium/mini_chromium.gyp +++ b/third_party/crashpad/crashpad/third_party/mini_chromium/mini_chromium.gyp @@ -14,25 +14,27 @@ { 'includes': [ - '../../build/crashpad_in_chromium.gypi', + '../../build/crashpad_dependencies.gypi', ], 'targets': [ { - # To support both Crashpad’s standalone build and its in-Chromium build, - # Crashpad code depending on base should do so through this shim, which - # will either get base from mini_chromium or Chromium depending on the - # build type. + # To support Crashpad’s standalone build, its in-Chromium build, and its + # build depending on external libraries, Crashpad code depending on base + # should do so through this shim, which will either get base from + # mini_chromium, Chromium, or an external library depending on the build + # type. 'target_name': 'base', 'type': 'none', 'conditions': [ - ['crashpad_in_chromium==0', { + ['crashpad_dependencies=="standalone"', { 'dependencies': [ 'mini_chromium/base/base.gyp:base', ], 'export_dependent_settings': [ 'mini_chromium/base/base.gyp:base', ], - }, { # else: crashpad_in_chromium!=0 + }], + ['crashpad_dependencies=="chromium"', { 'dependencies': [ '<(DEPTH)/base/base.gyp:base', ], @@ -40,6 +42,14 @@ '<(DEPTH)/base/base.gyp:base', ], }], + ['crashpad_dependencies=="external"', { + 'dependencies': [ + '../../../../mini_chromium/mini_chromium/base/base.gyp:base', + ], + 'export_dependent_settings': [ + '../../../../mini_chromium/mini_chromium/base/base.gyp:base', + ], + }], ], }, ], |