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

Side by Side Diff: runtime/vm/native_symbol_win.cc

Issue 109803002: Profiler Take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/os.h » ('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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "vm/native_symbol.h" 8 #include "vm/native_symbol.h"
9 #include "vm/thread.h" 9 #include "vm/thread.h"
10 10
(...skipping 14 matching lines...) Expand all
25 if (!SymInitialize(hProcess, NULL, TRUE)) { 25 if (!SymInitialize(hProcess, NULL, TRUE)) {
26 DWORD error = GetLastError(); 26 DWORD error = GetLastError();
27 printf("Failed to init NativeSymbolResolver (SymInitialize %d)\n", error); 27 printf("Failed to init NativeSymbolResolver (SymInitialize %d)\n", error);
28 return; 28 return;
29 } 29 }
30 #endif 30 #endif
31 } 31 }
32 32
33 33
34 void NativeSymbolResolver::ShutdownOnce() { 34 void NativeSymbolResolver::ShutdownOnce() {
35 ScopedMutex lock(lock_); 35 MutexLocker lock(lock_);
36 if (!running_) { 36 if (!running_) {
37 return; 37 return;
38 } 38 }
39 running_ = false; 39 running_ = false;
40 #if 0 40 #if 0
41 HANDLE hProcess = GetCurrentProcess(); 41 HANDLE hProcess = GetCurrentProcess();
42 if (!SymCleanup(hProcess)) { 42 if (!SymCleanup(hProcess)) {
43 DWORD error = GetLastError(); 43 DWORD error = GetLastError();
44 printf("Failed to shutdown NativeSymbolResolver (SymCleanup %d)\n", error); 44 printf("Failed to shutdown NativeSymbolResolver (SymCleanup %d)\n", error);
45 } 45 }
46 #endif 46 #endif
47 } 47 }
48 48
49 49
50 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc) { 50 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc) {
51 static const intptr_t kMaxNameLength = 2048; 51 static const intptr_t kMaxNameLength = 2048;
52 static const intptr_t kSymbolInfoSize = sizeof(SYMBOL_INFO); // NOLINT. 52 static const intptr_t kSymbolInfoSize = sizeof(SYMBOL_INFO); // NOLINT.
53 static char buffer[kSymbolInfoSize + kMaxNameLength]; 53 static char buffer[kSymbolInfoSize + kMaxNameLength];
54 static char name_buffer[kMaxNameLength]; 54 static char name_buffer[kMaxNameLength];
55 ScopedMutex lock(lock_); 55 MutexLocker lock(lock_);
56 if (!running_) { 56 if (!running_) {
57 return NULL; 57 return NULL;
58 } 58 }
59 #if 0 59 #if 0
60 memset(&buffer[0], 0, sizeof(buffer)); 60 memset(&buffer[0], 0, sizeof(buffer));
61 HANDLE hProcess = GetCurrentProcess(); 61 HANDLE hProcess = GetCurrentProcess();
62 DWORD64 address = static_cast<DWORD64>(pc); 62 DWORD64 address = static_cast<DWORD64>(pc);
63 PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(&buffer[0]); 63 PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(&buffer[0]);
64 pSymbol->SizeOfStruct = kSymbolInfoSize; 64 pSymbol->SizeOfStruct = kSymbolInfoSize;
65 pSymbol->MaxNameLen = kMaxNameLength; 65 pSymbol->MaxNameLen = kMaxNameLength;
66 BOOL r = SymFromAddr(hProcess, address, NULL, pSymbol); 66 BOOL r = SymFromAddr(hProcess, address, NULL, pSymbol);
67 if (r == FALSE) { 67 if (r == FALSE) {
68 return NULL; 68 return NULL;
69 } 69 }
70 return strdup(pSymbol->Name); 70 return strdup(pSymbol->Name);
71 #endif 71 #endif
72 return NULL; 72 return NULL;
73 } 73 }
74 74
75 75
76 void NativeSymbolResolver::FreeSymbolName(char* name) { 76 void NativeSymbolResolver::FreeSymbolName(char* name) {
77 free(name); 77 free(name);
78 } 78 }
79 79
80 80
81 } // namespace dart 81 } // namespace dart
82 82
83 #endif // defined(TARGET_OS_WINDOWS) 83 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/os.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698