| OLD | NEW | 
|     1 // Copyright 2015 The Chromium Authors. All rights reserved. |     1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
|     2 // Use of this source code is governed by a BSD-style license that can be |     2 // Use of this source code is governed by a BSD-style license that can be | 
|     3 // found in the LICENSE file. |     3 // found in the LICENSE file. | 
|     4  |     4  | 
|     5 #include <stddef.h> |     5 #include <stddef.h> | 
|     6 #include <stdint.h> |     6 #include <stdint.h> | 
|     7  |     7  | 
|     8 #include <cstdlib> |     8 #include <cstdlib> | 
|     9 #include <utility> |     9 #include <utility> | 
|    10  |    10  | 
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   594   std::vector<CallStackProfile> profiles; |   594   std::vector<CallStackProfile> profiles; | 
|   595   CaptureProfiles(params, AVeryLongTimeDelta(), &profiles); |   595   CaptureProfiles(params, AVeryLongTimeDelta(), &profiles); | 
|   596  |   596  | 
|   597   // Check that the profile and samples sizes are correct, and the module |   597   // Check that the profile and samples sizes are correct, and the module | 
|   598   // indices are in range. |   598   // indices are in range. | 
|   599   ASSERT_EQ(1u, profiles.size()); |   599   ASSERT_EQ(1u, profiles.size()); | 
|   600   const CallStackProfile& profile = profiles[0]; |   600   const CallStackProfile& profile = profiles[0]; | 
|   601   ASSERT_EQ(1u, profile.samples.size()); |   601   ASSERT_EQ(1u, profile.samples.size()); | 
|   602   EXPECT_EQ(params.sampling_interval, profile.sampling_period); |   602   EXPECT_EQ(params.sampling_interval, profile.sampling_period); | 
|   603   const Sample& sample = profile.samples[0]; |   603   const Sample& sample = profile.samples[0]; | 
|   604   EXPECT_EQ(0u, sample.process_phases); |   604   EXPECT_EQ(0u, sample.process_milestones); | 
|   605   for (const auto& frame : sample.frames) { |   605   for (const auto& frame : sample.frames) { | 
|   606     ASSERT_GE(frame.module_index, 0u); |   606     ASSERT_GE(frame.module_index, 0u); | 
|   607     ASSERT_LT(frame.module_index, profile.modules.size()); |   607     ASSERT_LT(frame.module_index, profile.modules.size()); | 
|   608   } |   608   } | 
|   609  |   609  | 
|   610   // Check that the stack contains a frame for |   610   // Check that the stack contains a frame for | 
|   611   // TargetThread::SignalAndWaitUntilSignaled() and that the frame has this |   611   // TargetThread::SignalAndWaitUntilSignaled() and that the frame has this | 
|   612   // executable's module. |   612   // executable's module. | 
|   613   Frames::const_iterator loc = FindFirstFrameWithinFunction( |   613   Frames::const_iterator loc = FindFirstFrameWithinFunction( | 
|   614       sample, &TargetThread::SignalAndWaitUntilSignaled); |   614       sample, &TargetThread::SignalAndWaitUntilSignaled); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|   630 #define MAYBE_Annotations DISABLED_Annotations |   630 #define MAYBE_Annotations DISABLED_Annotations | 
|   631 #endif |   631 #endif | 
|   632 TEST(StackSamplingProfilerTest, MAYBE_Annotations) { |   632 TEST(StackSamplingProfilerTest, MAYBE_Annotations) { | 
|   633   StackSamplingProfiler::ResetAnnotationsForTesting(); |   633   StackSamplingProfiler::ResetAnnotationsForTesting(); | 
|   634  |   634  | 
|   635   SamplingParams params; |   635   SamplingParams params; | 
|   636   params.sampling_interval = TimeDelta::FromMilliseconds(0); |   636   params.sampling_interval = TimeDelta::FromMilliseconds(0); | 
|   637   params.samples_per_burst = 1; |   637   params.samples_per_burst = 1; | 
|   638  |   638  | 
|   639   // Check that a run picks up annotations. |   639   // Check that a run picks up annotations. | 
|   640   StackSamplingProfiler::SetProcessPhase(1); |   640   StackSamplingProfiler::SetProcessMilestone(1); | 
|   641   std::vector<CallStackProfile> profiles1; |   641   std::vector<CallStackProfile> profiles1; | 
|   642   CaptureProfiles(params, AVeryLongTimeDelta(), &profiles1); |   642   CaptureProfiles(params, AVeryLongTimeDelta(), &profiles1); | 
|   643   ASSERT_EQ(1u, profiles1.size()); |   643   ASSERT_EQ(1u, profiles1.size()); | 
|   644   const CallStackProfile& profile1 = profiles1[0]; |   644   const CallStackProfile& profile1 = profiles1[0]; | 
|   645   ASSERT_EQ(1u, profile1.samples.size()); |   645   ASSERT_EQ(1u, profile1.samples.size()); | 
|   646   const Sample& sample1 = profile1.samples[0]; |   646   const Sample& sample1 = profile1.samples[0]; | 
|   647   EXPECT_EQ(1u << 1, sample1.process_phases); |   647   EXPECT_EQ(1u << 1, sample1.process_milestones); | 
|   648  |   648  | 
|   649   // Run it a second time but with changed annotations. These annotations |   649   // Run it a second time but with changed annotations. These annotations | 
|   650   // should appear in the first acquired sample. |   650   // should appear in the first acquired sample. | 
|   651   StackSamplingProfiler::SetProcessPhase(2); |   651   StackSamplingProfiler::SetProcessMilestone(2); | 
|   652   std::vector<CallStackProfile> profiles2; |   652   std::vector<CallStackProfile> profiles2; | 
|   653   CaptureProfiles(params, AVeryLongTimeDelta(), &profiles2); |   653   CaptureProfiles(params, AVeryLongTimeDelta(), &profiles2); | 
|   654   ASSERT_EQ(1u, profiles2.size()); |   654   ASSERT_EQ(1u, profiles2.size()); | 
|   655   const CallStackProfile& profile2 = profiles2[0]; |   655   const CallStackProfile& profile2 = profiles2[0]; | 
|   656   ASSERT_EQ(1u, profile2.samples.size()); |   656   ASSERT_EQ(1u, profile2.samples.size()); | 
|   657   const Sample& sample2 = profile2.samples[0]; |   657   const Sample& sample2 = profile2.samples[0]; | 
|   658   EXPECT_EQ(sample1.process_phases | (1u << 2), sample2.process_phases); |   658   EXPECT_EQ(sample1.process_milestones | (1u << 2), sample2.process_milestones); | 
|   659 } |   659 } | 
|   660  |   660  | 
|   661 // Checks that the profiler handles stacks containing dynamically-allocated |   661 // Checks that the profiler handles stacks containing dynamically-allocated | 
|   662 // stack memory. |   662 // stack memory. | 
|   663 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |   663 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 
|   664 #define MAYBE_Alloca Alloca |   664 #define MAYBE_Alloca Alloca | 
|   665 #else |   665 #else | 
|   666 #define MAYBE_Alloca DISABLED_Alloca |   666 #define MAYBE_Alloca DISABLED_Alloca | 
|   667 #endif |   667 #endif | 
|   668 TEST(StackSamplingProfilerTest, MAYBE_Alloca) { |   668 TEST(StackSamplingProfilerTest, MAYBE_Alloca) { | 
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1009 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |  1009 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 
|  1010 #define MAYBE_UnloadedLibrary UnloadedLibrary |  1010 #define MAYBE_UnloadedLibrary UnloadedLibrary | 
|  1011 #else |  1011 #else | 
|  1012 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary |  1012 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary | 
|  1013 #endif |  1013 #endif | 
|  1014 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { |  1014 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { | 
|  1015   TestLibraryUnload(true); |  1015   TestLibraryUnload(true); | 
|  1016 } |  1016 } | 
|  1017  |  1017  | 
|  1018 }  // namespace base |  1018 }  // namespace base | 
| OLD | NEW |