summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKelebek1 <eeeedddccc@hotmail.co.uk>2023-01-14 06:12:41 +0100
committerKelebek1 <eeeedddccc@hotmail.co.uk>2023-01-14 06:12:41 +0100
commitce0b8d618da77fef0088067d19f5d36a13e74cbc (patch)
tree3f6cdc042723e3ea6c81076579379f21ac100dba /src
parentAdd stacktrace symbol demangling (diff)
downloadyuzu-ce0b8d618da77fef0088067d19f5d36a13e74cbc.tar
yuzu-ce0b8d618da77fef0088067d19f5d36a13e74cbc.tar.gz
yuzu-ce0b8d618da77fef0088067d19f5d36a13e74cbc.tar.bz2
yuzu-ce0b8d618da77fef0088067d19f5d36a13e74cbc.tar.lz
yuzu-ce0b8d618da77fef0088067d19f5d36a13e74cbc.tar.xz
yuzu-ce0b8d618da77fef0088067d19f5d36a13e74cbc.tar.zst
yuzu-ce0b8d618da77fef0088067d19f5d36a13e74cbc.zip
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/demangle.cpp33
-rw-r--r--src/common/demangle.h25
3 files changed, 36 insertions, 23 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 57eec57b5..bd6ac6716 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.cpp
demangle.h
div_ceil.h
dynamic_library.cpp
diff --git a/src/common/demangle.cpp b/src/common/demangle.cpp
new file mode 100644
index 000000000..17abdb85e
--- /dev/null
+++ b/src/common/demangle.cpp
@@ -0,0 +1,33 @@
+// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "common/demangle.h"
+
+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
diff --git a/src/common/demangle.h b/src/common/demangle.h
index 1c4143629..f072d22f3 100644
--- a/src/common/demangle.h
+++ b/src/common/demangle.h
@@ -5,29 +5,8 @@
#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 DemangleSymbol(const std::string& mangled);
- std::string ret = demangled;
- std::free(demangled);
- return ret;
-}
-} // namespace Common \ No newline at end of file
+} // namespace Common