Skip to content
Permalink
Browse files
Merge pull request #9263 from lioncash/core-log2
Core: Convert logging over to fmt pt.2
  • Loading branch information
leoetlino committed Nov 20, 2020
2 parents 7f5cecf + a0f9b04 commit f45a4a5
Show file tree
Hide file tree
Showing 48 changed files with 505 additions and 489 deletions.
@@ -253,7 +253,7 @@ u32 AnalyzeCommand(const u8* data, DecodeMode mode)
}
else
{
PanicAlert("FifoPlayer: Unknown Opcode (0x%x).\n", cmd);
PanicAlertFmt("FifoPlayer: Unknown Opcode ({:#x}).\n", cmd);
return 0;
}
break;
@@ -215,8 +215,8 @@ std::unique_ptr<FifoDataFile> FifoDataFile::Load(const std::string& filename, bo

if (header.fileId != FILE_ID || header.min_loader_version > VERSION_NUMBER)
{
CriticalAlertT(
"The DFF's minimum loader version (%d) exceeds the version of this FIFO Player (%d)",
CriticalAlertFmtT(
"The DFF's minimum loader version ({0}) exceeds the version of this FIFO Player ({1})",
header.min_loader_version, VERSION_NUMBER);
file.Close();
return nullptr;
@@ -257,13 +257,13 @@ std::unique_ptr<FifoDataFile> FifoDataFile::Load(const std::string& filename, bo
if (header.mem1_size != Memory::GetRamSizeReal() ||
header.mem2_size != Memory::GetExRamSizeReal())
{
CriticalAlertT("Emulated memory size mismatch!\n"
"Current: MEM1 %08X (%3d MiB), MEM2 %08X (%3d MiB)\n"
"DFF: MEM1 %08X (%3d MiB), MEM2 %08X (%3d MiB)",
Memory::GetRamSizeReal(), Memory::GetRamSizeReal() / 0x100000,
Memory::GetExRamSizeReal(), Memory::GetExRamSizeReal() / 0x100000,
header.mem1_size, header.mem1_size / 0x100000, header.mem2_size,
header.mem2_size / 0x100000);
CriticalAlertFmtT("Emulated memory size mismatch!\n"
"Current: MEM1 {0:08X} ({1} MiB), MEM2 {2:08X} ({3} MiB)\n"
"DFF: MEM1 {4:08X} ({5} MiB), MEM2 {6:08X} ({7} MiB)",
Memory::GetRamSizeReal(), Memory::GetRamSizeReal() / 0x100000,
Memory::GetExRamSizeReal(), Memory::GetExRamSizeReal() / 0x100000,
header.mem1_size, header.mem1_size / 0x100000, header.mem2_size,
header.mem2_size / 0x100000);
file.Close();
return nullptr;
}
@@ -99,7 +99,7 @@ class FifoPlayer::CPUCore final : public CPUCoreBase
{
// NOTE: AdvanceFrame() will get stuck forever in Dual Core because the FIFO
// is disabled by CPU::EnableStepping(true) so the frame never gets displayed.
PanicAlertT("Cannot SingleStep the FIFO. Use Frame Advance instead.");
PanicAlertFmtT("Cannot SingleStep the FIFO. Use Frame Advance instead.");
}

const char* GetName() const override { return "FifoPlayer"; }
@@ -82,8 +82,8 @@ void FifoRecorder::WriteGPCommand(const u8* data, u32 size)
// Make sure FifoPlayer's command analyzer agrees about the size of the command.
if (analyzed_size != size)
{
PanicAlert("FifoRecorder: Expected command to be %i bytes long, we were given %i bytes",
analyzed_size, size);
PanicAlertFmt("FifoRecorder: Expected command to be {} bytes long, we were given {} bytes",
analyzed_size, size);
}

// Copy data to buffer
@@ -121,7 +121,7 @@ void PatchFunctions()
s_hooked_addresses[addr] = i;
PowerPC::ppcState.iCache.Invalidate(addr);
}
INFO_LOG(OSHLE, "Patching %s %08x", os_patches[i].name, symbol->address);
INFO_LOG_FMT(OSHLE, "Patching {} {:08x}", os_patches[i].name, symbol->address);
}
}
}
@@ -147,7 +147,7 @@ void Execute(u32 current_pc, u32 hook_index)
}
else
{
PanicAlert("HLE system tried to call an undefined HLE function %i.", hook_index);
PanicAlertFmt("HLE system tried to call an undefined HLE function {}.", hook_index);
}
}

