diff --git a/rpcs3/Emu/Cell/Modules/cellFont.cpp b/rpcs3/Emu/Cell/Modules/cellFont.cpp index a705e4a112..82e39b32bd 100644 --- a/rpcs3/Emu/Cell/Modules/cellFont.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFont.cpp @@ -65,7 +65,7 @@ s32 cellFontOpenFontMemory(vm::ptr library, u32 fontAddr, u32 f s32 cellFontOpenFontFile(vm::ptr library, vm::cptr fontPath, u32 subNum, s32 uniqueId, vm::ptr font) { - cellFont.warning("cellFontOpenFontFile(library=*0x%x, fontPath=*0x%x, subNum=%d, uniqueId=%d, font=*0x%x)", library, fontPath, subNum, uniqueId, font); + cellFont.warning("cellFontOpenFontFile(library=*0x%x, fontPath=%s, subNum=%d, uniqueId=%d, font=*0x%x)", library, fontPath, subNum, uniqueId, font); fs::file f(vfs::get(fontPath.get_ptr())); if (!f) diff --git a/rpcs3/Emu/Cell/Modules/cellFs.cpp b/rpcs3/Emu/Cell/Modules/cellFs.cpp index 4d5216c648..e3ea2a8086 100644 --- a/rpcs3/Emu/Cell/Modules/cellFs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFs.cpp @@ -14,7 +14,7 @@ logs::channel cellFs("cellFs", logs::level::notice); s32 cellFsOpen(vm::cptr path, s32 flags, vm::ptr fd, vm::cptr arg, u64 size) { - cellFs.warning("cellFsOpen(path=*0x%x, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx) -> sys_fs_open()", path, flags, fd, arg, size); + cellFs.warning("cellFsOpen(path=%s, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx) -> sys_fs_open()", path, flags, fd, arg, size); // TODO @@ -48,7 +48,7 @@ s32 cellFsClose(u32 fd) s32 cellFsOpendir(vm::cptr path, vm::ptr fd) { - cellFs.warning("cellFsOpendir(path=*0x%x, fd=*0x%x) -> sys_fs_opendir()", path, fd); + cellFs.warning("cellFsOpendir(path=%s, fd=*0x%x) -> sys_fs_opendir()", path, fd); // TODO @@ -79,7 +79,7 @@ s32 cellFsClosedir(u32 fd) s32 cellFsStat(vm::cptr path, vm::ptr sb) { - cellFs.warning("cellFsStat(path=*0x%x, sb=*0x%x) -> sys_fs_stat()", path, sb); + cellFs.warning("cellFsStat(path=%s, sb=*0x%x) -> sys_fs_stat()", path, sb); // TODO @@ -97,7 +97,7 @@ s32 cellFsFstat(u32 fd, vm::ptr sb) s32 cellFsMkdir(vm::cptr path, s32 mode) { - cellFs.warning("cellFsMkdir(path=*0x%x, mode=%#o) -> sys_fs_mkdir()", path, mode); + cellFs.warning("cellFsMkdir(path=%s, mode=%#o) -> sys_fs_mkdir()", path, mode); // TODO @@ -107,7 +107,7 @@ s32 cellFsMkdir(vm::cptr path, s32 mode) s32 cellFsRename(vm::cptr from, vm::cptr to) { - cellFs.warning("cellFsRename(from=*0x%x, to=*0x%x) -> sys_fs_rename()", from, to); + cellFs.warning("cellFsRename(from=%s, to=%s) -> sys_fs_rename()", from, to); // TODO @@ -117,7 +117,7 @@ s32 cellFsRename(vm::cptr from, vm::cptr to) s32 cellFsRmdir(vm::cptr path) { - cellFs.warning("cellFsRmdir(path=*0x%x) -> sys_fs_rmdir()", path); + cellFs.warning("cellFsRmdir(path=%s) -> sys_fs_rmdir()", path); // TODO @@ -127,7 +127,7 @@ s32 cellFsRmdir(vm::cptr path) s32 cellFsUnlink(vm::cptr path) { - cellFs.warning("cellFsUnlink(path=*0x%x) -> sys_fs_unlink()", path); + cellFs.warning("cellFsUnlink(path=%s) -> sys_fs_unlink()", path); // TODO @@ -170,7 +170,7 @@ s32 cellFsFGetBlockSize(u32 fd, vm::ptr sector_size, vm::ptr block_siz s32 cellFsGetBlockSize(vm::cptr path, vm::ptr sector_size, vm::ptr block_size) { - cellFs.warning("cellFsGetBlockSize(path=*0x%x, sector_size=*0x%x, block_size=*0x%x) -> sys_fs_get_block_size()", path, sector_size, block_size); + cellFs.warning("cellFsGetBlockSize(path=%s, sector_size=*0x%x, block_size=*0x%x) -> sys_fs_get_block_size()", path, sector_size, block_size); // TODO @@ -180,7 +180,7 @@ s32 cellFsGetBlockSize(vm::cptr path, vm::ptr sector_size, vm::ptr path, u64 size) { - cellFs.warning("cellFsTruncate(path=*0x%x, size=0x%llx) -> sys_fs_truncate()", path, size); + cellFs.warning("cellFsTruncate(path=%s, size=0x%llx) -> sys_fs_truncate()", path, size); // TODO @@ -198,7 +198,7 @@ s32 cellFsFtruncate(u32 fd, u64 size) s32 cellFsChmod(vm::cptr path, s32 mode) { - cellFs.warning("cellFsChmod(path=*0x%x, mode=%#o) -> sys_fs_chmod()", path, mode); + cellFs.warning("cellFsChmod(path=%s, mode=%#o) -> sys_fs_chmod()", path, mode); // TODO @@ -208,8 +208,7 @@ s32 cellFsChmod(vm::cptr path, s32 mode) s32 cellFsGetFreeSize(vm::cptr path, vm::ptr block_size, vm::ptr block_count) { - cellFs.warning("cellFsGetFreeSize(path=*0x%x, block_size=*0x%x, block_count=*0x%x)", path, block_size, block_count); - cellFs.warning("*** path = '%s'", path.get_ptr()); + cellFs.warning("cellFsGetFreeSize(path=%s, block_size=*0x%x, block_count=*0x%x)", path, block_size, block_count); // TODO: Get real values. Currently, it always returns 40 GB of free space divided in 4 KB blocks *block_size = 4096; // ? @@ -648,7 +647,7 @@ s32 sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil s32 cellFsSdataOpen(vm::cptr path, s32 flags, vm::ptr fd, vm::cptr arg, u64 size) { - cellFs.notice("cellFsSdataOpen(path=*0x%x, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size); + cellFs.notice("cellFsSdataOpen(path=%s, flags=%#o, fd=*0x%x, arg=*0x%x, size=0x%llx)", path, flags, fd, arg, size); if (flags != CELL_FS_O_RDONLY) { @@ -748,8 +747,7 @@ struct fs_aio_manager s32 cellFsAioInit(vm::cptr mount_point) { - cellFs.warning("cellFsAioInit(mount_point=*0x%x)", mount_point); - cellFs.warning("*** mount_point = '%s'", mount_point.get_ptr()); + cellFs.warning("cellFsAioInit(mount_point=%s)", mount_point); // TODO: create AIO thread (if not exists) for specified mount point fxm::get_always(); @@ -759,8 +757,7 @@ s32 cellFsAioInit(vm::cptr mount_point) s32 cellFsAioFinish(vm::cptr mount_point) { - cellFs.warning("cellFsAioFinish(mount_point=*0x%x)", mount_point); - cellFs.warning("*** mount_point = '%s'", mount_point.get_ptr()); + cellFs.warning("cellFsAioFinish(mount_point=%s)", mount_point); // TODO: delete existing AIO thread for specified mount point @@ -883,7 +880,7 @@ s32 cellFsChangeFileSizeWithoutAllocation() s32 cellFsAllocateFileAreaWithoutZeroFill(vm::cptr path, u64 size) { - cellFs.warning("cellFsAllocateFileAreaWithoutZeroFill(path=*0x%x, size=0x%llx)", path, size); + cellFs.warning("cellFsAllocateFileAreaWithoutZeroFill(path=%s, size=0x%llx)", path, size); return sys_fs_truncate(path, size); } diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index d6877986e9..4821479aa5 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -52,7 +52,7 @@ struct content_permission final s32 cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) { - cellGame.error("cellHddGameCheck(version=%d, dirName=*0x%x, errDialog=%d, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); + cellGame.error("cellHddGameCheck(version=%d, dirName=%s, errDialog=%d, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); std::string dir = dirName.get_ptr(); @@ -248,7 +248,7 @@ ppu_error_code cellGamePatchCheck(vm::ptr size, vm::ptr dirName, vm::ptr size) { - cellGame.warning("cellGameDataCheck(type=%d, dirName=*0x%x, size=*0x%x)", type, dirName, size); + cellGame.warning("cellGameDataCheck(type=%d, dirName=%s, size=*0x%x)", type, dirName, size); if ((type - 1) >= 3) { @@ -270,7 +270,7 @@ ppu_error_code cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr contentIn const std::string& dir = "/dev_hdd0/game/" + prm->dir; // Make temporary directory persistent - fs::remove_all(vfs::get(dir)); - - if (fs::rename(vfs::get("/dev_hdd1/game/" + prm->dir), vfs::get(dir))) + if (!fs::exists(vfs::get(dir)) && fs::rename(vfs::get("/dev_hdd1/game/" + prm->dir), vfs::get(dir))) { cellGame.success("cellGameContentPermit(): created directory %s", dir); } else { - fmt::throw_exception("cellGameContentPermit(): failed to rename to %s", dir); + fmt::throw_exception("cellGameContentPermit(): failed to initialize %s", dir); } // Create PARAM.SFO @@ -334,7 +332,7 @@ ppu_error_code cellGameContentPermit(vm::ptr contentIn ppu_error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) { - cellGame.error("cellGameDataCheckCreate2(version=0x%x, dirName=*0x%x, errDialog=0x%x, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); + cellGame.error("cellGameDataCheckCreate2(version=0x%x, dirName=%s, errDialog=0x%x, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); if (version != CELL_GAMEDATA_VERSION_CURRENT || errDialog > 1) { @@ -422,7 +420,7 @@ ppu_error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) { - cellGame.warning("cellGameDataCheckCreate(version=0x%x, dirName=*0x%x, errDialog=0x%x, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); + cellGame.warning("cellGameDataCheckCreate(version=0x%x, dirName=%s, errDialog=0x%x, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); // TODO: almost identical, the only difference is that this function will always calculate the size of game data return cellGameDataCheckCreate2(ppu, version, dirName, errDialog, funcStat, container); @@ -620,7 +618,7 @@ s32 cellGameGetLocalWebContentPath() ppu_error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr dirName) { - cellGame.warning("cellGameContentErrorDialog(type=%d, errNeedSizeKB=%d, dirName=*0x%x)", type, errNeedSizeKB, dirName); + cellGame.warning("cellGameContentErrorDialog(type=%d, errNeedSizeKB=%d, dirName=%s)", type, errNeedSizeKB, dirName); std::string errorName; switch (type) @@ -646,7 +644,7 @@ ppu_error_code cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr< if (dirName) { - errorMsg += fmt::format("\nDirectory name: %s", dirName.get_ptr()); + errorMsg += fmt::format("\nDirectory name: %s", dirName); } const auto dlg = Emu.GetCallbacks().get_msg_dialog(); diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp index 16df4adb45..59f5f6cafe 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp @@ -17,7 +17,7 @@ s32 cellMsgDialogOpen() s32 cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) { - cellSysutil.warning("cellMsgDialogOpen2(type=0x%x, msgString=*0x%x, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam); + cellSysutil.warning("cellMsgDialogOpen2(type=0x%x, msgString=%s, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam); if (!msgString || std::strlen(msgString.get_ptr()) >= 0x200 || type & -0x33f8) { @@ -249,17 +249,14 @@ s32 cellMsgDialogAbort() return CELL_SYSUTIL_ERROR_BUSY; } - if (!fxm::remove()) - { - fmt::throw_exception("Failed to remove MsgDialog object" HERE); - } + VERIFY(fxm::remove()); return CELL_OK; } s32 cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr msgString) { - cellSysutil.warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString=*0x%x)", progressBarIndex, msgString); + cellSysutil.warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString=%s)", progressBarIndex, msgString); const auto dlg = fxm::get(); diff --git a/rpcs3/Emu/Cell/Modules/cellOvis.cpp b/rpcs3/Emu/Cell/Modules/cellOvis.cpp index 2b4716f959..f7a5daa2bd 100644 --- a/rpcs3/Emu/Cell/Modules/cellOvis.cpp +++ b/rpcs3/Emu/Cell/Modules/cellOvis.cpp @@ -13,7 +13,7 @@ enum s32 cellOvisGetOverlayTableSize(vm::cptr elf) { - cellOvis.todo("cellOvisGetOverlayTableSize(elf=*0x%x)", elf); + cellOvis.todo("cellOvisGetOverlayTableSize(elf=%s)", elf); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellRtc.cpp b/rpcs3/Emu/Cell/Modules/cellRtc.cpp index 0c53abf9f4..e0d51456b1 100644 --- a/rpcs3/Emu/Cell/Modules/cellRtc.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRtc.cpp @@ -71,14 +71,14 @@ s32 cellRtcFormatRfc3339LocalTime(vm::ptr pszDateTime, vm::ptr pUtc, vm::cptr pszDateTime) { - cellRtc.todo("cellRtcParseDateTime(pUtc=*0x%x, pszDateTime=*0x%x)", pUtc, pszDateTime); + cellRtc.todo("cellRtcParseDateTime(pUtc=*0x%x, pszDateTime=%s)", pUtc, pszDateTime); return CELL_OK; } s32 cellRtcParseRfc3339(vm::ptr pUtc, vm::cptr pszDateTime) { - cellRtc.todo("cellRtcParseRfc3339(pUtc=*0x%x, pszDateTime=*0x%x)", pUtc, pszDateTime); + cellRtc.todo("cellRtcParseRfc3339(pUtc=*0x%x, pszDateTime=%s)", pUtc, pszDateTime); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellSail.cpp b/rpcs3/Emu/Cell/Modules/cellSail.cpp index c5cd84ceff..5a1bcd771d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSail.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSail.cpp @@ -786,7 +786,7 @@ s32 cellSailPlayerAddDescriptor(vm::ptr pSelf, vm::ptr pSelf, s32 streamType, vm::ptr pMediaInfo, vm::cptr pUri, vm::pptr ppDesc) { - cellSail.todo("cellSailPlayerCreateDescriptor(pSelf=*0x%x, streamType=%d, pMediaInfo=*0x%x, pUri=*0x%x, ppDesc=**0x%x)", pSelf, streamType, pMediaInfo, pUri, ppDesc); + cellSail.todo("cellSailPlayerCreateDescriptor(pSelf=*0x%x, streamType=%d, pMediaInfo=*0x%x, pUri=%s, ppDesc=**0x%x)", pSelf, streamType, pMediaInfo, pUri, ppDesc); u32 descriptorAddress = vm::alloc(sizeof(CellSailDescriptor), vm::main); auto descriptor = vm::ptr::make(descriptorAddress); diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index dcc6c92a60..28fed0f6da 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -696,7 +696,7 @@ s32 cellSaveDataFixedLoad(ppu_thread& ppu, u32 version, PSetList setList, PSetBu s32 cellSaveDataAutoSave2(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr userdata) { - cellSaveData.warning("cellSaveDataAutoSave2(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", + cellSaveData.warning("cellSaveDataAutoSave2(version=%d, dirName=%s, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", version, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null); @@ -705,7 +705,7 @@ s32 cellSaveDataAutoSave2(ppu_thread& ppu, u32 version, vm::cptr dirName, s32 cellSaveDataAutoLoad2(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr userdata) { - cellSaveData.warning("cellSaveDataAutoLoad2(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", + cellSaveData.warning("cellSaveDataAutoLoad2(version=%d, dirName=%s, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", version, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null); @@ -714,7 +714,7 @@ s32 cellSaveDataAutoLoad2(ppu_thread& ppu, u32 version, vm::cptr dirName, s32 cellSaveDataAutoSave(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container) { - cellSaveData.warning("cellSaveDataAutoSave(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", + cellSaveData.warning("cellSaveDataAutoSave(version=%d, dirName=%s, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", version, dirName, errDialog, setBuf, funcStat, funcFile, container); return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null); @@ -723,7 +723,7 @@ s32 cellSaveDataAutoSave(ppu_thread& ppu, u32 version, vm::cptr dirName, u s32 cellSaveDataAutoLoad(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container) { - cellSaveData.warning("cellSaveDataAutoLoad(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", + cellSaveData.warning("cellSaveDataAutoLoad(version=%d, dirName=%s, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", version, dirName, errDialog, setBuf, funcStat, funcFile, container); return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null); @@ -801,7 +801,7 @@ s32 cellSaveDataUserFixedLoad(ppu_thread& ppu, u32 version, u32 userId, PSetList s32 cellSaveDataUserAutoSave(ppu_thread& ppu, u32 version, u32 userId, vm::cptr dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr userdata) { - cellSaveData.error("cellSaveDataUserAutoSave(version=%d, userId=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", + cellSaveData.error("cellSaveDataUserAutoSave(version=%d, userId=%d, dirName=%s, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", version, userId, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null); @@ -809,7 +809,7 @@ s32 cellSaveDataUserAutoSave(ppu_thread& ppu, u32 version, u32 userId, vm::cptr< s32 cellSaveDataUserAutoLoad(ppu_thread& ppu, u32 version, u32 userId, vm::cptr dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr userdata) { - cellSaveData.error("cellSaveDataUserAutoLoad(version=%d, userId=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", + cellSaveData.error("cellSaveDataUserAutoLoad(version=%d, userId=%d, dirName=%s, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", version, userId, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null); diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index 5a1ce6c9d9..2c9975e6f5 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -1350,7 +1350,7 @@ s32 cellSpursAttributeSetMemoryContainerForSpuThread(vm::ptr /// Set the prefix for SPURS s32 cellSpursAttributeSetNamePrefix(vm::ptr attr, vm::cptr prefix, u32 size) { - cellSpurs.warning("cellSpursAttributeSetNamePrefix(attr=*0x%x, prefix=*0x%x, size=%d)", attr, prefix, size); + cellSpurs.warning("cellSpursAttributeSetNamePrefix(attr=*0x%x, prefix=%s, size=%d)", attr, prefix, size); if (!attr || !prefix) { @@ -2064,7 +2064,7 @@ s32 _cellSpursWorkloadAttributeInitialize(vm::ptr at /// Set the name of a workload s32 cellSpursWorkloadAttributeSetName(vm::ptr attr, vm::cptr nameClass, vm::cptr nameInstance) { - cellSpurs.warning("cellSpursWorkloadAttributeSetName(attr=*0x%x, nameClass=*0x%x, nameInstance=*0x%x)", attr, nameClass, nameInstance); + cellSpurs.warning("cellSpursWorkloadAttributeSetName(attr=*0x%x, nameClass=%s, nameInstance=%s)", attr, nameClass, nameInstance); if (!attr) { @@ -3623,7 +3623,7 @@ s32 cellSpursCreateTaskWithAttribute() s32 cellSpursTasksetAttributeSetName(vm::ptr attr, vm::cptr name) { - cellSpurs.warning("cellSpursTasksetAttributeSetName(attr=*0x%x, name=*0x%x)", attr, name); + cellSpurs.warning("cellSpursTasksetAttributeSetName(attr=*0x%x, name=%s)", attr, name); if (!attr || !name) { diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 2892df0e21..62c50e4823 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -103,28 +103,28 @@ s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr drm_path) s32 sceNpDrmIsAvailable(u32 k_licensee_addr, vm::cptr drm_path) { - sceNp.warning("sceNpDrmIsAvailable(k_licensee=*0x%x, drm_path=*0x%x)", k_licensee_addr, drm_path); + sceNp.warning("sceNpDrmIsAvailable(k_licensee=*0x%x, drm_path=%s)", k_licensee_addr, drm_path); return npDrmIsAvailable(k_licensee_addr, drm_path); } s32 sceNpDrmIsAvailable2(u32 k_licensee_addr, vm::cptr drm_path) { - sceNp.warning("sceNpDrmIsAvailable2(k_licensee=*0x%x, drm_path=*0x%x)", k_licensee_addr, drm_path); + sceNp.warning("sceNpDrmIsAvailable2(k_licensee=*0x%x, drm_path=%s)", k_licensee_addr, drm_path); return npDrmIsAvailable(k_licensee_addr, drm_path); } s32 sceNpDrmVerifyUpgradeLicense(vm::cptr content_id) { - sceNp.todo("sceNpDrmVerifyUpgradeLicense(content_id=*0x%x)", content_id); + sceNp.todo("sceNpDrmVerifyUpgradeLicense(content_id=%s)", content_id); return CELL_OK; } s32 sceNpDrmVerifyUpgradeLicense2(vm::cptr content_id) { - sceNp.todo("sceNpDrmVerifyUpgradeLicense2(content_id=*0x%x)", content_id); + sceNp.todo("sceNpDrmVerifyUpgradeLicense2(content_id=%s)", content_id); return CELL_OK; } @@ -135,9 +135,9 @@ s32 sceNpDrmExecuteGamePurchase() return CELL_OK; } -s32 sceNpDrmGetTimelimit(vm::ptr path, vm::ptr time_remain) +s32 sceNpDrmGetTimelimit(vm::cptr path, vm::ptr time_remain) { - sceNp.warning("sceNpDrmGetTimelimit(path=*0x%x, time_remain=*0x%x)", path, time_remain); + sceNp.warning("sceNpDrmGetTimelimit(path=%s, time_remain=*0x%x)", path, time_remain); *time_remain = 0x7FFFFFFFFFFFFFFFULL; diff --git a/rpcs3/Emu/Cell/Modules/sys_heap.cpp b/rpcs3/Emu/Cell/Modules/sys_heap.cpp index 96287fffc4..29ab02b917 100644 --- a/rpcs3/Emu/Cell/Modules/sys_heap.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_heap.cpp @@ -19,7 +19,7 @@ struct HeapInfo u32 _sys_heap_create_heap(vm::cptr name, u32 arg2, u32 arg3, u32 arg4) { - sysPrxForUser.warning("_sys_heap_create_heap(name=*0x%x, arg2=0x%x, arg3=0x%x, arg4=0x%x)", name, arg2, arg3, arg4); + sysPrxForUser.warning("_sys_heap_create_heap(name=%s, arg2=0x%x, arg3=0x%x, arg4=0x%x)", name, arg2, arg3, arg4); return idm::make(name.get_ptr()); } diff --git a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp index 0d3861c56d..2cbca7311d 100644 --- a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp @@ -153,7 +153,7 @@ vm::ptr _sys_memset(vm::ptr dst, s32 value, u32 size) { sysPrxForUser.trace("_sys_memset(dst=*0x%x, value=%d, size=0x%x)", dst, value, size); - memset(dst.get_ptr(), value, size); + std::memset(dst.get_ptr(), value, size); return dst; } @@ -162,7 +162,7 @@ vm::ptr _sys_memcpy(vm::ptr dst, vm::cptr src, u32 size) { sysPrxForUser.trace("_sys_memcpy(dst=*0x%x, src=*0x%x, size=0x%x)", dst, src, size); - memcpy(dst.get_ptr(), src.get_ptr(), size); + std::memcpy(dst.get_ptr(), src.get_ptr(), size); return dst; } @@ -171,7 +171,7 @@ s32 _sys_memcmp(vm::cptr buf1, vm::cptr buf2, u32 size) { sysPrxForUser.trace("_sys_memcmp(buf1=*0x%x, buf2=*0x%x, size=%d)", buf1, buf2, size); - return memcmp(buf1.get_ptr(), buf2.get_ptr(), size); + return std::memcmp(buf1.get_ptr(), buf2.get_ptr(), size); } s32 _sys_memchr() @@ -183,88 +183,76 @@ vm::ptr _sys_memmove(vm::ptr dst, vm::cptr src, u32 size) { sysPrxForUser.trace("_sys_memmove(dst=*0x%x, src=*0x%x, size=%d)", dst, src, size); - memmove(dst.get_ptr(), src.get_ptr(), size); + std::memmove(dst.get_ptr(), src.get_ptr(), size); return dst; } s64 _sys_strlen(vm::cptr str) { - sysPrxForUser.trace("_sys_strlen(str=*0x%x)", str); + sysPrxForUser.trace("_sys_strlen(str=%s)", str); - return strlen(str.get_ptr()); + return std::strlen(str.get_ptr()); } s32 _sys_strcmp(vm::cptr str1, vm::cptr str2) { - sysPrxForUser.trace("_sys_strcmp(str1=*0x%x, str2=*0x%x)", str1, str2); + sysPrxForUser.trace("_sys_strcmp(str1=%s, str2=%s)", str1, str2); - return strcmp(str1.get_ptr(), str2.get_ptr()); + return std::strcmp(str1.get_ptr(), str2.get_ptr()); } s32 _sys_strncmp(vm::cptr str1, vm::cptr str2, s32 max) { - sysPrxForUser.trace("_sys_strncmp(str1=*0x%x, str2=*0x%x, max=%d)", str1, str2, max); + sysPrxForUser.trace("_sys_strncmp(str1=%s, str2=%s, max=%d)", str1, str2, max); - return strncmp(str1.get_ptr(), str2.get_ptr(), max); + return std::strncmp(str1.get_ptr(), str2.get_ptr(), max); } vm::ptr _sys_strcat(vm::ptr dest, vm::cptr source) { - sysPrxForUser.trace("_sys_strcat(dest=*0x%x, source=*0x%x)", dest, source); + sysPrxForUser.trace("_sys_strcat(dest=*0x%x, source=%s)", dest, source); - if (strcat(dest.get_ptr(), source.get_ptr()) != dest.get_ptr()) - { - fmt::throw_exception("Unexpected strcat() result" HERE); - } + VERIFY(std::strcat(dest.get_ptr(), source.get_ptr()) == dest.get_ptr()); return dest; } vm::cptr _sys_strchr(vm::cptr str, s32 ch) { - sysPrxForUser.trace("_sys_strchr(str=*0x%x, ch=0x%x)", str, ch); + sysPrxForUser.trace("_sys_strchr(str=%s, ch=0x%x)", str, ch); return vm::cptr::make(vm::get_addr(strchr(str.get_ptr(), ch))); } vm::ptr _sys_strncat(vm::ptr dest, vm::cptr source, u32 len) { - sysPrxForUser.trace("_sys_strncat(dest=*0x%x, source=*0x%x, len=%d)", dest, source, len); + sysPrxForUser.trace("_sys_strncat(dest=*0x%x, source=%s, len=%d)", dest, source, len); - if (strncat(dest.get_ptr(), source.get_ptr(), len) != dest.get_ptr()) - { - fmt::throw_exception("Unexpected strncat() result" HERE); - } + VERIFY(std::strncat(dest.get_ptr(), source.get_ptr(), len) == dest.get_ptr()); return dest; } vm::ptr _sys_strcpy(vm::ptr dest, vm::cptr source) { - sysPrxForUser.trace("_sys_strcpy(dest=*0x%x, source=*0x%x)", dest, source); + sysPrxForUser.trace("_sys_strcpy(dest=*0x%x, source=%s)", dest, source); - if (strcpy(dest.get_ptr(), source.get_ptr()) != dest.get_ptr()) - { - fmt::throw_exception("Unexpected strcpy() result" HERE); - } + VERIFY(std::strcpy(dest.get_ptr(), source.get_ptr()) == dest.get_ptr()); return dest; } vm::ptr _sys_strncpy(vm::ptr dest, vm::cptr source, u32 len) { - sysPrxForUser.trace("_sys_strncpy(dest=*0x%x, source=*0x%x, len=%d)", dest, source, len); + sysPrxForUser.trace("_sys_strncpy(dest=*0x%x, source=%s, len=%d)", dest, source, len); if (!dest || !source) { return vm::null; } - if (strncpy(dest.get_ptr(), source.get_ptr(), len) != dest.get_ptr()) - { - fmt::throw_exception("Unexpected strncpy() result" HERE); - } + VERIFY(std::strncpy(dest.get_ptr(), source.get_ptr(), len) == dest.get_ptr()); return dest; } @@ -314,12 +302,10 @@ s32 _sys_free(u32 addr) s32 _sys_snprintf(ppu_thread& ppu, vm::ptr dst, u32 count, vm::cptr fmt, ppu_va_args_t va_args) { - sysPrxForUser.warning("_sys_snprintf(dst=*0x%x, count=%d, fmt=*0x%x, ...)", dst, count, fmt); + sysPrxForUser.warning("_sys_snprintf(dst=*0x%x, count=%d, fmt=%s, ...)", dst, count, fmt); std::string result = ps3_fmt(ppu, fmt, va_args.count); - sysPrxForUser.warning("*** '%s' -> '%s'", fmt.get_ptr(), result); - if (!count) { return 0; // ??? @@ -336,7 +322,7 @@ s32 _sys_snprintf(ppu_thread& ppu, vm::ptr dst, u32 count, vm::cptr s32 _sys_printf(ppu_thread& ppu, vm::cptr fmt, ppu_va_args_t va_args) { - sysPrxForUser.warning("_sys_printf(fmt=*0x%x, ...)", fmt); + sysPrxForUser.warning("_sys_printf(fmt=%s, ...)", fmt); if (g_tty) { diff --git a/rpcs3/Emu/Cell/Modules/sys_net.cpp b/rpcs3/Emu/Cell/Modules/sys_net.cpp index c26f3399d2..a559ff9430 100644 --- a/rpcs3/Emu/Cell/Modules/sys_net.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_net.cpp @@ -324,7 +324,7 @@ namespace sys_net u32 inet_addr(vm::cptr cp) { - libnet.warning("inet_addr(cp=*0x%x)", cp); + libnet.warning("inet_addr(cp=%s)", cp); return htonl(::inet_addr(cp.get_ptr())); // return a big-endian IP address (WTF? function should return LITTLE-ENDIAN value) } @@ -374,7 +374,7 @@ namespace sys_net vm::cptr inet_ntop(s32 af, vm::ptr src, vm::ptr dst, u32 size) { - libnet.warning("inet_ntop(af=%d, src=*0x%x, dst=*0x%x, size=%d)", af, src, dst, size); + libnet.warning("inet_ntop(af=%d, src=%s, dst=*0x%x, size=%d)", af, src, dst, size); const char* result = ::inet_ntop(af, src.get_ptr(), dst.get_ptr(), size); if (result == nullptr) @@ -387,7 +387,7 @@ namespace sys_net s32 inet_pton(s32 af, vm::cptr src, vm::ptr dst) { - libnet.warning("inet_pton(af=%d, src=*0x%x, dst=*0x%x)", af, src, dst); + libnet.warning("inet_pton(af=%d, src=%s, dst=*0x%x)", af, src, dst); return ::inet_pton(af, src.get_ptr(), dst.get_ptr()); } diff --git a/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp b/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp index 0ac57c6d6b..a7f2bd06d8 100644 --- a/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_ppu_thread_.cpp @@ -14,7 +14,7 @@ extern void ppu_free_tls(u32 addr); s32 sys_ppu_thread_create(vm::ptr thread_id, u32 entry, u64 arg, s32 prio, u32 stacksize, u64 flags, vm::cptr threadname) { - sysPrxForUser.warning("sys_ppu_thread_create(thread_id=*0x%x, entry=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=*0x%x)", + sysPrxForUser.warning("sys_ppu_thread_create(thread_id=*0x%x, entry=0x%x, arg=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=%s)", thread_id, entry, arg, prio, stacksize, flags, threadname); // Allocate TLS diff --git a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp index bd15dcec3f..905627bdee 100644 --- a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp @@ -65,13 +65,12 @@ s32 sys_spu_image_close(vm::ptr img) s32 sys_raw_spu_load(s32 id, vm::cptr path, vm::ptr entry) { - sysPrxForUser.warning("sys_raw_spu_load(id=%d, path=*0x%x, entry=*0x%x)", id, path, entry); - sysPrxForUser.warning("*** path = '%s'", path.get_ptr()); + sysPrxForUser.warning("sys_raw_spu_load(id=%d, path=%s, entry=*0x%x)", id, path, entry); const fs::file f(vfs::get(path.get_ptr())); if (!f) { - sysPrxForUser.error("sys_raw_spu_load() error: '%s' not found!", path.get_ptr()); + sysPrxForUser.error("sys_raw_spu_load() error: %s not found!", path); return CELL_ENOENT; } @@ -80,7 +79,7 @@ s32 sys_raw_spu_load(s32 id, vm::cptr path, vm::ptr entry) if (hdr.CheckMagic()) { - fmt::throw_exception("sys_raw_spu_load() error: '%s' is encrypted! Try to decrypt it manually and try again.", path.get_ptr()); + fmt::throw_exception("sys_raw_spu_load() error: %s is encrypted! Try to decrypt it manually and try again.", path); } f.seek(0); diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 308dc4ce75..3147dfd719 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -54,12 +54,11 @@ ppu_error_code sys_fs_test(u32 arg1, u32 arg2, vm::ptr arg3, u32 arg4, vm:: ppu_error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 mode, vm::cptr arg, u64 size) { - sys_fs.warning("sys_fs_open(path=*0x%x, flags=%#o, fd=*0x%x, mode=%#o, arg=*0x%x, size=0x%llx)", path, flags, fd, mode, arg, size); - sys_fs.warning("*** path = '%s'", path.get_ptr()); + sys_fs.warning("sys_fs_open(path=%s, flags=%#o, fd=*0x%x, mode=%#o, arg=*0x%x, size=0x%llx)", path, flags, fd, mode, arg, size); if (!path[0]) { - sys_fs.error("sys_fs_open('%s') failed: path is invalid", path.get_ptr()); + sys_fs.error("sys_fs_open(%s) failed: path is invalid", path); return CELL_EINVAL; } @@ -67,7 +66,7 @@ ppu_error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 if (local_path.empty()) { - sys_fs.error("sys_fs_open('%s') failed: device not mounted", path.get_ptr()); + sys_fs.error("sys_fs_open(%s) failed: device not mounted", path); return CELL_ENOTMOUNTED; } @@ -75,7 +74,7 @@ ppu_error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 if (fs::is_dir(local_path)) { - sys_fs.error("sys_fs_open('%s') failed: path is a directory", path.get_ptr()); + sys_fs.error("sys_fs_open(%s) failed: path is a directory", path); return CELL_EISDIR; } @@ -127,14 +126,14 @@ ppu_error_code sys_fs_open(vm::cptr path, s32 flags, vm::ptr fd, s32 if (!test(open_mode)) { - fmt::throw_exception("Invalid or unimplemented flags (%#o): '%s'" HERE, flags, path.get_ptr()); + fmt::throw_exception("sys_fs_open(%s): Invalid or unimplemented flags: %#o" HERE, path, flags); } fs::file file(local_path, open_mode); if (!file) { - sys_fs.error("sys_fs_open('%s'): failed to open file (flags=%#o, mode=%#o)", path.get_ptr(), flags, mode); + sys_fs.error("sys_fs_open(%s): failed to open file (flags=%#o, mode=%#o)", path, flags, mode); if (test(open_mode & fs::excl)) { @@ -220,14 +219,13 @@ ppu_error_code sys_fs_close(u32 fd) ppu_error_code sys_fs_opendir(vm::cptr path, vm::ptr fd) { - sys_fs.warning("sys_fs_opendir(path=*0x%x, fd=*0x%x)", path, fd); - sys_fs.warning("*** path = '%s'", path.get_ptr()); + sys_fs.warning("sys_fs_opendir(path=%s, fd=*0x%x)", path, fd); const std::string& local_path = vfs::get(path.get_ptr()); if (local_path.empty()) { - sys_fs.error("sys_fs_opendir('%s') failed: device not mounted", path.get_ptr()); + sys_fs.error("sys_fs_opendir(%s) failed: device not mounted", path); return CELL_ENOTMOUNTED; } @@ -235,7 +233,7 @@ ppu_error_code sys_fs_opendir(vm::cptr path, vm::ptr fd) if (fs::is_file(local_path)) { - sys_fs.error("sys_fs_opendir('%s') failed: path is a file", path.get_ptr()); + sys_fs.error("sys_fs_opendir(%s) failed: path is a file", path); return CELL_ENOTDIR; } @@ -243,7 +241,7 @@ ppu_error_code sys_fs_opendir(vm::cptr path, vm::ptr fd) if (!dir) { - sys_fs.error("sys_fs_opendir('%s'): failed to open directory", path.get_ptr()); + sys_fs.error("sys_fs_opendir(%s): failed to open directory", path); return CELL_ENOENT; } @@ -306,14 +304,13 @@ ppu_error_code sys_fs_closedir(u32 fd) ppu_error_code sys_fs_stat(vm::cptr path, vm::ptr sb) { - sys_fs.warning("sys_fs_stat(path=*0x%x, sb=*0x%x)", path, sb); - sys_fs.warning("*** path = '%s'", path.get_ptr()); + sys_fs.warning("sys_fs_stat(path=%s, sb=*0x%x)", path, sb); const std::string& local_path = vfs::get(path.get_ptr()); if (local_path.empty()) { - sys_fs.warning("sys_fs_stat('%s') failed: not mounted", path.get_ptr()); + sys_fs.warning("sys_fs_stat(%s) failed: not mounted", path); return CELL_ENOTMOUNTED; } @@ -321,7 +318,7 @@ ppu_error_code sys_fs_stat(vm::cptr path, vm::ptr sb) if (!fs::stat(local_path, info)) { - sys_fs.error("sys_fs_stat('%s') failed: not found", path.get_ptr()); + sys_fs.error("sys_fs_stat(%s) failed: not found", path); return CELL_ENOENT; } @@ -366,8 +363,7 @@ ppu_error_code sys_fs_fstat(u32 fd, vm::ptr sb) ppu_error_code sys_fs_mkdir(vm::cptr path, s32 mode) { - sys_fs.warning("sys_fs_mkdir(path=*0x%x, mode=%#o)", path, mode); - sys_fs.warning("*** path = '%s'", path.get_ptr()); + sys_fs.warning("sys_fs_mkdir(path=%s, mode=%#o)", path, mode); const std::string& local_path = vfs::get(path.get_ptr()); @@ -381,29 +377,26 @@ ppu_error_code sys_fs_mkdir(vm::cptr path, s32 mode) return CELL_EIO; // ??? } - sys_fs.notice("sys_fs_mkdir(): directory '%s' created", path.get_ptr()); + sys_fs.notice("sys_fs_mkdir(): directory %s created", path); return CELL_OK; } ppu_error_code sys_fs_rename(vm::cptr from, vm::cptr to) { - sys_fs.warning("sys_fs_rename(from=*0x%x, to=*0x%x)", from, to); - sys_fs.warning("*** from = '%s'", from.get_ptr()); - sys_fs.warning("*** to = '%s'", to.get_ptr()); + sys_fs.warning("sys_fs_rename(from=%s, to=%s)", from, to); if (!fs::rename(vfs::get(from.get_ptr()), vfs::get(to.get_ptr()))) { return CELL_ENOENT; // ??? } - sys_fs.notice("sys_fs_rename(): '%s' renamed to '%s'", from.get_ptr(), to.get_ptr()); + sys_fs.notice("sys_fs_rename(): %s renamed to %s", from, to); return CELL_OK; } ppu_error_code sys_fs_rmdir(vm::cptr path) { - sys_fs.warning("sys_fs_rmdir(path=*0x%x)", path); - sys_fs.warning("*** path = '%s'", path.get_ptr()); + sys_fs.warning("sys_fs_rmdir(path=%s)", path); if (!fs::remove_dir(vfs::get(path.get_ptr()))) { @@ -416,14 +409,13 @@ ppu_error_code sys_fs_rmdir(vm::cptr path) return CELL_EIO; // ??? } - sys_fs.notice("sys_fs_rmdir(): directory '%s' removed", path.get_ptr()); + sys_fs.notice("sys_fs_rmdir(): directory %s removed", path); return CELL_OK; } ppu_error_code sys_fs_unlink(vm::cptr path) { - sys_fs.warning("sys_fs_unlink(path=*0x%x)", path); - sys_fs.warning("*** path = '%s'", path.get_ptr()); + sys_fs.warning("sys_fs_unlink(path=%s)", path); if (!fs::remove_file(vfs::get(path.get_ptr()))) { @@ -436,7 +428,7 @@ ppu_error_code sys_fs_unlink(vm::cptr path) return CELL_EIO; // ??? } - sys_fs.notice("sys_fs_unlink(): file '%s' deleted", path.get_ptr()); + sys_fs.notice("sys_fs_unlink(): file %s deleted", path); return CELL_OK; } @@ -540,8 +532,7 @@ ppu_error_code sys_fs_fget_block_size(u32 fd, vm::ptr sector_size, vm::ptr< ppu_error_code sys_fs_get_block_size(vm::cptr path, vm::ptr sector_size, vm::ptr block_size, vm::ptr arg4) { - sys_fs.todo("sys_fs_get_block_size(path=*0x%x, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x, arg5=*0x%x)", path, sector_size, block_size, arg4); - sys_fs.todo("*** path = '%s'", path.get_ptr()); + sys_fs.todo("sys_fs_get_block_size(path=%s, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x, arg5=*0x%x)", path, sector_size, block_size, arg4); *sector_size = 4096; // ? *block_size = 4096; // ? @@ -551,8 +542,7 @@ ppu_error_code sys_fs_get_block_size(vm::cptr path, vm::ptr sector_si ppu_error_code sys_fs_truncate(vm::cptr path, u64 size) { - sys_fs.warning("sys_fs_truncate(path=*0x%x, size=0x%llx)", path, size); - sys_fs.warning("*** path = '%s'", path.get_ptr()); + sys_fs.warning("sys_fs_truncate(path=%s, size=0x%llx)", path, size); if (!fs::truncate_file(vfs::get(path.get_ptr()), size)) { @@ -597,8 +587,7 @@ ppu_error_code sys_fs_ftruncate(u32 fd, u64 size) ppu_error_code sys_fs_chmod(vm::cptr path, s32 mode) { - sys_fs.todo("sys_fs_chmod(path=*0x%x, mode=%#o) -> CELL_OK", path, mode); - sys_fs.todo("*** path = '%s'", path.get_ptr()); + sys_fs.todo("sys_fs_chmod(path=%s, mode=%#o) -> CELL_OK", path, mode); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index de895a5f3f..3d043f4a8c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -212,7 +212,7 @@ s32 sys_ppu_thread_restart(u32 thread_id) s32 _sys_ppu_thread_create(vm::ptr thread_id, vm::ptr param, u64 arg, u64 unk, s32 prio, u32 stacksize, u64 flags, vm::cptr threadname) { - sys_ppu_thread.warning("_sys_ppu_thread_create(thread_id=*0x%x, param=*0x%x, arg=0x%llx, unk=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=*0x%x)", + sys_ppu_thread.warning("_sys_ppu_thread_create(thread_id=*0x%x, param=*0x%x, arg=0x%llx, unk=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=%s)", thread_id, param, arg, unk, prio, stacksize, flags, threadname); LV2_LOCK; @@ -272,7 +272,7 @@ s32 sys_ppu_thread_start(u32 thread_id) s32 sys_ppu_thread_rename(u32 thread_id, vm::cptr name) { - sys_ppu_thread.todo("sys_ppu_thread_rename(thread_id=0x%x, name=*0x%x)", thread_id, name); + sys_ppu_thread.todo("sys_ppu_thread_rename(thread_id=0x%x, name=%s)", thread_id, name); LV2_LOCK; diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index 08f7284365..aaf0141234 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -35,7 +35,7 @@ s32 prx_load_module(std::string path, u64 flags, vm::ptr path, u64 flags, vm::ptr pOpt) { - sys_prx.warning("sys_prx_load_module(path=*0x%x, flags=0x%llx, pOpt=*0x%x)", path, flags, pOpt); + sys_prx.warning("sys_prx_load_module(path=%s, flags=0x%llx, pOpt=*0x%x)", path, flags, pOpt); return prx_load_module(path.get_ptr(), flags, pOpt); } @@ -157,8 +157,7 @@ s32 sys_prx_get_module_id_by_address() s32 sys_prx_get_module_id_by_name(vm::cptr name, u64 flags, vm::ptr pOpt) { - const char *realName = name.get_ptr(); - sys_prx.todo("sys_prx_get_module_id_by_name(name=%s, flags=%d, pOpt=*0x%x)", realName, flags, pOpt); + sys_prx.todo("sys_prx_get_module_id_by_name(name=%s, flags=%d, pOpt=*0x%x)", name, flags, pOpt); //if (realName == "?") ... diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 3400c340c9..98728e2e2f 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -56,12 +56,12 @@ s32 sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu) s32 sys_spu_image_open(vm::ptr img, vm::cptr path) { - sys_spu.warning("sys_spu_image_open(img=*0x%x, path=*0x%x)", img, path); + sys_spu.warning("sys_spu_image_open(img=*0x%x, path=%s)", img, path); const fs::file f(vfs::get(path.get_ptr())); if (!f) { - sys_spu.error("sys_spu_image_open() error: '%s' not found!", path.get_ptr()); + sys_spu.error("sys_spu_image_open() error: %s not found!", path); return CELL_ENOENT; } @@ -70,7 +70,7 @@ s32 sys_spu_image_open(vm::ptr img, vm::cptr path) if (hdr.CheckMagic()) { - fmt::throw_exception("sys_spu_image_open() error: '%s' is encrypted! Try to decrypt it manually and try again.", path.get_ptr()); + fmt::throw_exception("sys_spu_image_open() error: %s is encrypted! Try to decrypt it manually and try again.", path); } f.seek(0); @@ -150,7 +150,7 @@ s32 sys_spu_thread_initialize(vm::ptr thread, u32 group_id, u32 spu_num, vm return CELL_EBUSY; } - *thread = spu_thread_initialize(group_id, spu_num, img, attr->name ? std::string(attr->name.get_ptr(), attr->name_len) : "", attr->option, arg->arg1, arg->arg2, arg->arg3, arg->arg4); + *thread = spu_thread_initialize(group_id, spu_num, img, attr->name ? std::string(attr->name.get_ptr(), attr->name_len - 1) : "", attr->option, arg->arg1, arg->arg2, arg->arg3, arg->arg4); return CELL_OK; } @@ -223,7 +223,7 @@ s32 sys_spu_thread_group_create(vm::ptr id, u32 num, s32 prio, vm::ptrtype); } - *id = idm::make(std::string{ attr->name.get_ptr(), attr->nsize - 1 }, num, prio, attr->type, attr->ct); + *id = idm::make(std::string(attr->name.get_ptr(), attr->nsize - 1), num, prio, attr->type, attr->ct); return CELL_OK; } diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index d4ba7d49df..49eda32873 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -1,11 +1,7 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Memory.h" #include "Emu/System.h" #include "Utilities/Thread.h" -#include "Emu/CPU/CPUThread.h" -#include "Emu/Cell/PPUThread.h" -#include "Emu/Cell/SPUThread.h" -#include "Emu/PSP2/ARMv7Thread.h" #ifdef _WIN32 #include @@ -822,3 +818,56 @@ namespace vm throw access_violation(addr, cause); } } + +void fmt_class_string>::format(std::string& out, u64 arg) +{ + fmt_class_string::format(out, arg); +} + +void fmt_class_string>::format(std::string& out, u64 arg) +{ + // Special case (may be allowed for some arguments) + if (arg == 0) + { + out += u8"«NULL»"; + return; + } + + // Filter certainly invalid addresses (TODO) + if (arg < 0x10000 || arg >= 0xf0000000) + { + out += u8"«INVALID_ADDRESS:"; + fmt_class_string::format(out, arg); + out += u8"»"; + return; + } + + const auto start = out.size(); + + try + { + out += u8"“"; + + for (vm::_ptr_base ptr = vm::cast(arg);; ptr++) + { + if (const char ch = *ptr) + { + out += ch; + } + else + { + break; + } + } + + out += u8"”"; + } + catch (const vm::access_violation&) + { + // Recover from invalid memory access + out.resize(start); + out += u8"«INVALID_ADDRESS:"; + fmt_class_string::format(out, arg); + out += u8"»"; + } +} diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 24242fbac8..cd0a079bdc 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -494,10 +494,34 @@ struct to_se, Se> template struct fmt_unveil, void> { - using type = typename fmt_unveil::type; + using type = vm::_ptr_base; // Use only T, ignoring AT static inline auto get(const vm::_ptr_base& arg) { return fmt_unveil::get(arg.addr()); } }; + +template<> +struct fmt_class_string, void> +{ + static void format(std::string& out, u64 arg); +}; + +template +struct fmt_class_string, void> : fmt_class_string, void> +{ + // Classify all pointers as const void* +}; + +template<> +struct fmt_class_string, void> +{ + static void format(std::string& out, u64 arg); +}; + +template<> +struct fmt_class_string, void> : fmt_class_string> +{ + // Classify char* as const char* +}; diff --git a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp index 641b6039e5..2c190178a3 100644 --- a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp @@ -90,7 +90,7 @@ s32 sceKernelGetMemBlockInfoByAddr(vm::ptr vbase, vm::ptr pName, vm::ptr entry, s32 initPriority, u32 stackSize, u32 attr, s32 cpuAffinityMask, vm::cptr pOptParam) { - sceLibKernel.warning("sceKernelCreateThread(pName=*0x%x, entry=*0x%x, initPriority=%d, stackSize=0x%x, attr=0x%x, cpuAffinityMask=0x%x, pOptParam=*0x%x)", + sceLibKernel.warning("sceKernelCreateThread(pName=%s, entry=*0x%x, initPriority=%d, stackSize=0x%x, attr=0x%x, cpuAffinityMask=0x%x, pOptParam=*0x%x)", pName, entry, initPriority, stackSize, attr, cpuAffinityMask, pOptParam); const auto thread = idm::make_ptr(pName.get_ptr()); @@ -738,7 +738,7 @@ template<> DECLARE(psp2_event_flag::ipc::g_ipc) {}; arm_error_code sceKernelCreateEventFlag(vm::cptr pName, u32 attr, u32 initPattern, vm::cptr pOptParam) { - sceLibKernel.error("sceKernelCreateEventFlag(pName=*0x%x, attr=0x%x, initPattern=0x%x, pOptParam=*0x%x)", pName, attr, initPattern, pOptParam); + sceLibKernel.error("sceKernelCreateEventFlag(pName=%s, attr=0x%x, initPattern=0x%x, pOptParam=*0x%x)", pName, attr, initPattern, pOptParam); // Create EVF auto evf = std::make_shared(pName.get_ptr(), attr, initPattern); @@ -778,7 +778,7 @@ arm_error_code sceKernelDeleteEventFlag(s32 evfId) arm_error_code sceKernelOpenEventFlag(vm::cptr pName) { - sceLibKernel.error("sceKernelOpenEventFlag(pName=*0x%x)", pName); + sceLibKernel.error("sceKernelOpenEventFlag(pName=%s)", pName); const auto evf = psp2_event_flag::ipc::get(pName.get_ptr()); @@ -1019,7 +1019,7 @@ arm_error_code sceKernelGetEventFlagInfo(s32 evfId, vm::ptr pName, u32 attr, s32 initCount, s32 maxCount, vm::cptr pOptParam) { - sceLibKernel.error("sceKernelCreateSema(pName=*0x%x, attr=0x%x, initCount=%d, maxCount=%d, pOptParam=*0x%x)", pName, attr, initCount, maxCount, pOptParam); + sceLibKernel.error("sceKernelCreateSema(pName=%s, attr=0x%x, initCount=%d, maxCount=%d, pOptParam=*0x%x)", pName, attr, initCount, maxCount, pOptParam); return NOT_AN_ERROR(idm::make(pName.get_ptr(), attr, initCount, maxCount)); } @@ -1095,7 +1095,7 @@ s32 sceKernelGetSemaInfo(s32 semaId, vm::ptr pInfo) arm_error_code sceKernelCreateMutex(vm::cptr pName, u32 attr, s32 initCount, vm::cptr pOptParam) { - sceLibKernel.error("sceKernelCreateMutex(pName=*0x%x, attr=0x%x, initCount=%d, pOptParam=*0x%x)", pName, attr, initCount, pOptParam); + sceLibKernel.error("sceKernelCreateMutex(pName=%s, attr=0x%x, initCount=%d, pOptParam=*0x%x)", pName, attr, initCount, pOptParam); return NOT_AN_ERROR(idm::make(pName.get_ptr(), attr, initCount)); } @@ -1202,7 +1202,7 @@ s32 sceKernelGetLwMutexInfoById(s32 lwMutexId, vm::ptr pIn arm_error_code sceKernelCreateCond(vm::cptr pName, u32 attr, s32 mutexId, vm::cptr pOptParam) { - sceLibKernel.error("sceKernelCreateCond(pName=*0x%x, attr=0x%x, mutexId=0x%x, pOptParam=*0x%x)", pName, attr, mutexId, pOptParam); + sceLibKernel.error("sceKernelCreateCond(pName=%s, attr=0x%x, mutexId=0x%x, pOptParam=*0x%x)", pName, attr, mutexId, pOptParam); const auto mutex = idm::get(mutexId); diff --git a/rpcs3/Emu/PSP2/Modules/sceLibc.cpp b/rpcs3/Emu/PSP2/Modules/sceLibc.cpp index 2984cc798c..14ea3596e0 100644 --- a/rpcs3/Emu/PSP2/Modules/sceLibc.cpp +++ b/rpcs3/Emu/PSP2/Modules/sceLibc.cpp @@ -201,25 +201,20 @@ namespace sce_libc_func void printf(ARMv7Thread& cpu, vm::cptr fmt, arm_va_args_t va_args) { - sceLibc.warning("printf(fmt=*0x%x)", fmt); - sceLibc.trace("*** *fmt = '%s'", fmt.get_ptr()); - - const std::string& result = arm_fmt(cpu, fmt, va_args.count); - sceLibc.trace("*** -> '%s'", result); + sceLibc.warning("printf(fmt=%s, ...)", fmt); if (g_tty) { - g_tty.write(result); + g_tty.write(arm_fmt(cpu, fmt, va_args.count)); } } void sprintf(ARMv7Thread& cpu, vm::ptr str, vm::cptr fmt, arm_va_args_t va_args) { - sceLibc.warning("sprintf(str=*0x%x, fmt=*0x%x)", str, fmt); - sceLibc.trace("*** *fmt = '%s'", fmt.get_ptr()); + sceLibc.warning("sprintf(str=*0x%x, fmt=%s, ...)", str, fmt); const std::string& result = arm_fmt(cpu, fmt, va_args.count); - sceLibc.trace("*** -> '%s'", result); + sceLibc.trace("sprintf() -> '%s'", result); ::memcpy(str.get_ptr(), result.c_str(), result.size() + 1); }