Line data Source code
1 : /*
2 : * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3 : * Author: Martin Rupp
4 : *
5 : * This file is part of UG4.
6 : *
7 : * UG4 is free software: you can redistribute it and/or modify it under the
8 : * terms of the GNU Lesser General Public License version 3 (as published by the
9 : * Free Software Foundation) with the following additional attribution
10 : * requirements (according to LGPL/GPL v3 §7):
11 : *
12 : * (1) The following notice must be displayed in the Appropriate Legal Notices
13 : * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 : *
15 : * (2) The following notice must be displayed at a prominent place in the
16 : * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 : *
18 : * (3) The following bibliography is recommended for citation and must be
19 : * preserved in all covered files:
20 : * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 : * parallel geometric multigrid solver on hierarchically distributed grids.
22 : * Computing and visualization in science 16, 4 (2013), 151-164"
23 : * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 : * flexible software system for simulating pde based models on high performance
25 : * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 : *
27 : * This program is distributed in the hope that it will be useful,
28 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : * GNU Lesser General Public License for more details.
31 : */
32 :
33 : #ifdef UG_POSIX
34 : #include <cxxabi.h>
35 : #endif
36 :
37 : #include <sstream>
38 : #include <string>
39 : #include <stdlib.h>
40 :
41 : using namespace std;
42 : namespace ug{
43 :
44 : #ifdef UG_POSIX
45 0 : string demangle_block(const char *str)
46 : {
47 0 : stringstream ss;
48 : char lastc=0x00;
49 : string s;
50 : int status;
51 0 : for(char c = *str; c != 0x00; c = *(++str))
52 : {
53 : // mangled names start with _ . consider only if last sign was space or tab or newline
54 0 : if(c == '_' && (lastc==' ' || lastc == '\n' || lastc == '\t'))
55 : {
56 : s = "_";
57 : // add all characters to the string until space, tab or newline
58 0 : for(c = *(++str); c != 0x00; c = *(++str))
59 : {
60 : if(c == ' ' || c == '\n' || c == '\t')
61 : break;
62 : s += c;
63 : }
64 : // some compilers add an additional _ in front. skip it.
65 : const char *p = s.c_str();
66 0 : if(s.length() > 2 && s[1] == '_') p = p+1;
67 0 : char *realname = abi::__cxa_demangle(p, 0, 0, &status);
68 0 : if(status==0)
69 0 : ss << realname; // demangle successfull
70 : else
71 : ss << s; // demangling failed, print normal string
72 0 : free(realname);
73 : }
74 0 : ss << c;
75 : lastc =c;
76 : }
77 0 : return ss.str();
78 0 : }
79 :
80 6 : string demangle(const char *str)
81 : {
82 : int status;
83 6 : char *realname = abi::__cxa_demangle(str, 0, 0, &status);
84 6 : if(status==0)
85 6 : return realname; // demangle successfull
86 : else
87 0 : return str; // demangling failed, print normal string
88 : }
89 : #else
90 : string demangle_block(const char *str)
91 : {
92 : return str;
93 : }
94 : string demangle(const char *str)
95 : {
96 : return str;
97 : }
98 : #endif
99 : }
|