| Index: base/profiler/stack_sampling_profiler_unittest.cc
|
| diff --git a/base/profiler/stack_sampling_profiler_unittest.cc b/base/profiler/stack_sampling_profiler_unittest.cc
|
| index 3a59e6d2c300ff58534d4cac8b8e80a9ea1fd2c0..a9a3a19fdbaaa4781c8c5d1a115c28f7467b63a5 100644
|
| --- a/base/profiler/stack_sampling_profiler_unittest.cc
|
| +++ b/base/profiler/stack_sampling_profiler_unittest.cc
|
| @@ -48,6 +48,7 @@ namespace base {
|
|
|
| using SamplingParams = StackSamplingProfiler::SamplingParams;
|
| using Frame = StackSamplingProfiler::Frame;
|
| +using Frames = std::vector<StackSamplingProfiler::Frame>;
|
| using Module = StackSamplingProfiler::Module;
|
| using Sample = StackSamplingProfiler::Sample;
|
| using CallStackProfile = StackSamplingProfiler::CallStackProfile;
|
| @@ -395,7 +396,7 @@ const void* MaybeFixupFunctionAddressForILT(const void* function_address) {
|
| // Searches through the frames in |sample|, returning an iterator to the first
|
| // frame that has an instruction pointer within |target_function|. Returns
|
| // sample.end() if no such frames are found.
|
| -Sample::const_iterator FindFirstFrameWithinFunction(
|
| +Frames::const_iterator FindFirstFrameWithinFunction(
|
| const Sample& sample,
|
| TargetFunction target_function) {
|
| uintptr_t function_start = reinterpret_cast<uintptr_t>(
|
| @@ -403,12 +404,12 @@ Sample::const_iterator FindFirstFrameWithinFunction(
|
| target_function)));
|
| uintptr_t function_end =
|
| reinterpret_cast<uintptr_t>(target_function(nullptr, nullptr, nullptr));
|
| - for (auto it = sample.begin(); it != sample.end(); ++it) {
|
| + for (auto it = sample.frames.begin(); it != sample.frames.end(); ++it) {
|
| if ((it->instruction_pointer >= function_start) &&
|
| (it->instruction_pointer <= function_end))
|
| return it;
|
| }
|
| - return sample.end();
|
| + return sample.frames.end();
|
| }
|
|
|
| // Formats a sample into a string that can be output for test diagnostics.
|
| @@ -416,7 +417,7 @@ std::string FormatSampleForDiagnosticOutput(
|
| const Sample& sample,
|
| const std::vector<Module>& modules) {
|
| std::string output;
|
| - for (const Frame& frame : sample) {
|
| + for (const Frame& frame : sample.frames) {
|
| output += StringPrintf(
|
| "0x%p %s\n", reinterpret_cast<const void*>(frame.instruction_pointer),
|
| modules[frame.module_index].filename.AsUTF8Unsafe().c_str());
|
| @@ -517,10 +518,10 @@ void TestLibraryUnload(bool wait_until_unloaded) {
|
|
|
| // Check that the stack contains a frame for
|
| // TargetThread::SignalAndWaitUntilSignaled().
|
| - Sample::const_iterator end_frame = FindFirstFrameWithinFunction(
|
| + Frames::const_iterator end_frame = FindFirstFrameWithinFunction(
|
| sample,
|
| &TargetThread::SignalAndWaitUntilSignaled);
|
| - ASSERT_TRUE(end_frame != sample.end())
|
| + ASSERT_TRUE(end_frame != sample.frames.end())
|
| << "Function at "
|
| << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
|
| &TargetThread::SignalAndWaitUntilSignaled))
|
| @@ -535,7 +536,7 @@ void TestLibraryUnload(bool wait_until_unloaded) {
|
| // ... WaitableEvent and system frames ...
|
| // TargetThread::SignalAndWaitUntilSignaled
|
| // TargetThread::OtherLibraryCallback
|
| - EXPECT_EQ(2, sample.end() - end_frame)
|
| + EXPECT_EQ(2, sample.frames.end() - end_frame)
|
| << "Stack:\n"
|
| << FormatSampleForDiagnosticOutput(sample, profile.modules);
|
| } else {
|
| @@ -544,17 +545,17 @@ void TestLibraryUnload(bool wait_until_unloaded) {
|
| // the same stack as |wait_until_unloaded|, if not we should have the full
|
| // stack. The important thing is that we should not crash.
|
|
|
| - if ((sample.end() - 1) - end_frame == 2) {
|
| + if ((sample.frames.end() - 1) - end_frame == 2) {
|
| // This is the same case as |wait_until_unloaded|.
|
| return;
|
| }
|
|
|
| // Check that the stack contains a frame for
|
| // TargetThread::CallThroughOtherLibrary().
|
| - Sample::const_iterator other_library_frame = FindFirstFrameWithinFunction(
|
| + Frames::const_iterator other_library_frame = FindFirstFrameWithinFunction(
|
| sample,
|
| &TargetThread::CallThroughOtherLibrary);
|
| - ASSERT_TRUE(other_library_frame != sample.end())
|
| + ASSERT_TRUE(other_library_frame != sample.frames.end())
|
| << "Function at "
|
| << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
|
| &TargetThread::CallThroughOtherLibrary))
|
| @@ -599,7 +600,7 @@ TEST(StackSamplingProfilerTest, MAYBE_Basic) {
|
| ASSERT_EQ(1u, profile.samples.size());
|
| EXPECT_EQ(params.sampling_interval, profile.sampling_period);
|
| const Sample& sample = profile.samples[0];
|
| - for (const auto& frame : sample) {
|
| + for (const auto& frame : sample.frames) {
|
| ASSERT_GE(frame.module_index, 0u);
|
| ASSERT_LT(frame.module_index, profile.modules.size());
|
| }
|
| @@ -607,10 +608,10 @@ TEST(StackSamplingProfilerTest, MAYBE_Basic) {
|
| // Check that the stack contains a frame for
|
| // TargetThread::SignalAndWaitUntilSignaled() and that the frame has this
|
| // executable's module.
|
| - Sample::const_iterator loc = FindFirstFrameWithinFunction(
|
| + Frames::const_iterator loc = FindFirstFrameWithinFunction(
|
| sample,
|
| &TargetThread::SignalAndWaitUntilSignaled);
|
| - ASSERT_TRUE(loc != sample.end())
|
| + ASSERT_TRUE(loc != sample.frames.end())
|
| << "Function at "
|
| << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
|
| &TargetThread::SignalAndWaitUntilSignaled))
|
| @@ -656,10 +657,10 @@ TEST(StackSamplingProfilerTest, MAYBE_Alloca) {
|
|
|
| // Check that the stack contains a frame for
|
| // TargetThread::SignalAndWaitUntilSignaled().
|
| - Sample::const_iterator end_frame = FindFirstFrameWithinFunction(
|
| + Frames::const_iterator end_frame = FindFirstFrameWithinFunction(
|
| sample,
|
| &TargetThread::SignalAndWaitUntilSignaled);
|
| - ASSERT_TRUE(end_frame != sample.end())
|
| + ASSERT_TRUE(end_frame != sample.frames.end())
|
| << "Function at "
|
| << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
|
| &TargetThread::SignalAndWaitUntilSignaled))
|
| @@ -667,10 +668,10 @@ TEST(StackSamplingProfilerTest, MAYBE_Alloca) {
|
| << FormatSampleForDiagnosticOutput(sample, profile.modules);
|
|
|
| // Check that the stack contains a frame for TargetThread::CallWithAlloca().
|
| - Sample::const_iterator alloca_frame = FindFirstFrameWithinFunction(
|
| + Frames::const_iterator alloca_frame = FindFirstFrameWithinFunction(
|
| sample,
|
| &TargetThread::CallWithAlloca);
|
| - ASSERT_TRUE(alloca_frame != sample.end())
|
| + ASSERT_TRUE(alloca_frame != sample.frames.end())
|
| << "Function at "
|
| << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
|
| &TargetThread::CallWithAlloca))
|
| @@ -926,10 +927,10 @@ TEST(StackSamplingProfilerTest, MAYBE_OtherLibrary) {
|
|
|
| // Check that the stack contains a frame for
|
| // TargetThread::CallThroughOtherLibrary().
|
| - Sample::const_iterator other_library_frame = FindFirstFrameWithinFunction(
|
| + Frames::const_iterator other_library_frame = FindFirstFrameWithinFunction(
|
| sample,
|
| &TargetThread::CallThroughOtherLibrary);
|
| - ASSERT_TRUE(other_library_frame != sample.end())
|
| + ASSERT_TRUE(other_library_frame != sample.frames.end())
|
| << "Function at "
|
| << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
|
| &TargetThread::CallThroughOtherLibrary))
|
| @@ -938,10 +939,10 @@ TEST(StackSamplingProfilerTest, MAYBE_OtherLibrary) {
|
|
|
| // Check that the stack contains a frame for
|
| // TargetThread::SignalAndWaitUntilSignaled().
|
| - Sample::const_iterator end_frame = FindFirstFrameWithinFunction(
|
| + Frames::const_iterator end_frame = FindFirstFrameWithinFunction(
|
| sample,
|
| &TargetThread::SignalAndWaitUntilSignaled);
|
| - ASSERT_TRUE(end_frame != sample.end())
|
| + ASSERT_TRUE(end_frame != sample.frames.end())
|
| << "Function at "
|
| << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
|
| &TargetThread::SignalAndWaitUntilSignaled))
|
|
|