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