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

Side by Side Diff: base/profiler/native_stack_sampler_win.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 | « no previous file | base/profiler/stack_sampling_profiler_unittest.cc » ('j') | 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 <objbase.h> 5 #include <objbase.h>
6 #include <windows.h> 6 #include <windows.h>
7 #include <winternl.h> 7 #include <winternl.h>
8 8
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <map> 10 #include <map>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // recording the instruction pointers for each frame in |instruction_pointers|. 141 // recording the instruction pointers for each frame in |instruction_pointers|.
142 int RecordStack(CONTEXT* context, int max_stack_size, 142 int RecordStack(CONTEXT* context, int max_stack_size,
143 const void* instruction_pointers[], 143 const void* instruction_pointers[],
144 ScopedModuleHandle modules[]) { 144 ScopedModuleHandle modules[]) {
145 #ifdef _WIN64 145 #ifdef _WIN64
146 Win32StackFrameUnwinder frame_unwinder; 146 Win32StackFrameUnwinder frame_unwinder;
147 int i = 0; 147 int i = 0;
148 for (; (i < max_stack_size) && context->Rip; ++i) { 148 for (; (i < max_stack_size) && context->Rip; ++i) {
149 instruction_pointers[i] = reinterpret_cast<const void*>(context->Rip); 149 instruction_pointers[i] = reinterpret_cast<const void*>(context->Rip);
150 if (!frame_unwinder.TryUnwind(context, &modules[i])) 150 if (!frame_unwinder.TryUnwind(context, &modules[i]))
151 return i + 1; 151 return i;
152 } 152 }
153 return i; 153 return i;
154 #else 154 #else
155 return 0; 155 return 0;
156 #endif 156 #endif
157 } 157 }
158 158
159 // Gets the unique build ID for a module. Windows build IDs are created by a 159 // Gets the unique build ID for a module. Windows build IDs are created by a
160 // concatenation of a GUID and AGE fields found in the headers of a module. The 160 // concatenation of a GUID and AGE fields found in the headers of a module. The
161 // GUID is stored in the first 16 bytes and the AGE is stored in the last 4 161 // GUID is stored in the first 16 bytes and the AGE is stored in the last 4
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 if (thread_handle) { 495 if (thread_handle) {
496 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin( 496 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin(
497 win::ScopedHandle(thread_handle), 497 win::ScopedHandle(thread_handle),
498 test_delegate)); 498 test_delegate));
499 } 499 }
500 #endif 500 #endif
501 return scoped_ptr<NativeStackSampler>(); 501 return scoped_ptr<NativeStackSampler>();
502 } 502 }
503 503
504 } // namespace base 504 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698