From 9a9456345e78297a3caa02d90a2145d4aca98e0e Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Thu, 24 Oct 2024 15:24:09 -0400 Subject: [PATCH] Fix edge case in unmangled function symbols --- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 2d0734270128..3faa273d086a 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -424,15 +424,25 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, const std::string& { // If it does, the symbol is likely demangled, so look for the end of the name size_t nameEndOffset = parenthesisOffset; - while (processed_name[nameEndOffset] != ')') + int depth = 0; // Current parenthesis depth + while (true) { + char curChar = processed_name[nameEndOffset]; + if (curChar == '(') + depth++; + else if (curChar == ')') + depth--; + nameEndOffset++; + + if (depth == 0) + break; } nameEndOffset++; // Advance past the ending parenthesis // If the name ends with const, advance past it - if (processed_name.find(") const") != std::string::npos) + if (processed_name.find(") const ") != std::string::npos) { nameEndOffset += 6; }