Fix some function name shenanigans

This commit is contained in:
Henrik Rydgård committed 2026-08-14 14:55:06 +02:00
1 parent f5bd302694
commit 5ce4cbc18a
4 files changed
+31 -16

No files matched your search

+3 -8
View File
@@ -385,17 +385,11 @@ const HLEFunction *GetHLEFunc(std::string_view moduleName, u32 nib) {
return 0;
}
// WARNING: Not thread-safe!
const char *GetHLEFuncName(std::string_view moduleName, u32 nib) {
_dbg_assert_msg_(!moduleName.empty(), "Invalid module name.");
const HLEFunction *func = GetHLEFunc(moduleName, nib);
if (func)
return func->name;
static char temp[64];
snprintf(temp, sizeof(temp), "[UNK: 0x%08x]", nib);
return temp;
return func ? func->name : nullptr;
}
const char *GetHLEFuncName(int moduleIndex, int func) {
@@ -913,7 +907,8 @@ const HLEFunction *GetSyscallFuncPointer(MIPSOpcode op) {
std::string importModuleName, importingModuleName;
u32 nid = 0;
if (currentMIPS->pc >= 8 && KernelFindImportByStubAddr(currentMIPS->pc - 8, &importModuleName, &nid, &importingModuleName)) {
ERROR_LOG(Log::HLE, "Unknown syscall: unresolved import %s/%08x (%s), called from '%s'", importModuleName.c_str(), nid, GetHLEFuncName(importModuleName, nid), importingModuleName.c_str());
const char *funcName = GetHLEFuncName(importModuleName, nid);
ERROR_LOG(Log::HLE, "Unknown syscall: unresolved import %s/%08x (%s), called from '%s'", importModuleName.c_str(), nid, funcName ? funcName : "(unknown)", importingModuleName.c_str());
} else {
ERROR_LOG(Log::HLE, "Unknown syscall: Module: '%.*s' (module: %d func: %d)", (int)modName.size(), modName.data(), modulenum, funcnum);
}
+3
View File
@@ -112,8 +112,11 @@ const HLEModuleMeta *GetHLEModuleMeta(std::string_view modname);
bool ShouldHLEModule(std::string_view modname, bool *wasDisabledManually = nullptr);
bool ShouldHLEModuleByImportName(std::string_view importModuleName);
// May return nullptr
const char *GetHLEFuncName(std::string_view module, u32 nib);
// May return nullptr if indices out of range.
const char *GetHLEFuncName(int module, int func);
const HLEModule *GetHLEModuleByName(std::string_view name);
const HLEFunction *GetHLEFunc(std::string_view module, u32 nib);
int GetHLEFuncIndexByNib(int moduleIndex, u32 nib);
+16 -4
View File
@@ -307,11 +307,17 @@ void PSPModule::ImportFunc(const FuncSymbolImport &func, bool reimporting) {
return;
}
DEBUG_LOG(Log::Loader, "Importing %s : %08x", GetHLEFuncName(func.moduleName, func.nid), func.stubAddr);
const char *funcName = GetHLEFuncName(func.moduleName, func.nid);
char temp[256];
if (funcName) {
snprintf(temp, sizeof(temp), "zz_%s", funcName);
} else {
snprintf(temp, sizeof(temp), "zz_%s_%08x", func.moduleName, func.nid);
}
DEBUG_LOG(Log::Loader, "Importing %s : %08x", temp, func.stubAddr);
// Add the symbol to the symbol map for debugging.
char temp[256];
snprintf(temp, sizeof(temp), "zz_%s", GetHLEFuncName(func.moduleName, func.nid));
g_symbolMap->AddFunction(temp, func.stubAddr, 8);
// Keep track and actually hook it up if possible.
@@ -676,7 +682,13 @@ void ImportFuncSymbol(const FuncSymbolImport &func, bool reimporting, const char
// Prioritize HLE implementations, if we should HLE this.
if (shouldHLE && GetHLEFunc(func.moduleName, func.nid)) {
if (reimporting && Memory::Read_Instruction(func.stubAddr + 4) != GetSyscallOp(func.moduleName, func.nid)) {
WARN_LOG(Log::Loader, "Reimporting updated syscall %s", GetHLEFuncName(func.moduleName, func.nid));
const char *name = GetHLEFuncName(func.moduleName, func.nid);
char temp[256];
if (temp) {
WARN_LOG(Log::Loader, "Reimporting updated syscall from %s: %s", func.moduleName, name);
} else {
WARN_LOG(Log::Loader, "Reimporting updated syscall from %s: zz_%08x", func.moduleName, func.nid);
}
}
// TODO: There's some double lookup going on here (we already did the lookup in GetHLEFunc above).
WriteHLESyscall(func.moduleName, func.nid, func.stubAddr);
+9 -4
View File
@@ -120,10 +120,15 @@ namespace MIPSDis
}
void Dis_Syscall(MIPSOpcode op, uint32_t pc, char *out, size_t outSize) {
u32 callno = (op>>6) & 0xFFFFF; //20 bits
int funcnum = callno & 0xFFF;
int modulenum = (callno & 0xFF000) >> 12;
snprintf(out, outSize, "syscall\t %s", GetHLEFuncName(modulenum, funcnum));
const u32 callno = (op>>6) & 0xFFFFF; //20 bits
const int funcNum = callno & 0xFFF;
const int moduleNum = (callno & 0xFF000) >> 12;
const char *funcName = GetHLEFuncName(moduleNum, funcNum);
if (funcName) {
snprintf(out, outSize, "syscall\t %s", funcName);
} else {
snprintf(out, outSize, "syscall\t %02x:%03x", moduleNum, funcNum);
}
}
void Dis_ToHiloTransfer(MIPSOpcode op, uint32_t pc, char *out, size_t outSize) {