Commit c2259413 authored by wittman's avatar wittman Committed by Commit bot

Stack sampling profiler: fix off-by-one error on truncated stacks

Stacks that are truncated due to the Win32StackFrameUnwinder being
unable to unwind are being reported with an extra frame.

BUG=555770

Review URL: https://codereview.chromium.org/1469983002

Cr-Commit-Position: refs/heads/master@{#361230}
parent db274ce9
...@@ -148,7 +148,7 @@ int RecordStack(CONTEXT* context, int max_stack_size, ...@@ -148,7 +148,7 @@ int RecordStack(CONTEXT* context, int max_stack_size,
for (; (i < max_stack_size) && context->Rip; ++i) { for (; (i < max_stack_size) && context->Rip; ++i) {
instruction_pointers[i] = reinterpret_cast<const void*>(context->Rip); instruction_pointers[i] = reinterpret_cast<const void*>(context->Rip);
if (!frame_unwinder.TryUnwind(context, &modules[i])) if (!frame_unwinder.TryUnwind(context, &modules[i]))
return i + 1; return i;
} }
return i; return i;
#else #else
......
...@@ -515,15 +515,14 @@ void TestLibraryUnload(bool wait_until_unloaded) { ...@@ -515,15 +515,14 @@ void TestLibraryUnload(bool wait_until_unloaded) {
<< FormatSampleForDiagnosticOutput(sample, profile.modules); << FormatSampleForDiagnosticOutput(sample, profile.modules);
if (wait_until_unloaded) { if (wait_until_unloaded) {
// The stack should look like this, resulting in two frames between // The stack should look like this, resulting one frame after
// SignalAndWaitUntilSignaled and the last frame, which should be the one in // SignalAndWaitUntilSignaled. The frame in the now-unloaded library is not
// the now-unloaded library: // recorded since we can't get module information.
// //
// ... WaitableEvent and system frames ... // ... WaitableEvent and system frames ...
// TargetThread::SignalAndWaitUntilSignaled // TargetThread::SignalAndWaitUntilSignaled
// TargetThread::OtherLibraryCallback // TargetThread::OtherLibraryCallback
// InvokeCallbackFunction (in other library, now unloaded) EXPECT_EQ(2, sample.end() - end_frame)
EXPECT_EQ(2, (sample.end() - 1) - end_frame)
<< "Stack:\n" << "Stack:\n"
<< FormatSampleForDiagnosticOutput(sample, profile.modules); << FormatSampleForDiagnosticOutput(sample, profile.modules);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment