Skip to content
Permalink
Browse files
Merge pull request #9258 from lioncash/core-log
Core: Convert logging over to fmt pt. 1
  • Loading branch information
leoetlino committed Nov 19, 2020
2 parents e3247b5 + 958cbf3 commit eff566b
Show file tree
Hide file tree
Showing 37 changed files with 433 additions and 414 deletions.
@@ -245,13 +245,13 @@ std::vector<ARCode> LoadCodes(const IniFile& global_ini, const IniFile& local_in
}
else
{
PanicAlertT("Action Replay Error: invalid AR code line: %s", line.c_str());
PanicAlertFmtT("Action Replay Error: invalid AR code line: {0}", line);

if (!success_addr)
PanicAlertT("The address is invalid");
PanicAlertFmtT("The address is invalid");

if (!success_val)
PanicAlertT("The value is invalid");
PanicAlertFmtT("The value is invalid");
}
}
else
@@ -316,7 +316,7 @@ static void VLogInfo(std::string_view format, fmt::format_args args)
return;

std::string text = fmt::vformat(format, args);
INFO_LOG(ACTIONREPLAY, "%s", text.c_str());
INFO_LOG_FMT(ACTIONREPLAY, "{}", text);

if (use_internal_log)
{
@@ -403,9 +403,9 @@ static bool Subtype_RamWriteAndFill(const ARAddr& addr, const u32 data)

default:
LogInfo("Bad Size");
PanicAlertT("Action Replay Error: Invalid size "
"(%08x : address = %08x) in Ram Write And Fill (%s)",
addr.size, addr.gcaddr, s_current_code->name.c_str());
PanicAlertFmtT("Action Replay Error: Invalid size "
"({0:08x} : address = {1:08x}) in Ram Write And Fill ({2})",
addr.size, addr.gcaddr, s_current_code->name);
return false;
}

@@ -463,9 +463,9 @@ static bool Subtype_WriteToPointer(const ARAddr& addr, const u32 data)

default:
LogInfo("Bad Size");
PanicAlertT("Action Replay Error: Invalid size "
"(%08x : address = %08x) in Write To Pointer (%s)",
addr.size, addr.gcaddr, s_current_code->name.c_str());
PanicAlertFmtT("Action Replay Error: Invalid size "
"({0:08x} : address = {1:08x}) in Write To Pointer ({2})",
addr.size, addr.gcaddr, s_current_code->name);
return false;
}
return true;
@@ -525,9 +525,9 @@ static bool Subtype_AddCode(const ARAddr& addr, const u32 data)

default:
LogInfo("Bad Size");
PanicAlertT("Action Replay Error: Invalid size "
"(%08x : address = %08x) in Add Code (%s)",
addr.size, addr.gcaddr, s_current_code->name.c_str());
PanicAlertFmtT("Action Replay Error: Invalid size "
"({0:08x} : address = {1:08x}) in Add Code ({2})",
addr.size, addr.gcaddr, s_current_code->name);
return false;
}
return true;
@@ -540,9 +540,9 @@ static bool Subtype_MasterCodeAndWriteToCCXXXXXX(const ARAddr& addr, const u32 d
// u8 mcode_type = (data & 0xFF0000) >> 16;
// u8 mcode_count = (data & 0xFF00) >> 8;
// u8 mcode_number = data & 0xFF;
PanicAlertT("Action Replay Error: Master Code and Write To CCXXXXXX not implemented (%s)\n"
"Master codes are not needed. Do not use master codes.",
s_current_code->name.c_str());
PanicAlertFmtT("Action Replay Error: Master Code and Write To CCXXXXXX not implemented ({0})\n"
"Master codes are not needed. Do not use master codes.",
s_current_code->name);
return false;
}

@@ -615,8 +615,9 @@ static bool ZeroCode_FillAndSlide(const u32 val_last, const ARAddr& addr, const

default:
LogInfo("Bad Size");
PanicAlertT("Action Replay Error: Invalid size (%08x : address = %08x) in Fill and Slide (%s)",
size, new_addr, s_current_code->name.c_str());
PanicAlertFmtT(
"Action Replay Error: Invalid size ({0:08x} : address = {1:08x}) in Fill and Slide ({2})",
size, new_addr, s_current_code->name);
return false;
}
return true;
@@ -670,8 +671,8 @@ static bool ZeroCode_MemoryCopy(const u32 val_last, const ARAddr& addr, const u3
else
{
LogInfo("Bad Value");
PanicAlertT("Action Replay Error: Invalid value (%08x) in Memory Copy (%s)", (data & ~0x7FFF),
s_current_code->name.c_str());
PanicAlertFmtT("Action Replay Error: Invalid value ({0:08x}) in Memory Copy ({1})",
(data & ~0x7FFF), s_current_code->name);
return false;
}
return true;
@@ -707,8 +708,8 @@ static bool NormalCode(const ARAddr& addr, const u32 data)

default:
LogInfo("Bad Subtype");
PanicAlertT("Action Replay: Normal Code 0: Invalid Subtype %08x (%s)", addr.subtype,
s_current_code->name.c_str());
PanicAlertFmtT("Action Replay: Normal Code 0: Invalid Subtype {0:08x} ({1})", addr.subtype,
s_current_code->name);
return false;
}

@@ -749,8 +750,8 @@ static bool CompareValues(const u32 val1, const u32 val2, const int type)

default:
LogInfo("Unknown Compare type");
PanicAlertT("Action Replay: Invalid Normal Code Type %08x (%s)", type,
s_current_code->name.c_str());
PanicAlertFmtT("Action Replay: Invalid Normal Code Type {0:08x} ({1})", type,
s_current_code->name);
return false;
}
}
@@ -781,8 +782,8 @@ static bool ConditionalCode(const ARAddr& addr, const u32 data, int* const pSkip

default:
LogInfo("Bad Size");
PanicAlertT("Action Replay: Conditional Code: Invalid Size %08x (%s)", addr.size,
s_current_code->name.c_str());
PanicAlertFmtT("Action Replay: Conditional Code: Invalid Size {0:08x} ({1})", addr.size,
s_current_code->name);
return false;
}

@@ -805,8 +806,8 @@ static bool ConditionalCode(const ARAddr& addr, const u32 data, int* const pSkip

default:
LogInfo("Bad Subtype");
PanicAlertT("Action Replay: Normal Code %i: Invalid subtype %08x (%s)", 1, addr.subtype,
s_current_code->name.c_str());
PanicAlertFmtT("Action Replay: Normal Code {0}: Invalid subtype {1:08x} ({2})", 1,
addr.subtype, s_current_code->name);
return false;
}
}
@@ -889,7 +890,7 @@ static bool RunCodeLocked(const ARCode& arcode)
{
LogInfo(
"This action replay simulator does not support codes that modify Action Replay itself.");
PanicAlertT(
PanicAlertFmtT(
"This action replay simulator does not support codes that modify Action Replay itself.");
return false;
}
@@ -923,7 +924,7 @@ static bool RunCodeLocked(const ARCode& arcode)
// Todo: Set register 1BB4 to 1
LogInfo("ZCode: Executes all codes in the same row, Set register 1BB4 to 1 (zcode not "
"supported)");
PanicAlertT("Zero 3 code not supported");
PanicAlertFmtT("Zero 3 code not supported");
return false;

case ZCODE_04: // Fill & Slide or Memory Copy
@@ -943,7 +944,7 @@ static bool RunCodeLocked(const ARCode& arcode)

default:
LogInfo("ZCode: Unknown");
PanicAlertT("Zero code unknown to Dolphin: %08x", zcode);
PanicAlertFmtT("Zero code unknown to Dolphin: {0:08x}", zcode);
return false;
}

@@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <cstdint>
#include <map>
#include <optional>
#include <string>
@@ -97,17 +98,17 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::VolumeDisc& volume)
const std::optional<u32> entry = volume.ReadSwapped<u32>(offset + 0x10, partition);
const std::optional<u32> size = volume.ReadSwapped<u32>(offset + 0x14, partition);
const std::optional<u32> trailer = volume.ReadSwapped<u32>(offset + 0x18, partition);
if (!entry || !size || !trailer || *entry == (u32)-1 || *size + *trailer == (u32)-1)
if (!entry || !size || !trailer || *entry == UINT32_MAX || *size + *trailer == UINT32_MAX)
{
INFO_LOG(BOOT, "Invalid apploader. Your disc image is probably corrupted.");
INFO_LOG_FMT(BOOT, "Invalid apploader. Your disc image is probably corrupted.");
return false;
}
DVDRead(volume, offset + 0x20, 0x01200000, *size + *trailer, partition);

// TODO - Make Apploader(or just RunFunction()) debuggable!!!

// Call iAppLoaderEntry.
DEBUG_LOG(MASTER_LOG, "Call iAppLoaderEntry");
DEBUG_LOG_FMT(MASTER_LOG, "Call iAppLoaderEntry");
const u32 iAppLoaderFuncAddr = is_wii ? 0x80004000 : 0x80003100;
PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0;
PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4;
@@ -118,15 +119,15 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::VolumeDisc& volume)
const u32 iAppLoaderClose = PowerPC::Read_U32(iAppLoaderFuncAddr + 8);

// iAppLoaderInit
DEBUG_LOG(MASTER_LOG, "Call iAppLoaderInit");
DEBUG_LOG_FMT(MASTER_LOG, "Call iAppLoaderInit");
HLE::Patch(0x81300000, "AppLoaderReport"); // HLE OSReport for Apploader
PowerPC::ppcState.gpr[3] = 0x81300000;
RunFunction(iAppLoaderInit);

// iAppLoaderMain - Here we load the apploader, the DOL (the exe) and the FST (filesystem).
// To give you an idea about where the stuff is located on the disc take a look at yagcd
// ch 13.
DEBUG_LOG(MASTER_LOG, "Call iAppLoaderMain");
DEBUG_LOG_FMT(MASTER_LOG, "Call iAppLoaderMain");

PowerPC::ppcState.gpr[3] = 0x81300004;
PowerPC::ppcState.gpr[4] = 0x81300008;
@@ -140,13 +141,13 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::VolumeDisc& volume)
// iAppLoaderMain returns 0 when there are no more sections to copy.
while (PowerPC::ppcState.gpr[3] != 0x00)
{
u32 iRamAddress = PowerPC::Read_U32(0x81300004);
u32 iLength = PowerPC::Read_U32(0x81300008);
u32 iDVDOffset = PowerPC::Read_U32(0x8130000c) << (is_wii ? 2 : 0);
const u32 ram_address = PowerPC::Read_U32(0x81300004);
const u32 length = PowerPC::Read_U32(0x81300008);
const u32 dvd_offset = PowerPC::Read_U32(0x8130000c) << (is_wii ? 2 : 0);

INFO_LOG(MASTER_LOG, "DVDRead: offset: %08x memOffset: %08x length: %i", iDVDOffset,
iRamAddress, iLength);
DVDRead(volume, iDVDOffset, iRamAddress, iLength, partition);
INFO_LOG_FMT(MASTER_LOG, "DVDRead: offset: {:08x} memOffset: {:08x} length: {}", dvd_offset,
ram_address, length);
DVDRead(volume, dvd_offset, ram_address, length, partition);

PowerPC::ppcState.gpr[3] = 0x81300004;
PowerPC::ppcState.gpr[4] = 0x81300008;
@@ -156,7 +157,7 @@ bool CBoot::RunApploader(bool is_wii, const DiscIO::VolumeDisc& volume)
}

// iAppLoaderClose
DEBUG_LOG(MASTER_LOG, "call iAppLoaderClose");
DEBUG_LOG_FMT(MASTER_LOG, "call iAppLoaderClose");
RunFunction(iAppLoaderClose);
HLE::UnPatch("AppLoaderReport");

@@ -205,7 +206,7 @@ void CBoot::SetupGCMemory()
// execute the apploader, function by function, using the above utility.
bool CBoot::EmulatedBS2_GC(const DiscIO::VolumeDisc& volume)
{
INFO_LOG(BOOT, "Faking GC BS2...");
INFO_LOG_FMT(BOOT, "Faking GC BS2...");

SetupMSR();
SetupBAT(/*is_wii*/ false);
@@ -330,11 +331,11 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
serno = "123456789";
else
serno = Common::SettingsHandler::GenerateSerialNumber();
INFO_LOG(BOOT, "No previous serial number found, generated one instead: %s", serno.c_str());
INFO_LOG_FMT(BOOT, "No previous serial number found, generated one instead: {}", serno);
}
else
{
INFO_LOG(BOOT, "Using serial number: %s", serno.c_str());
INFO_LOG_FMT(BOOT, "Using serial number: {}", serno);
}

gen.AddSetting("AREA", region_setting.area);
@@ -351,14 +352,14 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
settings_file_path, {rw_mode, rw_mode, rw_mode});
if (!settings_file || !settings_file->Write(gen.GetBytes().data(), gen.GetBytes().size()))
{
PanicAlertT("SetupWiiMemory: Can't create setting.txt file");
PanicAlertFmtT("SetupWiiMemory: Can't create setting.txt file");
return false;
}

// Write the 256 byte setting.txt to memory.
Memory::CopyToEmu(0x3800, gen.GetBytes().data(), gen.GetBytes().size());

INFO_LOG(BOOT, "Setup Wii Memory...");
INFO_LOG_FMT(BOOT, "Setup Wii Memory...");

