| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 "platform/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_FUCHSIA) | 6 #if defined(TARGET_OS_FUCHSIA) |
| 7 | 7 |
| 8 #include "platform/memory_sanitizer.h" |
| 8 #include "vm/native_symbol.h" | 9 #include "vm/native_symbol.h" |
| 9 | 10 |
| 11 #include <cxxabi.h> // NOLINT |
| 10 #include <dlfcn.h> // NOLINT | 12 #include <dlfcn.h> // NOLINT |
| 11 | 13 |
| 12 namespace dart { | 14 namespace dart { |
| 13 | 15 |
| 14 void NativeSymbolResolver::InitOnce() { | 16 void NativeSymbolResolver::InitOnce() { |
| 15 } | 17 } |
| 16 | 18 |
| 17 | 19 |
| 18 void NativeSymbolResolver::ShutdownOnce() { | 20 void NativeSymbolResolver::ShutdownOnce() { |
| 19 } | 21 } |
| 20 | 22 |
| 21 | 23 |
| 22 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) { | 24 char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) { |
| 23 Dl_info info; | 25 Dl_info info; |
| 24 int r = dladdr(reinterpret_cast<void*>(pc), &info); | 26 int r = dladdr(reinterpret_cast<void*>(pc), &info); |
| 25 if (r == 0) { | 27 if (r == 0) { |
| 26 return NULL; | 28 return NULL; |
| 27 } | 29 } |
| 28 if (info.dli_sname == NULL) { | 30 if (info.dli_sname == NULL) { |
| 29 return NULL; | 31 return NULL; |
| 30 } | 32 } |
| 31 if (start != NULL) { | 33 if (start != NULL) { |
| 32 *start = reinterpret_cast<uintptr_t>(info.dli_saddr); | 34 *start = reinterpret_cast<uintptr_t>(info.dli_saddr); |
| 33 } | 35 } |
| 36 int status = 0; |
| 37 size_t len = 0; |
| 38 char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, &len, &status); |
| 39 MSAN_UNPOISON(demangled, len); |
| 40 if (status == 0) { |
| 41 return demangled; |
| 42 } |
| 34 return strdup(info.dli_sname); | 43 return strdup(info.dli_sname); |
| 35 } | 44 } |
| 36 | 45 |
| 37 | 46 |
| 38 void NativeSymbolResolver::FreeSymbolName(char* name) { | 47 void NativeSymbolResolver::FreeSymbolName(char* name) { |
| 39 free(name); | 48 free(name); |
| 40 } | 49 } |
| 41 | 50 |
| 42 } // namespace dart | 51 } // namespace dart |
| 43 | 52 |
| 44 #endif // defined(TARGET_OS_FUCHSIA) | 53 #endif // defined(TARGET_OS_FUCHSIA) |
| OLD | NEW |