diff --git a/Common/Log/LogManager.cpp b/Common/Log/LogManager.cpp index f2d9d75bb7..f08eb757ef 100644 --- a/Common/Log/LogManager.cpp +++ b/Common/Log/LogManager.cpp @@ -60,6 +60,7 @@ static const char level_to_char[8] = "-NEWIDV"; void AndroidLog(const LogMessage &message); #endif +// TODO: Get rid of this wrapper, not much point. void GenericLog(Log type, LogLevel level, const char *file, int line, const char* fmt, ...) { va_list args; va_start(args, fmt); diff --git a/Common/Net/HTTPServer.cpp b/Common/Net/HTTPServer.cpp index 6f4789d59e..91505edf74 100644 --- a/Common/Net/HTTPServer.cpp +++ b/Common/Net/HTTPServer.cpp @@ -114,7 +114,7 @@ void ServerRequest::WriteHttpResponseHeader(const char *ver, int status, int64_t buffer->Push("Connection: close\r\n"); } if (size >= 0) { - buffer->Printf("Content-Length: %llu\r\n", size); + buffer->Printf("Content-Length: %llu\r\n", (unsigned long long)size); } if (otherHeaders) { buffer->Push(otherHeaders, strlen(otherHeaders)); diff --git a/Core/Core.cpp b/Core/Core.cpp index eeff849f37..3a6ffb2c38 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -32,6 +32,7 @@ #include "Common/GPU/GraphicsContext.h" #include "Common/Thread/ThreadUtil.h" #include "Common/Log.h" +#include "Common/StringUtils.h" #include "Core/Core.h" #include "Core/Config.h" #include "Core/HLE/HLE.h" @@ -687,15 +688,16 @@ void Core_MemoryException(u32 address, u32 accessSize, u32 pc, MemoryExceptionTy } const char *desc = MemoryExceptionTypeAsString(type); + char msg[512]; + snprintf(msg, sizeof(msg), "%s: Invalid access at %08x%s (size %08x) %s%.*s", desc, address, addressSuffix.c_str(), accessSize, pcDetails, (int)additionalInfo.length(), additionalInfo.data()); if (action == ExceptionAction::Ignore) { - // Simplest logging and continue. - WARN_LOG(Log::MemMap, "%s: Invalid access at %08x%s (size %08x) %s%.*s", desc, address, addressSuffix.c_str(), accessSize, pcDetails, (int)additionalInfo.length(), additionalInfo.data()); + Core_SendDebugOutput(LogLevel::LWARNING, msg); return; } const std::string stackTrace = FormatStackTrace(WalkCurrentStack(-1)); // Do the most detailed logging we can. - ERROR_LOG(Log::MemMap, "%s: Invalid access at %08x%s (size %08x) %s%.*s\n%s", desc, address, addressSuffix.c_str(), accessSize, pcDetails, (int)additionalInfo.length(), additionalInfo.data(), stackTrace.c_str()); + Core_SendDebugOutput(LogLevel::LERROR, StringFromFormat("%s\n%s", msg, stackTrace.c_str())); if (action == ExceptionAction::Break) { MIPSExceptionInfo &e = g_exceptionInfo; e = {}; @@ -746,22 +748,23 @@ void Core_MemoryExceptionHLE(MIPSState *mips, u32 address, u32 accessSize, Memor } const u32 pc = mips->pc; + const char *desc = MemoryExceptionTypeAsString(type); + char msg[512]; - snprintf(msg, sizeof(msg), "Invalid access in %s(%s) %s at %08x%s (size %08x) PC %08x%s RA %08x%s", - funcName, args, - extra, address, ModuleAddressSuffix(address).c_str(), accessSize, + snprintf(msg, sizeof(msg), "%s: Invalid access %s in %s(%s) at %08x%s (size %08x) PC %08x%s RA %08x%s", + desc, extra, funcName, args, + address, ModuleAddressSuffix(address).c_str(), accessSize, pc, ModuleAddressSuffix(pc).c_str(), mips->r[MIPS_REG_RA], ModuleAddressSuffix(mips->r[MIPS_REG_RA]).c_str()); - const char *desc = MemoryExceptionTypeAsString(type); if (action == ExceptionAction::Ignore) { // Simplest logging and continue. - WARN_LOG(Log::MemMap, "HLE %s: %s", MemoryExceptionTypeAsString(type), msg); + Core_SendDebugOutput(LogLevel::LWARNING, msg); return; } const std::string stackTrace = FormatStackTrace(WalkCurrentStack(-1)); - ERROR_LOG(Log::MemMap, "%s: %s\n%s", desc, msg, stackTrace.c_str()); + Core_SendDebugOutput(LogLevel::LERROR, StringFromFormat("%s\n%s", msg, stackTrace.c_str())); if (action == ExceptionAction::Break) { MIPSExceptionInfo &e = g_exceptionInfo; e = {}; @@ -779,7 +782,10 @@ void Core_MemoryExceptionHLE(MIPSState *mips, u32 address, u32 accessSize, Memor // Can't be ignored, must break. Not sure we can get a meaningful stack trace here (since the PC is invalid). void Core_ExecException(u32 address, u32 pc, ExecExceptionType type) { const char *desc = ExecExceptionTypeAsString(type); - WARN_LOG(Log::MemMap, "%s: Invalid exec address %08x%s pc=%08x%s ra=%08x%s", desc, address, ModuleAddressSuffix(address).c_str(), pc, ModuleAddressSuffix(pc).c_str(), currentMIPS->r[MIPS_REG_RA], ModuleAddressSuffix(currentMIPS->r[MIPS_REG_RA]).c_str()); + + char msg[512]; + snprintf(msg, sizeof(msg), "%s: Invalid exec address %08x%s pc=%08x%s ra=%08x%s", desc, address, ModuleAddressSuffix(address).c_str(), pc, ModuleAddressSuffix(pc).c_str(), currentMIPS->r[MIPS_REG_RA], ModuleAddressSuffix(currentMIPS->r[MIPS_REG_RA]).c_str()); + Core_SendDebugOutput(LogLevel::LERROR, msg); MIPSExceptionInfo &e = g_exceptionInfo; e = {}; @@ -803,15 +809,18 @@ void Core_BreakException(u32 pc) { const std::string pcSuffix = ModuleAddressSuffix(pc); + char msg[512]; + snprintf(msg, sizeof(msg), "CPU exception: break instruction hit at %08x%s. Ignoring (use --break=log for more details or --break=break to break)", pc, pcSuffix.c_str()); + const ExceptionAction action = ResolveExceptionAction((ExceptionAction)g_Config.iExceptionActionBreak); if (action == ExceptionAction::Ignore) { // Simplest logging and continue. - WARN_LOG(Log::CPU, "CPU exception: break instruction hit at %08x%s. Ignoring (use --break=log for more details or --break=break to break)", pc, pcSuffix.c_str()); + Core_SendDebugOutput(LogLevel::LINFO, StringFromFormat("Ignoring CPU exception: break instruction hit at %08x%s", pc, pcSuffix.c_str())); return; } const std::string stackTrace = FormatStackTrace(WalkCurrentStack(-1)); - ERROR_LOG(Log::CPU, "CPU exception: break instruction hit at %08x%s (ra=%08x%s)\n%s", pc, pcSuffix.c_str(), currentMIPS->r[MIPS_REG_RA], ModuleAddressSuffix(currentMIPS->r[MIPS_REG_RA]).c_str(), stackTrace.c_str()); + Core_SendDebugOutput(LogLevel::LERROR, StringFromFormat("%s\n%s", msg, stackTrace.c_str())); if (action == ExceptionAction::Break) { Core_Break(BreakReason::BreakInstruction, currentMIPS->pc); } diff --git a/Core/System.cpp b/Core/System.cpp index 69d3dbfdcb..9e22df9527 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -36,6 +36,7 @@ #include "Common/System/OSD.h" #include "Common/Data/Text/I18n.h" #include "Common/File/Path.h" +#include "Common/StringUtils.h" #include "Common/File/FileUtil.h" #include "Common/File/DirListing.h" #include "Common/File/AndroidContentURI.h" @@ -359,7 +360,8 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin default: { // Trying to boot other things lands us here. We need to return a sensible error string. - ERROR_LOG(Log::Loader, "CPU_Init didn't recognize file. %s", errorString->c_str()); + ERROR_LOG(Log::Loader, "CPU_Init didn't recognize file: %s. %s", fileLoader->GetPath().c_str(), errorString->c_str()); + Core_SendDebugOutput(LogLevel::LINFO, StringFromFormat("File not recognized: %s. %s", fileLoader->GetPath().c_str(), errorString->c_str())); auto sy = GetI18NCategory(I18NCat::SYSTEM); if (errorString->empty()) { *errorString = sy->T("Not a PSP game");