From 303325768bba7b7e85b7d3d1689b7bb0b71e2052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 26 Sep 2016 15:41:57 +0200 Subject: [PATCH 1/3] SymbolDB: Only match against the function name This changes GetSymbolFromName to not require the passed name to completely match with the symbol name. Instead, we now match against the stripped symbol name (i.e. only the function name). This fixes a regression introduced by #4160, which prevented HLE::PatchFunctions() from working properly. --- Source/Core/Common/SymbolDB.cpp | 2 +- Source/Core/Common/SymbolDB.h | 1 + Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/SymbolDB.cpp b/Source/Core/Common/SymbolDB.cpp index 6b6f72d33e..9e91b64457 100644 --- a/Source/Core/Common/SymbolDB.cpp +++ b/Source/Core/Common/SymbolDB.cpp @@ -41,7 +41,7 @@ Symbol* SymbolDB::GetSymbolFromName(const std::string& name) { for (auto& func : functions) { - if (func.second.name == name) + if (func.second.function_name == name) return &func.second; } diff --git a/Source/Core/Common/SymbolDB.h b/Source/Core/Common/SymbolDB.h index db4f735683..8d2ae11614 100644 --- a/Source/Core/Common/SymbolDB.h +++ b/Source/Core/Common/SymbolDB.h @@ -30,6 +30,7 @@ struct Symbol }; std::string name; + std::string function_name; // stripped function name std::vector callers; // addresses of functions that call this function std::vector calls; // addresses of functions that are called by this function u32 hash = 0; // use for HLE function finding diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 345ed2602c..f9a7d6efaf 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -16,6 +16,15 @@ #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/SignatureDB.h" +static std::string GetStrippedFunctionName(const std::string& symbol_name) +{ + std::string name = symbol_name.substr(0, symbol_name.find('(')); + size_t position = name.find(' '); + if (position != std::string::npos) + name.erase(position); + return name; +} + PPCSymbolDB g_symbolDB; PPCSymbolDB::PPCSymbolDB() @@ -62,6 +71,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam // already got it, let's just update name, checksum & size to be sure. Symbol* tempfunc = &iter->second; tempfunc->name = name; + tempfunc->function_name = GetStrippedFunctionName(name); tempfunc->hash = SignatureDB::ComputeCodeChecksum(startAddr, startAddr + size - 4); tempfunc->type = type; tempfunc->size = size; @@ -77,6 +87,7 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam { PPCAnalyst::AnalyzeFunction(startAddr, tf, size); checksumToFunction[tf.hash] = &(functions[startAddr]); + tf.function_name = GetStrippedFunctionName(name); } tf.size = size; functions[startAddr] = tf; From e1cecbb233b04dbe714ce3e03974b714f7ec3b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 26 Sep 2016 15:50:31 +0200 Subject: [PATCH 2/3] HLE_OS: Convert debug messages from SJIS to UTF-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It looks like the debug output is also output as SJIS (similar to OSReport text), so we need to convert it to UTF-8 to prevent it from all showing up as �. This doesn't fix all display issues, but fixes all SJIS/UTF-8 related ones. --- Source/Core/Core/HLE/HLE_OS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HLE/HLE_OS.cpp b/Source/Core/Core/HLE/HLE_OS.cpp index da8e04c6c8..49da2e92e2 100644 --- a/Source/Core/Core/HLE/HLE_OS.cpp +++ b/Source/Core/Core/HLE/HLE_OS.cpp @@ -43,7 +43,7 @@ void HLE_GeneralDebugPrint() NPC = LR; - NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, report_message.c_str()); + NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str()); } // __write_console is slightly abnormal @@ -53,7 +53,7 @@ void HLE_write_console() NPC = LR; - NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, report_message.c_str()); + NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str()); } std::string GetStringVA(u32 strReg) From cb73bcc72ee011490e425347ba0b03e661212912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 26 Sep 2016 22:57:40 +0200 Subject: [PATCH 3/3] PPCSymbolDB: Drop useless const qualifier --- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 2 +- Source/Core/Core/PowerPC/PPCSymbolDB.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index f9a7d6efaf..aaa1eac5ca 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -112,7 +112,7 @@ Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr) return nullptr; } -const std::string PPCSymbolDB::GetDescription(u32 addr) +std::string PPCSymbolDB::GetDescription(u32 addr) { Symbol* symbol = GetSymbolFromAddr(addr); if (symbol) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.h b/Source/Core/Core/PowerPC/PPCSymbolDB.h index 25d05678fe..240f6ce83c 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.h +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.h @@ -31,7 +31,7 @@ public: Symbol* GetSymbolFromAddr(u32 addr) override; - const std::string GetDescription(u32 addr); + std::string GetDescription(u32 addr); void FillInCallers();