From 327bb2d8f046b0e1d6a9473b07458889a0ee1804 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 1 Feb 2020 11:31:27 +0300 Subject: [PATCH] Modernize PPU logging (ppu_log variable) --- Utilities/Log.h | 1 - Utilities/Thread.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellSysCache.cpp | 2 +- rpcs3/Emu/Cell/PPUAnalyser.cpp | 42 ++++++++++++------------- rpcs3/Emu/Cell/PPUFunction.cpp | 2 +- rpcs3/Emu/Cell/PPUInterpreter.cpp | 12 +++---- rpcs3/Emu/Cell/PPUThread.cpp | 40 +++++++++++------------ rpcs3/Emu/Cell/PPUThread.h | 2 ++ rpcs3/Emu/Cell/PPUTranslator.cpp | 14 ++++----- rpcs3/Emu/Cell/lv2/lv2.cpp | 18 +++++------ rpcs3/Emu/System.cpp | 4 +-- 11 files changed, 70 insertions(+), 69 deletions(-) diff --git a/Utilities/Log.h b/Utilities/Log.h index 611388b7e9..4c68112560 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -122,7 +122,6 @@ namespace logs namespace logs { /* Small set of predefined channels */ - LOG_CHANNEL(PPU); LOG_CHANNEL(SPU); } diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 90a4ef1da8..e0b006ff9c 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1447,7 +1447,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) { if (auto last_func = static_cast(cpu)->current_function) { - LOG_FATAL(PPU, "Function aborted: %s", last_func); + ppu_log.fatal("Function aborted: %s", last_func); } lv2_obj::sleep(*cpu); diff --git a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp index f5036c71f1..ab637d7d71 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp @@ -48,7 +48,7 @@ struct syscache_info cache_id.resize(cache_id.size() - 1); cache_id = cache_id.substr(cache_id.find_last_of('/') + 1); - LOG_SUCCESS(PPU, "Retained cache from parent process: %s", Emu.hdd1); + cellSysutil.success("Retained cache from parent process: %s", Emu.hdd1); return; } diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index 72d49d619e..f12245e67a 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -585,7 +585,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) func.addr = addr; func.toc = toc; func.name = fmt::format("__0x%x", func.addr); - LOG_TRACE(PPU, "Function 0x%x added (toc=0x%x)", addr, toc); + ppu_log.trace("Function 0x%x added (toc=0x%x)", addr, toc); return func; }; @@ -605,7 +605,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) if (ptr[0] >= start && ptr[0] < end && ptr[0] % 4 == 0 && ptr[1] == toc) { // New function - LOG_TRACE(PPU, "OPD*: [0x%x] 0x%x (TOC=0x%x)", ptr, ptr[0], ptr[1]); + ppu_log.trace("OPD*: [0x%x] 0x%x (TOC=0x%x)", ptr, ptr[0], ptr[1]); add_func(*ptr, addr_heap.count(ptr.addr()) ? toc : 0, 0); ptr++; } @@ -684,7 +684,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) } } - if (sec_end) LOG_NOTICE(PPU, "Reading OPD section at 0x%x...", sec.addr); + if (sec_end) ppu_log.notice("Reading OPD section at 0x%x...", sec.addr); // Mine for (vm::cptr ptr = vm::cast(sec.addr); ptr < sec_end; ptr += 2) @@ -695,7 +695,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) // Add function and TOC const u32 addr = ptr[0]; const u32 toc = ptr[1]; - LOG_TRACE(PPU, "OPD: [0x%x] 0x%x (TOC=0x%x)", ptr, addr, toc); + ppu_log.trace("OPD: [0x%x] 0x%x (TOC=0x%x)", ptr, addr, toc); TOCs.emplace(toc); auto& func = add_func(addr, addr_heap.count(ptr.addr()) ? toc : 0, 0); @@ -767,7 +767,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) ptr = vm::cast(ptr.addr() + size); } - if (sec_end && sec.size > 4) LOG_NOTICE(PPU, "Reading .eh_frame section at 0x%x...", sec.addr); + if (sec_end && sec.size > 4) ppu_log.notice("Reading .eh_frame section at 0x%x...", sec.addr); // Mine for (vm::cptr ptr = vm::cast(sec.addr); ptr < sec_end; ptr = vm::cast(ptr.addr() + ptr[0] + 4)) @@ -781,7 +781,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) if (ptr[1] == 0) { // CIE - LOG_TRACE(PPU, ".eh_frame: [0x%x] CIE 0x%x", ptr, ptr[0]); + ppu_log.trace(".eh_frame: [0x%x] CIE 0x%x", ptr, ptr[0]); } else { @@ -808,7 +808,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) } else { - LOG_ERROR(PPU, ".eh_frame: [0x%x] 0x%x, 0x%x, 0x%x, 0x%x, 0x%x", ptr, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4]); + ppu_log.error(".eh_frame: [0x%x] 0x%x, 0x%x, 0x%x, 0x%x, 0x%x", ptr, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4]); continue; } @@ -818,12 +818,12 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) addr += ptr.addr() + 8; } - LOG_TRACE(PPU, ".eh_frame: [0x%x] FDE 0x%x (cie=*0x%x, addr=0x%x, size=0x%x)", ptr, ptr[0], cie, addr, size); + ppu_log.trace(".eh_frame: [0x%x] FDE 0x%x (cie=*0x%x, addr=0x%x, size=0x%x)", ptr, ptr[0], cie, addr, size); // TODO: invalid offsets, zero offsets (removed functions?) if (addr % 4 || size % 4 || size > (end - start) || addr < start || addr + size > end) { - if (addr) LOG_ERROR(PPU, ".eh_frame: Invalid function 0x%x", addr); + if (addr) ppu_log.error(".eh_frame: Invalid function 0x%x", addr); continue; } @@ -1127,7 +1127,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) if (const u32 len = ppu_test(ptr, fend, ppu_patterns::abort)) { // Function "abort" - LOG_NOTICE(PPU, "Function [0x%x]: 'abort'", func.addr); + ppu_log.notice("Function [0x%x]: 'abort'", func.addr); func.attr += ppu_attr::no_return; func.attr += ppu_attr::known_size; func.size = len; @@ -1209,7 +1209,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) if (target < start || target >= end) { - LOG_WARNING(PPU, "[0x%x] Invalid branch at 0x%x -> 0x%x", func.addr, iaddr, target); + ppu_log.warning("[0x%x] Invalid branch at 0x%x -> 0x%x", func.addr, iaddr, target); continue; } @@ -1292,7 +1292,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) // Acknowledge jumptable detection failure if (!(func.attr & ppu_attr::no_size)) { - LOG_WARNING(PPU, "[0x%x] Jump table not found! 0x%x-0x%x", func.addr, jt_addr, jt_end); + ppu_log.warning("[0x%x] Jump table not found! 0x%x-0x%x", func.addr, jt_addr, jt_end); } func.attr += ppu_attr::no_size; @@ -1301,7 +1301,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) } else { - LOG_TRACE(PPU, "[0x%x] Jump table found: 0x%x-0x%x", func.addr, jt_addr, _ptr); + ppu_log.trace("[0x%x] Jump table found: 0x%x-0x%x", func.addr, jt_addr, _ptr); } } @@ -1327,7 +1327,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) else if (type == ppu_itype::STDU && func.attr & ppu_attr::no_size && (op.opcode == *_ptr || *_ptr == ppu_instructions::BLR())) { // Hack - LOG_SUCCESS(PPU, "[0x%x] Instruction repetition: 0x%08x", iaddr, op.opcode); + ppu_log.success("[0x%x] Instruction repetition: 0x%08x", iaddr, op.opcode); add_block(_ptr.addr()); block.second = _ptr.addr() - block.first; break; @@ -1433,7 +1433,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) // Just ensure that functions don't overlap if (func.addr + func.size > next) { - LOG_WARNING(PPU, "Function overlap: [0x%x] 0x%x -> 0x%x", func.addr, func.size, next - func.addr); + ppu_log.warning("Function overlap: [0x%x] 0x%x -> 0x%x", func.addr, func.size, next - func.addr); continue; //func.size = next - func.addr; // Also invalidate blocks @@ -1503,7 +1503,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) if (_ptr.addr() >= next) { - LOG_WARNING(PPU, "Function gap: [0x%x] 0x%x bytes at 0x%x", func.addr, next - start, start); + ppu_log.warning("Function gap: [0x%x] 0x%x bytes at 0x%x", func.addr, next - start, start); break; } } @@ -1527,17 +1527,17 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) for (auto&& pair : fmap) { auto& func = pair.second; - LOG_TRACE(PPU, "Function %s (size=0x%x, toc=0x%x, attr %#x)", func.name, func.size, func.toc, func.attr); + ppu_log.trace("Function %s (size=0x%x, toc=0x%x, attr %#x)", func.name, func.size, func.toc, func.attr); funcs.emplace_back(std::move(func)); } - LOG_NOTICE(PPU, "Function analysis: %zu functions (%zu enqueued)", funcs.size(), func_queue.size()); + ppu_log.notice("Function analysis: %zu functions (%zu enqueued)", funcs.size(), func_queue.size()); } void ppu_acontext::UNK(ppu_opcode_t op) { std::fill_n(gpr, 32, spec_gpr{}); - LOG_ERROR(PPU, "Unknown/Illegal opcode: 0x%08x at 0x%x" HERE, op.opcode, cia); + ppu_log.error("Unknown/Illegal opcode: 0x%08x at 0x%x" HERE, op.opcode, cia); } void ppu_acontext::MFVSCR(ppu_opcode_t op) @@ -3467,7 +3467,7 @@ const bool s_tes = []() { auto exp = ppu_acontext::spec_gpr::approx(r1.ones() & r2.ones(), r1.mask() & r2.mask()); - LOG_ERROR(PPU, "ppu_acontext failure:" + ppu_log.error("ppu_acontext failure:" "\n\tr1 = 0x%016x..0x%016x, 0x%016x:0x%016x" "\n\tr2 = 0x%016x..0x%016x, 0x%016x:0x%016x" "\n\tr3 = 0x%016x..0x%016x, 0x%016x:0x%016x" @@ -3483,7 +3483,7 @@ const bool s_tes = []() ppu_acontext::spec_gpr r1; r1 = ppu_acontext::spec_gpr::range(0x13311, 0x1fe22); r1 = r1 ^ ppu_acontext::spec_gpr::approx(0x000, 0xf00); - LOG_SUCCESS(PPU, "0x%x..0x%x", r1.imin, r1.imax); + ppu_log.success("0x%x..0x%x", r1.imin, r1.imax); return true; }(); diff --git a/rpcs3/Emu/Cell/PPUFunction.cpp b/rpcs3/Emu/Cell/PPUFunction.cpp index e4c466d55c..c30534a888 100644 --- a/rpcs3/Emu/Cell/PPUFunction.cpp +++ b/rpcs3/Emu/Cell/PPUFunction.cpp @@ -2525,7 +2525,7 @@ std::vector& ppu_function_manager::access() { [](ppu_thread& ppu) -> bool { - LOG_ERROR(PPU, "Unregistered function called (LR=0x%x)", ppu.lr); + ppu_log.error("Unregistered function called (LR=0x%x)", ppu.lr); ppu.gpr[3] = 0; ppu.cia = static_cast(ppu.lr) & ~3; return false; diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index 3efb65b078..421616cbd8 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -4750,7 +4750,7 @@ bool ppu_interpreter_precise::FNMADDS(ppu_thread& ppu, ppu_opcode_t op) bool ppu_interpreter::MTFSB1(ppu_thread& ppu, ppu_opcode_t op) { const u32 bit = op.crbd; - if (bit < 16 || bit > 19) LOG_WARNING(PPU, "MTFSB1(%d)", bit); + if (bit < 16 || bit > 19) ppu_log.warning("MTFSB1(%d)", bit); ppu.fpscr.bits[bit] = 1; if (UNLIKELY(op.rc)) ppu_cr_set(ppu, 1, ppu.fpscr.fg, ppu.fpscr.fl, ppu.fpscr.fe, ppu.fpscr.fu); return true; @@ -4758,7 +4758,7 @@ bool ppu_interpreter::MTFSB1(ppu_thread& ppu, ppu_opcode_t op) bool ppu_interpreter::MCRFS(ppu_thread& ppu, ppu_opcode_t op) { - if (op.crfs != 4) LOG_WARNING(PPU, "MCRFS(%d)", op.crfs); + if (op.crfs != 4) ppu_log.warning("MCRFS(%d)", op.crfs); ppu.cr.fields[op.crfd] = ppu.fpscr.fields[op.crfs]; return true; } @@ -4766,7 +4766,7 @@ bool ppu_interpreter::MCRFS(ppu_thread& ppu, ppu_opcode_t op) bool ppu_interpreter::MTFSB0(ppu_thread& ppu, ppu_opcode_t op) { const u32 bit = op.crbd; - if (bit < 16 || bit > 19) LOG_WARNING(PPU, "MTFSB0(%d)", bit); + if (bit < 16 || bit > 19) ppu_log.warning("MTFSB0(%d)", bit); ppu.fpscr.bits[bit] = 0; if (UNLIKELY(op.rc)) ppu_cr_set(ppu, 1, ppu.fpscr.fg, ppu.fpscr.fl, ppu.fpscr.fe, ppu.fpscr.fu); return true; @@ -4779,7 +4779,7 @@ bool ppu_interpreter::MTFSFI(ppu_thread& ppu, ppu_opcode_t op) if (bf != 4) { // Do nothing on non-FPCC field (TODO) - LOG_WARNING(PPU, "MTFSFI(%d)", op.crfd); + ppu_log.warning("MTFSFI(%d)", op.crfd); } else { @@ -4809,7 +4809,7 @@ bool ppu_interpreter::MTFSFI(ppu_thread& ppu, ppu_opcode_t op) bool ppu_interpreter::MFFS(ppu_thread& ppu, ppu_opcode_t op) { - LOG_WARNING(PPU, "MFFS"); + ppu_log.warning("MFFS"); ppu.fpr[op.frd] = std::bit_cast(u64{ppu.fpscr.fl} << 15 | u64{ppu.fpscr.fg} << 14 | u64{ppu.fpscr.fe} << 13 | u64{ppu.fpscr.fu} << 12); if (UNLIKELY(op.rc)) ppu_cr_set(ppu, 1, ppu.fpscr.fg, ppu.fpscr.fl, ppu.fpscr.fe, ppu.fpscr.fu); return true; @@ -4817,7 +4817,7 @@ bool ppu_interpreter::MFFS(ppu_thread& ppu, ppu_opcode_t op) bool ppu_interpreter::MTFSF(ppu_thread& ppu, ppu_opcode_t op) { - LOG_WARNING(PPU, "MTFSF"); + ppu_log.warning("MTFSF"); if (UNLIKELY(op.rc)) ppu_cr_set(ppu, 1, ppu.fpscr.fg, ppu.fpscr.fl, ppu.fpscr.fe, ppu.fpscr.fu); return true; } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 191f0f0510..8e4c864c54 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -191,7 +191,7 @@ static bool ppu_fallback(ppu_thread& ppu, ppu_opcode_t op) { if (g_cfg.core.ppu_debug) { - LOG_ERROR(PPU, "Unregistered instruction: 0x%08x", op.opcode); + ppu_log.error("Unregistered instruction: 0x%08x", op.opcode); } ppu_ref(ppu.cia) = ppu_cache(ppu.cia); @@ -204,7 +204,7 @@ void ppu_recompiler_fallback(ppu_thread& ppu) { if (g_cfg.core.ppu_debug) { - LOG_ERROR(PPU, "Unregistered PPU Function (LR=0x%llx)", ppu.lr); + ppu_log.error("Unregistered PPU Function (LR=0x%llx)", ppu.lr); } const auto& table = g_ppu_interpreter_fast.get_table(); @@ -243,7 +243,7 @@ static bool ppu_check_toc(ppu_thread& ppu, ppu_opcode_t op) if (ppu.gpr[2] != found->second) { - LOG_ERROR(PPU, "Unexpected TOC (0x%x, expected 0x%x)", ppu.gpr[2], found->second); + ppu_log.error("Unexpected TOC (0x%x, expected 0x%x)", ppu.gpr[2], found->second); if (!ppu.state.test_and_set(cpu_flag::dbg_pause) && ppu.check_state()) { @@ -264,7 +264,7 @@ extern void ppu_register_range(u32 addr, u32 size) { if (!size) { - LOG_ERROR(PPU, "ppu_register_range(0x%x): empty range", addr); + ppu_log.error("ppu_register_range(0x%x): empty range", addr); return; } @@ -297,7 +297,7 @@ extern void ppu_register_function_at(u32 addr, u32 size, ppu_function_t ptr) { if (g_cfg.core.ppu_debug) { - LOG_ERROR(PPU, "ppu_register_function_at(0x%x): empty range", addr); + ppu_log.error("ppu_register_function_at(0x%x): empty range", addr); } return; @@ -404,13 +404,13 @@ extern bool ppu_patch(u32 addr, u32 value) if (g_cfg.core.ppu_decoder == ppu_decoder_type::llvm && Emu.GetStatus() != system_state::ready) { // TODO: support recompilers - LOG_FATAL(PPU, "Patch failed at 0x%x: LLVM recompiler is used.", addr); + ppu_log.fatal("Patch failed at 0x%x: LLVM recompiler is used.", addr); return false; } if (!vm::try_access(addr, &value, sizeof(value), true)) { - LOG_FATAL(PPU, "Patch failed at 0x%x: invalid memory address.", addr); + ppu_log.fatal("Patch failed at 0x%x: invalid memory address.", addr); return false; } @@ -842,11 +842,11 @@ void ppu_thread::fast_call(u32 addr, u32 rtoc) { if (start_time) { - LOG_WARNING(PPU, "'%s' aborted (%fs)", current_function, (get_guest_system_time() - start_time) / 1000000.); + ppu_log.warning("'%s' aborted (%fs)", current_function, (get_guest_system_time() - start_time) / 1000000.); } else { - LOG_WARNING(PPU, "'%s' aborted", current_function); + ppu_log.warning("'%s' aborted", current_function); } } @@ -910,7 +910,7 @@ void ppu_thread::stack_pop_verbose(u32 addr, u32 size) noexcept if (context.gpr[1] != addr) { - LOG_ERROR(PPU, "Stack inconsistency (addr=0x%x, SP=0x%llx, size=0x%x)", addr, context.gpr[1], size); + ppu_log.error("Stack inconsistency (addr=0x%x, SP=0x%llx, size=0x%x)", addr, context.gpr[1], size); return; } @@ -918,7 +918,7 @@ void ppu_thread::stack_pop_verbose(u32 addr, u32 size) noexcept return; } - LOG_ERROR(PPU, "Invalid thread" HERE); + ppu_log.error("Invalid thread" HERE); } extern u64 get_timebased_time(); @@ -963,7 +963,7 @@ static void ppu_check(ppu_thread& ppu, u64 addr) static void ppu_trace(u64 addr) { - LOG_NOTICE(PPU, "Trace: 0x%llx", addr); + ppu_log.notice("Trace: 0x%llx", addr); } template @@ -987,7 +987,7 @@ static T ppu_load_acquire_reservation(ppu_thread& ppu, u32 addr) { if (UNLIKELY(count >= 10)) { - LOG_ERROR(PPU, "%s took too long: %u", sizeof(T) == 4 ? "LWARX" : "LDARX", count); + ppu_log.error("%s took too long: %u", sizeof(T) == 4 ? "LWARX" : "LDARX", count); } return static_cast(ppu.rdata << data_off >> size_off); @@ -1618,14 +1618,14 @@ extern void ppu_initialize(const ppu_module& info) { if (!jit) { - LOG_SUCCESS(PPU, "LLVM: Already exists: %s", obj_name); + ppu_log.success("LLVM: Already exists: %s", obj_name); continue; } std::lock_guard lock(jmutex); jit->add(cache_path + obj_name); - LOG_SUCCESS(PPU, "LLVM: Loaded module %s", obj_name); + ppu_log.success("LLVM: Loaded module %s", obj_name); continue; } @@ -1644,7 +1644,7 @@ extern void ppu_initialize(const ppu_module& info) if (!Emu.IsStopped()) { - LOG_WARNING(PPU, "LLVM: Compiling module %s%s", cache_path, obj_name); + ppu_log.warning("LLVM: Compiling module %s%s", cache_path, obj_name); // Use another JIT instance jit_compiler jit2({}, g_cfg.core.llvm_cpu, 0x1); @@ -1663,7 +1663,7 @@ extern void ppu_initialize(const ppu_module& info) std::lock_guard lock(jmutex); jit->add(cache_path + obj_name); - LOG_SUCCESS(PPU, "LLVM: Compiled module %s", obj_name); + ppu_log.success("LLVM: Compiled module %s", obj_name); }); } @@ -1807,7 +1807,7 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co { if (Emu.IsStopped()) { - LOG_SUCCESS(PPU, "LLVM: Translation cancelled"); + ppu_log.success("LLVM: Translation cancelled"); return; } @@ -1848,12 +1848,12 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co if (verifyModule(*module, &out)) { out.flush(); - LOG_ERROR(PPU, "LLVM: Verification failed for %s:\n%s", obj_name, result); + ppu_log.error("LLVM: Verification failed for %s:\n%s", obj_name, result); Emu.CallAfter([]{ Emu.Stop(); }); return; } - LOG_NOTICE(PPU, "LLVM: %zu functions generated", module->getFunctionList().size()); + ppu_log.notice("LLVM: %zu functions generated", module->getFunctionList().size()); } // Load or compile module diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index f1b926109d..6f1d55cf3d 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -4,6 +4,8 @@ #include "../Memory/vm_ptr.h" #include "Utilities/lockless.h" +LOG_CHANNEL(ppu_log, "PPU"); + enum class ppu_cmd : u32 { null, diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 11f0743c6e..29c3cb2d65 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -90,7 +90,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_mod // case 26: // case 28: { - LOG_NOTICE(PPU, "Ignoring relative relocation at 0x%x (%u)", rel.addr, rel.type); + ppu_log.notice("Ignoring relative relocation at 0x%x (%u)", rel.addr, rel.type); continue; } @@ -107,7 +107,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_mod case 73: case 78: { - LOG_ERROR(PPU, "Ignoring 64-bit relocation at 0x%x (%u)", rel.addr, rel.type); + ppu_log.error("Ignoring 64-bit relocation at 0x%x (%u)", rel.addr, rel.type); continue; } } @@ -115,7 +115,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_mod // Align relocation address (TODO) if (!m_relocs.emplace(rel.addr & ~3, &rel).second) { - LOG_ERROR(PPU, "Relocation repeated at 0x%x (%u)", rel.addr, rel.type); + ppu_log.error("Relocation repeated at 0x%x (%u)", rel.addr, rel.type); } } } @@ -200,7 +200,7 @@ Function* PPUTranslator::Translate(const ppu_function& info) if (m_rel) { // This is very bad. m_rel is normally set to nullptr after a relocation is handled (so it wasn't) - LOG_ERROR(PPU, "LLVM: [0x%x] Unsupported relocation(%u) in '%s'. Please report.", rel_found->first, m_rel->type, m_info.name); + ppu_log.error("LLVM: [0x%x] Unsupported relocation(%u) in '%s'. Please report.", rel_found->first, m_rel->type, m_info.name); return nullptr; } } @@ -563,7 +563,7 @@ void PPUTranslator::WriteMemory(Value* addr, Value* value, bool is_be, u32 align void PPUTranslator::CompilationError(const std::string& error) { - LOG_ERROR(PPU, "LLVM: [0x%08x] Error: %s", m_addr + (m_reloc ? m_reloc->addr : 0), error); + ppu_log.error("LLVM: [0x%08x] Error: %s", m_addr + (m_reloc ? m_reloc->addr : 0), error); } @@ -3943,7 +3943,7 @@ void PPUTranslator::MTFSFI(ppu_opcode_t op) void PPUTranslator::MFFS(ppu_opcode_t op) { - LOG_WARNING(PPU, "LLVM: [0x%08x] Warning: MFFS", m_addr + (m_reloc ? m_reloc->addr : 0)); + ppu_log.warning("LLVM: [0x%08x] Warning: MFFS", m_addr + (m_reloc ? m_reloc->addr : 0)); Value* result = m_ir->getInt64(0); @@ -3959,7 +3959,7 @@ void PPUTranslator::MFFS(ppu_opcode_t op) void PPUTranslator::MTFSF(ppu_opcode_t op) { - LOG_WARNING(PPU, "LLVM: [0x%08x] Warning: MTFSF", m_addr + (m_reloc ? m_reloc->addr : 0)); + ppu_log.warning("LLVM: [0x%08x] Warning: MTFSF", m_addr + (m_reloc ? m_reloc->addr : 0)); const auto value = GetFpr(op.frb, 32, true); diff --git a/rpcs3/Emu/Cell/lv2/lv2.cpp b/rpcs3/Emu/Cell/lv2/lv2.cpp index 06ebc98fd9..0d8cf6d059 100644 --- a/rpcs3/Emu/Cell/lv2/lv2.cpp +++ b/rpcs3/Emu/Cell/lv2/lv2.cpp @@ -47,7 +47,7 @@ void fmt_class_string::format(std::string& out, u64 arg) static bool null_func(ppu_thread& ppu) { - LOG_TODO(PPU, "Unimplemented syscall %s -> CELL_OK", ppu_syscall_code(ppu.gpr[11])); + ppu_log.todo("Unimplemented syscall %s -> CELL_OK", ppu_syscall_code(ppu.gpr[11])); ppu.gpr[3] = 0; ppu.cia += 4; return false; @@ -55,7 +55,7 @@ static bool null_func(ppu_thread& ppu) static bool uns_func(ppu_thread& ppu) { - LOG_TRACE(PPU, "Unused syscall %d -> ENOSYS", ppu.gpr[11]); + ppu_log.trace("Unused syscall %d -> ENOSYS", ppu.gpr[11]); ppu.gpr[3] = CELL_ENOSYS; ppu.cia += 4; return false; @@ -981,7 +981,7 @@ extern void ppu_execute_syscall(ppu_thread& ppu, u64 code) if (auto func = g_ppu_syscall_table[code]) { func(ppu); - LOG_TRACE(PPU, "Syscall '%s' (%llu) finished, r3=0x%llx", ppu_syscall_code(code), code, ppu.gpr[3]); + ppu_log.trace("Syscall '%s' (%llu) finished, r3=0x%llx", ppu_syscall_code(code), code, ppu.gpr[3]); return; } } @@ -1014,7 +1014,7 @@ void lv2_obj::sleep_unlocked(cpu_thread& thread, u64 timeout) if (auto ppu = static_cast(thread.id_type() == 1 ? &thread : nullptr)) { - LOG_TRACE(PPU, "sleep() - waiting (%zu)", g_pending.size()); + ppu_log.trace("sleep() - waiting (%zu)", g_pending.size()); const auto [_, ok] = ppu->state.fetch_op([&](bs_t& val) { @@ -1029,7 +1029,7 @@ void lv2_obj::sleep_unlocked(cpu_thread& thread, u64 timeout) if (!ok) { - LOG_FATAL(PPU, "sleep() failed (signaled) (%s)", ppu->current_function); + ppu_log.fatal("sleep() failed (signaled) (%s)", ppu->current_function); return; } @@ -1118,7 +1118,7 @@ void lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio) { if (it != end && *it == cpu) { - LOG_TRACE(PPU, "sleep() - suspended (p=%zu)", g_pending.size()); + ppu_log.trace("sleep() - suspended (p=%zu)", g_pending.size()); return; } @@ -1140,7 +1140,7 @@ void lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio) } } - LOG_TRACE(PPU, "awake(): %s", cpu->id); + ppu_log.trace("awake(): %s", cpu->id); }; if (cpu) @@ -1167,7 +1167,7 @@ void lv2_obj::awake_unlocked(cpu_thread* cpu, s32 prio) if (!target->state.test_and_set(cpu_flag::suspend)) { - LOG_TRACE(PPU, "suspend(): %s", target->id); + ppu_log.trace("suspend(): %s", target->id); g_pending.emplace_back(target); } } @@ -1193,7 +1193,7 @@ void lv2_obj::schedule_all() if (target->state & cpu_flag::suspend) { - LOG_TRACE(PPU, "schedule(): %s", target->id); + ppu_log.trace("schedule(): %s", target->id); target->state ^= (cpu_flag::signal + cpu_flag::suspend); target->start_time = 0; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index cf6394e92a..8a4f5d5475 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -595,7 +595,7 @@ std::string Emulator::PPUCache() const if (!_main || _main->cache.empty()) { - LOG_WARNING(PPU, "PPU Cache location not initialized."); + ppu_log.warning("PPU Cache location not initialized."); return {}; } @@ -1754,7 +1754,7 @@ void Emulator::Resume() } } - LOG_NOTICE(PPU, "[RESUME] Dumping instruction stats:%s", dump); + ppu_log.notice("[RESUME] Dumping instruction stats:%s", dump); } // Try to resume