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 <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 Loading... |
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 Loading... |
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 |
OLD | NEW |