@@ -37,8 +37,8 @@ void HLE_OSPanic()
StringPopBackIf(&error, '\n');
StringPopBackIf(&msg, '\n');

PanicAlert("OSPanic: %s: %s", error.c_str(), msg.c_str());
ERROR_LOG(OSREPORT, "%08x->%08x| OSPanic: %s: %s", LR, PC, error.c_str(), msg.c_str());
PanicAlertFmt("OSPanic: {}: {}", error, msg);
ERROR_LOG_FMT(OSREPORT, "{:08x}->{:08x}| OSPanic: {}: {}", LR, PC, error, msg);

NPC = LR;
}
@@ -82,7 +82,7 @@ void HLE_GeneralDebugPrint(ParameterType parameter_type)

NPC = LR;

NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str());
NOTICE_LOG_FMT(OSREPORT, "{:08x}->{:08x}| {}", LR, PC, SHIFTJISToUTF8(report_message));
}

// Generalized function for printing formatted string using parameter list.
@@ -103,24 +103,24 @@ void HLE_write_console()
std::string report_message = GetStringVA(4);
if (PowerPC::HostIsRAMAddress(GPR(5)))
{
u32 size = PowerPC::Read_U32(GPR(5));
const u32 size = PowerPC::Read_U32(GPR(5));
if (size > report_message.size())
WARN_LOG(OSREPORT, "__write_console uses an invalid size of 0x%08x", size);
WARN_LOG_FMT(OSREPORT, "__write_console uses an invalid size of {:#010x}", size);
else if (size == 0)
WARN_LOG(OSREPORT, "__write_console uses a size of zero");
WARN_LOG_FMT(OSREPORT, "__write_console uses a size of zero");
else
report_message = report_message.substr(0, size);
}
else
{
ERROR_LOG(OSREPORT, "__write_console uses an unreachable size pointer");
ERROR_LOG_FMT(OSREPORT, "__write_console uses an unreachable size pointer");
}

StringPopBackIf(&report_message, '\n');

NPC = LR;

NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str());
NOTICE_LOG_FMT(OSREPORT, "{:08x}->{:08x}| {}", LR, PC, SHIFTJISToUTF8(report_message));
}

// Log (v)dprintf message if fd is 1 (stdout) or 2 (stderr)
@@ -133,7 +133,7 @@ void HLE_LogDPrint(ParameterType parameter_type)

std::string report_message = GetStringVA(4, parameter_type);
StringPopBackIf(&report_message, '\n');
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str());
NOTICE_LOG_FMT(OSREPORT, "{:08x}->{:08x}| {}", LR, PC, SHIFTJISToUTF8(report_message));
}

// Log dprintf message
@@ -173,7 +173,7 @@ void HLE_LogFPrint(ParameterType parameter_type)

std::string report_message = GetStringVA(4, parameter_type);
StringPopBackIf(&report_message, '\n');
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str());
NOTICE_LOG_FMT(OSREPORT, "{:08x}->{:08x}| {}", LR, PC, SHIFTJISToUTF8(report_message));
}

