diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-01-13 22:06:13 +0100 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-01-14 05:43:21 +0100 |
commit | 80a55c1663ac600103e3d475c1f72b04e2e76f0f (patch) | |
tree | ac18dcb7f4714b3324733724edd449c77356345c /src/common/demangle.h | |
parent | Merge pull request #9605 from german77/mouse_mapping (diff) | |
download | yuzu-80a55c1663ac600103e3d475c1f72b04e2e76f0f.tar yuzu-80a55c1663ac600103e3d475c1f72b04e2e76f0f.tar.gz yuzu-80a55c1663ac600103e3d475c1f72b04e2e76f0f.tar.bz2 yuzu-80a55c1663ac600103e3d475c1f72b04e2e76f0f.tar.lz yuzu-80a55c1663ac600103e3d475c1f72b04e2e76f0f.tar.xz yuzu-80a55c1663ac600103e3d475c1f72b04e2e76f0f.tar.zst yuzu-80a55c1663ac600103e3d475c1f72b04e2e76f0f.zip |
Diffstat (limited to 'src/common/demangle.h')
-rw-r--r-- | src/common/demangle.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/common/demangle.h b/src/common/demangle.h new file mode 100644 index 000000000..1c4143629 --- /dev/null +++ b/src/common/demangle.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <string> + +namespace llvm { +char* itaniumDemangle(const char* mangled_name, char* buf, size_t* n, int* status); +} + +namespace Common { +std::string DemangleSymbol(const std::string& mangled) { + auto is_itanium = [](const std::string& name) -> bool { + // A valid Itanium encoding requires 1-4 leading underscores, followed by 'Z'. + auto pos = name.find_first_not_of('_'); + return pos > 0 && pos <= 4 && name[pos] == 'Z'; + }; + + char* demangled = nullptr; + if (is_itanium(mangled)) { + demangled = llvm::itaniumDemangle(mangled.c_str(), nullptr, nullptr, nullptr); + } + + if (!demangled) { + return mangled; + } + + std::string ret = demangled; + std::free(demangled); + return ret; +} +} // namespace Common
\ No newline at end of file |