| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 int i = 0; | 33 int i = 0; |
| 34 for (; (i < max_stack_size) && context->Rip; ++i) { | 34 for (; (i < max_stack_size) && context->Rip; ++i) { |
| 35 // Try to look up unwind metadata for the current function. | 35 // Try to look up unwind metadata for the current function. |
| 36 ULONG64 image_base; | 36 ULONG64 image_base; |
| 37 PRUNTIME_FUNCTION runtime_function = | 37 PRUNTIME_FUNCTION runtime_function = |
| 38 RtlLookupFunctionEntry(context->Rip, &image_base, nullptr); | 38 RtlLookupFunctionEntry(context->Rip, &image_base, nullptr); |
| 39 | 39 |
| 40 instruction_pointers[i] = reinterpret_cast<const void*>(context->Rip); | 40 instruction_pointers[i] = reinterpret_cast<const void*>(context->Rip); |
| 41 | 41 |
| 42 if (runtime_function) { | 42 if (runtime_function) { |
| 43 KNONVOLATILE_CONTEXT_POINTERS nvcontext = {0}; | 43 KNONVOLATILE_CONTEXT_POINTERS nvcontext = {}; |
| 44 void* handler_data; | 44 void* handler_data; |
| 45 ULONG64 establisher_frame; | 45 ULONG64 establisher_frame; |
| 46 RtlVirtualUnwind(0, image_base, context->Rip, runtime_function, context, | 46 RtlVirtualUnwind(0, image_base, context->Rip, runtime_function, context, |
| 47 &handler_data, &establisher_frame, &nvcontext); | 47 &handler_data, &establisher_frame, &nvcontext); |
| 48 } else { | 48 } else { |
| 49 // If we don't have a RUNTIME_FUNCTION, then in theory this should be a | 49 // If we don't have a RUNTIME_FUNCTION, then in theory this should be a |
| 50 // leaf function whose frame contains only a return address, at | 50 // leaf function whose frame contains only a return address, at |
| 51 // RSP. However, crash data also indicates that some third party libraries | 51 // RSP. However, crash data also indicates that some third party libraries |
| 52 // do not provide RUNTIME_FUNCTION information for non-leaf functions. We | 52 // do not provide RUNTIME_FUNCTION information for non-leaf functions. We |
| 53 // could manually unwind the stack in the former case, but attempting to | 53 // could manually unwind the stack in the former case, but attempting to |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 348 |
| 349 if (thread_handle) { | 349 if (thread_handle) { |
| 350 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin( | 350 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin( |
| 351 win::ScopedHandle(thread_handle))); | 351 win::ScopedHandle(thread_handle))); |
| 352 } | 352 } |
| 353 #endif | 353 #endif |
| 354 return scoped_ptr<NativeStackSampler>(); | 354 return scoped_ptr<NativeStackSampler>(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace base | 357 } // namespace base |
| OLD | NEW |