// Log fprintf message
@@ -42,7 +42,7 @@ u32 HLE::SystemVABI::VAListStruct::GetGPR(u32 gpr) const
{
if (gpr < 3 || gpr > 10)
{
ERROR_LOG(OSHLE, "VAListStruct at %08x doesn't have GPR%d!", m_address, gpr);
ERROR_LOG_FMT(OSHLE, "VAListStruct at {:08x} doesn't have GPR{}!", m_address, gpr);
return 0;
}
const u32 gpr_address = Common::AlignUp(GetGPRArea() + 4 * (gpr - 3), 4);
@@ -53,7 +53,7 @@ double HLE::SystemVABI::VAListStruct::GetFPR(u32 fpr) const
{
if (!m_has_fpr_area || fpr < 1 || fpr > 8)
{
ERROR_LOG(OSHLE, "VAListStruct at %08x doesn't have FPR%d!", m_address, fpr);
ERROR_LOG_FMT(OSHLE, "VAListStruct at {:08x} doesn't have FPR{}!", m_address, fpr);
return 0.0;
}
const u32 fpr_address = Common::AlignUp(GetFPRArea() + 8 * (fpr - 1), 8);
@@ -168,21 +168,22 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)

if (s_control.AIINTMSK != tmp_ai_ctrl.AIINTMSK)
{
DEBUG_LOG(AUDIO_INTERFACE, "Change AIINTMSK to %d", tmp_ai_ctrl.AIINTMSK);
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIINTMSK to {}", tmp_ai_ctrl.AIINTMSK);
s_control.AIINTMSK = tmp_ai_ctrl.AIINTMSK;
}

if (s_control.AIINTVLD != tmp_ai_ctrl.AIINTVLD)
{
DEBUG_LOG(AUDIO_INTERFACE, "Change AIINTVLD to %d", tmp_ai_ctrl.AIINTVLD);
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIINTVLD to {}", tmp_ai_ctrl.AIINTVLD);
s_control.AIINTVLD = tmp_ai_ctrl.AIINTVLD;
}

// Set frequency of streaming audio
if (tmp_ai_ctrl.AISFR != s_control.AISFR)
{
// AISFR rates below are intentionally inverted wrt yagcd
DEBUG_LOG(AUDIO_INTERFACE, "Change AISFR to %s", tmp_ai_ctrl.AISFR ? "48khz" : "32khz");
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AISFR to {}",
tmp_ai_ctrl.AISFR ? "48khz" : "32khz");
s_control.AISFR = tmp_ai_ctrl.AISFR;
s_ais_sample_rate = tmp_ai_ctrl.AISFR ? Get48KHzSampleRate() : Get32KHzSampleRate();
g_sound_stream->GetMixer()->SetStreamInputSampleRate(s_ais_sample_rate);
@@ -191,7 +192,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// Set frequency of DMA
if (tmp_ai_ctrl.AIDFR != s_control.AIDFR)
{
DEBUG_LOG(AUDIO_INTERFACE, "Change AIDFR to %s", tmp_ai_ctrl.AIDFR ? "32khz" : "48khz");
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Change AIDFR to {}",
tmp_ai_ctrl.AIDFR ? "32khz" : "48khz");
s_control.AIDFR = tmp_ai_ctrl.AIDFR;
s_aid_sample_rate = tmp_ai_ctrl.AIDFR ? Get32KHzSampleRate() : Get48KHzSampleRate();
g_sound_stream->GetMixer()->SetDMAInputSampleRate(s_aid_sample_rate);
@@ -200,7 +202,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// Streaming counter
if (tmp_ai_ctrl.PSTAT != s_control.PSTAT)
{
DEBUG_LOG(AUDIO_INTERFACE, "%s streaming audio", tmp_ai_ctrl.PSTAT ? "start" : "stop");
DEBUG_LOG_FMT(AUDIO_INTERFACE, "{} streaming audio",
tmp_ai_ctrl.PSTAT ? "start" : "stop");
s_control.PSTAT = tmp_ai_ctrl.PSTAT;
s_last_cpu_time = CoreTiming::GetTicks();

@@ -211,14 +214,14 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// AI Interrupt
if (tmp_ai_ctrl.AIINT)
{
DEBUG_LOG(AUDIO_INTERFACE, "Clear AIS Interrupt");
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Clear AIS Interrupt");
s_control.AIINT = 0;
}

// Sample Count Reset
if (tmp_ai_ctrl.SCRESET)
{
DEBUG_LOG(AUDIO_INTERFACE, "Reset AIS sample counter");
DEBUG_LOG_FMT(AUDIO_INTERFACE, "Reset AIS sample counter");
s_sample_counter = 0;

s_last_cpu_time = CoreTiming::GetTicks();
@@ -247,8 +250,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)

mmio->Register(base | AI_INTERRUPT_TIMING, MMIO::DirectRead<u32>(&s_interrupt_timing),
MMIO::ComplexWrite<u32>([](u32, u32 val) {
DEBUG_LOG(AUDIO_INTERFACE, "AI_INTERRUPT_TIMING=%08x@%08x", val,
PowerPC::ppcState.pc);
DEBUG_LOG_FMT(AUDIO_INTERFACE, "AI_INTERRUPT_TIMING={:08x} at PC: {:08x}", val,
PowerPC::ppcState.pc);
s_interrupt_timing = val;
CoreTiming::RemoveEvent(event_type_ai);
CoreTiming::ScheduleEvent(GetAIPeriod(), event_type_ai);
@@ -329,8 +329,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
s_dspState.pad = tmpControl.pad;
if (s_dspState.pad != 0)
{
PanicAlert(
"DSPInterface (w) DSP state (CC00500A) gets a value with junk in the padding %08x",
PanicAlertFmt(
"DSPInterface (w) DSP state (CC00500A) gets a value with junk in the padding {:08x}",
val);
}

@@ -359,8 +359,8 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
s_audioDMA.current_source_address = s_audioDMA.SourceAddress;
s_audioDMA.remaining_blocks_count = s_audioDMA.AudioDMAControl.NumBlocks;

INFO_LOG(AUDIO_INTERFACE, "Audio DMA configured: %i blocks from 0x%08x",
s_audioDMA.AudioDMAControl.NumBlocks, s_audioDMA.SourceAddress);
INFO_LOG_FMT(AUDIO_INTERFACE, "Audio DMA configured: {} blocks from {:#010x}",
s_audioDMA.AudioDMAControl.NumBlocks, s_audioDMA.SourceAddress);

// We make the samples ready as soon as possible
void* address = Memory::GetPointer(s_audioDMA.SourceAddress);
@@ -484,8 +484,8 @@ static void Do_ARAM_DMA()
if (s_arDMA.Cnt.dir)
{
// ARAM -> MRAM
DEBUG_LOG(DSPINTERFACE, "DMA %08x bytes from ARAM %08x to MRAM %08x PC: %08x",
s_arDMA.Cnt.count, s_arDMA.ARAddr, s_arDMA.MMAddr, PC);
DEBUG_LOG_FMT(DSPINTERFACE, "DMA {:08x} bytes from ARAM {:08x} to MRAM {:08x} PC: {:08x}",
s_arDMA.Cnt.count, s_arDMA.ARAddr, s_arDMA.MMAddr, PC);

// Outgoing data from ARAM is mirrored every 64MB (verified on real HW)
s_arDMA.ARAddr &= 0x3ffffff;
@@ -531,8 +531,8 @@ static void Do_ARAM_DMA()
else
{
// MRAM -> ARAM
DEBUG_LOG(DSPINTERFACE, "DMA %08x bytes from MRAM %08x to ARAM %08x PC: %08x",
s_arDMA.Cnt.count, s_arDMA.MMAddr, s_arDMA.ARAddr, PC);
DEBUG_LOG_FMT(DSPINTERFACE, "DMA {:08x} bytes from MRAM {:08x} to ARAM {:08x} PC: {:08x}",
s_arDMA.Cnt.count, s_arDMA.MMAddr, s_arDMA.ARAddr, PC);

// Incoming data into ARAM is mirrored every 64MB (verified on real HW)
s_arDMA.ARAddr &= 0x3ffffff;
@@ -60,7 +60,7 @@ void DSPHLE::SendMailToDSP(u32 mail)
{
if (m_ucode != nullptr)
{
DEBUG_LOG(DSP_MAIL, "CPU writes 0x%08x", mail);
DEBUG_LOG_FMT(DSP_MAIL, "CPU writes {:#010x}", mail);
m_ucode->HandleMail(mail);
}
}
@@ -166,7 +166,7 @@ void DSPHLE::DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value)
}
else
{
PanicAlert("CPU can't write %08x to DSP mailbox", value);
PanicAlertFmt("CPU can't write {:08x} to DSP mailbox", value);
}
}

@@ -181,7 +181,7 @@ void DSPHLE::DSP_WriteMailBoxLow(bool cpu_mailbox, u16 value)
}
else
{
PanicAlert("CPU can't write %08x to DSP mailbox", value);
PanicAlertFmt("CPU can't write {:08x} to DSP mailbox", value);
}
}

@@ -37,7 +37,7 @@ void CMailHandler::PushMail(u32 mail, bool interrupt, int cycles_into_future)
}
}
m_Mails.emplace(mail, false);
DEBUG_LOG(DSP_MAIL, "DSP writes 0x%08x", mail);
DEBUG_LOG_FMT(DSP_MAIL, "DSP writes {:#010x}", mail);
}

