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

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

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 months 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
« no previous file with comments | « runtime/vm/native_symbol_macos.cc ('k') | runtime/vm/object.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(HOST_OS_WINDOWS) 6 #if defined(HOST_OS_WINDOWS)
7 7
8 #include "vm/lockers.h" 8 #include "vm/lockers.h"
9 #include "vm/native_symbol.h" 9 #include "vm/native_symbol.h"
10 #include "vm/os_thread.h" 10 #include "vm/os_thread.h"
(...skipping 11 matching lines...) Expand all
22 running_ = true; 22 running_ = true;
23 SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); 23 SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
24 HANDLE hProcess = GetCurrentProcess(); 24 HANDLE hProcess = GetCurrentProcess();
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 } 30 }
31 31
32
33 void NativeSymbolResolver::ShutdownOnce() { 32 void NativeSymbolResolver::ShutdownOnce() {
34 MutexLocker lock(lock_); 33 MutexLocker lock(lock_);
35 if (!running_) { 34 if (!running_) {
36 return; 35 return;
37 } 36 }
38 running_ = false; 37 running_ = false;
39 HANDLE hProcess = GetCurrentProcess(); 38 HANDLE hProcess = GetCurrentProcess();
40 if (!SymCleanup(hProcess)) { 39 if (!SymCleanup(hProcess)) {
41 DWORD error = GetLastError(); 40 DWORD error = GetLastError();
42 printf("Failed to shutdown NativeSymbolResolver (SymCleanup %d)\n", error); 41 printf("Failed to shutdown NativeSymbolResolver (SymCleanup %d)\n", error);
43 } 42 }
44 } 43 }
45 44
46
47 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) { 45 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) {
48 static const intptr_t kMaxNameLength = 2048; 46 static const intptr_t kMaxNameLength = 2048;
49 static const intptr_t kSymbolInfoSize = sizeof(SYMBOL_INFO); // NOLINT. 47 static const intptr_t kSymbolInfoSize = sizeof(SYMBOL_INFO); // NOLINT.
50 static char buffer[kSymbolInfoSize + kMaxNameLength]; 48 static char buffer[kSymbolInfoSize + kMaxNameLength];
51 static char name_buffer[kMaxNameLength]; 49 static char name_buffer[kMaxNameLength];
52 MutexLocker lock(lock_); 50 MutexLocker lock(lock_);
53 if (!running_) { 51 if (!running_) {
54 return NULL; 52 return NULL;
55 } 53 }
56 if (start != NULL) { 54 if (start != NULL) {
57 *start = NULL; 55 *start = NULL;
58 } 56 }
59 memset(&buffer[0], 0, sizeof(buffer)); 57 memset(&buffer[0], 0, sizeof(buffer));
60 HANDLE hProcess = GetCurrentProcess(); 58 HANDLE hProcess = GetCurrentProcess();
61 DWORD64 address = static_cast<DWORD64>(pc); 59 DWORD64 address = static_cast<DWORD64>(pc);
62 PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(&buffer[0]); 60 PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(&buffer[0]);
63 pSymbol->SizeOfStruct = kSymbolInfoSize; 61 pSymbol->SizeOfStruct = kSymbolInfoSize;
64 pSymbol->MaxNameLen = kMaxNameLength; 62 pSymbol->MaxNameLen = kMaxNameLength;
65 DWORD64 displacement; 63 DWORD64 displacement;
66 BOOL r = SymFromAddr(hProcess, address, &displacement, pSymbol); 64 BOOL r = SymFromAddr(hProcess, address, &displacement, pSymbol);
67 if (r == FALSE) { 65 if (r == FALSE) {
68 return NULL; 66 return NULL;
69 } 67 }
70 if (start != NULL) { 68 if (start != NULL) {
71 *start = pc - displacement; 69 *start = pc - displacement;
72 } 70 }
73 return strdup(pSymbol->Name); 71 return strdup(pSymbol->Name);
74 } 72 }
75 73
76
77 void NativeSymbolResolver::FreeSymbolName(char* name) { 74 void NativeSymbolResolver::FreeSymbolName(char* name) {
78 free(name); 75 free(name);
79 } 76 }
80 77
81
82 bool NativeSymbolResolver::LookupSharedObject(uword pc, 78 bool NativeSymbolResolver::LookupSharedObject(uword pc,
83 uword* dso_base, 79 uword* dso_base,
84 char** dso_name) { 80 char** dso_name) {
85 return false; 81 return false;
86 } 82 }
87 83
88 } // namespace dart 84 } // namespace dart
89 85
90 #endif // defined(HOST_OS_WINDOWS) 86 #endif // defined(HOST_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/vm/native_symbol_macos.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698