summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorKelebek1 <eeeedddccc@hotmail.co.uk>2023-01-13 22:06:13 +0100
committerKelebek1 <eeeedddccc@hotmail.co.uk>2023-01-14 05:43:21 +0100
commit80a55c1663ac600103e3d475c1f72b04e2e76f0f (patch)
treeac18dcb7f4714b3324733724edd449c77356345c /src/common
parentMerge pull request #9605 from german77/mouse_mapping (diff)
downloadyuzu-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')
-rw-r--r--src/common/CMakeLists.txt3
-rw-r--r--src/common/demangle.h33
2 files changed, 35 insertions, 1 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 45332cf95..57eec57b5 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -38,6 +38,7 @@ add_library(common STATIC
common_precompiled_headers.h
common_types.h
concepts.h
+ demangle.h
div_ceil.h
dynamic_library.cpp
dynamic_library.h
@@ -175,7 +176,7 @@ endif()
create_target_directory_groups(common)
target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads)
-target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd)
+target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd demangle)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(common PRIVATE precompiled_headers.h)
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