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