diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/base/profiler/stack_sampler_impl.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/profiler/stack_sampler_impl.cc')
-rw-r--r-- | chromium/base/profiler/stack_sampler_impl.cc | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/chromium/base/profiler/stack_sampler_impl.cc b/chromium/base/profiler/stack_sampler_impl.cc index 9903b33feea..7b28a6036e0 100644 --- a/chromium/base/profiler/stack_sampler_impl.cc +++ b/chromium/base/profiler/stack_sampler_impl.cc @@ -4,11 +4,11 @@ #include "base/profiler/stack_sampler_impl.h" +#include <iterator> #include <utility> #include "base/check.h" #include "base/compiler_specific.h" -#include "base/logging.h" #include "base/profiler/metadata_recorder.h" #include "base/profiler/profile_builder.h" #include "base/profiler/sample_metadata.h" @@ -64,15 +64,22 @@ class StackCopierDelegate : public StackCopier::Delegate { } // namespace -StackSamplerImpl::StackSamplerImpl(std::unique_ptr<StackCopier> stack_copier, - std::unique_ptr<Unwinder> native_unwinder, - ModuleCache* module_cache, - StackSamplerTestDelegate* test_delegate) +// |core_unwinders| is iterated backward since |core_unwinders| is passed in +// increasing priority order while |unwinders_| is stored in decreasing priority +// order. +StackSamplerImpl::StackSamplerImpl( + std::unique_ptr<StackCopier> stack_copier, + std::vector<std::unique_ptr<Unwinder>> core_unwinders, + ModuleCache* module_cache, + StackSamplerTestDelegate* test_delegate) : stack_copier_(std::move(stack_copier)), + unwinders_(std::make_move_iterator(core_unwinders.rbegin()), + std::make_move_iterator(core_unwinders.rend())), module_cache_(module_cache), test_delegate_(test_delegate) { - DCHECK(native_unwinder); - unwinders_.push_front(std::move(native_unwinder)); + DCHECK(!unwinders_.empty()); + for (const auto& unwinder : unwinders_) + unwinder->AddInitialModules(module_cache_); } StackSamplerImpl::~StackSamplerImpl() = default; @@ -89,6 +96,8 @@ void StackSamplerImpl::RecordStackFrames(StackBuffer* stack_buffer, RegisterContext thread_context; uintptr_t stack_top; TimeTicks timestamp; + + bool copy_stack_succeeded; { // Make this scope as small as possible because |metadata_provider| is // holding a lock. @@ -96,11 +105,15 @@ void StackSamplerImpl::RecordStackFrames(StackBuffer* stack_buffer, GetSampleMetadataRecorder()); StackCopierDelegate delegate(&unwinders_, profile_builder, &metadata_provider); - bool success = stack_copier_->CopyStack( + copy_stack_succeeded = stack_copier_->CopyStack( stack_buffer, &stack_top, ×tamp, &thread_context, &delegate); - if (!success) - return; } + if (!copy_stack_succeeded) { + profile_builder->OnSampleCompleted( + {}, timestamp.is_null() ? TimeTicks::Now() : timestamp); + return; + } + for (const auto& unwinder : unwinders_) unwinder->UpdateModules(module_cache_); @@ -155,8 +168,8 @@ std::vector<Frame> StackSamplerImpl::WalkStack( result = unwinder->get()->TryUnwind(thread_context, stack_top, module_cache, &stack); - // The native unwinder should be the only one that returns COMPLETED - // since the stack starts in native code. + // The unwinder with the lowest priority should be the only one that returns + // COMPLETED since the stack starts in native code. DCHECK(result != UnwindResult::COMPLETED || unwinder->get() == unwinders.back().get()); } while (result != UnwindResult::ABORTED && |