blob: 6b837b803a9d7222e657702a6e76debcc3a6c0e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "tensorflow/stream_executor/lib/demangle.h"
#if (__GNUC__ >= 4 || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)) && \
!defined(__mips__)
# define HAS_CXA_DEMANGLE 1
#else
# define HAS_CXA_DEMANGLE 0
#endif
#include <stdlib.h>
#if HAS_CXA_DEMANGLE
#include <cxxabi.h>
#endif
namespace perftools {
namespace gputools {
namespace port {
// The API reference of abi::__cxa_demangle() can be found in
// libstdc++'s manual.
// https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a01696.html
string Demangle(const char *mangled) {
string demangled;
int status = 0;
char *result = NULL;
#if HAS_CXA_DEMANGLE
result = abi::__cxa_demangle(mangled, NULL, NULL, &status);
#endif
if (status == 0 && result != NULL) { // Demangling succeeeded.
demangled.append(result);
free(result);
}
return demangled;
}
} // namespace port
} // namespace gputools
} // namespace perftools
|