u16 CMailHandler::ReadDSPMailboxHigh()
@@ -121,7 +121,7 @@ void CMailHandler::DoState(PointerWrap& p)
temp.emplace(value, interrupt);
}
if (!m_Mails.empty())
PanicAlert("CMailHandler::DoState - WTF?");
PanicAlertFmt("CMailHandler::DoState - WTF?");

// Restore queue.
for (int i = 0; i < sz; i++)
@@ -26,7 +26,7 @@ namespace DSP::HLE
{
AXUCode::AXUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc), m_cmdlist_size(0)
{
INFO_LOG(DSPHLE, "Instantiating AXUCode: crc=%08x", crc);
INFO_LOG_FMT(DSPHLE, "Instantiating AXUCode: crc={:08x}", crc);
}

AXUCode::~AXUCode()
@@ -64,7 +64,7 @@ void AXUCode::LoadResamplingCoefficients()
if (fidx >= filenames.size())
return;

INFO_LOG(DSPHLE, "Loading polyphase resampling coeffs from %s", filename.c_str());
INFO_LOG_FMT(DSPHLE, "Loading polyphase resampling coeffs from {}", filename);

File::IOFile fp(filename, "rb");
fp.ReadBytes(m_coeffs, 0x1000);
@@ -106,10 +106,10 @@ void AXUCode::HandleCommandList()
u32 pb_addr = 0;

