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