From 638956aa81de255bf4bbd4e69a717eabf4ceadb9 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 2 Jul 2018 10:13:26 -0600 Subject: Rename logging macro back to LOG_* --- src/common/assert.h | 4 +-- src/common/file_util.cpp | 80 +++++++++++++++++++++---------------------- src/common/logging/filter.cpp | 6 ++-- src/common/logging/log.h | 14 ++++---- src/common/memory_util.cpp | 16 ++++----- src/common/param_package.cpp | 12 +++---- src/common/string_util.cpp | 8 ++--- 7 files changed, 70 insertions(+), 70 deletions(-) (limited to 'src/common') diff --git a/src/common/assert.h b/src/common/assert.h index 3ee07f6a2..fbe87273b 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -30,7 +30,7 @@ __declspec(noinline, noreturn) #define ASSERT(_a_) \ do \ if (!(_a_)) { \ - assert_noinline_call([] { NGLOG_CRITICAL(Debug, "Assertion Failed!"); }); \ + assert_noinline_call([] { LOG_CRITICAL(Debug, "Assertion Failed!"); }); \ } \ while (0) @@ -38,7 +38,7 @@ __declspec(noinline, noreturn) do \ if (!(_a_)) { \ assert_noinline_call( \ - [&] { NGLOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \ + [&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \ } \ while (0) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 2d0b81c6e..40b633092 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -118,7 +118,7 @@ bool IsDirectory(const std::string& filename) { #endif if (result < 0) { - NGLOG_DEBUG(Common_Filesystem, "stat failed on {}: {}", filename, GetLastErrorMsg()); + LOG_DEBUG(Common_Filesystem, "stat failed on {}: {}", filename, GetLastErrorMsg()); return false; } @@ -128,29 +128,29 @@ bool IsDirectory(const std::string& filename) { // Deletes a given filename, return true on success // Doesn't supports deleting a directory bool Delete(const std::string& filename) { - NGLOG_TRACE(Common_Filesystem, "file {}", filename); + LOG_TRACE(Common_Filesystem, "file {}", filename); // Return true because we care about the file no // being there, not the actual delete. if (!Exists(filename)) { - NGLOG_DEBUG(Common_Filesystem, "{} does not exist", filename); + LOG_DEBUG(Common_Filesystem, "{} does not exist", filename); return true; } // We can't delete a directory if (IsDirectory(filename)) { - NGLOG_ERROR(Common_Filesystem, "Failed: {} is a directory", filename); + LOG_ERROR(Common_Filesystem, "Failed: {} is a directory", filename); return false; } #ifdef _WIN32 if (!DeleteFileW(Common::UTF8ToUTF16W(filename).c_str())) { - NGLOG_ERROR(Common_Filesystem, "DeleteFile failed on {}: {}", filename, GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "DeleteFile failed on {}: {}", filename, GetLastErrorMsg()); return false; } #else if (unlink(filename.c_str()) == -1) { - NGLOG_ERROR(Common_Filesystem, "unlink failed on {}: {}", filename, GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "unlink failed on {}: {}", filename, GetLastErrorMsg()); return false; } #endif @@ -160,16 +160,16 @@ bool Delete(const std::string& filename) { // Returns true if successful, or path already exists. bool CreateDir(const std::string& path) { - NGLOG_TRACE(Common_Filesystem, "directory {}", path); + LOG_TRACE(Common_Filesystem, "directory {}", path); #ifdef _WIN32 if (::CreateDirectoryW(Common::UTF8ToUTF16W(path).c_str(), nullptr)) return true; DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) { - NGLOG_DEBUG(Common_Filesystem, "CreateDirectory failed on {}: already exists", path); + LOG_DEBUG(Common_Filesystem, "CreateDirectory failed on {}: already exists", path); return true; } - NGLOG_ERROR(Common_Filesystem, "CreateDirectory failed on {}: {}", path, error); + LOG_ERROR(Common_Filesystem, "CreateDirectory failed on {}: {}", path, error); return false; #else if (mkdir(path.c_str(), 0755) == 0) @@ -178,11 +178,11 @@ bool CreateDir(const std::string& path) { int err = errno; if (err == EEXIST) { - NGLOG_DEBUG(Common_Filesystem, "mkdir failed on {}: already exists", path); + LOG_DEBUG(Common_Filesystem, "mkdir failed on {}: already exists", path); return true; } - NGLOG_ERROR(Common_Filesystem, "mkdir failed on {}: {}", path, strerror(err)); + LOG_ERROR(Common_Filesystem, "mkdir failed on {}: {}", path, strerror(err)); return false; #endif } @@ -190,10 +190,10 @@ bool CreateDir(const std::string& path) { // Creates the full path of fullPath returns true on success bool CreateFullPath(const std::string& fullPath) { int panicCounter = 100; - NGLOG_TRACE(Common_Filesystem, "path {}", fullPath); + LOG_TRACE(Common_Filesystem, "path {}", fullPath); if (FileUtil::Exists(fullPath)) { - NGLOG_DEBUG(Common_Filesystem, "path exists {}", fullPath); + LOG_DEBUG(Common_Filesystem, "path exists {}", fullPath); return true; } @@ -209,14 +209,14 @@ bool CreateFullPath(const std::string& fullPath) { // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") std::string const subPath(fullPath.substr(0, position + 1)); if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { - NGLOG_ERROR(Common, "CreateFullPath: directory creation failed"); + LOG_ERROR(Common, "CreateFullPath: directory creation failed"); return false; } // A safety check panicCounter--; if (panicCounter <= 0) { - NGLOG_ERROR(Common, "CreateFullPath: directory structure is too deep"); + LOG_ERROR(Common, "CreateFullPath: directory structure is too deep"); return false; } position++; @@ -225,11 +225,11 @@ bool CreateFullPath(const std::string& fullPath) { // Deletes a directory filename, returns true on success bool DeleteDir(const std::string& filename) { - NGLOG_TRACE(Common_Filesystem, "directory {}", filename); + LOG_TRACE(Common_Filesystem, "directory {}", filename); // check if a directory if (!FileUtil::IsDirectory(filename)) { - NGLOG_ERROR(Common_Filesystem, "Not a directory {}", filename); + LOG_ERROR(Common_Filesystem, "Not a directory {}", filename); return false; } @@ -240,14 +240,14 @@ bool DeleteDir(const std::string& filename) { if (rmdir(filename.c_str()) == 0) return true; #endif - NGLOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); return false; } // renames file srcFilename to destFilename, returns true on success bool Rename(const std::string& srcFilename, const std::string& destFilename) { - NGLOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); + LOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); #ifdef _WIN32 if (_wrename(Common::UTF8ToUTF16W(srcFilename).c_str(), Common::UTF8ToUTF16W(destFilename).c_str()) == 0) @@ -256,20 +256,20 @@ bool Rename(const std::string& srcFilename, const std::string& destFilename) { if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) return true; #endif - NGLOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, + LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); return false; } // copies file srcFilename to destFilename, returns true on success bool Copy(const std::string& srcFilename, const std::string& destFilename) { - NGLOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); + LOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); #ifdef _WIN32 if (CopyFileW(Common::UTF8ToUTF16W(srcFilename).c_str(), Common::UTF8ToUTF16W(destFilename).c_str(), FALSE)) return true; - NGLOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, + LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); return false; #else @@ -282,7 +282,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { // Open input file FILE* input = fopen(srcFilename.c_str(), "rb"); if (!input) { - NGLOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename, + LOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); return false; } @@ -291,7 +291,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { FILE* output = fopen(destFilename.c_str(), "wb"); if (!output) { fclose(input); - NGLOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename, + LOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); return false; } @@ -302,7 +302,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { size_t rnum = fread(buffer, sizeof(char), BSIZE, input); if (rnum != BSIZE) { if (ferror(input) != 0) { - NGLOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", + LOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); goto bail; } @@ -311,7 +311,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { // write output size_t wnum = fwrite(buffer, sizeof(char), rnum, output); if (wnum != rnum) { - NGLOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, + LOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); goto bail; } @@ -332,12 +332,12 @@ bail: // Returns the size of filename (64bit) u64 GetSize(const std::string& filename) { if (!Exists(filename)) { - NGLOG_ERROR(Common_Filesystem, "failed {}: No such file", filename); + LOG_ERROR(Common_Filesystem, "failed {}: No such file", filename); return 0; } if (IsDirectory(filename)) { - NGLOG_ERROR(Common_Filesystem, "failed {}: is a directory", filename); + LOG_ERROR(Common_Filesystem, "failed {}: is a directory", filename); return 0; } @@ -348,11 +348,11 @@ u64 GetSize(const std::string& filename) { if (stat(filename.c_str(), &buf) == 0) #endif { - NGLOG_TRACE(Common_Filesystem, "{}: {}", filename, buf.st_size); + LOG_TRACE(Common_Filesystem, "{}: {}", filename, buf.st_size); return buf.st_size; } - NGLOG_ERROR(Common_Filesystem, "Stat failed {}: {}", filename, GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "Stat failed {}: {}", filename, GetLastErrorMsg()); return 0; } @@ -360,7 +360,7 @@ u64 GetSize(const std::string& filename) { u64 GetSize(const int fd) { struct stat buf; if (fstat(fd, &buf) != 0) { - NGLOG_ERROR(Common_Filesystem, "GetSize: stat failed {}: {}", fd, GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "GetSize: stat failed {}: {}", fd, GetLastErrorMsg()); return 0; } return buf.st_size; @@ -371,13 +371,13 @@ u64 GetSize(FILE* f) { // can't use off_t here because it can be 32-bit u64 pos = ftello(f); if (fseeko(f, 0, SEEK_END) != 0) { - NGLOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), + LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), GetLastErrorMsg()); return 0; } u64 size = ftello(f); if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { - NGLOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), + LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), GetLastErrorMsg()); return 0; } @@ -386,10 +386,10 @@ u64 GetSize(FILE* f) { // creates an empty file filename, returns true on success bool CreateEmptyFile(const std::string& filename) { - NGLOG_TRACE(Common_Filesystem, "{}", filename); + LOG_TRACE(Common_Filesystem, "{}", filename); if (!FileUtil::IOFile(filename, "wb")) { - NGLOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); return false; } @@ -398,7 +398,7 @@ bool CreateEmptyFile(const std::string& filename) { bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, DirectoryEntryCallable callback) { - NGLOG_TRACE(Common_Filesystem, "directory {}", directory); + LOG_TRACE(Common_Filesystem, "directory {}", directory); // How many files + directories we found unsigned found_entries = 0; @@ -556,7 +556,7 @@ std::string GetCurrentDir() { char* dir; if (!(dir = getcwd(nullptr, 0))) { #endif - NGLOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: {}", GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: {}", GetLastErrorMsg()); return nullptr; } #ifdef _WIN32 @@ -676,7 +676,7 @@ std::string GetSysDirectory() { #endif sysDir += DIR_SEP; - NGLOG_DEBUG(Common_Filesystem, "Setting to {}:", sysDir); + LOG_DEBUG(Common_Filesystem, "Setting to {}:", sysDir); return sysDir; } @@ -692,7 +692,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new if (!FileUtil::IsDirectory(paths[D_USER_IDX])) { paths[D_USER_IDX] = AppDataRoamingDirectory() + DIR_SEP EMU_DATA_DIR DIR_SEP; } else { - NGLOG_INFO(Common_Filesystem, "Using the local user directory"); + LOG_INFO(Common_Filesystem, "Using the local user directory"); } paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; @@ -719,7 +719,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new if (!newPath.empty()) { if (!FileUtil::IsDirectory(newPath)) { - NGLOG_ERROR(Common_Filesystem, "Invalid path specified {}", newPath); + LOG_ERROR(Common_Filesystem, "Invalid path specified {}", newPath); return paths[DirIDX]; } else { paths[DirIDX] = newPath; diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 428723dce..fdfb66696 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -65,14 +65,14 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, const std::string::const_iterator end) { auto level_separator = std::find(begin, end, ':'); if (level_separator == end) { - NGLOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: %s", + LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: %s", std::string(begin, end).c_str()); return false; } const Level level = GetLevelByName(level_separator + 1, end); if (level == Level::Count) { - NGLOG_ERROR(Log, "Unknown log level in filter: %s", std::string(begin, end).c_str()); + LOG_ERROR(Log, "Unknown log level in filter: %s", std::string(begin, end).c_str()); return false; } @@ -83,7 +83,7 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, const Class log_class = GetClassByName(begin, level_separator); if (log_class == Class::Count) { - NGLOG_ERROR(Log, "Unknown log class in filter: %s", std::string(begin, end).c_str()); + LOG_ERROR(Log, "Unknown log class in filter: %s", std::string(begin, end).c_str()); return false; } diff --git a/src/common/logging/log.h b/src/common/logging/log.h index c5015531c..e96c90e16 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -109,25 +109,25 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig } // namespace Log #ifdef _DEBUG -#define NGLOG_TRACE(log_class, ...) \ +#define LOG_TRACE(log_class, ...) \ ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, __FILE__, __LINE__, \ __func__, __VA_ARGS__) #else -#define NGLOG_TRACE(log_class, fmt, ...) (void(0)) +#define LOG_TRACE(log_class, fmt, ...) (void(0)) #endif -#define NGLOG_DEBUG(log_class, ...) \ +#define LOG_DEBUG(log_class, ...) \ ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Debug, __FILE__, __LINE__, \ __func__, __VA_ARGS__) -#define NGLOG_INFO(log_class, ...) \ +#define LOG_INFO(log_class, ...) \ ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Info, __FILE__, __LINE__, \ __func__, __VA_ARGS__) -#define NGLOG_WARNING(log_class, ...) \ +#define LOG_WARNING(log_class, ...) \ ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Warning, __FILE__, __LINE__, \ __func__, __VA_ARGS__) -#define NGLOG_ERROR(log_class, ...) \ +#define LOG_ERROR(log_class, ...) \ ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Error, __FILE__, __LINE__, \ __func__, __VA_ARGS__) -#define NGLOG_CRITICAL(log_class, ...) \ +#define LOG_CRITICAL(log_class, ...) \ ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, __FILE__, __LINE__, \ __func__, __VA_ARGS__) diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 4d1ec8fb9..5d89209ed 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -55,7 +55,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { if (ptr == MAP_FAILED) { ptr = nullptr; #endif - NGLOG_ERROR(Common_Memory, "Failed to allocate executable memory"); + LOG_ERROR(Common_Memory, "Failed to allocate executable memory"); } #if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) else { @@ -68,7 +68,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { #if EMU_ARCH_BITS == 64 if ((u64)ptr >= 0x80000000 && low == true) - NGLOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!"); + LOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!"); #endif return ptr; @@ -85,7 +85,7 @@ void* AllocateMemoryPages(size_t size) { #endif if (ptr == nullptr) - NGLOG_ERROR(Common_Memory, "Failed to allocate raw memory"); + LOG_ERROR(Common_Memory, "Failed to allocate raw memory"); return ptr; } @@ -99,12 +99,12 @@ void* AllocateAlignedMemory(size_t size, size_t alignment) { ptr = memalign(alignment, size); #else if (posix_memalign(&ptr, alignment, size) != 0) - NGLOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); + LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); #endif #endif if (ptr == nullptr) - NGLOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); + LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); return ptr; } @@ -113,7 +113,7 @@ void FreeMemoryPages(void* ptr, size_t size) { if (ptr) { #ifdef _WIN32 if (!VirtualFree(ptr, 0, MEM_RELEASE)) - NGLOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n{}", GetLastErrorMsg()); + LOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n{}", GetLastErrorMsg()); #else munmap(ptr, size); #endif @@ -134,7 +134,7 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute) { #ifdef _WIN32 DWORD oldValue; if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue)) - NGLOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n{}", GetLastErrorMsg()); + LOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n{}", GetLastErrorMsg()); #else mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ); #endif @@ -145,7 +145,7 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute) { DWORD oldValue; if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue)) - NGLOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n{}", GetLastErrorMsg()); + LOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n{}", GetLastErrorMsg()); #else mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ); diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index ab0154133..e0df430ab 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp @@ -25,7 +25,7 @@ ParamPackage::ParamPackage(const std::string& serialized) { std::vector key_value; Common::SplitString(pair, KEY_VALUE_SEPARATOR, key_value); if (key_value.size() != 2) { - NGLOG_ERROR(Common, "invalid key pair {}", pair); + LOG_ERROR(Common, "invalid key pair {}", pair); continue; } @@ -64,7 +64,7 @@ std::string ParamPackage::Serialize() const { std::string ParamPackage::Get(const std::string& key, const std::string& default_value) const { auto pair = data.find(key); if (pair == data.end()) { - NGLOG_DEBUG(Common, "key '{}' not found", key); + LOG_DEBUG(Common, "key '{}' not found", key); return default_value; } @@ -74,14 +74,14 @@ std::string ParamPackage::Get(const std::string& key, const std::string& default int ParamPackage::Get(const std::string& key, int default_value) const { auto pair = data.find(key); if (pair == data.end()) { - NGLOG_DEBUG(Common, "key '{}' not found", key); + LOG_DEBUG(Common, "key '{}' not found", key); return default_value; } try { return std::stoi(pair->second); } catch (const std::logic_error&) { - NGLOG_ERROR(Common, "failed to convert {} to int", pair->second); + LOG_ERROR(Common, "failed to convert {} to int", pair->second); return default_value; } } @@ -89,14 +89,14 @@ int ParamPackage::Get(const std::string& key, int default_value) const { float ParamPackage::Get(const std::string& key, float default_value) const { auto pair = data.find(key); if (pair == data.end()) { - NGLOG_DEBUG(Common, "key {} not found", key); + LOG_DEBUG(Common, "key {} not found", key); return default_value; } try { return std::stof(pair->second); } catch (const std::logic_error&) { - NGLOG_ERROR(Common, "failed to convert {} to float", pair->second); + LOG_ERROR(Common, "failed to convert {} to float", pair->second); return default_value; } } diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 646400db0..ea9d8f77c 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -281,7 +281,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string& iconv_t const conv_desc = iconv_open("UTF-8", fromcode); if ((iconv_t)(-1) == conv_desc) { - NGLOG_ERROR(Common, "Iconv initialization failure [{}]: {}", fromcode, strerror(errno)); + LOG_ERROR(Common, "Iconv initialization failure [{}]: {}", fromcode, strerror(errno)); iconv_close(conv_desc); return {}; } @@ -310,7 +310,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string& ++src_buffer; } } else { - NGLOG_ERROR(Common, "iconv failure [{}]: {}", fromcode, strerror(errno)); + LOG_ERROR(Common, "iconv failure [{}]: {}", fromcode, strerror(errno)); break; } } @@ -329,7 +329,7 @@ std::u16string UTF8ToUTF16(const std::string& input) { iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8"); if ((iconv_t)(-1) == conv_desc) { - NGLOG_ERROR(Common, "Iconv initialization failure [UTF-8]: {}", strerror(errno)); + LOG_ERROR(Common, "Iconv initialization failure [UTF-8]: {}", strerror(errno)); iconv_close(conv_desc); return {}; } @@ -358,7 +358,7 @@ std::u16string UTF8ToUTF16(const std::string& input) { ++src_buffer; } } else { - NGLOG_ERROR(Common, "iconv failure [UTF-8]: {}", strerror(errno)); + LOG_ERROR(Common, "iconv failure [UTF-8]: {}", strerror(errno)); break; } } -- cgit v1.2.3 From 0d46f0df122dbc9b9a9d9f97e2da6b1953ef939b Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 2 Jul 2018 10:20:50 -0600 Subject: Update clang format --- src/common/assert.h | 5 +- src/common/file_util.cpp | 18 ++++---- src/common/logging/filter.cpp | 2 +- src/core/arm/dynarmic/arm_dynarmic.cpp | 2 +- src/core/core.cpp | 4 +- src/core/file_sys/partition_filesystem.cpp | 4 +- src/core/file_sys/program_metadata.cpp | 2 +- src/core/file_sys/romfs_filesystem.cpp | 12 ++--- src/core/gdbstub/gdbstub.cpp | 17 ++++--- src/core/hle/kernel/hle_ipc.cpp | 2 +- src/core/hle/kernel/server_session.cpp | 2 +- src/core/hle/kernel/shared_memory.cpp | 4 +- src/core/hle/kernel/svc.cpp | 53 ++++++++++------------ src/core/hle/kernel/thread.cpp | 2 +- src/core/hle/kernel/vm_manager.cpp | 10 ++-- src/core/hle/service/apm/interface.cpp | 2 +- src/core/hle/service/filesystem/filesystem.cpp | 4 +- .../hle/service/nvdrv/devices/nvdisp_disp0.cpp | 4 +- .../hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 16 +++---- src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 8 ++-- .../hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 4 +- src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 20 ++++---- .../hle/service/nvdrv/devices/nvhost_nvdec.cpp | 2 +- src/core/hle/service/sm/sm.cpp | 3 +- src/core/hle/service/sockets/bsd.cpp | 3 +- src/core/hle/service/vi/vi.cpp | 6 +-- src/core/loader/elf.cpp | 10 ++-- src/core/memory.cpp | 24 +++++----- src/video_core/command_processor.cpp | 6 +-- src/video_core/engines/fermi_2d.cpp | 2 +- src/video_core/engines/maxwell_3d.cpp | 4 +- src/video_core/renderer_opengl/gl_rasterizer.cpp | 10 ++-- .../renderer_opengl/gl_shader_decompiler.cpp | 12 ++--- src/video_core/renderer_opengl/maxwell_to_gl.h | 5 +- src/video_core/renderer_opengl/renderer_opengl.cpp | 2 +- src/yuzu/game_list.cpp | 3 +- src/yuzu_cmd/yuzu.cpp | 6 +-- 37 files changed, 141 insertions(+), 154 deletions(-) (limited to 'src/common') diff --git a/src/common/assert.h b/src/common/assert.h index fbe87273b..655446f34 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -30,15 +30,14 @@ __declspec(noinline, noreturn) #define ASSERT(_a_) \ do \ if (!(_a_)) { \ - assert_noinline_call([] { LOG_CRITICAL(Debug, "Assertion Failed!"); }); \ + assert_noinline_call([] { LOG_CRITICAL(Debug, "Assertion Failed!"); }); \ } \ while (0) #define ASSERT_MSG(_a_, ...) \ do \ if (!(_a_)) { \ - assert_noinline_call( \ - [&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \ + assert_noinline_call([&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \ } \ while (0) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 40b633092..2152e3fea 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -257,7 +257,7 @@ bool Rename(const std::string& srcFilename, const std::string& destFilename) { return true; #endif LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, - GetLastErrorMsg()); + GetLastErrorMsg()); return false; } @@ -270,7 +270,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { return true; LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, - GetLastErrorMsg()); + GetLastErrorMsg()); return false; #else @@ -283,7 +283,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { FILE* input = fopen(srcFilename.c_str(), "rb"); if (!input) { LOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename, - destFilename, GetLastErrorMsg()); + destFilename, GetLastErrorMsg()); return false; } @@ -292,7 +292,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { if (!output) { fclose(input); LOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename, - destFilename, GetLastErrorMsg()); + destFilename, GetLastErrorMsg()); return false; } @@ -303,7 +303,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { if (rnum != BSIZE) { if (ferror(input) != 0) { LOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", - srcFilename, destFilename, GetLastErrorMsg()); + srcFilename, destFilename, GetLastErrorMsg()); goto bail; } } @@ -312,7 +312,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { size_t wnum = fwrite(buffer, sizeof(char), rnum, output); if (wnum != rnum) { LOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, - destFilename, GetLastErrorMsg()); + destFilename, GetLastErrorMsg()); goto bail; } } @@ -371,14 +371,12 @@ u64 GetSize(FILE* f) { // can't use off_t here because it can be 32-bit u64 pos = ftello(f); if (fseeko(f, 0, SEEK_END) != 0) { - LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), - GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), GetLastErrorMsg()); return 0; } u64 size = ftello(f); if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { - LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), - GetLastErrorMsg()); + LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), GetLastErrorMsg()); return 0; } return size; diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index fdfb66696..733247b51 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -66,7 +66,7 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, auto level_separator = std::find(begin, end, ':'); if (level_separator == end) { LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: %s", - std::string(begin, end).c_str()); + std::string(begin, end).c_str()); return false; } diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 975ac6e3f..42605374b 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -56,7 +56,7 @@ public: void InterpreterFallback(u64 pc, size_t num_instructions) override { LOG_INFO(Core_ARM, "Unicorn fallback @ 0x{:X} for {} instructions (instr = {:08X})", pc, - num_instructions, MemoryReadCode(pc)); + num_instructions, MemoryReadCode(pc)); ARM_Interface::ThreadContext ctx; parent.SaveContext(ctx); diff --git a/src/core/core.cpp b/src/core/core.cpp index 8c2977522..8335d502e 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -95,7 +95,7 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file if (system_mode.second != Loader::ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to determine system mode (Error {})!", - static_cast(system_mode.second)); + static_cast(system_mode.second)); switch (system_mode.second) { case Loader::ResultStatus::ErrorEncrypted: @@ -112,7 +112,7 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file ResultStatus init_result{Init(emu_window, system_mode.first.get())}; if (init_result != ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", - static_cast(init_result)); + static_cast(init_result)); System::Shutdown(); return init_result; } diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp index ebbc0b252..46d438aca 100644 --- a/src/core/file_sys/partition_filesystem.cpp +++ b/src/core/file_sys/partition_filesystem.cpp @@ -129,8 +129,8 @@ void PartitionFilesystem::Print() const { LOG_DEBUG(Service_FS, "Files: {}", pfs_header.num_entries); for (u32 i = 0; i < pfs_header.num_entries; i++) { LOG_DEBUG(Service_FS, " > File {}: {} (0x{:X} bytes, at 0x{:X})", i, - pfs_entries[i].name.c_str(), pfs_entries[i].fs_entry.size, - GetFileOffset(pfs_entries[i].name)); + pfs_entries[i].name.c_str(), pfs_entries[i].fs_entry.size, + GetFileOffset(pfs_entries[i].name)); } } } // namespace FileSys diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index a17268b2c..226811115 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp @@ -83,7 +83,7 @@ void ProgramMetadata::Print() const { LOG_DEBUG(Service_FS, "Process category: {}", npdm_header.process_category); LOG_DEBUG(Service_FS, "Flags: 0x{:02X}", npdm_header.flags); LOG_DEBUG(Service_FS, " > 64-bit instructions: {}", - npdm_header.has_64_bit_instructions ? "YES" : "NO"); + npdm_header.has_64_bit_instructions ? "YES" : "NO"); auto address_space = "Unknown"; switch (npdm_header.address_space_type) { diff --git a/src/core/file_sys/romfs_filesystem.cpp b/src/core/file_sys/romfs_filesystem.cpp index 4dbd6a786..83162622b 100644 --- a/src/core/file_sys/romfs_filesystem.cpp +++ b/src/core/file_sys/romfs_filesystem.cpp @@ -28,22 +28,21 @@ ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const { ResultCode RomFS_FileSystem::RenameFile(const std::string& src_path, const std::string& dest_path) const { - LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).", - GetName()); + LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).", GetName()); // TODO(wwylele): Use correct error code return ResultCode(-1); } ResultCode RomFS_FileSystem::DeleteDirectory(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive ({}).", - GetName()); + GetName()); // TODO(wwylele): Use correct error code return ResultCode(-1); } ResultCode RomFS_FileSystem::DeleteDirectoryRecursively(const Path& path) const { LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive ({}).", - GetName()); + GetName()); // TODO(wwylele): Use correct error code return ResultCode(-1); } @@ -56,14 +55,13 @@ ResultCode RomFS_FileSystem::CreateFile(const std::string& path, u64 size) const ResultCode RomFS_FileSystem::CreateDirectory(const std::string& path) const { LOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive ({}).", - GetName()); + GetName()); // TODO(wwylele): Use correct error code return ResultCode(-1); } ResultCode RomFS_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { - LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).", - GetName()); + LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).", GetName()); // TODO(wwylele): Use correct error code return ResultCode(-1); } diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 500734f2d..938852a1a 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -414,7 +414,7 @@ static void RemoveBreakpoint(BreakpointType type, PAddr addr) { auto bp = p.find(static_cast(addr)); if (bp != p.end()) { LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: {:016X} bytes at {:016X} of type {}", - bp->second.len, bp->second.addr, static_cast(type)); + bp->second.len, bp->second.addr, static_cast(type)); p.erase(static_cast(addr)); } } @@ -460,9 +460,9 @@ bool CheckBreakpoint(PAddr addr, BreakpointType type) { if (bp->second.active && (addr >= bp->second.addr && addr < bp->second.addr + len)) { LOG_DEBUG(Debug_GDBStub, - "Found breakpoint type {} @ {:016X}, range: {:016X}" - " - {:016X} ({:X} bytes)", - static_cast(type), addr, bp->second.addr, bp->second.addr + len, len); + "Found breakpoint type {} @ {:016X}, range: {:016X}" + " - {:016X} ({:X} bytes)", + static_cast(type), addr, bp->second.addr, bp->second.addr + len, len); return true; } } @@ -658,10 +658,9 @@ static void ReadCommand() { u8 checksum_calculated = CalculateChecksum(command_buffer, command_length); if (checksum_received != checksum_calculated) { - LOG_ERROR( - Debug_GDBStub, - "gdb: invalid checksum: calculated {:02X} and read {:02X} for ${}# (length: {})", - checksum_calculated, checksum_received, command_buffer, command_length); + LOG_ERROR(Debug_GDBStub, + "gdb: invalid checksum: calculated {:02X} and read {:02X} for ${}# (length: {})", + checksum_calculated, checksum_received, command_buffer, command_length); command_length = 0; @@ -889,7 +888,7 @@ static bool CommitBreakpoint(BreakpointType type, PAddr addr, u64 len) { p.insert({addr, breakpoint}); LOG_DEBUG(Debug_GDBStub, "gdb: added {} breakpoint: {:016X} bytes at {:016X}", - static_cast(type), breakpoint.len, breakpoint.addr); + static_cast(type), breakpoint.len, breakpoint.addr); return true; } diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 5ac3227d1..609cdbff2 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -280,7 +280,7 @@ size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size, int buffe const size_t buffer_size{GetWriteBufferSize(buffer_index)}; if (size > buffer_size) { LOG_CRITICAL(Core, "size ({:016X}) is greater than buffer_size ({:016X})", size, - buffer_size); + buffer_size); size = buffer_size; // TODO(bunnei): This needs to be HW tested } diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 29fecef20..0d5cba1d9 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -82,7 +82,7 @@ ResultCode ServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& con } LOG_CRITICAL(IPC, "Unknown domain command={}", - static_cast(domain_message_header->command.Value())); + static_cast(domain_message_header->command.Value())); ASSERT(false); } diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 80fa81abd..93f7f2772 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -108,7 +108,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi // Error out if the requested permissions don't match what the creator process allows. if (static_cast(permissions) & ~static_cast(own_other_permissions)) { LOG_ERROR(Kernel, "cannot map id={}, address=0x{:X} name={}, permissions don't match", - GetObjectId(), address, name); + GetObjectId(), address, name); return ERR_INVALID_COMBINATION; } @@ -116,7 +116,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi if (other_permissions != MemoryPermission::DontCare && static_cast(this->permissions) & ~static_cast(other_permissions)) { LOG_ERROR(Kernel, "cannot map id={}, address=0x{:X} name={}, permissions don't match", - GetObjectId(), address, name); + GetObjectId(), address, name); return ERR_WRONG_PERMISSION; } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 843fffd7e..5ad923fe7 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -47,14 +47,14 @@ static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state /// Maps a memory range into a different range. static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, - src_addr, size); + src_addr, size); return Core::CurrentProcess()->MirrorMemory(dst_addr, src_addr, size); } /// Unmaps a region that was previously mapped with svcMapMemory static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, - src_addr, size); + src_addr, size); return Core::CurrentProcess()->UnmapMemory(dst_addr, src_addr, size); } @@ -150,7 +150,7 @@ static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtrvm_manager; @@ -314,12 +314,12 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) break; case GetInfoType::PrivilegedProcessId: LOG_WARNING(Kernel_SVC, - "(STUBBED) Attempted to query privileged process id bounds, returned 0"); + "(STUBBED) Attempted to query privileged process id bounds, returned 0"); *result = 0; break; case GetInfoType::UserExceptionContextAddr: LOG_WARNING(Kernel_SVC, - "(STUBBED) Attempted to query user exception context address, returned 0"); + "(STUBBED) Attempted to query user exception context address, returned 0"); *result = 0; break; default: @@ -331,8 +331,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) /// Sets the thread activity static ResultCode SetThreadActivity(Handle handle, u32 unknown) { - LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, - unknown); + LOG_WARNING(Kernel_SVC, "(STUBBED) called, handle=0x{:08X}, unknown=0x{:08X}", handle, unknown); return RESULT_SUCCESS; } @@ -383,10 +382,9 @@ static u32 GetCurrentProcessorNumber() { static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size, u32 permissions) { - LOG_TRACE( - Kernel_SVC, - "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", - shared_memory_handle, addr, size, permissions); + LOG_TRACE(Kernel_SVC, + "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", + shared_memory_handle, addr, size, permissions); SharedPtr shared_memory = g_handle_table.Get(shared_memory_handle); if (!shared_memory) { @@ -414,7 +412,7 @@ static ResultCode MapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 s static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 size) { LOG_WARNING(Kernel_SVC, "called, shared_memory_handle=0x{:08X}, addr=0x{:X}, size=0x{:X}", - shared_memory_handle, addr, size); + shared_memory_handle, addr, size); SharedPtr shared_memory = g_handle_table.Get(shared_memory_handle); @@ -531,9 +529,9 @@ static ResultCode CreateThread(Handle* out_handle, VAddr entry_point, u64 arg, V Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); LOG_TRACE(Kernel_SVC, - "called entrypoint=0x{:08X} ({}), arg=0x{:08X}, stacktop=0x{:08X}, " - "threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}", - entry_point, name, arg, stack_top, priority, processor_id, *out_handle); + "called entrypoint=0x{:08X} ({}), arg=0x{:08X}, stacktop=0x{:08X}, " + "threadpriority=0x{:08X}, processorid=0x{:08X} : created handle=0x{:08X}", + entry_point, name, arg, stack_top, priority, processor_id, *out_handle); return RESULT_SUCCESS; } @@ -612,7 +610,7 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var /// Signal process wide key static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target) { LOG_TRACE(Kernel_SVC, "called, condition_variable_addr=0x{:X}, target=0x{:08X}", - condition_variable_addr, target); + condition_variable_addr, target); auto RetrieveWaitingThreads = [](size_t core_index, std::vector>& waiting_threads, VAddr condvar_addr) { @@ -693,7 +691,7 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target // Wait for an address (via Address Arbiter) static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout) { LOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, timeout={}", - address, type, value, timeout); + address, type, value, timeout); // If the passed address is a kernel virtual address, return invalid memory state. if (Memory::IsKernelVirtualAddress(address)) { return ERR_INVALID_ADDRESS_STATE; @@ -717,9 +715,8 @@ static ResultCode WaitForAddress(VAddr address, u32 type, s32 value, s64 timeout // Signals to an address (via Address Arbiter) static ResultCode SignalToAddress(VAddr address, u32 type, s32 value, s32 num_to_wake) { - LOG_WARNING(Kernel_SVC, - "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}", address, - type, value, num_to_wake); + LOG_WARNING(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}", + address, type, value, num_to_wake); // If the passed address is a kernel virtual address, return invalid memory state. if (Memory::IsKernelVirtualAddress(address)) { return ERR_INVALID_ADDRESS_STATE; @@ -769,8 +766,8 @@ static ResultCode ResetSignal(Handle handle) { /// Creates a TransferMemory object static ResultCode CreateTransferMemory(Handle* handle, VAddr addr, u64 size, u32 permissions) { - LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, - size, permissions); + LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x{:X}, size=0x{:X}, perms=0x{:08X}", addr, size, + permissions); *handle = 0; return RESULT_SUCCESS; } @@ -791,7 +788,7 @@ static ResultCode GetThreadCoreMask(Handle thread_handle, u32* core, u64* mask) static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, mask=0x{:16X}, core=0x{:X}", thread_handle, - mask, core); + mask, core); const SharedPtr thread = g_handle_table.Get(thread_handle); if (!thread) { @@ -831,7 +828,7 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { static ResultCode CreateSharedMemory(Handle* handle, u64 size, u32 local_permissions, u32 remote_permissions) { LOG_TRACE(Kernel_SVC, "called, size=0x{:X}, localPerms=0x{:08X}, remotePerms=0x{:08X}", size, - local_permissions, remote_permissions); + local_permissions, remote_permissions); auto sharedMemHandle = SharedMemory::Create(g_handle_table.Get(KernelHandle::CurrentProcess), size, static_cast(local_permissions), diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 01c346520..9a9746585 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -344,7 +344,7 @@ ResultVal> Thread::Create(std::string name, VAddr entry_point, if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) { LOG_ERROR(Kernel_SVC, - "Not enough space in region to allocate a new TLS page for thread"); + "Not enough space in region to allocate a new TLS page for thread"); return ERR_OUT_OF_MEMORY; } diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index e05aa5931..034dd490e 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -243,11 +243,11 @@ void VMManager::LogLayout() const { for (const auto& p : vma_map) { const VirtualMemoryArea& vma = p.second; LOG_DEBUG(Kernel, "{:016X} - {:016X} size: {:016X} {}{}{} {}", vma.base, - vma.base + vma.size, vma.size, - (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-', - (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-', - (u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-', - GetMemoryStateName(vma.meminfo_state)); + vma.base + vma.size, vma.size, + (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-', + (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-', + (u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-', + GetMemoryStateName(vma.meminfo_state)); } } diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp index cf43949ec..751d73f8d 100644 --- a/src/core/hle/service/apm/interface.cpp +++ b/src/core/hle/service/apm/interface.cpp @@ -30,7 +30,7 @@ private: rb.Push(RESULT_SUCCESS); LOG_WARNING(Service_APM, "(STUBBED) called mode={} config={}", static_cast(mode), - config); + config); } void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 8046aa5de..f58b518b6 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -25,8 +25,8 @@ ResultCode RegisterFileSystem(std::unique_ptr&& fact ASSERT_MSG(inserted, "Tried to register more than one system with same id code"); auto& filesystem = result.first->second; - LOG_DEBUG(Service_FS, "Registered file system {} with id code 0x{:08X}", - filesystem->GetName(), static_cast(type)); + LOG_DEBUG(Service_FS, "Registered file system {} with id code 0x{:08X}", filesystem->GetName(), + static_cast(type)); return RESULT_SUCCESS; } diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index af216e521..c39d5a164 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp @@ -21,8 +21,8 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform) { VAddr addr = nvmap_dev->GetObjectAddress(buffer_handle); LOG_WARNING(Service, - "Drawing from address {:X} offset {:08X} Width {} Height {} Stride {} Format {}", - addr, offset, width, height, stride, format); + "Drawing from address {:X} offset {:08X} Width {} Height {} Stride {} Format {}", + addr, offset, width, height, stride, format); using PixelFormat = Tegra::FramebufferConfig::PixelFormat; const Tegra::FramebufferConfig framebuffer{ diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 6b9a4f7c1..57b128b40 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -15,7 +15,7 @@ namespace Service::Nvidia::Devices { u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector& input, std::vector& output) { LOG_DEBUG(Service_NVDRV, "called, command=0x{:08X}, input_size=0x{:X}, output_size=0x{:X}", - command.raw, input.size(), output.size()); + command.raw, input.size(), output.size()); switch (static_cast(command.raw)) { case IoctlCommand::IocInitalizeExCommand: @@ -50,7 +50,7 @@ u32 nvhost_as_gpu::AllocateSpace(const std::vector& input, std::vector& IoctlAllocSpace params{}; std::memcpy(¶ms, input.data(), input.size()); LOG_DEBUG(Service_NVDRV, "called, pages={:X}, page_size={:X}, flags={:X}", params.pages, - params.page_size, params.flags); + params.page_size, params.flags); auto& gpu = Core::System::GetInstance().GPU(); const u64 size{static_cast(params.pages) * static_cast(params.page_size)}; @@ -76,7 +76,7 @@ u32 nvhost_as_gpu::Remap(const std::vector& input, std::vector& output) for (const auto& entry : entries) { LOG_WARNING(Service_NVDRV, "remap entry, offset=0x{:X} handle=0x{:X} pages=0x{:X}", - entry.offset, entry.nvmap_handle, entry.pages); + entry.offset, entry.nvmap_handle, entry.pages); Tegra::GPUVAddr offset = static_cast(entry.offset) << 0x10; auto object = nvmap_dev->GetObject(entry.nvmap_handle); @@ -99,10 +99,10 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector& input, std::vector& ou std::memcpy(¶ms, input.data(), input.size()); LOG_DEBUG(Service_NVDRV, - "called, flags={:X}, nvmap_handle={:X}, buffer_offset={}, mapping_size={}" - ", offset={}", - params.flags, params.nvmap_handle, params.buffer_offset, params.mapping_size, - params.offset); + "called, flags={:X}, nvmap_handle={:X}, buffer_offset={}, mapping_size={}" + ", offset={}", + params.flags, params.nvmap_handle, params.buffer_offset, params.mapping_size, + params.offset); if (!params.nvmap_handle) { return 0; @@ -179,7 +179,7 @@ u32 nvhost_as_gpu::GetVARegions(const std::vector& input, std::vector& o IoctlGetVaRegions params{}; std::memcpy(¶ms, input.data(), input.size()); LOG_WARNING(Service_NVDRV, "(STUBBED) called, buf_addr={:X}, buf_size={:X}", params.buf_addr, - params.buf_size); + params.buf_size); params.buf_size = 0x30; params.regions[0].offset = 0x04000000; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index b7d8233ad..303acdcb3 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -10,7 +10,7 @@ namespace Service::Nvidia::Devices { u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector& input, std::vector& output) { LOG_DEBUG(Service_NVDRV, "called, command=0x{:08X}, input_size=0x{:X}, output_size=0x{:X}", - command.raw, input.size(), output.size()); + command.raw, input.size(), output.size()); switch (static_cast(command.raw)) { case IoctlCommand::IocGetConfigCommand: @@ -30,7 +30,7 @@ u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector& input, std::vector& IocGetConfigParams params{}; std::memcpy(¶ms, input.data(), sizeof(params)); LOG_DEBUG(Service_NVDRV, "called, setting={}!{}", params.domain_str.data(), - params.param_str.data()); + params.param_str.data()); if (!strcmp(params.domain_str.data(), "nv")) { if (!strcmp(params.param_str.data(), "NV_MEMORY_PROFILER")) { @@ -54,8 +54,8 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& IocCtrlEventWaitParams params{}; std::memcpy(¶ms, input.data(), sizeof(params)); LOG_WARNING(Service_NVDRV, - "(STUBBED) called, syncpt_id={}, threshold={}, timeout={}, is_async={}", - params.syncpt_id, params.threshold, params.timeout, is_async); + "(STUBBED) called, syncpt_id={}, threshold={}, timeout={}, is_async={}", + params.syncpt_id, params.threshold, params.timeout, is_async); // TODO(Subv): Implement actual syncpt waiting. params.value = 0; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index b595d6e83..44e062f50 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp @@ -11,7 +11,7 @@ namespace Service::Nvidia::Devices { u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector& input, std::vector& output) { LOG_DEBUG(Service_NVDRV, "called, command=0x{:08X}, input_size=0x{:X}, output_size=0x{:X}", - command.raw, input.size(), output.size()); + command.raw, input.size(), output.size()); switch (static_cast(command.raw)) { case IoctlCommand::IocGetCharacteristicsCommand: @@ -84,7 +84,7 @@ u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector& input, std::vector& IoctlGpuGetTpcMasksArgs params{}; std::memcpy(¶ms, input.data(), input.size()); LOG_INFO(Service_NVDRV, "called, mask=0x{:X}, mask_buf_addr=0x{:X}", params.mask_buf_size, - params.mask_buf_addr); + params.mask_buf_addr); // TODO(ogniK): Confirm value on hardware if (params.mask_buf_size) params.tpc_mask_size = 4 * 1; // 4 * num_gpc diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 2812e029e..8de870596 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices { u32 nvhost_gpu::ioctl(Ioctl command, const std::vector& input, std::vector& output) { LOG_DEBUG(Service_NVDRV, "called, command=0x{:08X}, input_size=0x{:X}, output_size=0x{:X}", - command.raw, input.size(), output.size()); + command.raw, input.size(), output.size()); switch (static_cast(command.raw)) { case IoctlCommand::IocSetNVMAPfdCommand: @@ -76,7 +76,7 @@ u32 nvhost_gpu::GetClientData(const std::vector& input, std::vector& out u32 nvhost_gpu::ZCullBind(const std::vector& input, std::vector& output) { std::memcpy(&zcull_params, input.data(), input.size()); LOG_DEBUG(Service_NVDRV, "called, gpu_va={:X}, mode={:X}", zcull_params.gpu_va, - zcull_params.mode); + zcull_params.mode); std::memcpy(output.data(), &zcull_params, output.size()); return 0; } @@ -84,8 +84,8 @@ u32 nvhost_gpu::ZCullBind(const std::vector& input, std::vector& output) u32 nvhost_gpu::SetErrorNotifier(const std::vector& input, std::vector& output) { IoctlSetErrorNotifier params{}; std::memcpy(¶ms, input.data(), input.size()); - LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset={:X}, size={:X}, mem={:X}", - params.offset, params.size, params.mem); + LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset={:X}, size={:X}, mem={:X}", params.offset, + params.size, params.mem); std::memcpy(output.data(), ¶ms, output.size()); return 0; } @@ -100,10 +100,10 @@ u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector& input, std::vector& ou IoctlAllocGpfifoEx2 params{}; std::memcpy(¶ms, input.data(), input.size()); LOG_WARNING(Service_NVDRV, - "(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, " - "unk1={:X}, unk2={:X}, unk3={:X}", - params.num_entries, params.flags, params.unk0, params.unk1, params.unk2, - params.unk3); + "(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, " + "unk1={:X}, unk2={:X}, unk3={:X}", + params.num_entries, params.flags, params.unk0, params.unk1, params.unk2, + params.unk3); params.fence_out.id = 0; params.fence_out.value = 0; std::memcpy(output.data(), ¶ms, output.size()); @@ -114,7 +114,7 @@ u32 nvhost_gpu::AllocateObjectContext(const std::vector& input, std::vector< IoctlAllocObjCtx params{}; std::memcpy(¶ms, input.data(), input.size()); LOG_WARNING(Service_NVDRV, "(STUBBED) called, class_num={:X}, flags={:X}", params.class_num, - params.flags); + params.flags); params.obj_id = 0x0; std::memcpy(output.data(), ¶ms, output.size()); return 0; @@ -127,7 +127,7 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector& input, std::vector& outp IoctlSubmitGpfifo params{}; std::memcpy(¶ms, input.data(), sizeof(IoctlSubmitGpfifo)); LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo={:X}, num_entries={:X}, flags={:X}", - params.gpfifo, params.num_entries, params.flags); + params.gpfifo, params.num_entries, params.flags); auto entries = std::vector(); entries.resize(params.num_entries); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index 313c50ef5..b51c73ee8 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp @@ -10,7 +10,7 @@ namespace Service::Nvidia::Devices { u32 nvhost_nvdec::ioctl(Ioctl command, const std::vector& input, std::vector& output) { LOG_DEBUG(Service_NVDRV, "called, command=0x{:08X}, input_size=0x{:X}, output_size=0x{:X}", - command.raw, input.size(), output.size()); + command.raw, input.size(), output.size()); switch (static_cast(command.raw)) { case IoctlCommand::IocSetNVMAPfdCommand: diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index ae4d4d32c..f22a2a79f 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -102,8 +102,7 @@ void SM::GetService(Kernel::HLERequestContext& ctx) { if (client_port.Failed()) { IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0); rb.Push(client_port.Code()); - LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, - client_port.Code().raw); + LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, client_port.Code().raw); if (name.length() == 0) return; // LibNX Fix UNIMPLEMENTED(); diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index f03666089..32648bdd9 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -32,8 +32,7 @@ void BSD::Socket(Kernel::HLERequestContext& ctx) { u32 type = rp.Pop(); u32 protocol = rp.Pop(); - LOG_WARNING(Service, "(STUBBED) called domain={} type={} protocol={}", domain, type, - protocol); + LOG_WARNING(Service, "(STUBBED) called domain={} type={} protocol={}", domain, type, protocol); u32 fd = next_fd++; diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index dbd09d07d..f3765b555 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -548,7 +548,7 @@ private: u32 type = rp.Pop(); LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={:08X}, type={:08X}", id, addval, - type); + type); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } @@ -641,7 +641,7 @@ private: IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0); rb.Push(RESULT_SUCCESS); LOG_WARNING(Service_VI, "(STUBBED) called, layer_id=0x{:08X}, visibility={}", layer_id, - visibility); + visibility); } }; @@ -763,7 +763,7 @@ private: IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0); rb.Push(RESULT_SUCCESS); LOG_WARNING(Service_VI, "(STUBBED) called, layer_id=0x{:X}, visibility={}", layer_id, - visibility); + visibility); } std::shared_ptr nv_flinger; diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index c984ef852..b69e5c6ef 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp @@ -305,7 +305,7 @@ SharedPtr ElfReader::LoadInto(u32 vaddr) { for (unsigned int i = 0; i < header->e_phnum; ++i) { Elf32_Phdr* p = &segments[i]; LOG_DEBUG(Loader, "Type: {} Vaddr: {:08X} Filesz: {:08X} Memsz: {:08X} ", p->p_type, - p->p_vaddr, p->p_filesz, p->p_memsz); + p->p_vaddr, p->p_filesz, p->p_memsz); if (p->p_type == PT_LOAD) { CodeSet::Segment* codeset_segment; @@ -318,15 +318,15 @@ SharedPtr ElfReader::LoadInto(u32 vaddr) { codeset_segment = &codeset->data; } else { LOG_ERROR(Loader, "Unexpected ELF PT_LOAD segment id {} with flags {:X}", i, - p->p_flags); + p->p_flags); continue; } if (codeset_segment->size != 0) { LOG_ERROR(Loader, - "ELF has more than one segment of the same type. Skipping extra " - "segment (id {})", - i); + "ELF has more than one segment of the same type. Skipping extra " + "segment (id {})", + i); continue; } diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 103ff0b77..190ccc25c 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -44,7 +44,7 @@ PageTable* GetCurrentPageTable() { static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { LOG_DEBUG(HW_Memory, "Mapping {} onto {:016X}-{:016X}", fmt::ptr(memory), base * PAGE_SIZE, - (base + size) * PAGE_SIZE); + (base + size) * PAGE_SIZE); RasterizerFlushVirtualRegion(base << PAGE_BITS, size * PAGE_SIZE, FlushMode::FlushAndInvalidate); @@ -206,7 +206,7 @@ void Write(const VAddr vaddr, const T data) { switch (type) { case PageType::Unmapped: LOG_ERROR(HW_Memory, "Unmapped Write{} 0x{:08X} @ 0x{:016X}", sizeof(data) * 8, - static_cast(data), vaddr); + static_cast(data), vaddr); return; case PageType::Memory: ASSERT_MSG(false, "Mapped memory page without a pointer @ {:016X}", vaddr); @@ -349,8 +349,8 @@ void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached) // The GPU <-> CPU virtual memory mapping is not 1:1 if (!maybe_vaddr) { LOG_ERROR(HW_Memory, - "Trying to flush a cached region to an invalid physical address {:016X}", - gpu_addr); + "Trying to flush a cached region to an invalid physical address {:016X}", + gpu_addr); continue; } VAddr vaddr = *maybe_vaddr; @@ -485,8 +485,8 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_ switch (page_table.attributes[page_index]) { case PageType::Unmapped: { LOG_ERROR(HW_Memory, - "Unmapped ReadBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", - current_vaddr, src_addr, size); + "Unmapped ReadBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", + current_vaddr, src_addr, size); std::memset(dest_buffer, 0, copy_amount); break; } @@ -549,8 +549,8 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi switch (page_table.attributes[page_index]) { case PageType::Unmapped: { LOG_ERROR(HW_Memory, - "Unmapped WriteBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", - current_vaddr, dest_addr, size); + "Unmapped WriteBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", + current_vaddr, dest_addr, size); break; } case PageType::Memory: { @@ -597,8 +597,8 @@ void ZeroBlock(const Kernel::Process& process, const VAddr dest_addr, const size switch (page_table.attributes[page_index]) { case PageType::Unmapped: { LOG_ERROR(HW_Memory, - "Unmapped ZeroBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", - current_vaddr, dest_addr, size); + "Unmapped ZeroBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", + current_vaddr, dest_addr, size); break; } case PageType::Memory: { @@ -638,8 +638,8 @@ void CopyBlock(const Kernel::Process& process, VAddr dest_addr, VAddr src_addr, switch (page_table.attributes[page_index]) { case PageType::Unmapped: { LOG_ERROR(HW_Memory, - "Unmapped CopyBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", - current_vaddr, src_addr, size); + "Unmapped CopyBlock @ 0x{:016X} (start address = 0x{:016X}, size = {})", + current_vaddr, src_addr, size); ZeroBlock(process, dest_addr, copy_amount); break; } diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 98b33c201..31ea3adad 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -30,9 +30,9 @@ enum class BufferMethods { void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) { LOG_WARNING(HW_GPU, - "Processing method {:08X} on subchannel {} value " - "{:08X} remaining params {}", - method, subchannel, value, remaining_params); + "Processing method {:08X} on subchannel {} value " + "{:08X} remaining params {}", + method, subchannel, value, remaining_params); if (method == static_cast(BufferMethods::BindObject)) { // Bind the current subchannel to the desired engine id. diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index f9cbab8e2..34053e393 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp @@ -27,7 +27,7 @@ void Fermi2D::WriteReg(u32 method, u32 value) { void Fermi2D::HandleSurfaceCopy() { LOG_WARNING(HW_GPU, "Requested a surface copy with operation {}", - static_cast(regs.operation)); + static_cast(regs.operation)); const GPUVAddr source = regs.src.Address(); const GPUVAddr dest = regs.dst.Address(); diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index bbd34f060..9b209a49e 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -207,8 +207,8 @@ void Maxwell3D::ProcessQueryGet() { } void Maxwell3D::DrawArrays() { - LOG_DEBUG(HW_GPU, "called, topology={}, count={}", - static_cast(regs.draw.topology.Value()), regs.vertex_buffer.count); + LOG_DEBUG(HW_GPU, "called, topology={}, count={}", static_cast(regs.draw.topology.Value()), + regs.vertex_buffer.count); ASSERT_MSG(!(regs.index_array.count && regs.vertex_buffer.count), "Both indexed and direct?"); auto debug_context = Core::System::GetInstance().GetGPUDebugContext(); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 99282dac3..7c71f890b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -166,8 +166,8 @@ std::pair RasterizerOpenGL::SetupVertexArrays(u8* array_ptr, for (unsigned index = 0; index < 16; ++index) { auto& attrib = regs.vertex_attrib_format[index]; LOG_DEBUG(HW_GPU, "vertex attrib {}, count={}, size={}, type={}, offset={}, normalize={}", - index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(), - attrib.offset.Value(), attrib.IsNormalized()); + index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(), + attrib.offset.Value(), attrib.IsNormalized()); auto& buffer = regs.vertex_array[attrib.buffer]; ASSERT(buffer.IsEnabled()); @@ -251,8 +251,8 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset) { break; } default: - LOG_CRITICAL(HW_GPU, "Unimplemented shader index={}, enable={}, offset=0x{:08X}", - index, shader_config.enable.Value(), shader_config.offset); + LOG_CRITICAL(HW_GPU, "Unimplemented shader index={}, enable={}, offset=0x{:08X}", index, + shader_config.enable.Value(), shader_config.offset); UNREACHABLE(); } @@ -588,7 +588,7 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr if (size > MaxConstbufferSize) { LOG_ERROR(HW_GPU, "indirect constbuffer size {} exceeds maximum {}", size, - MaxConstbufferSize); + MaxConstbufferSize); size = MaxConstbufferSize; } } else { diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 2e801cdf6..2901280a1 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -919,7 +919,7 @@ private: break; default: LOG_CRITICAL(HW_GPU, "Unhandled MUFU sub op: {0:x}", - static_cast(instr.sub_op.Value())); + static_cast(instr.sub_op.Value())); UNREACHABLE(); } break; @@ -1059,7 +1059,7 @@ private: } default: { LOG_CRITICAL(HW_GPU, "Unhandled ArithmeticIntegerImmediate instruction: {}", - opcode->GetName()); + opcode->GetName()); UNREACHABLE(); } } @@ -1125,7 +1125,7 @@ private: } default: { LOG_CRITICAL(HW_GPU, "Unhandled ArithmeticInteger instruction: {}", - opcode->GetName()); + opcode->GetName()); UNREACHABLE(); } } @@ -1220,7 +1220,7 @@ private: break; default: LOG_CRITICAL(HW_GPU, "Unimplemented f2f rounding mode {}", - static_cast(instr.conversion.f2f.rounding.Value())); + static_cast(instr.conversion.f2f.rounding.Value())); UNREACHABLE(); break; } @@ -1254,7 +1254,7 @@ private: break; default: LOG_CRITICAL(HW_GPU, "Unimplemented f2i rounding mode {}", - static_cast(instr.conversion.f2i.rounding.Value())); + static_cast(instr.conversion.f2i.rounding.Value())); UNREACHABLE(); break; } @@ -1306,7 +1306,7 @@ private: default: LOG_CRITICAL(HW_GPU, "Unhandled type: {}", - static_cast(instr.ld_c.type.Value())); + static_cast(instr.ld_c.type.Value())); UNREACHABLE(); } break; diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h index 1913397e4..6b9bb3df1 100644 --- a/src/video_core/renderer_opengl/maxwell_to_gl.h +++ b/src/video_core/renderer_opengl/maxwell_to_gl.h @@ -91,7 +91,7 @@ inline GLenum TextureFilterMode(Tegra::Texture::TextureFilter filter_mode) { return GL_NEAREST; } LOG_CRITICAL(Render_OpenGL, "Unimplemented texture filter mode={}", - static_cast(filter_mode)); + static_cast(filter_mode)); UNREACHABLE(); return {}; } @@ -110,8 +110,7 @@ inline GLenum WrapMode(Tegra::Texture::WrapMode wrap_mode) { // manually mix them. However the shader part of this is not yet implemented. return GL_CLAMP_TO_BORDER; } - LOG_CRITICAL(Render_OpenGL, "Unimplemented texture wrap mode={}", - static_cast(wrap_mode)); + LOG_CRITICAL(Render_OpenGL, "Unimplemented texture wrap mode={}", static_cast(wrap_mode)); UNREACHABLE(); return {}; } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index af5b480a3..00841e937 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -302,7 +302,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x, } else { // Other transformations are unsupported LOG_CRITICAL(Render_OpenGL, "Unsupported framebuffer_transform_flags={}", - static_cast(framebuffer_transform_flags)); + static_cast(framebuffer_transform_flags)); UNIMPLEMENTED(); } } diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 6f53b63c1..5a708dc73 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -325,8 +325,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { void GameList::PopulateAsync(const QString& dir_path, bool deep_scan) { if (!FileUtil::Exists(dir_path.toStdString()) || !FileUtil::IsDirectory(dir_path.toStdString())) { - LOG_ERROR(Frontend, "Could not find game list folder at {}", - dir_path.toLocal8Bit().data()); + LOG_ERROR(Frontend, "Could not find game list folder at {}", dir_path.toLocal8Bit().data()); search_field->setFilterResult(0, 0); return; } diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 91b024819..079f93736 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -160,9 +160,9 @@ int main(int argc, char** argv) { return -1; case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted: LOG_CRITICAL(Frontend, "The game that you are trying to load must be decrypted before " - "being used with yuzu. \n\n For more information on dumping and " - "decrypting games, please refer to: " - "https://yuzu-emu.org/wiki/dumping-game-cartridges/"); + "being used with yuzu. \n\n For more information on dumping and " + "decrypting games, please refer to: " + "https://yuzu-emu.org/wiki/dumping-game-cartridges/"); return -1; case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat: LOG_CRITICAL(Frontend, "Error while loading ROM: The ROM format is not supported."); -- cgit v1.2.3 From 6269a01b4e9963ffdaf98ddf5d5f2a90d49e58ff Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 2 Jul 2018 11:10:41 -0600 Subject: Add configurable logging backends --- src/common/common_paths.h | 3 + src/common/file_util.cpp | 17 +++- src/common/file_util.h | 11 +- src/common/logging/backend.cpp | 157 +++++++++++++++++++++++++++-- src/common/logging/backend.h | 87 +++++++++++++++- src/yuzu/CMakeLists.txt | 10 ++ src/yuzu/configuration/config.cpp | 3 +- src/yuzu/configuration/configure_debug.cpp | 22 ++++ src/yuzu/configuration/configure_debug.ui | 41 ++++++++ src/yuzu/debugger/console.cpp | 45 +++++++++ src/yuzu/debugger/console.h | 14 +++ src/yuzu/main.cpp | 10 +- src/yuzu/ui_settings.h | 3 + src/yuzu_cmd/yuzu.cpp | 7 +- 14 files changed, 408 insertions(+), 22 deletions(-) create mode 100644 src/yuzu/debugger/console.cpp create mode 100644 src/yuzu/debugger/console.h (limited to 'src/common') diff --git a/src/common/common_paths.h b/src/common/common_paths.h index 0a6132dab..d03fca314 100644 --- a/src/common/common_paths.h +++ b/src/common/common_paths.h @@ -32,12 +32,15 @@ #define SDMC_DIR "sdmc" #define NAND_DIR "nand" #define SYSDATA_DIR "sysdata" +#define LOG_DIR "log" // Filenames // Files in the directory returned by GetUserPath(D_CONFIG_IDX) #define EMU_CONFIG "emu.ini" #define DEBUGGER_CONFIG "debugger.ini" #define LOGGER_CONFIG "logger.ini" +// Files in the directory returned by GetUserPath(D_LOGS_IDX) +#define LOG_FILE "citra_log.txt" // Sys files #define SHARED_FONT "shared_font.bin" diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 2152e3fea..b9e1fd1f6 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -713,6 +713,8 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; paths[D_NAND_IDX] = paths[D_USER_IDX] + NAND_DIR DIR_SEP; paths[D_SYSDATA_IDX] = paths[D_USER_IDX] + SYSDATA_DIR DIR_SEP; + // TODO: Put the logs in a better location for each OS + paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOG_DIR DIR_SEP; } if (!newPath.empty()) { @@ -799,8 +801,8 @@ void SplitFilename83(const std::string& filename, std::array& short_nam IOFile::IOFile() {} -IOFile::IOFile(const std::string& filename, const char openmode[]) { - Open(filename, openmode); +IOFile::IOFile(const std::string& filename, const char openmode[], int flags) { + Open(filename, openmode, flags); } IOFile::~IOFile() { @@ -821,11 +823,16 @@ void IOFile::Swap(IOFile& other) noexcept { std::swap(m_good, other.m_good); } -bool IOFile::Open(const std::string& filename, const char openmode[]) { +bool IOFile::Open(const std::string& filename, const char openmode[], int flags) { Close(); #ifdef _WIN32 - _wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), - Common::UTF8ToUTF16W(openmode).c_str()); + if (flags != 0) { + m_file = _wfsopen(Common::UTF8ToUTF16W(filename).c_str(), + Common::UTF8ToUTF16W(openmode).c_str(), flags); + } else { + _wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), + Common::UTF8ToUTF16W(openmode).c_str()); + } #else m_file = fopen(filename.c_str(), openmode); #endif diff --git a/src/common/file_util.h b/src/common/file_util.h index fc6b3ea46..5bc7fbf7c 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -156,7 +156,10 @@ void SplitFilename83(const std::string& filename, std::array& short_nam class IOFile : public NonCopyable { public: IOFile(); - IOFile(const std::string& filename, const char openmode[]); + // flags is used for windows specific file open mode flags, which + // allows yuzu to open the logs in shared write mode, so that the file + // isn't considered "locked" while yuzu is open and people can open the log file and view it + IOFile(const std::string& filename, const char openmode[], int flags = 0); ~IOFile(); @@ -165,7 +168,7 @@ public: void Swap(IOFile& other) noexcept; - bool Open(const std::string& filename, const char openmode[]); + bool Open(const std::string& filename, const char openmode[], int flags = 0); bool Close(); template @@ -220,6 +223,10 @@ public: return WriteArray(&object, 1); } + size_t WriteString(const std::string& str) { + return WriteArray(str.c_str(), str.length()); + } + bool IsOpen() const { return nullptr != m_file; } diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index c26b20062..242914c6a 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -2,16 +2,145 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include +#include +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include // For _SH_DENYWR +#else +#define _SH_DENYWR 0 +#endif #include "common/assert.h" +#include "common/common_funcs.h" // snprintf compatibility define #include "common/logging/backend.h" -#include "common/logging/filter.h" #include "common/logging/log.h" #include "common/logging/text_formatter.h" #include "common/string_util.h" +#include "common/threadsafe_queue.h" namespace Log { +/** + * Static state as a singleton. + */ +class Impl { +public: + static Impl& Instance() { + static Impl backend; + return backend; + } + + Impl(Impl const&) = delete; + const Impl& operator=(Impl const&) = delete; + + void PushEntry(Entry e) { + std::lock_guard lock(message_mutex); + message_queue.Push(std::move(e)); + message_cv.notify_one(); + } + + void AddBackend(std::unique_ptr backend) { + std::lock_guard lock(writing_mutex); + backends.push_back(std::move(backend)); + } + + void RemoveBackend(const std::string& backend_name) { + std::lock_guard lock(writing_mutex); + auto it = std::remove_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { + return !strcmp(i->GetName(), backend_name.c_str()); + }); + backends.erase(it, backends.end()); + } + + const Filter& GetGlobalFilter() const { + return filter; + } + + void SetGlobalFilter(const Filter& f) { + filter = f; + } + + Backend* GetBackend(const std::string& backend_name) { + auto it = std::find_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { + return !strcmp(i->GetName(), backend_name.c_str()); + }); + if (it == backends.end()) + return nullptr; + return it->get(); + } + +private: + Impl() { + backend_thread = std::thread([&] { + Entry entry; + auto write_logs = [&](Entry& e) { + std::lock_guard lock(writing_mutex); + for (const auto& backend : backends) { + backend->Write(e); + } + }; + while (true) { + std::unique_lock lock(message_mutex); + message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); }); + if (!running) { + break; + } + write_logs(entry); + } + // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case + // where a system is repeatedly spamming logs even on close. + constexpr int MAX_LOGS_TO_WRITE = 100; + int logs_written = 0; + while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) { + write_logs(entry); + } + }); + } + + ~Impl() { + running = false; + message_cv.notify_one(); + backend_thread.join(); + } + + std::atomic_bool running{true}; + std::mutex message_mutex, writing_mutex; + std::condition_variable message_cv; + std::thread backend_thread; + std::vector> backends; + Common::MPSCQueue message_queue; + Filter filter; +}; + +void ConsoleBackend::Write(const Entry& entry) { + PrintMessage(entry); +} + +void ColorConsoleBackend::Write(const Entry& entry) { + PrintColoredMessage(entry); +} + +// _SH_DENYWR allows read only access to the file for other programs. +// It is #defined to 0 on other platforms +FileBackend::FileBackend(const std::string& filename) + : file(filename, "w", _SH_DENYWR), bytes_written(0) {} + +void FileBackend::Write(const Entry& entry) { + // prevent logs from going over the maximum size (in case its spamming and the user doesn't + // know) + constexpr size_t MAX_BYTES_WRITTEN = 50 * 1024L * 1024L; + if (!file.IsOpen() || bytes_written > MAX_BYTES_WRITTEN) { + return; + } + bytes_written += file.WriteString(FormatLogMessage(entry) + '\n'); + if (entry.log_level >= Level::Error) { + file.Flush(); + } +} + /// Macro listing all log classes. Code should define CLS and SUB as desired before invoking this. #define ALL_LOG_CLASSES() \ CLS(Log) \ @@ -125,20 +254,32 @@ Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsign return entry; } -static Filter* filter = nullptr; +void SetGlobalFilter(const Filter& filter) { + Impl::Instance().SetGlobalFilter(filter); +} + +void AddBackend(std::unique_ptr backend) { + Impl::Instance().AddBackend(std::move(backend)); +} -void SetFilter(Filter* new_filter) { - filter = new_filter; +void RemoveBackend(const std::string& backend_name) { + Impl::Instance().RemoveBackend(backend_name); +} + +Backend* GetBackend(const std::string& backend_name) { + return Impl::Instance().GetBackend(backend_name); } void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, const char* format, const fmt::format_args& args) { - if (filter && !filter->CheckMessage(log_class, log_level)) + auto filter = Impl::Instance().GetGlobalFilter(); + if (!filter.CheckMessage(log_class, log_level)) return; + Entry entry = CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args)); - PrintColoredMessage(entry); + Impl::Instance().PushEntry(std::move(entry)); } -} // namespace Log +} // namespace Log \ No newline at end of file diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index 7e81efb23..57cdf6b2d 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -1,13 +1,15 @@ // Copyright 2014 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. - #pragma once #include #include +#include #include #include +#include "common/file_util.h" +#include "common/logging/filter.h" #include "common/logging/log.h" namespace Log { @@ -34,6 +36,80 @@ struct Entry { Entry& operator=(const Entry& o) = default; }; +/** + * Interface for logging backends. As loggers can be created and removed at runtime, this can be + * used by a frontend for adding a custom logging backend as needed + */ +class Backend { +public: + virtual ~Backend() = default; + virtual void SetFilter(const Filter& new_filter) { + filter = new_filter; + } + virtual const char* GetName() const = 0; + virtual void Write(const Entry& entry) = 0; + +private: + Filter filter; +}; + +/** + * Backend that writes to stderr without any color commands + */ +class ConsoleBackend : public Backend { +public: + static const char* Name() { + return "console"; + } + const char* GetName() const override { + return Name(); + } + void Write(const Entry& entry) override; +}; + +/** + * Backend that writes to stderr and with color + */ +class ColorConsoleBackend : public Backend { +public: + static const char* Name() { + return "color_console"; + } + + const char* GetName() const override { + return Name(); + } + void Write(const Entry& entry) override; +}; + +/** + * Backend that writes to a file passed into the constructor + */ +class FileBackend : public Backend { +public: + explicit FileBackend(const std::string& filename); + + static const char* Name() { + return "file"; + } + + const char* GetName() const override { + return Name(); + } + + void Write(const Entry& entry) override; + +private: + FileUtil::IOFile file; + size_t bytes_written; +}; + +void AddBackend(std::unique_ptr backend); + +void RemoveBackend(const std::string& backend_name); + +Backend* GetBackend(const std::string& backend_name); + /** * Returns the name of the passed log class as a C-string. Subclasses are separated by periods * instead of underscores as in the enumeration. @@ -49,5 +125,10 @@ const char* GetLevelName(Level log_level); Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, const char* function, std::string message); -void SetFilter(Filter* filter); -} // namespace Log +/** + * The global filter will prevent any messages from even being processed if they are filtered. Each + * backend can have a filter, but if the level is lower than the global filter, the backend will + * never get the message + */ +void SetGlobalFilter(const Filter& filter); +} // namespace Log \ No newline at end of file diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index c662570d2..7de919a8e 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -30,6 +30,8 @@ add_executable(yuzu debugger/graphics/graphics_breakpoints_p.h debugger/graphics/graphics_surface.cpp debugger/graphics/graphics_surface.h + debugger/console.cpp + debugger/console.h debugger/profiler.cpp debugger/profiler.h debugger/wait_tree.cpp @@ -81,6 +83,14 @@ if (APPLE) target_sources(yuzu PRIVATE ${MACOSX_ICON}) set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE TRUE) set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) +elseif(WIN32) + # compile as a win32 gui application instead of a console application + target_link_libraries(yuzu PRIVATE Qt5::WinMain) + if(MSVC) + set_target_properties(yuzu PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") + elseif(MINGW) + set_target_properties(yuzu PROPERTIES LINK_FLAGS_RELEASE "-mwindows") + endif() endif() create_target_directory_groups(yuzu) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index cd7986efa..a32134fbe 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -160,6 +160,7 @@ void Config::ReadValues() { UISettings::values.confirm_before_closing = qt_config->value("confirmClose", true).toBool(); UISettings::values.first_start = qt_config->value("firstStart", true).toBool(); UISettings::values.callout_flags = qt_config->value("calloutFlags", 0).toUInt(); + UISettings::values.show_console = qt_config->value("showConsole", false).toBool(); qt_config->endGroup(); } @@ -246,7 +247,7 @@ void Config::SaveValues() { qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing); qt_config->setValue("firstStart", UISettings::values.first_start); qt_config->setValue("calloutFlags", UISettings::values.callout_flags); - + qt_config->setValue("showConsole", UISettings::values.show_console); qt_config->endGroup(); } diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index a45edd510..241db4ae3 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -2,13 +2,26 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include "common/file_util.h" +#include "common/logging/backend.h" +#include "common/logging/filter.h" +#include "common/logging/log.h" +#include "core/core.h" #include "core/settings.h" #include "ui_configure_debug.h" #include "yuzu/configuration/configure_debug.h" +#include "yuzu/debugger/console.h" +#include "yuzu/ui_settings.h" ConfigureDebug::ConfigureDebug(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureDebug) { ui->setupUi(this); this->setConfiguration(); + connect(ui->open_log_button, &QPushButton::pressed, []() { + QString path = QString::fromStdString(FileUtil::GetUserPath(D_LOGS_IDX)); + QDesktopServices::openUrl(QUrl::fromLocalFile(path)); + }); } ConfigureDebug::~ConfigureDebug() {} @@ -17,10 +30,19 @@ void ConfigureDebug::setConfiguration() { ui->toggle_gdbstub->setChecked(Settings::values.use_gdbstub); ui->gdbport_spinbox->setEnabled(Settings::values.use_gdbstub); ui->gdbport_spinbox->setValue(Settings::values.gdbstub_port); + ui->toggle_console->setEnabled(!Core::System::GetInstance().IsPoweredOn()); + ui->toggle_console->setChecked(UISettings::values.show_console); + ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter)); } void ConfigureDebug::applyConfiguration() { Settings::values.use_gdbstub = ui->toggle_gdbstub->isChecked(); Settings::values.gdbstub_port = ui->gdbport_spinbox->value(); + UISettings::values.show_console = ui->toggle_console->isChecked(); + Settings::values.log_filter = ui->log_filter_edit->text().toStdString(); + Debugger::ToggleConsole(); + Log::Filter filter; + filter.ParseFilterString(Settings::values.log_filter); + Log::SetGlobalFilter(filter); Settings::Apply(); } diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index a10bea2f4..118e91cf1 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -72,6 +72,47 @@ + + + + Logging + + + + + + + + Global Log Filter + + + + + + + + + + + + + + Show Log Console (Windows Only) + + + + + + + Open Log Location + + + + + + + + diff --git a/src/yuzu/debugger/console.cpp b/src/yuzu/debugger/console.cpp new file mode 100644 index 000000000..e3d2d975f --- /dev/null +++ b/src/yuzu/debugger/console.cpp @@ -0,0 +1,45 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#ifdef _WIN32 +#include + +#include +#endif + +#include "common/logging/backend.h" +#include "yuzu/debugger/console.h" +#include "yuzu/ui_settings.h" + +namespace Debugger { +void ToggleConsole() { +#if defined(_WIN32) && !defined(_DEBUG) + FILE* temp; + if (UISettings::values.show_console) { + if (AllocConsole()) { + // The first parameter for freopen_s is a out parameter, so we can just ignore it + freopen_s(&temp, "CONIN$", "r", stdin); + freopen_s(&temp, "CONOUT$", "w", stdout); + freopen_s(&temp, "CONOUT$", "w", stderr); + Log::AddBackend(std::make_unique()); + } + } else { + if (FreeConsole()) { + // In order to close the console, we have to also detach the streams on it. + // Just redirect them to NUL if there is no console window + Log::RemoveBackend(Log::ColorConsoleBackend::Name()); + freopen_s(&temp, "NUL", "r", stdin); + freopen_s(&temp, "NUL", "w", stdout); + freopen_s(&temp, "NUL", "w", stderr); + } + } +#else + if (UISettings::values.show_console) { + Log::AddBackend(std::make_unique()); + } else { + Log::RemoveBackend(Log::ColorConsoleBackend::Name()); + } +#endif +} +} // namespace Debugger diff --git a/src/yuzu/debugger/console.h b/src/yuzu/debugger/console.h new file mode 100644 index 000000000..d1990c496 --- /dev/null +++ b/src/yuzu/debugger/console.h @@ -0,0 +1,14 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Debugger { + +/** + * Uses the WINAPI to hide or show the stderr console. This function is a placeholder until we can + * get a real qt logging window which would work for all platforms. + */ +void ToggleConsole(); +} // namespace Debugger \ No newline at end of file diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 2c52415f9..05a8ae6d2 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -31,6 +31,7 @@ #include "yuzu/bootmanager.h" #include "yuzu/configuration/config.h" #include "yuzu/configuration/configure_dialog.h" +#include "yuzu/debugger/console.h" #include "yuzu/debugger/graphics/graphics_breakpoints.h" #include "yuzu/debugger/graphics/graphics_surface.h" #include "yuzu/debugger/profiler.h" @@ -261,6 +262,7 @@ void GMainWindow::RestoreUIState() { ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar); statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); + Debugger::ToggleConsole(); } void GMainWindow::ConnectWidgetEvents() { @@ -906,8 +908,7 @@ void GMainWindow::UpdateUITheme() { #endif int main(int argc, char* argv[]) { - Log::Filter log_filter(Log::Level::Info); - Log::SetFilter(&log_filter); + Log::AddBackend(std::make_unique()); MicroProfileOnThreadCreate("Frontend"); SCOPE_EXIT({ MicroProfileShutdown(); }); @@ -925,7 +926,12 @@ int main(int argc, char* argv[]) { GMainWindow main_window; // After settings have been loaded by GMainWindow, apply the filter + Log::Filter log_filter; log_filter.ParseFilterString(Settings::values.log_filter); + Log::SetGlobalFilter(log_filter); + FileUtil::CreateFullPath(FileUtil::GetUserPath(D_LOGS_IDX)); + Log::AddBackend( + std::make_unique(FileUtil::GetUserPath(D_LOGS_IDX) + LOG_FILE)); main_window.show(); return app.exec(); diff --git a/src/yuzu/ui_settings.h b/src/yuzu/ui_settings.h index 8e215a002..2286c2559 100644 --- a/src/yuzu/ui_settings.h +++ b/src/yuzu/ui_settings.h @@ -51,6 +51,9 @@ struct Values { std::vector shortcuts; uint32_t callout_flags; + + // logging + bool show_console; }; extern Values values; diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 079f93736..89a3e9f30 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -126,7 +126,12 @@ int main(int argc, char** argv) { #endif Log::Filter log_filter(Log::Level::Debug); - Log::SetFilter(&log_filter); + Log::SetGlobalFilter(log_filter); + + Log::AddBackend(std::make_unique()); + FileUtil::CreateFullPath(FileUtil::GetUserPath(D_LOGS_IDX)); + Log::AddBackend( + std::make_unique(FileUtil::GetUserPath(D_LOGS_IDX) + LOG_FILE)); MicroProfileOnThreadCreate("EmuThread"); SCOPE_EXIT({ MicroProfileShutdown(); }); -- cgit v1.2.3 From 76b475faf774a7a357bdc707e556c75f7975bc45 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 2 Jul 2018 21:39:22 -0400 Subject: Fix build and address review feedback --- src/common/logging/filter.cpp | 8 ++++---- src/yuzu_cmd/yuzu.cpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 733247b51..4e783a577 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -65,14 +65,14 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, const std::string::const_iterator end) { auto level_separator = std::find(begin, end, ':'); if (level_separator == end) { - LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: %s", - std::string(begin, end).c_str()); + LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: {}", + std::string(begin, end)); return false; } const Level level = GetLevelByName(level_separator + 1, end); if (level == Level::Count) { - LOG_ERROR(Log, "Unknown log level in filter: %s", std::string(begin, end).c_str()); + LOG_ERROR(Log, "Unknown log level in filter: {}", std::string(begin, end)); return false; } @@ -83,7 +83,7 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, const Class log_class = GetClassByName(begin, level_separator); if (log_class == Class::Count) { - LOG_ERROR(Log, "Unknown log class in filter: %s", std::string(begin, end).c_str()); + LOG_ERROR(Log, "Unknown log class in filter: {}", std::string(begin, end)); return false; } diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 89a3e9f30..8ddd202d8 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -7,6 +7,7 @@ #include #include +#include "common/common_paths.h" #include "common/logging/backend.h" #include "common/logging/filter.h" #include "common/logging/log.h" -- cgit v1.2.3