Add even more logging to savedata code

This commit is contained in:
Henrik Rydgård 2024-09-27 00:47:05 +02:00
parent edf41df79a
commit 21ee18b730
6 changed files with 88 additions and 55 deletions

View File

@ -120,7 +120,7 @@ int PSPSaveDialog::Init(int paramAddr)
const u32 mode = (u32)param.GetPspParam()->mode;
const char *modeName = mode < ARRAY_SIZE(utilitySavedataTypeNames) ? utilitySavedataTypeNames[mode] : "UNKNOWN";
INFO_LOG(Log::sceUtility,"sceUtilitySavedataInitStart(%08x) - %s (%d)", paramAddr, modeName, mode);
INFO_LOG(Log::sceUtility,"sceUtilitySavedataInitStart(%08x) : Game key (hex): %s", paramAddr, param.GetKey(param.GetPspParam()).c_str());
INFO_LOG(Log::sceUtility,"Game key (hex): %s", param.GetKey(param.GetPspParam()).c_str());
yesnoChoice = 1;
switch ((SceUtilitySavedataFocus)(u32)param.GetPspParam()->focus)

View File

@ -69,7 +69,7 @@
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_WRONG_UMD (0x801103Ca)
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_INTERNAL (0x801103Cb)
class PSPSaveDialog: public PSPDialog {
class PSPSaveDialog : public PSPDialog {
public:
PSPSaveDialog(UtilityDialogType type);
~PSPSaveDialog();
@ -88,7 +88,6 @@ protected:
}
private:
void DisplayBanner(int which);
void DisplaySaveList(bool canMove = true);
void DisplaySaveIcon(bool checkExists);
@ -158,4 +157,3 @@ private:
std::mutex paramLock;
volatile SaveIOStatus ioThreadStatus;
};

View File

