2017-12-08 01:34:52 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-05 15:57:42 +00:00
|
|
|
#include <memory>
|
2017-12-08 01:34:52 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
/** Demangles C++ symbol name.
|
|
|
|
* When demangling fails, returns the original name and sets status to non-zero.
|
2018-05-25 18:13:48 +00:00
|
|
|
* TODO: Write msvc version (now returns the same string)
|
2017-12-08 01:34:52 +00:00
|
|
|
*/
|
|
|
|
std::string demangle(const char * name, int & status);
|
|
|
|
|
|
|
|
inline std::string demangle(const char * name)
|
|
|
|
{
|
|
|
|
int status = 0;
|
|
|
|
return demangle(name, status);
|
|
|
|
}
|
2020-02-03 19:50:08 +00:00
|
|
|
|
|
|
|
// abi::__cxa_demangle returns a C string of known size that should be deleted
|
|
|
|
// with free().
|
2020-02-05 10:24:24 +00:00
|
|
|
struct FreeingDeleter
|
2020-02-03 19:50:08 +00:00
|
|
|
{
|
2020-02-05 10:24:24 +00:00
|
|
|
template <typename PointerType>
|
|
|
|
void operator() (PointerType ptr)
|
2020-02-03 19:50:08 +00:00
|
|
|
{
|
2020-02-05 10:24:24 +00:00
|
|
|
std::free(ptr);
|
2020-02-03 19:50:08 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-02-05 10:24:24 +00:00
|
|
|
typedef std::unique_ptr<char, FreeingDeleter> DemangleResult;
|
|
|
|
|
2020-02-04 13:31:15 +00:00
|
|
|
DemangleResult tryDemangle(const char * name);
|