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