| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "call_stack.h" | 5 #include "tools/memory_watcher/call_stack.h" |
| 6 |
| 6 #include <shlwapi.h> | 7 #include <shlwapi.h> |
| 7 #include <tlhelp32.h> | 8 #include <tlhelp32.h> |
| 8 | 9 |
| 9 #include "memory_hook.h" | 10 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 11 #include "tools/memory_watcher/memory_hook.h" |
| 11 | 12 |
| 12 // Typedefs for explicit dynamic linking with functions exported from | 13 // Typedefs for explicit dynamic linking with functions exported from |
| 13 // dbghelp.dll. | 14 // dbghelp.dll. |
| 14 typedef BOOL (__stdcall *t_StackWalk64)(DWORD, HANDLE, HANDLE, | 15 typedef BOOL (__stdcall *t_StackWalk64)(DWORD, HANDLE, HANDLE, |
| 15 LPSTACKFRAME64, PVOID, | 16 LPSTACKFRAME64, PVOID, |
| 16 PREAD_PROCESS_MEMORY_ROUTINE64, | 17 PREAD_PROCESS_MEMORY_ROUTINE64, |
| 17 PFUNCTION_TABLE_ACCESS_ROUTINE64, | 18 PFUNCTION_TABLE_ACCESS_ROUTINE64, |
| 18 PGET_MODULE_BASE_ROUTINE64, | 19 PGET_MODULE_BASE_ROUTINE64, |
| 19 PTRANSLATE_ADDRESS_ROUTINE64); | 20 PTRANSLATE_ADDRESS_ROUTINE64); |
| 20 typedef PVOID (__stdcall *t_SymFunctionTableAccess64)(HANDLE, DWORD64); | 21 typedef PVOID (__stdcall *t_SymFunctionTableAccess64)(HANDLE, DWORD64); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 (*symbol_cache_)[intruction_pointer] = ""; | 335 (*symbol_cache_)[intruction_pointer] = ""; |
| 335 continue; | 336 continue; |
| 336 } | 337 } |
| 337 | 338 |
| 338 line += " "; | 339 line += " "; |
| 339 line += static_cast<char*>(Line.FileName); | 340 line += static_cast<char*>(Line.FileName); |
| 340 line += " ("; | 341 line += " ("; |
| 341 // TODO(jar): get something like this template to work :-/ | 342 // TODO(jar): get something like this template to work :-/ |
| 342 // line += IntToCustomString<PrivateAllocatorString>(Line.LineNumber); | 343 // line += IntToCustomString<PrivateAllocatorString>(Line.LineNumber); |
| 343 // ...and then delete this line, which uses std::string. | 344 // ...and then delete this line, which uses std::string. |
| 344 line += IntToString(Line.LineNumber).c_str(); | 345 line += base::IntToString(Line.LineNumber).c_str(); |
| 345 line += "): "; | 346 line += "): "; |
| 346 line += symbol->Name; | 347 line += symbol->Name; |
| 347 line += "\n"; | 348 line += "\n"; |
| 348 } else { | 349 } else { |
| 349 line += " unknown (0):"; | 350 line += " unknown (0):"; |
| 350 line += symbol->Name; | 351 line += symbol->Name; |
| 351 line += "\n"; | 352 line += "\n"; |
| 352 } | 353 } |
| 353 } else { | 354 } else { |
| 354 // OK - couldn't get any info. Try for the module. | 355 // OK - couldn't get any info. Try for the module. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 return MemoryHook::Alloc(size); | 390 return MemoryHook::Alloc(size); |
| 390 } | 391 } |
| 391 | 392 |
| 392 void AllocationStack::operator delete(void* ptr) { | 393 void AllocationStack::operator delete(void* ptr) { |
| 393 AllocationStack *stack = reinterpret_cast<AllocationStack*>(ptr); | 394 AllocationStack *stack = reinterpret_cast<AllocationStack*>(ptr); |
| 394 AutoLock lock(freelist_lock_); | 395 AutoLock lock(freelist_lock_); |
| 395 DCHECK(stack->next_ == NULL); | 396 DCHECK(stack->next_ == NULL); |
| 396 stack->next_ = freelist_; | 397 stack->next_ = freelist_; |
| 397 freelist_ = stack; | 398 freelist_ = stack; |
| 398 } | 399 } |
| OLD | NEW |