/*
Set hardcoded global variables to Wii memory. These are partly collected from
@@ -438,7 +439,7 @@ static void WriteEmptyPlayRecord()
// execute the apploader
bool CBoot::EmulatedBS2_Wii(const DiscIO::VolumeDisc& volume)
{
INFO_LOG(BOOT, "Faking Wii BS2...");
INFO_LOG_FMT(BOOT, "Faking Wii BS2...");
if (volume.GetVolumeType() != DiscIO::Platform::WiiDisc)
return false;

@@ -2,7 +2,6 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <cinttypes>
#include <memory>

#include "Common/CommonTypes.h"
@@ -29,7 +28,7 @@ bool CBoot::BootNANDTitle(const u64 title_id)
if (ticket.IsValid())
console_type = ticket.GetConsoleType();
else
ERROR_LOG(BOOT, "No ticket was found for %016" PRIx64, title_id);
ERROR_LOG_FMT(BOOT, "No ticket was found for {:016x}", title_id);
SetupWiiMemory(console_type);
return es->LaunchTitle(title_id);
}
@@ -38,7 +37,7 @@ bool CBoot::Boot_WiiWAD(const DiscIO::VolumeWAD& wad)
{
if (!WiiUtils::InstallWAD(*IOS::HLE::GetIOS(), wad, WiiUtils::InstallType::Temporary))
{
PanicAlertT("Cannot boot this WAD because it could not be installed to the NAND.");
PanicAlertFmtT("Cannot boot this WAD because it could not be installed to the NAND.");
return false;
}
return BootNANDTitle(wad.GetTMD().GetTitleId());
@@ -126,23 +126,23 @@ const char* ElfReader::GetSectionName(int section) const
// This is just a simple elf loader, good enough to load elfs generated by devkitPPC
bool ElfReader::LoadIntoMemory(bool only_in_mem1) const
{
INFO_LOG(MASTER_LOG, "String section: %i", header->e_shstrndx);
INFO_LOG_FMT(MASTER_LOG, "String section: {}", header->e_shstrndx);

if (bRelocate)
{
PanicAlert("Error: Dolphin doesn't know how to load a relocatable elf.");
PanicAlertFmt("Error: Dolphin doesn't know how to load a relocatable elf.");
return false;
}

INFO_LOG(MASTER_LOG, "%i segments:", header->e_phnum);
INFO_LOG_FMT(MASTER_LOG, "{} segments:", header->e_phnum);

// Copy segments into ram.
for (int i = 0; i < header->e_phnum; i++)
{
Elf32_Phdr* p = segments + i;

INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr,
p->p_filesz, p->p_memsz);
INFO_LOG_FMT(MASTER_LOG, "Type: {} Vaddr: {:08x} Filesz: {} Memsz: {}", p->p_type, p->p_vaddr,
p->p_filesz, p->p_memsz);

if (p->p_type == PT_LOAD)
{
@@ -158,11 +158,12 @@ bool ElfReader::LoadIntoMemory(bool only_in_mem1) const
if (srcSize < dstSize)
Memory::Memset(writeAddr + srcSize, 0, dstSize - srcSize); // zero out bss

INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", writeAddr, p->p_memsz);
INFO_LOG_FMT(MASTER_LOG, "Loadable Segment Copied to {:08x}, size {:08x}", writeAddr,
p->p_memsz);
}
}

INFO_LOG(MASTER_LOG, "Done loading.");
INFO_LOG_FMT(MASTER_LOG, "Done loading.");
return true;
}

@@ -223,7 +223,7 @@ static GPUDeterminismMode ParseGPUDeterminismMode(const std::string& mode)
if (mode == "fake-completion")
return GPUDeterminismMode::FakeCompletion;

NOTICE_LOG(BOOT, "Unknown GPU determinism mode %s", mode.c_str());
NOTICE_LOG_FMT(BOOT, "Unknown GPU determinism mode {}", mode);
return GPUDeterminismMode::Auto;
}

@@ -75,7 +75,7 @@ void SaveToSYSCONF(Config::LayerType layer)
idle_entry->bytes = std::vector<u8>(2);
else
idle_entry->bytes[0] = 0;
NOTICE_LOG(CORE, "Disabling WC24 'standby' (shutdown to idle) to avoid hanging on shutdown");
NOTICE_LOG_FMT(CORE, "Disabling WC24 'standby' (shutdown to idle) to avoid hanging on shutdown");

IOS::HLE::RestoreBTInfoSection(&sysconf);
sysconf.Save();
@@ -143,8 +143,8 @@ class BaseConfigLayerLoader final : public Config::ConfigLayerLoader
auto ini = inis.find(location.system);
if (ini == inis.end())
{
ERROR_LOG(COMMON, "Config can't map system '%s' to an INI file!",
Config::GetSystemName(location.system).c_str());
ERROR_LOG_FMT(COMMON, "Config can't map system '{}' to an INI file!",
Config::GetSystemName(location.system));
continue;
}

0 comments on commit eff566b

Please sign in to comment.