2019-11-29 13:55:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/String.h>
|
|
|
|
#include <cxxabi.h>
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
2020-01-16 21:04:44 +00:00
|
|
|
inline String demangle(const StringView& name)
|
2019-11-29 13:55:07 +00:00
|
|
|
{
|
2019-12-29 06:17:04 +00:00
|
|
|
#ifdef KERNEL
|
2019-11-29 13:55:07 +00:00
|
|
|
int status = 0;
|
2020-01-16 21:04:44 +00:00
|
|
|
auto* demangled_name = abi::__cxa_demangle(String(name).characters(), nullptr, nullptr, &status);
|
2019-11-29 13:55:07 +00:00
|
|
|
auto string = String(status == 0 ? demangled_name : name);
|
|
|
|
if (status == 0)
|
|
|
|
kfree(demangled_name);
|
|
|
|
return string;
|
2019-12-29 06:17:04 +00:00
|
|
|
#else
|
|
|
|
return name;
|
|
|
|
#endif
|
2019-11-29 13:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using AK::demangle;
|