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

Side by Side Diff: runtime/vm/native_symbol_macos.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_linux.cc ('k') | runtime/vm/native_symbol_win.cc » ('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_MACOS) 6 #if defined(HOST_OS_MACOS)
7 7
8 #include "vm/native_symbol.h" 8 #include "vm/native_symbol.h"
9 9
10 #include <cxxabi.h> // NOLINT 10 #include <cxxabi.h> // NOLINT
11 #include <dlfcn.h> // NOLINT 11 #include <dlfcn.h> // NOLINT
12 12
13 namespace dart { 13 namespace dart {
14 14
15 void NativeSymbolResolver::InitOnce() {} 15 void NativeSymbolResolver::InitOnce() {}
16 16
17
18 void NativeSymbolResolver::ShutdownOnce() {} 17 void NativeSymbolResolver::ShutdownOnce() {}
19 18
20
21 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) { 19 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) {
22 Dl_info info; 20 Dl_info info;
23 int r = dladdr(reinterpret_cast<void*>(pc), &info); 21 int r = dladdr(reinterpret_cast<void*>(pc), &info);
24 if (r == 0) { 22 if (r == 0) {
25 return NULL; 23 return NULL;
26 } 24 }
27 if (info.dli_sname == NULL) { 25 if (info.dli_sname == NULL) {
28 return NULL; 26 return NULL;
29 } 27 }
30 if (start != NULL) { 28 if (start != NULL) {
31 *start = reinterpret_cast<uintptr_t>(info.dli_saddr); 29 *start = reinterpret_cast<uintptr_t>(info.dli_saddr);
32 } 30 }
33 int status; 31 int status;
34 char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, NULL, &status); 32 char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, NULL, &status);
35 if (status == 0) { 33 if (status == 0) {
36 return demangled; 34 return demangled;
37 } 35 }
38 return strdup(info.dli_sname); 36 return strdup(info.dli_sname);
39 } 37 }
40 38
41
42 void NativeSymbolResolver::FreeSymbolName(char* name) { 39 void NativeSymbolResolver::FreeSymbolName(char* name) {
43 free(name); 40 free(name);
44 } 41 }
45 42
46
47 bool NativeSymbolResolver::LookupSharedObject(uword pc, 43 bool NativeSymbolResolver::LookupSharedObject(uword pc,
48 uword* dso_base, 44 uword* dso_base,
49 char** dso_name) { 45 char** dso_name) {
50 Dl_info info; 46 Dl_info info;
51 int r = dladdr(reinterpret_cast<void*>(pc), &info); 47 int r = dladdr(reinterpret_cast<void*>(pc), &info);
52 if (r == 0) { 48 if (r == 0) {
53 return false; 49 return false;
54 } 50 }
55 *dso_base = reinterpret_cast<uword>(info.dli_fbase); 51 *dso_base = reinterpret_cast<uword>(info.dli_fbase);
56 *dso_name = strdup(info.dli_fname); 52 *dso_name = strdup(info.dli_fname);
57 return true; 53 return true;
58 } 54 }
59 55
60 } // namespace dart 56 } // namespace dart
61 57
62 #endif // defined(HOST_OS_MACOS) 58 #endif // defined(HOST_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/vm/native_symbol_linux.cc ('k') | runtime/vm/native_symbol_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698