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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 HMODULE module_handle, | 259 HMODULE module_handle, |
260 StackSamplingProfiler::Module* module) { | 260 StackSamplingProfiler::Module* module) { |
261 wchar_t module_name[MAX_PATH]; | 261 wchar_t module_name[MAX_PATH]; |
262 DWORD result_length = | 262 DWORD result_length = |
263 GetModuleFileName(module_handle, module_name, arraysize(module_name)); | 263 GetModuleFileName(module_handle, module_name, arraysize(module_name)); |
264 if (result_length == 0) | 264 if (result_length == 0) |
265 return false; | 265 return false; |
266 | 266 |
267 module->filename = base::FilePath(module_name); | 267 module->filename = base::FilePath(module_name); |
268 | 268 |
269 module->base_address = reinterpret_cast<const void*>(module_handle); | 269 module->base_address = reinterpret_cast<uintptr_t>(module_handle); |
270 | 270 |
271 module->id = GetBuildIDForModule(module_handle); | 271 module->id = GetBuildIDForModule(module_handle); |
272 if (module->id.empty()) | 272 if (module->id.empty()) |
273 return false; | 273 return false; |
274 | 274 |
275 return true; | 275 return true; |
276 } | 276 } |
277 | 277 |
278 size_t NativeStackSamplerWin::GetModuleIndex( | 278 size_t NativeStackSamplerWin::GetModuleIndex( |
279 HMODULE module_handle, | 279 HMODULE module_handle, |
(...skipping 18 matching lines...) Expand all Loading... |
298 const void* const instruction_pointers[], | 298 const void* const instruction_pointers[], |
299 const HMODULE module_handles[], | 299 const HMODULE module_handles[], |
300 int stack_depth, | 300 int stack_depth, |
301 StackSamplingProfiler::Sample* sample, | 301 StackSamplingProfiler::Sample* sample, |
302 std::vector<StackSamplingProfiler::Module>* module) { | 302 std::vector<StackSamplingProfiler::Module>* module) { |
303 sample->clear(); | 303 sample->clear(); |
304 sample->reserve(stack_depth); | 304 sample->reserve(stack_depth); |
305 | 305 |
306 for (int i = 0; i < stack_depth; ++i) { | 306 for (int i = 0; i < stack_depth; ++i) { |
307 sample->push_back(StackSamplingProfiler::Frame( | 307 sample->push_back(StackSamplingProfiler::Frame( |
308 instruction_pointers[i], | 308 reinterpret_cast<uintptr_t>(instruction_pointers[i]), |
309 GetModuleIndex(module_handles[i], module))); | 309 GetModuleIndex(module_handles[i], module))); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 } // namespace | 313 } // namespace |
314 | 314 |
315 scoped_ptr<NativeStackSampler> NativeStackSampler::Create( | 315 scoped_ptr<NativeStackSampler> NativeStackSampler::Create( |
316 PlatformThreadId thread_id) { | 316 PlatformThreadId thread_id) { |
317 #if _WIN64 | 317 #if _WIN64 |
318 // Get the thread's handle. | 318 // Get the thread's handle. |
319 HANDLE thread_handle = ::OpenThread( | 319 HANDLE thread_handle = ::OpenThread( |
320 THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION, | 320 THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION, |
321 FALSE, | 321 FALSE, |
322 thread_id); | 322 thread_id); |
323 | 323 |
324 if (thread_handle) { | 324 if (thread_handle) { |
325 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin( | 325 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin( |
326 win::ScopedHandle(thread_handle))); | 326 win::ScopedHandle(thread_handle))); |
327 } | 327 } |
328 #endif | 328 #endif |
329 return scoped_ptr<NativeStackSampler>(); | 329 return scoped_ptr<NativeStackSampler>(); |
330 } | 330 } |
331 | 331 |
332 } // namespace base | 332 } // namespace base |
OLD | NEW |