Skip to content

Commit f9ed825

Browse files
deepa181TheRealMDoerr
authored andcommitted
8303082: [AIX] Missing C++ name demangling with XLClang++
Reviewed-by: tsteele, mdoerr, stuefe
1 parent 73a084c commit f9ed825

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

src/hotspot/os/aix/porting_aix.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,7 @@
3333
#include "runtime/os.hpp"
3434
#include "utilities/align.hpp"
3535
#include "utilities/debug.hpp"
36-
37-
// distinguish old xlc and xlclang++, where
38-
// <ibmdemangle.h> is suggested but not found in GA release (might come with a fix)
39-
#if defined(__clang__)
40-
#define DISABLE_DEMANGLE
41-
// #include <ibmdemangle.h>
42-
#else
43-
#include <demangle.h>
44-
#endif
45-
36+
#include <cxxabi.h>
4637
#include <sys/debug.h>
4738
#include <pthread.h>
4839
#include <ucontext.h>
@@ -244,21 +235,18 @@ bool AixSymbols::get_function_name (
244235
}
245236
p_name[i] = '\0';
246237

247-
// If it is a C++ name, try and demangle it using the Demangle interface (see demangle.h).
248-
#ifndef DISABLE_DEMANGLE
238+
// If it is a C++ name, try and demangle it using the __cxa_demangle interface(see demangle.h).
249239
if (demangle) {
250-
char* rest;
251-
Name* const name = Demangle(p_name, rest);
252-
if (name) {
253-
const char* const demangled_name = name->Text();
254-
if (demangled_name) {
255-
strncpy(p_name, demangled_name, namelen-1);
256-
p_name[namelen-1] = '\0';
257-
}
258-
delete name;
240+
int status;
241+
char *demangled_name = abi::__cxa_demangle(p_name, nullptr, nullptr, &status);
242+
if ((demangled_name != nullptr) && (status == 0)) {
243+
strncpy(p_name, demangled_name, namelen-1);
244+
p_name[namelen-1] = '\0';
245+
}
246+
if (demangled_name != nullptr) {
247+
ALLOW_C_FUNCTION(::free, ::free(demangled_name));
259248
}
260249
}
261-
#endif
262250
} else {
263251
strncpy(p_name, "<nameless function>", namelen-1);
264252
p_name[namelen-1] = '\0';

0 commit comments

Comments
 (0)