#if 0
INFO_LOG(DSPHLE, "Command list:");
INFO_LOG_FMT(DSPHLE, "Command list:");
for (u32 i = 0; m_cmdlist[i] != CMD_END; ++i)
INFO_LOG(DSPHLE, "%04x", m_cmdlist[i]);
INFO_LOG(DSPHLE, "-------------");
INFO_LOG_FMT(DSPHLE, "{:04x}", m_cmdlist[i]);
INFO_LOG_FMT(DSPHLE, "-------------");
#endif

u32 curr_idx = 0;
@@ -272,7 +272,7 @@ void AXUCode::HandleCommandList()
}

default:
ERROR_LOG(DSPHLE, "Unknown command in AX command list: %04x", cmd);
ERROR_LOG_FMT(DSPHLE, "Unknown command in AX command list: {:04x}", cmd);
end = true;
break;
}
@@ -661,7 +661,7 @@ void AXUCode::HandleMail(u32 mail)
}
else
{
ERROR_LOG(DSPHLE, "Unknown mail sent to AX::HandleMail: %08x", mail);
ERROR_LOG_FMT(DSPHLE, "Unknown mail sent to AX::HandleMail: {:08x}", mail);
}

next_is_cmdlist = set_next_is_cmdlist;
@@ -671,7 +671,7 @@ void AXUCode::CopyCmdList(u32 addr, u16 size)
{
if (size >= std::size(m_cmdlist))
{
ERROR_LOG(DSPHLE, "Command list at %08x is too large: size=%d", addr, size);
ERROR_LOG_FMT(DSPHLE, "Command list at {:08x} is too large: size={}", addr, size);
return;
}

@@ -26,7 +26,7 @@ AXWiiUCode::AXWiiUCode(DSPHLE* dsphle, u32 crc) : AXUCode(dsphle, crc), m_last_m
for (u16& volume : m_last_aux_volumes)
volume = 0x8000;

INFO_LOG(DSPHLE, "Instantiating AXWiiUCode");
INFO_LOG_FMT(DSPHLE, "Instantiating AXWiiUCode");

m_old_axwii = (crc == 0xfa450138);
}

0 comments on commit f45a4a5

Please sign in to comment.