Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: base/profiler/stack_sampling_profiler_unittest.cc

Issue 1469983002: Stack sampling profiler: fix off-by-one error on truncated stacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: update tests Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/profiler/native_stack_sampler_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <cstdlib> 5 #include <cstdlib>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 sample, 508 sample,
509 &TargetThread::SignalAndWaitUntilSignaled); 509 &TargetThread::SignalAndWaitUntilSignaled);
510 ASSERT_TRUE(end_frame != sample.end()) 510 ASSERT_TRUE(end_frame != sample.end())
511 << "Function at " 511 << "Function at "
512 << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>( 512 << MaybeFixupFunctionAddressForILT(reinterpret_cast<const void*>(
513 &TargetThread::SignalAndWaitUntilSignaled)) 513 &TargetThread::SignalAndWaitUntilSignaled))
514 << " was not found in stack:\n" 514 << " was not found in stack:\n"
515 << FormatSampleForDiagnosticOutput(sample, profile.modules); 515 << FormatSampleForDiagnosticOutput(sample, profile.modules);
516 516
517 if (wait_until_unloaded) { 517 if (wait_until_unloaded) {
518 // The stack should look like this, resulting in two frames between 518 // The stack should look like this, resulting one frame after
519 // SignalAndWaitUntilSignaled and the last frame, which should be the one in 519 // SignalAndWaitUntilSignaled. The frame in the now-unloaded library is not
520 // the now-unloaded library: 520 // recorded since we can't get module information.
521 // 521 //
522 // ... WaitableEvent and system frames ... 522 // ... WaitableEvent and system frames ...
523 // TargetThread::SignalAndWaitUntilSignaled 523 // TargetThread::SignalAndWaitUntilSignaled
524 // TargetThread::OtherLibraryCallback 524 // TargetThread::OtherLibraryCallback
525 // InvokeCallbackFunction (in other library, now unloaded) 525 EXPECT_EQ(2, sample.end() - end_frame)
526 EXPECT_EQ(2, (sample.end() - 1) - end_frame)
527 << "Stack:\n" 526 << "Stack:\n"
528 << FormatSampleForDiagnosticOutput(sample, profile.modules); 527 << FormatSampleForDiagnosticOutput(sample, profile.modules);
529 } else { 528 } else {
530 // We didn't wait for the asynchonous unloading to complete, so the results 529 // We didn't wait for the asynchonous unloading to complete, so the results
531 // are non-deterministic: if the library finished unloading we should have 530 // are non-deterministic: if the library finished unloading we should have
532 // the same stack as |wait_until_unloaded|, if not we should have the full 531 // the same stack as |wait_until_unloaded|, if not we should have the full
533 // stack. The important thing is that we should not crash. 532 // stack. The important thing is that we should not crash.
534 533
535 if ((sample.end() - 1) - end_frame == 2) { 534 if ((sample.end() - 1) - end_frame == 2) {
536 // This is the same case as |wait_until_unloaded|. 535 // This is the same case as |wait_until_unloaded|.
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) 953 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED)
955 #define MAYBE_UnloadedLibrary UnloadedLibrary 954 #define MAYBE_UnloadedLibrary UnloadedLibrary
956 #else 955 #else
957 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary 956 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary
958 #endif 957 #endif
959 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { 958 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) {
960 TestLibraryUnload(true); 959 TestLibraryUnload(true);
961 } 960 }
962 961
963 } // namespace base 962 } // namespace base
OLDNEW
« no previous file with comments | « base/profiler/native_stack_sampler_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698