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: {
13: #if defined(PETSC_HAVE_CXXABI_H)
14: char *newname;
15: int status;
17: newname = __cxxabiv1::__cxa_demangle(mangledName, NULL, NULL, &status);
18: if (status) {
19: if (status == -1) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_MEM, "Failed to allocate memory for symbol %s", mangledName);
20: else if (status == -2) {
21: /* Mangled name is not a valid name under the C++ ABI mangling rules */
22: PetscStrallocpy(mangledName, name);
23: return(0);
24: } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_LIB, "Demangling failed for symbol %s", mangledName);
25: }
26: PetscStrallocpy(newname, name);
27: free(newname);
28: #else
29: PetscStrallocpy(mangledName, name);
30: #endif
31: return(0);
32: }