2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-11-29 16:55:07 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/String.h>
|
2020-03-23 15:45:10 +03:00
|
|
|
#include <AK/StringView.h>
|
2021-09-20 01:17:31 +03:00
|
|
|
#include <cxxabi.h>
|
2019-11-29 16:55:07 +03:00
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
2020-01-17 00:04:44 +03:00
|
|
|
inline String demangle(const StringView& name)
|
2019-11-29 16:55:07 +03:00
|
|
|
{
|
|
|
|
int status = 0;
|
2020-05-06 20:18:24 +03:00
|
|
|
auto* demangled_name = abi::__cxa_demangle(name.to_string().characters(), nullptr, nullptr, &status);
|
2019-11-29 16:55:07 +03:00
|
|
|
auto string = String(status == 0 ? demangled_name : name);
|
|
|
|
if (status == 0)
|
|
|
|
kfree(demangled_name);
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using AK::demangle;
|