@ -459,7 +459,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
}
}
u8* cryptedData = 0;
u8 *cryptedData = 0;
int cryptedSize = 0;
u8 cryptedHash[0x10]{};
// Encrypt save.
@ -487,6 +487,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
bool hasKey = decryptMode > 1;
if (hasKey && !HasKey(param)) {
delete[] cryptedData;
ERROR_LOG(Log::sceUtility, "Inconsistent hasKey");
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_PARAM;
}
@ -629,9 +630,12 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveDirName, int saveId, bool secureMode) {
if (!param) {
ERROR_LOG(Log::sceUtility, "Param missing");
return SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA;
}
INFO_LOG(Log::sceUtility, "Load: %s", saveDirName.c_str());
bool isRWMode = param->mode == SCE_UTILITY_SAVEDATA_TYPE_READDATA || param->mode == SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE;
std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName));
@ -639,10 +643,12 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD
std::string filePath = dirPath + "/" + fileName;
if (!pspFileSystem.GetFileInfo(dirPath).exists) {
WARN_LOG(Log::sceUtility, "Load: Dir not found: %s", dirPath.c_str());
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA : SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA;
}
if (!fileName.empty() && !pspFileSystem.GetFileInfo(filePath).exists) {
WARN_LOG(Log::sceUtility, "Load: File not found: %s", filePath.c_str());
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND : SCE_UTILITY_SAVEDATA_ERROR_LOAD_FILE_NOT_FOUND;
}
@ -650,8 +656,10 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD
// This isn't reset if the path doesn't even exist.
param->dataSize = 0;
int result = LoadSaveData(param, saveDirName, dirPath, secureMode);
if (result != 0)
if (result != 0) {
WARN_LOG(Log::sceUtility, "LoadSaveData failed: %s", dirPath.c_str());
return result;
}
// Load sfo
if (!LoadSFO(param, dirPath)) {
@ -691,8 +699,10 @@ int SavedataParam::LoadSaveData(SceUtilitySavedataParam *param, const std::strin
std::string filename = GetFileName(param);
std::string filePath = dirPath + "/" + filename;
// Blank filename always means success, if secureVersion was correct.
if (filename.empty())
if (filename.empty()) {
INFO_LOG(Log::sceUtility, "'Loading' blank filename, returning success.");
return 0;
}
s64 readSize;
INFO_LOG(Log::sceUtility, "Loading file with size %u in %s", param->dataBufSize, filePath.c_str());
@ -1592,7 +1602,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
PSPFileInfo info = GetSaveInfo(fileDataDir);
if (info.exists) {
SetFileInfo(realCount, info, thisSaveName);
INFO_LOG(Log::sceUtility, "Save data exists: %s = %s", thisSaveName.c_str(), fileDataDir.c_str());
INFO_LOG(Log::sceUtility, "Save data folder exists: %s = %s", thisSaveName.c_str(), fileDataDir.c_str());
realCount++;
} else {
if (listEmptyFile) {
@ -1607,6 +1617,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
saveNameListDataCount = realCount;
}
}
// Load info on only save
if (!hasMultipleFileName) {
saveNameListData = 0;
@ -1620,7 +1631,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
PSPFileInfo info = GetSaveInfo(fileDataDir);
if (info.exists) {
SetFileInfo(0, info, GetSaveName(param));
INFO_LOG(Log::sceUtility, "Save data exists: %s = %s", GetSaveName(param).c_str(), fileDataDir.c_str());
INFO_LOG(Log::sceUtility, "Save data folder exists: %s = %s", GetSaveName(param).c_str(), fileDataDir.c_str());
saveNameListDataCount = 1;
} else {
if (listEmptyFile) {

View File

@ -1039,8 +1039,8 @@ void VFSFileSystem::CloseFile(u32 handle) {
delete [] iter->second.fileData;
entries.erase(iter);
} else {
//This shouldn't happen...
ERROR_LOG(Log::FileSystem,"Cannot close file that hasn't been opened: %08x", handle);
// This shouldn't happen...
ERROR_LOG(Log::FileSystem, "Cannot close file that hasn't been opened: %08x", handle);
}
}

View File

@ -479,7 +479,7 @@ size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) {
OpenFileEntry &e = iter->second;
if (size < 0) {
ERROR_LOG_REPORT(Log::FileSystem, "Invalid read for %lld bytes from umd %s", size, e.file ? e.file->name.c_str() : "device");
ERROR_LOG_REPORT(Log::FileSystem, "Invalid read for %lld bytes from umd %s", size, e.file ? e.file->name.c_str() : "lba");
return 0;
}
@ -520,7 +520,7 @@ size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) {
if (newSize == 0) {
INFO_LOG(Log::FileSystem, "Attempted read at end of file, 0-size read simulated");
} else {
INFO_LOG(Log::FileSystem, "Reading beyond end of file from seekPos %d, clamping size %lld to %lld", e.seekPos, size, newSize);
WARN_LOG(Log::FileSystem, "Reading beyond end of file (%s) from seekPos %d, clamping size %lld to %lld", e.file ? e.file->name.c_str() : "lba", e.seekPos, size, newSize);
}
size = newSize;
}

View File

@ -79,6 +79,20 @@ static const int atrac3PlusModuleDeps[] = {0x0300, 0};
static const int mpegBaseModuleDeps[] = {0x0300, 0};
static const int mp4ModuleDeps[] = {0x0300, 0};
static const char *g_paramNames[] = {
"N/A (0)",
"NICKNAME", // 1
"ADHOC_CHANNEL", // 2
"WLAN_POWERSAVE", // =3
"DATE_FORMAT", // 4
"TIME_FORMAT", // 5
"TIMEZONE", // 6
"INT_DAYLIGHTSAVINGS", // 7
"INT_LANGUAGE", // 8
"BUTTON_PREFERENCE", // 9
"LOCK_PARENTAL_LEVEL", // 10
};
struct ModuleLoadInfo {
ModuleLoadInfo(int m, u32 s, void(*n)(int) = nullptr) : mod(m), size(s), dependencies(noDeps), notify(n) {
}
@ -827,7 +841,12 @@ static u32 sceUtilityGetSystemParamString(u32 id, u32 destAddr, int destSize)
// TODO: What error code?
return -1;
}
DEBUG_LOG(Log::sceUtility, "sceUtilityGetSystemParamString(%i, %08x, %i)", id, destAddr, destSize);
const char *name = "N/A ??";
if (id < ARRAY_SIZE(g_paramNames)) {
name = g_paramNames[id];
}
DEBUG_LOG(Log::sceUtility, "sceUtilityGetSystemParamString(%i - %s, %08x, %i)", id, name, destAddr, destSize);
char *buf = (char *)Memory::GetPointerWriteUnchecked(destAddr);
switch (id) {
case PSP_SYSTEMPARAM_ID_STRING_NICKNAME:
@ -916,7 +935,12 @@ static u32 sceUtilityGetSystemParamInt(u32 id, u32 destaddr)
return PSP_SYSTEMPARAM_RETVAL_FAIL;
}
INFO_LOG(Log::sceUtility, "sceUtilityGetSystemParamInt(%i, %08x <- %08x)", id, destaddr, param);
const char *name = "N/A ??";
if (id < ARRAY_SIZE(g_paramNames)) {
name = g_paramNames[id];
}
INFO_LOG(Log::sceUtility, "sceUtilityGetSystemParamInt(%i (%s), %08x <- %08x)", id, name, destaddr, param);
Memory::Write_U32(param, destaddr);
return 0;
}