Actual source code: demangle.cxx
1: #define PETSC_SKIP_COMPLEX
2: #include <petscsys.h>
4: #if defined(PETSC_HAVE_CXXABI_H)
5: #include <cxxabi.h>
6: #endif
8: PetscErrorCode PetscDemangleSymbol(const char mangledName[], char **name)
9: {
10: #if defined(PETSC_HAVE_CXXABI_H)
11: char *newname;
12: int status;
14: newname = __cxxabiv1::__cxa_demangle(mangledName, NULL, NULL, &status);
15: if (status) {
17: if (status == -2) {
18: /* Mangled name is not a valid name under the C++ ABI mangling rules */
19: PetscStrallocpy(mangledName, name);
20: return 0;
21: } else SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "Demangling failed for symbol %s", mangledName);
22: }
23: PetscStrallocpy(newname, name);
24: free(newname);
25: #else
26: PetscStrallocpy(mangledName, name);
27: #endif
28: return 0;
29: }