summaryrefslogtreecommitdiff
path: root/chromium/base/profiler
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-12 09:13:00 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-16 09:58:26 +0000
commit03561cae90f1d99b5c54b1ef3be69f10e882b25e (patch)
treecc5f0958e823c044e7ae51cc0117fe51432abe5e /chromium/base/profiler
parentfa98118a45f7e169f8846086dc2c22c49a8ba310 (diff)
downloadqtwebengine-chromium-03561cae90f1d99b5c54b1ef3be69f10e882b25e.tar.gz
BASELINE: Update Chromium to 88.0.4324.208
Change-Id: I3ae87d23e4eff4b4a469685658740a213600c667 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/profiler')
-rw-r--r--chromium/base/profiler/arm_cfi_table.cc7
-rw-r--r--chromium/base/profiler/metadata_recorder_unittest.cc3
-rw-r--r--chromium/base/profiler/module_cache.cc7
-rw-r--r--chromium/base/profiler/module_cache_unittest.cc2
-rw-r--r--chromium/base/profiler/native_unwinder_android_unittest.cc34
-rw-r--r--chromium/base/profiler/stack_copier_signal_unittest.cc7
-rw-r--r--chromium/base/profiler/stack_sampler_impl.cc18
-rw-r--r--chromium/base/profiler/stack_sampler_impl.h5
-rw-r--r--chromium/base/profiler/stack_sampling_profiler.cc2
-rw-r--r--chromium/base/profiler/stack_sampling_profiler_test_util.cc2
-rw-r--r--chromium/base/profiler/stack_sampling_profiler_unittest.cc54
-rw-r--r--chromium/base/profiler/thread_delegate_posix.h2
12 files changed, 104 insertions, 39 deletions
diff --git a/chromium/base/profiler/arm_cfi_table.cc b/chromium/base/profiler/arm_cfi_table.cc
index a9593b4a828..04f97370388 100644
--- a/chromium/base/profiler/arm_cfi_table.cc
+++ b/chromium/base/profiler/arm_cfi_table.cc
@@ -4,7 +4,7 @@
#include "base/profiler/arm_cfi_table.h"
-#include <algorithm>
+#include "base/ranges/algorithm.h"
namespace base {
@@ -91,8 +91,7 @@ Optional<ArmCFITable::FrameEntry> ArmCFITable::FindEntryForAddress(
// Find the required function address in UNW_INDEX as the last function lower
// or equal to |address| (the value right before the result of upper_bound(),
// if any).
- auto func_it = std::upper_bound(function_addresses_.begin(),
- function_addresses_.end(), address);
+ auto func_it = ranges::upper_bound(function_addresses_, address);
// If no function comes before |address|, no CFI entry is returned.
if (func_it == function_addresses_.begin())
return nullopt;
@@ -157,4 +156,4 @@ Optional<ArmCFITable::FrameEntry> ArmCFITable::FindEntryForAddress(
return last_frame_entry;
}
-} // namespace base \ No newline at end of file
+} // namespace base
diff --git a/chromium/base/profiler/metadata_recorder_unittest.cc b/chromium/base/profiler/metadata_recorder_unittest.cc
index 4aff812a044..33332c150a2 100644
--- a/chromium/base/profiler/metadata_recorder_unittest.cc
+++ b/chromium/base/profiler/metadata_recorder_unittest.cc
@@ -4,6 +4,7 @@
#include "base/profiler/metadata_recorder.h"
+#include "base/ranges/algorithm.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -213,7 +214,7 @@ TEST(MetadataRecorderTest, ReclaimInactiveSlots) {
}
MetadataRecorder::ItemArray items_arr;
- std::copy(items_set.begin(), items_set.end(), items_arr.begin());
+ ranges::copy(items_set, items_arr.begin());
MetadataRecorder::ItemArray recorder_items;
size_t recorder_item_count =
diff --git a/chromium/base/profiler/module_cache.cc b/chromium/base/profiler/module_cache.cc
index 9c72296a9f8..b36ba462c92 100644
--- a/chromium/base/profiler/module_cache.cc
+++ b/chromium/base/profiler/module_cache.cc
@@ -4,10 +4,11 @@
#include "base/profiler/module_cache.h"
-#include <algorithm>
#include <iterator>
#include <utility>
+#include "base/ranges/algorithm.h"
+
namespace base {
namespace {
@@ -69,8 +70,8 @@ void ModuleCache::UpdateNonNativeModules(
//
// stable_partition is O(m*log(r)) where m is the number of current modules
// and r is the number of modules to remove. insert and erase are both O(r).
- auto first_module_defunct_modules = std::stable_partition(
- non_native_modules_.begin(), non_native_modules_.end(),
+ auto first_module_defunct_modules = ranges::stable_partition(
+ non_native_modules_,
[&defunct_modules_set](const std::unique_ptr<const Module>& module) {
return defunct_modules_set.find(module.get()) ==
defunct_modules_set.end();
diff --git a/chromium/base/profiler/module_cache_unittest.cc b/chromium/base/profiler/module_cache_unittest.cc
index b6eb063f008..57986440945 100644
--- a/chromium/base/profiler/module_cache_unittest.cc
+++ b/chromium/base/profiler/module_cache_unittest.cc
@@ -12,7 +12,7 @@
#include "base/callback_helpers.h"
#include "base/profiler/module_cache.h"
#include "base/strings/string_piece.h"
-#include "base/test/bind_test_util.h"
+#include "base/test/bind.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromium/base/profiler/native_unwinder_android_unittest.cc b/chromium/base/profiler/native_unwinder_android_unittest.cc
index 7bcbecedbec..5972c77327a 100644
--- a/chromium/base/profiler/native_unwinder_android_unittest.cc
+++ b/chromium/base/profiler/native_unwinder_android_unittest.cc
@@ -24,7 +24,7 @@
#include "base/profiler/stack_sampling_profiler_test_util.h"
#include "base/profiler/thread_delegate_posix.h"
#include "base/strings/stringprintf.h"
-#include "base/test/bind_test_util.h"
+#include "base/test/bind.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -102,7 +102,13 @@ std::vector<Frame> CaptureScenario(
}
// Checks that the expected information is present in sampled frames.
-TEST(NativeUnwinderAndroidTest, PlainFunction) {
+#if defined(ADDRESS_SANITIZER)
+// TODO(https://crbug.com/1147315): Fix, re-enable.
+#define MAYBE_PlainFunction DISABLED_PlainFunction
+#else
+#define MAYBE_PlainFunction PlainFunction
+#endif
+TEST(NativeUnwinderAndroidTest, MAYBE_PlainFunction) {
UnwindScenario scenario(BindRepeating(&CallWithPlainFunction));
std::unique_ptr<unwindstack::Maps> maps = NativeUnwinderAndroid::CreateMaps();
@@ -136,7 +142,13 @@ TEST(NativeUnwinderAndroidTest, PlainFunction) {
// Checks that the unwinder handles stacks containing dynamically-allocated
// stack memory.
-TEST(NativeUnwinderAndroidTest, Alloca) {
+#if defined(ADDRESS_SANITIZER)
+// TODO(https://crbug.com/1147315): Fix, re-enable.
+#define MAYBE_Alloca DISABLED_Alloca
+#else
+#define MAYBE_Alloca Alloca
+#endif
+TEST(NativeUnwinderAndroidTest, MAYBE_Alloca) {
UnwindScenario scenario(BindRepeating(&CallWithAlloca));
std::unique_ptr<unwindstack::Maps> maps = NativeUnwinderAndroid::CreateMaps();
@@ -170,7 +182,13 @@ TEST(NativeUnwinderAndroidTest, Alloca) {
// Checks that a stack that runs through another library produces a stack with
// the expected functions.
-TEST(NativeUnwinderAndroidTest, OtherLibrary) {
+#if defined(ADDRESS_SANITIZER)
+// TODO(https://crbug.com/1147315): Fix, re-enable.
+#define MAYBE_OtherLibrary DISABLED_OtherLibrary
+#else
+#define MAYBE_OtherLibrary OtherLibrary
+#endif
+TEST(NativeUnwinderAndroidTest, MAYBE_OtherLibrary) {
NativeLibrary other_library = LoadOtherLibrary();
UnwindScenario scenario(
BindRepeating(&CallThroughOtherLibrary, Unretained(other_library)));
@@ -234,7 +252,13 @@ TEST(NativeUnwinderAndroidTest, ExcludeOtherLibrary) {
}
// Check that unwinding can be resumed after an incomplete unwind.
-TEST(NativeUnwinderAndroidTest, ResumeUnwinding) {
+#if defined(ADDRESS_SANITIZER)
+// TODO(https://crbug.com/1147315): Fix, re-enable.
+#define MAYBE_ResumeUnwinding DISABLED_ResumeUnwinding
+#else
+#define MAYBE_ResumeUnwinding ResumeUnwinding
+#endif
+TEST(NativeUnwinderAndroidTest, MAYBE_ResumeUnwinding) {
NativeLibrary other_library = LoadOtherLibrary();
UnwindScenario scenario(
BindRepeating(&CallThroughOtherLibrary, Unretained(other_library)));
diff --git a/chromium/base/profiler/stack_copier_signal_unittest.cc b/chromium/base/profiler/stack_copier_signal_unittest.cc
index dd7434c2a24..c6d4839f13e 100644
--- a/chromium/base/profiler/stack_copier_signal_unittest.cc
+++ b/chromium/base/profiler/stack_copier_signal_unittest.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <utility>
+#include "base/debug/alias.h"
#include "base/profiler/sampling_profiler_thread_token.h"
#include "base/profiler/stack_buffer.h"
#include "base/profiler/stack_copier_signal.h"
@@ -100,11 +101,11 @@ TEST(StackCopierSignalTest, MAYBE_CopyStack) {
ASSERT_TRUE(thread_delegate);
StackCopierSignal copier(std::move(thread_delegate));
- // Copy the sentinel values onto the stack. Volatile to defeat compiler
- // optimizations.
- volatile uint32_t sentinels[size(kStackSentinels)];
+ // Copy the sentinel values onto the stack.
+ uint32_t sentinels[size(kStackSentinels)];
for (size_t i = 0; i < size(kStackSentinels); ++i)
sentinels[i] = kStackSentinels[i];
+ base::debug::Alias((void*)sentinels); // Defeat compiler optimizations.
bool result = copier.CopyStack(&stack_buffer, &stack_top, &timestamp,
&context, &stack_copier_delegate);
diff --git a/chromium/base/profiler/stack_sampler_impl.cc b/chromium/base/profiler/stack_sampler_impl.cc
index a05b10e2705..bbe91e469e5 100644
--- a/chromium/base/profiler/stack_sampler_impl.cc
+++ b/chromium/base/profiler/stack_sampler_impl.cc
@@ -16,6 +16,7 @@
#include "base/profiler/stack_copier.h"
#include "base/profiler/suspendable_thread_delegate.h"
#include "base/profiler/unwinder.h"
+#include "base/ranges/algorithm.h"
#include "build/build_config.h"
// IMPORTANT NOTE: Some functions within this implementation are invoked while
@@ -92,10 +93,16 @@ void StackSamplerImpl::Initialize() {
for (const auto& unwinder : unwinders_)
unwinder->AddInitialModules(module_cache_);
+
+ was_initialized_ = true;
}
void StackSamplerImpl::AddAuxUnwinder(std::unique_ptr<Unwinder> unwinder) {
- unwinder->AddInitialModules(module_cache_);
+ // Initialize() invokes AddInitialModules() on the unwinders that are present
+ // at the time. If it hasn't occurred yet, we allow it to add the initial
+ // modules, otherwise we do it here.
+ if (was_initialized_)
+ unwinder->AddInitialModules(module_cache_);
unwinders_.push_front(std::move(unwinder));
}
@@ -169,11 +176,10 @@ std::vector<Frame> StackSamplerImpl::WalkStack(
do {
// Choose an authoritative unwinder for the current module. Use the first
// unwinder that thinks it can unwind from the current frame.
- auto unwinder =
- std::find_if(unwinders.begin(), unwinders.end(),
- [&stack](const std::unique_ptr<Unwinder>& unwinder) {
- return unwinder->CanUnwindFrom(stack.back());
- });
+ auto unwinder = ranges::find_if(
+ unwinders, [&stack](const std::unique_ptr<Unwinder>& unwinder) {
+ return unwinder->CanUnwindFrom(stack.back());
+ });
if (unwinder == unwinders.end())
return stack;
diff --git a/chromium/base/profiler/stack_sampler_impl.h b/chromium/base/profiler/stack_sampler_impl.h
index 8e351acac0e..2739071d374 100644
--- a/chromium/base/profiler/stack_sampler_impl.h
+++ b/chromium/base/profiler/stack_sampler_impl.h
@@ -62,6 +62,11 @@ class BASE_EXPORT StackSamplerImpl : public StackSampler {
ModuleCache* const module_cache_;
const RepeatingClosure record_sample_callback_;
StackSamplerTestDelegate* const test_delegate_;
+
+ // True if ownership of the object has been passed to the profiling thread and
+ // initialization has occurred there. If that's the case then any further aux
+ // unwinder that's provided needs to be set up within AddAuxUnwinder().
+ bool was_initialized_ = false;
};
} // namespace base
diff --git a/chromium/base/profiler/stack_sampling_profiler.cc b/chromium/base/profiler/stack_sampling_profiler.cc
index 572ba1f8f5c..2bd80be9f37 100644
--- a/chromium/base/profiler/stack_sampling_profiler.cc
+++ b/chromium/base/profiler/stack_sampling_profiler.cc
@@ -12,8 +12,8 @@
#include "base/atomic_sequence_num.h"
#include "base/atomicops.h"
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/callback.h"
+#include "base/callback_helpers.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
diff --git a/chromium/base/profiler/stack_sampling_profiler_test_util.cc b/chromium/base/profiler/stack_sampling_profiler_test_util.cc
index 7685106d1b0..0bb9fb9d542 100644
--- a/chromium/base/profiler/stack_sampling_profiler_test_util.cc
+++ b/chromium/base/profiler/stack_sampling_profiler_test_util.cc
@@ -16,7 +16,7 @@
#include "base/profiler/stack_sampling_profiler.h"
#include "base/profiler/unwinder.h"
#include "base/strings/stringprintf.h"
-#include "base/test/bind_test_util.h"
+#include "base/test/bind.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromium/base/profiler/stack_sampling_profiler_unittest.cc b/chromium/base/profiler/stack_sampling_profiler_unittest.cc
index 7951dfe2b51..6c8c3a3299e 100644
--- a/chromium/base/profiler/stack_sampling_profiler_unittest.cc
+++ b/chromium/base/profiler/stack_sampling_profiler_unittest.cc
@@ -5,7 +5,6 @@
#include <stddef.h>
#include <stdint.h>
-#include <algorithm>
#include <cstdlib>
#include <memory>
#include <set>
@@ -26,13 +25,14 @@
#include "base/profiler/stack_sampling_profiler.h"
#include "base/profiler/stack_sampling_profiler_test_util.h"
#include "base/profiler/unwinder.h"
+#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/scoped_native_library.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
-#include "base/test/bind_test_util.h"
+#include "base/test/bind.h"
#include "base/threading/simple_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
@@ -270,10 +270,10 @@ size_t WaitForSamplingComplete(
const std::vector<std::unique_ptr<TestProfilerInfo>>& infos) {
// Map unique_ptrs to something that WaitMany can accept.
std::vector<WaitableEvent*> sampling_completed_rawptrs(infos.size());
- std::transform(infos.begin(), infos.end(), sampling_completed_rawptrs.begin(),
- [](const std::unique_ptr<TestProfilerInfo>& info) {
- return &info.get()->completed;
- });
+ ranges::transform(infos, sampling_completed_rawptrs.begin(),
+ [](const std::unique_ptr<TestProfilerInfo>& info) {
+ return &info.get()->completed;
+ });
// Wait for one profiler to finish.
return WaitableEvent::WaitMany(sampling_completed_rawptrs.data(),
sampling_completed_rawptrs.size());
@@ -474,12 +474,19 @@ PROFILER_TEST_F(StackSamplingProfilerTest, MAYBE_Basic) {
// A simple unwinder that always generates one frame then aborts the stack walk.
class TestAuxUnwinder : public Unwinder {
public:
- TestAuxUnwinder(const Frame& frame_to_report)
- : frame_to_report_(frame_to_report) {}
+ TestAuxUnwinder(const Frame& frame_to_report,
+ base::RepeatingClosure add_initial_modules_callback)
+ : frame_to_report_(frame_to_report),
+ add_initial_modules_callback_(std::move(add_initial_modules_callback)) {
+ }
TestAuxUnwinder(const TestAuxUnwinder&) = delete;
TestAuxUnwinder& operator=(const TestAuxUnwinder&) = delete;
+ void AddInitialModules(ModuleCache* module_cache) override {
+ if (add_initial_modules_callback_)
+ add_initial_modules_callback_.Run();
+ }
bool CanUnwindFrom(const Frame& current_frame) const override { return true; }
UnwindResult TryUnwind(RegisterContext* thread_context,
@@ -492,6 +499,7 @@ class TestAuxUnwinder : public Unwinder {
private:
const Frame frame_to_report_;
+ base::RepeatingClosure add_initial_modules_callback_;
};
// Checks that the profiler handles stacks containing dynamically-allocated
@@ -1285,6 +1293,12 @@ PROFILER_TEST_F(StackSamplingProfilerTest, AddAuxUnwinder_BeforeStart) {
UnwindScenario scenario(BindRepeating(&CallWithPlainFunction));
+ int add_initial_modules_invocation_count = 0;
+ const auto add_initial_modules_callback =
+ [&add_initial_modules_invocation_count]() {
+ ++add_initial_modules_invocation_count;
+ };
+
Profile profile;
WithTargetThread(
&scenario,
@@ -1303,12 +1317,15 @@ PROFILER_TEST_F(StackSamplingProfilerTest, AddAuxUnwinder_BeforeStart) {
sampling_thread_completed.Signal();
})),
CreateCoreUnwindersFactoryForTesting(module_cache()));
- profiler.AddAuxUnwinder(
- std::make_unique<TestAuxUnwinder>(Frame(23, nullptr)));
+ profiler.AddAuxUnwinder(std::make_unique<TestAuxUnwinder>(
+ Frame(23, nullptr),
+ BindLambdaForTesting(add_initial_modules_callback)));
profiler.Start();
sampling_thread_completed.Wait();
}));
+ ASSERT_EQ(1, add_initial_modules_invocation_count);
+
// The sample should have one frame from the context values and one from the
// TestAuxUnwinder.
ASSERT_EQ(1u, profile.samples.size());
@@ -1326,6 +1343,12 @@ PROFILER_TEST_F(StackSamplingProfilerTest, AddAuxUnwinder_AfterStart) {
UnwindScenario scenario(BindRepeating(&CallWithPlainFunction));
+ int add_initial_modules_invocation_count = 0;
+ const auto add_initial_modules_callback =
+ [&add_initial_modules_invocation_count]() {
+ ++add_initial_modules_invocation_count;
+ };
+
Profile profile;
WithTargetThread(
&scenario,
@@ -1345,11 +1368,14 @@ PROFILER_TEST_F(StackSamplingProfilerTest, AddAuxUnwinder_AfterStart) {
})),
CreateCoreUnwindersFactoryForTesting(module_cache()));
profiler.Start();
- profiler.AddAuxUnwinder(
- std::make_unique<TestAuxUnwinder>(Frame(23, nullptr)));
+ profiler.AddAuxUnwinder(std::make_unique<TestAuxUnwinder>(
+ Frame(23, nullptr),
+ BindLambdaForTesting(add_initial_modules_callback)));
sampling_thread_completed.Wait();
}));
+ ASSERT_EQ(1, add_initial_modules_invocation_count);
+
// The sample should have one frame from the context values and one from the
// TestAuxUnwinder.
ASSERT_EQ(1u, profile.samples.size());
@@ -1387,8 +1413,8 @@ PROFILER_TEST_F(StackSamplingProfilerTest, AddAuxUnwinder_AfterStop) {
CreateCoreUnwindersFactoryForTesting(module_cache()));
profiler.Start();
profiler.Stop();
- profiler.AddAuxUnwinder(
- std::make_unique<TestAuxUnwinder>(Frame(23, nullptr)));
+ profiler.AddAuxUnwinder(std::make_unique<TestAuxUnwinder>(
+ Frame(23, nullptr), base::RepeatingClosure()));
sampling_thread_completed.Wait();
}));
diff --git a/chromium/base/profiler/thread_delegate_posix.h b/chromium/base/profiler/thread_delegate_posix.h
index 8f38047d038..a26b7d57344 100644
--- a/chromium/base/profiler/thread_delegate_posix.h
+++ b/chromium/base/profiler/thread_delegate_posix.h
@@ -5,6 +5,8 @@
#ifndef BASE_PROFILER_THREAD_DELEGATE_POSIX_H_
#define BASE_PROFILER_THREAD_DELEGATE_POSIX_H_
+#include <memory>
+
#include "base/base_export.h"
#include "base/profiler/sampling_profiler_thread_token.h"
#include "base/profiler/thread_delegate.h"