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
|
|
|
|
|
2021-12-26 20:07:14 +03:00
|
|
|
#ifndef KERNEL
|
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
# include <AK/DeprecatedString.h>
|
2021-12-26 20:07:14 +03:00
|
|
|
# include <AK/StringView.h>
|
|
|
|
# include <cxxabi.h>
|
2019-11-29 16:55:07 +03:00
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
inline DeprecatedString demangle(StringView name)
|
2019-11-29 16:55:07 +03:00
|
|
|
{
|
|
|
|
int status = 0;
|
2022-12-06 04:12:49 +03:00
|
|
|
auto* demangled_name = abi::__cxa_demangle(name.to_deprecated_string().characters(), nullptr, nullptr, &status);
|
2022-12-04 21:02:33 +03:00
|
|
|
auto string = DeprecatedString(status == 0 ? StringView { demangled_name, strlen(demangled_name) } : name);
|
2019-11-29 16:55:07 +03:00
|
|
|
if (status == 0)
|
2022-01-12 06:27:21 +03:00
|
|
|
free(demangled_name);
|
2019-11-29 16:55:07 +03:00
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-26 14:18:30 +03:00
|
|
|
# if USING_AK_GLOBALLY
|
2019-11-29 16:55:07 +03:00
|
|
|
using AK::demangle;
|
2022-11-26 14:18:30 +03:00
|
|
|
# endif
|
2021-12-26 20:07:14 +03:00
|
|
|
|
|
|
|
#endif
|