MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / demangle

Function demangle

src/framework/backtrace/backtrace.cpp:29–61  ·  view source on GitHub ↗

! * \brief demangle ABI-mandated entry point in the * C++ runtime library for demangling * \param value backtrace string * \return demangled value */

Source from the content-addressed store, hash-verified

27 * \return demangled value
28 */
29static std::string demangle(void *value)
30{
31 if (!value)
32 return "";
33
34 std::ostringstream ostream;
35 ostream.imbue(std::locale::classic());
36 ostream << value << " : ";
37 Dl_info info = { nullptr, nullptr, nullptr, nullptr };
38 if (dladdr(value, &info) == 0) {
39 ostream << "???";
40 } else {
41 if (info.dli_sname) {
42 int status = 0;
43 char *demangledName = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
44 if (demangledName) {
45 ostream << demangledName;
46 free(demangledName);
47 } else {
48 ostream << info.dli_sname;
49 }
50 } else {
51 ostream << "???";
52 }
53
54 long offset = reinterpret_cast<char *>(value) - reinterpret_cast<char *>(info.dli_saddr);
55 ostream << std::hex << " + 0x" << offset;
56
57 if (info.dli_fname)
58 ostream << " @ " << info.dli_fname;
59 }
60 return ostream.str();
61}
62
63static void printStack(void *frames[], int numFrames)
64{

Callers 1

printStackFunction · 0.85

Calls 1

strMethod · 0.80

Tested by

no test coverage detected