citra-emu
/
citra
Archived
1
0
Fork 0

service/err_f: Migrate logging macros (#3849)

* service/err_f: Migrate logging macros

* service/err_f: Added static_cast<u32>
This commit is contained in:
NarcolepticK 2018-06-21 05:14:59 -04:00 committed by Weiyi Wang
parent 964602dfcb
commit 831e3a0b54
1 changed files with 42 additions and 43 deletions

View File

@ -132,30 +132,30 @@ static std::string GetCurrentSystemTime() {
} }
static void LogGenericInfo(const ErrInfo::ErrInfoCommon& errinfo_common) { static void LogGenericInfo(const ErrInfo::ErrInfoCommon& errinfo_common) {
LOG_CRITICAL(Service_ERR, "PID: 0x%08X", errinfo_common.pid); NGLOG_CRITICAL(Service_ERR, "PID: 0x{:08X}", errinfo_common.pid);
LOG_CRITICAL(Service_ERR, "REV: 0x%08X_0x%08X", errinfo_common.rev_high, NGLOG_CRITICAL(Service_ERR, "REV: 0x{:08X}_0x{:08X}", errinfo_common.rev_high,
errinfo_common.rev_low); errinfo_common.rev_low);
LOG_CRITICAL(Service_ERR, "TID: 0x%08X_0x%08X", errinfo_common.title_id_high, NGLOG_CRITICAL(Service_ERR, "TID: 0x{:08X}_0x{:08X}", errinfo_common.title_id_high,
errinfo_common.title_id_low); errinfo_common.title_id_low);
LOG_CRITICAL(Service_ERR, "AID: 0x%08X_0x%08X", errinfo_common.app_title_id_high, NGLOG_CRITICAL(Service_ERR, "AID: 0x{:08X}_0x{:08X}", errinfo_common.app_title_id_high,
errinfo_common.app_title_id_low); errinfo_common.app_title_id_low);
LOG_CRITICAL(Service_ERR, "ADR: 0x%08X", errinfo_common.pc_address); NGLOG_CRITICAL(Service_ERR, "ADR: 0x{:08X}", errinfo_common.pc_address);
ResultCode result_code{errinfo_common.result_code}; ResultCode result_code{errinfo_common.result_code};
LOG_CRITICAL(Service_ERR, "RSL: 0x%08X", result_code.raw); NGLOG_CRITICAL(Service_ERR, "RSL: 0x{:08X}", result_code.raw);
LOG_CRITICAL(Service_ERR, " Level: %u", result_code.level.Value()); NGLOG_CRITICAL(Service_ERR, " Level: {}", static_cast<u32>(result_code.level.Value()));
LOG_CRITICAL(Service_ERR, " Summary: %u", result_code.summary.Value()); NGLOG_CRITICAL(Service_ERR, " Summary: {}", static_cast<u32>(result_code.summary.Value()));
LOG_CRITICAL(Service_ERR, " Module: %u", result_code.module.Value()); NGLOG_CRITICAL(Service_ERR, " Module: {}", static_cast<u32>(result_code.module.Value()));
LOG_CRITICAL(Service_ERR, " Desc: %u", result_code.description.Value()); NGLOG_CRITICAL(Service_ERR, " Desc: {}", static_cast<u32>(result_code.description.Value()));
} }
void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) { void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 1, 32, 0); IPC::RequestParser rp(ctx, 1, 32, 0);
LOG_CRITICAL(Service_ERR, "Fatal error"); NGLOG_CRITICAL(Service_ERR, "Fatal error");
const ErrInfo errinfo = rp.PopRaw<ErrInfo>(); const ErrInfo errinfo = rp.PopRaw<ErrInfo>();
LOG_CRITICAL(Service_ERR, "Fatal error type: %s", NGLOG_CRITICAL(Service_ERR, "Fatal error type: {}",
GetErrType(errinfo.errinfo_common.specifier).c_str()); GetErrType(errinfo.errinfo_common.specifier));
Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorUnknown); Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorUnknown);
// Generic Info // Generic Info
@ -166,57 +166,56 @@ void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) {
case FatalErrType::Corrupted: case FatalErrType::Corrupted:
case FatalErrType::CardRemoved: case FatalErrType::CardRemoved:
case FatalErrType::Logged: { case FatalErrType::Logged: {
LOG_CRITICAL(Service_ERR, "Datetime: %s", GetCurrentSystemTime().c_str()); NGLOG_CRITICAL(Service_ERR, "Datetime: {}", GetCurrentSystemTime());
break; break;
} }
case FatalErrType::Exception: { case FatalErrType::Exception: {
const auto& errtype = errinfo.exception; const auto& errtype = errinfo.exception;
// Register Info // Register Info
LOG_CRITICAL(Service_ERR, "ARM Registers:"); NGLOG_CRITICAL(Service_ERR, "ARM Registers:");
for (u32 index = 0; index < errtype.exception_data.exception_context.arm_regs.size(); for (u32 index = 0; index < errtype.exception_data.exception_context.arm_regs.size();
++index) { ++index) {
if (index < 13) { if (index < 13) {
LOG_DEBUG(Service_ERR, "r%u=0x%08X", index, NGLOG_DEBUG(Service_ERR, "r{}=0x{:08X}", index,
errtype.exception_data.exception_context.arm_regs.at(index)); errtype.exception_data.exception_context.arm_regs.at(index));
} else if (index == 13) { } else if (index == 13) {
LOG_CRITICAL(Service_ERR, "SP=0x%08X", NGLOG_CRITICAL(Service_ERR, "SP=0x{:08X}",
errtype.exception_data.exception_context.arm_regs.at(index)); errtype.exception_data.exception_context.arm_regs.at(index));
} else if (index == 14) { } else if (index == 14) {
LOG_CRITICAL(Service_ERR, "LR=0x%08X", NGLOG_CRITICAL(Service_ERR, "LR=0x{:08X}",
errtype.exception_data.exception_context.arm_regs.at(index)); errtype.exception_data.exception_context.arm_regs.at(index));
} else if (index == 15) { } else if (index == 15) {
LOG_CRITICAL(Service_ERR, "PC=0x%08X", NGLOG_CRITICAL(Service_ERR, "PC=0x{:08X}",
errtype.exception_data.exception_context.arm_regs.at(index)); errtype.exception_data.exception_context.arm_regs.at(index));
} }
} }
LOG_CRITICAL(Service_ERR, "CPSR=0x%08X", errtype.exception_data.exception_context.cpsr); NGLOG_CRITICAL(Service_ERR, "CPSR=0x{:08X}", errtype.exception_data.exception_context.cpsr);
// Exception Info // Exception Info
LOG_CRITICAL( NGLOG_CRITICAL(Service_ERR, "EXCEPTION TYPE: {}",
Service_ERR, "EXCEPTION TYPE: %s", GetExceptionType(errtype.exception_data.exception_info.exception_type));
GetExceptionType(errtype.exception_data.exception_info.exception_type).c_str());
switch (static_cast<ExceptionType>(errtype.exception_data.exception_info.exception_type)) { switch (static_cast<ExceptionType>(errtype.exception_data.exception_info.exception_type)) {
case ExceptionType::PrefetchAbort: case ExceptionType::PrefetchAbort:
LOG_CRITICAL(Service_ERR, "IFSR: 0x%08X", errtype.exception_data.exception_info.sr); NGLOG_CRITICAL(Service_ERR, "IFSR: 0x{:08X}", errtype.exception_data.exception_info.sr);
LOG_CRITICAL(Service_ERR, "r15: 0x%08X", errtype.exception_data.exception_info.ar); NGLOG_CRITICAL(Service_ERR, "r15: 0x{:08X}", errtype.exception_data.exception_info.ar);
break; break;
case ExceptionType::DataAbort: case ExceptionType::DataAbort:
LOG_CRITICAL(Service_ERR, "DFSR: 0x%08X", errtype.exception_data.exception_info.sr); NGLOG_CRITICAL(Service_ERR, "DFSR: 0x{:08X}", errtype.exception_data.exception_info.sr);
LOG_CRITICAL(Service_ERR, "DFAR: 0x%08X", errtype.exception_data.exception_info.ar); NGLOG_CRITICAL(Service_ERR, "DFAR: 0x{:08X}", errtype.exception_data.exception_info.ar);
break; break;
case ExceptionType::VectorFP: case ExceptionType::VectorFP:
LOG_CRITICAL(Service_ERR, "FPEXC: 0x%08X", NGLOG_CRITICAL(Service_ERR, "FPEXC: 0x{:08X}",
errtype.exception_data.exception_info.fpinst); errtype.exception_data.exception_info.fpinst);
LOG_CRITICAL(Service_ERR, "FINST: 0x%08X", NGLOG_CRITICAL(Service_ERR, "FINST: 0x{:08X}",
errtype.exception_data.exception_info.fpinst); errtype.exception_data.exception_info.fpinst);
LOG_CRITICAL(Service_ERR, "FINST2: 0x%08X", NGLOG_CRITICAL(Service_ERR, "FINST2: 0x{:08X}",
errtype.exception_data.exception_info.fpinst2); errtype.exception_data.exception_info.fpinst2);
break; break;
case ExceptionType::Undefined: case ExceptionType::Undefined:
break; // Not logging exception_info for this case break; // Not logging exception_info for this case
} }
LOG_CRITICAL(Service_ERR, "Datetime: %s", GetCurrentSystemTime().c_str()); NGLOG_CRITICAL(Service_ERR, "Datetime: {}", GetCurrentSystemTime());
break; break;
} }
@ -224,8 +223,8 @@ void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) {
const auto& errtype = errinfo.result_failure; const auto& errtype = errinfo.result_failure;
// Failure Message // Failure Message
LOG_CRITICAL(Service_ERR, "Failure Message: %s", errtype.message); NGLOG_CRITICAL(Service_ERR, "Failure Message: {}", errtype.message);
LOG_CRITICAL(Service_ERR, "Datetime: %s", GetCurrentSystemTime().c_str()); NGLOG_CRITICAL(Service_ERR, "Datetime: {}", GetCurrentSystemTime());
break; break;
} }