mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 00:14:07 +01:00
ircd::mods: Add cxx abi name demangling.
This commit is contained in:
parent
f7c1e43ae9
commit
28cf226c3a
2 changed files with 28 additions and 0 deletions
|
@ -129,6 +129,9 @@ struct import_shared
|
|||
import_shared(const std::string &modname, const std::string &symname);
|
||||
};
|
||||
|
||||
|
||||
std::string demangle(const std::string &symbol);
|
||||
|
||||
std::string postfixed(const std::string &name);
|
||||
std::string unpostfixed(const std::string &name);
|
||||
|
||||
|
@ -158,6 +161,7 @@ namespace ircd {
|
|||
using mods::module; // Bring struct module into main ircd::
|
||||
using mods::import;
|
||||
using mods::import_shared;
|
||||
using mods::demangle;
|
||||
|
||||
} // namespace ircd
|
||||
|
||||
|
|
24
ircd/mods.cc
24
ircd/mods.cc
|
@ -24,6 +24,7 @@
|
|||
* USA
|
||||
*/
|
||||
|
||||
#include <cxxabi.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/dll.hpp>
|
||||
|
||||
|
@ -582,6 +583,29 @@ ircd::mods::prefix_if_relative(const filesystem::path &path)
|
|||
return path.is_relative()? (modroot / path) : path;
|
||||
}
|
||||
|
||||
std::string
|
||||
ircd::mods::demangle(const std::string &symbol)
|
||||
{
|
||||
size_t len;
|
||||
int status;
|
||||
const custom_ptr<char> buf
|
||||
{
|
||||
abi::__cxa_demangle(symbol.c_str(), nullptr, &len, &status),
|
||||
std::free
|
||||
};
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case 0: break;
|
||||
case -1: throw error("Demangle failed -1: memory allocation failure");
|
||||
case -2: throw error("Demangle failed -2: mangled name is not valid");
|
||||
case -3: throw error("Demangle failed -3: invalid argument");
|
||||
default: throw error("Demangle failed %d: unknown error", status);
|
||||
}
|
||||
|
||||
return { buf.get(), len };
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// mod (internal)
|
||||
|
|
Loading…
Reference in a new issue