デバッグ用マクロの整理

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@35 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-02-08 06:29:49 +00:00
parent db3e51d581
commit a649e84533
8 changed files with 37 additions and 91 deletions

View File

@ -231,7 +231,7 @@ extern "C" void nnMain(void)
{ {
s_CanReadSerialNumber = true; s_CanReadSerialNumber = true;
} }
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
common::HardwareInfo hwInfo; common::HardwareInfo hwInfo;
hwInfo.AddCheckDigit(reinterpret_cast<char*>(s_SerialNo)); hwInfo.AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
@ -239,21 +239,21 @@ extern "C" void nnMain(void)
// デバイスIDの取得 // デバイスIDの取得
bit32 deviceId; bit32 deviceId;
result = nn::ps::CTR::GetDeviceId(&deviceId); result = nn::ps::CTR::GetDeviceId(&deviceId);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
// MACアドレスの取得 // MACアドレスの取得
nn::nwm::Mac mac; nn::nwm::Mac mac;
char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE]; char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE];
result = nn::nwm::GetMacAddress(mac); result = nn::nwm::GetMacAddress(mac);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
mac.GetString(macAddress); mac.GetString(macAddress);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
// フレンドコードの取得 // フレンドコードの取得
nn::friends::CTR::FriendKey friendKey; nn::friends::CTR::FriendKey friendKey;
result = nn::friends::CTR::GetMyFriendKey(&friendKey); result = nn::friends::CTR::GetMyFriendKey(&friendKey);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result , __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey); u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey);
// バージョンの取得 // バージョンの取得

View File

@ -102,10 +102,7 @@ void DeleteTrash()
NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName); NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName);
result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring( result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring(
entryIndex->entryName)).c_str()); entryIndex->entryName)).c_str());
if(result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
} }
// ファイルならログとAP設定以外は削除する // ファイルならログとAP設定以外は削除する
@ -117,10 +114,7 @@ void DeleteTrash()
NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName); NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName);
result = nn::fs::TryDeleteFile( result = nn::fs::TryDeleteFile(
(currentDirectory + ::std::wstring(entryIndex->entryName)).c_str()); (currentDirectory + ::std::wstring(entryIndex->entryName)).c_str());
if(result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
} }
} }
} }
@ -146,7 +140,7 @@ void DeleteTrash()
else else
{ {
NN_LOG("failed initialize directory\n"); NN_LOG("failed initialize directory\n");
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
dir.Finalize(); dir.Finalize();
} }
@ -367,10 +361,7 @@ void ExportThreadFunc()
nn::Result result; nn::Result result;
result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND);
if(result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
result = common::SdMountManager::Mount(); result = common::SdMountManager::Mount();
@ -401,11 +392,7 @@ nn::Result WriteSaveData()
nn::Result result; nn::Result result;
result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND);
if(result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
return result;
}
u32 fileNum = 0; u32 fileNum = 0;
u32 fileSize = 0; u32 fileSize = 0;

View File

@ -258,26 +258,26 @@ extern "C" void nnMain(void)
{ {
s_CanReadSerialNumber = true; s_CanReadSerialNumber = true;
} }
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
// デバイスIDの取得 // デバイスIDの取得
bit32 deviceId; bit32 deviceId;
result = nn::ps::CTR::GetDeviceId(&deviceId); result = nn::ps::CTR::GetDeviceId(&deviceId);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
// MACアドレスの取得 // MACアドレスの取得
nn::nwm::Mac mac; nn::nwm::Mac mac;
char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE]; char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE];
result = nn::nwm::GetMacAddress(mac); result = nn::nwm::GetMacAddress(mac);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
mac.GetString(macAddress); mac.GetString(macAddress);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result, __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
// フレンドコードの取得 // フレンドコードの取得
nn::friends::CTR::FriendKey friendKey; nn::friends::CTR::FriendKey friendKey;
result = nn::friends::CTR::GetMyFriendKey(&friendKey); result = nn::friends::CTR::GetMyFriendKey(&friendKey);
common::Logger::GetLoggerInstance()->PrintResultIfFailed(result , __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey); u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey);
// バージョンの取得 // バージョンの取得

View File

@ -400,7 +400,7 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
if (s_FgNupRetryCount++ < RETRY_MAX) if (s_FgNupRetryCount++ < RETRY_MAX)
{ {
// エラーのためやり直す // エラーのためやり直す
COMMON_LOGGER_RESULT(GetUpdateResult()); COMMON_LOGGER_RESULT_IF_FAILED(GetUpdateResult());
COMMON_LOGGER("Network Update Failed. Retrying... %d\n", s_FgNupRetryCount); COMMON_LOGGER("Network Update Failed. Retrying... %d\n", s_FgNupRetryCount);
// FGNUP用のスレッドを作るとこからやり直し // FGNUP用のスレッドを作るとこからやり直し

View File

@ -267,10 +267,7 @@ bool EqualsIVSFileandIVS()
NN_LOG("Failed Allocate Heap!! %s, %d", __FILE__, __LINE__); NN_LOG("Failed Allocate Heap!! %s, %d", __FILE__, __LINE__);
} }
} }
else COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
s_CheckedEqualsIVSFileandIVS = true; s_CheckedEqualsIVSFileandIVS = true;
common::HeapManager::GetHeap()->Free(enc); common::HeapManager::GetHeap()->Free(enc);
@ -396,10 +393,7 @@ void ImportMcuRtc()
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
} }
else COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
common::HeapManager::GetHeap()->Free(buf); common::HeapManager::GetHeap()->Free(buf);
} }
@ -450,10 +444,7 @@ void InitializeFileSystem()
NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName); NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName);
result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring( result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring(
entryIndex->entryName)).c_str()); entryIndex->entryName)).c_str());
if (result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
} }
// ファイルなら削除する // ファイルなら削除する
@ -462,10 +453,7 @@ void InitializeFileSystem()
NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName); NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName);
result = nn::fs::TryDeleteFile( result = nn::fs::TryDeleteFile(
(currentDirectory + ::std::wstring(entryIndex->entryName)).c_str()); (currentDirectory + ::std::wstring(entryIndex->entryName)).c_str());
if (result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
} }
} }
@ -559,16 +547,10 @@ void ImportThreadFunc()
nn::Result result; nn::Result result;
result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND); result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND);
if(result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
result = common::SdMountManager::Mount(); result = common::SdMountManager::Mount();
if(result.IsFailure()) COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize(); size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
NN_LOG("AllocatableSize = %d\n", bufSize); NN_LOG("AllocatableSize = %d\n", bufSize);
@ -655,10 +637,7 @@ void ImportNorData()
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
} }
else COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
common::HeapManager::GetHeap()->Free(buf); common::HeapManager::GetHeap()->Free(buf);
} }
@ -686,10 +665,7 @@ void Cleanup()
nn::am::DoCleanup(nn::fs::MEDIA_TYPE_NAND); nn::am::DoCleanup(nn::fs::MEDIA_TYPE_NAND);
} }
} }
else COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
} }
void DeleteConsoleInitializedFile() void DeleteConsoleInitializedFile()
@ -1091,7 +1067,7 @@ bool ReadSetting()
else else
{ {
NN_LOG("configfileLoader Initialize Failed\n"); NN_LOG("configfileLoader Initialize Failed\n");
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
retval = false; retval = false;
} }
common::HeapManager::GetHeap()->Free(heapAddr); common::HeapManager::GetHeap()->Free(heapAddr);
@ -1099,7 +1075,7 @@ bool ReadSetting()
else else
{ {
NN_LOG("Can't Allocate Heap\n"); NN_LOG("Can't Allocate Heap\n");
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
retval = false; retval = false;
} }

View File

@ -76,21 +76,6 @@ void CommonLogger::PrintResult(const char* fmt, ...)
va_end(vlist); va_end(vlist);
} }
void CommonLogger::PrintResultIfFailed(nn::Result result, u32 line)
{
if (result.IsFailure())
{
if(line != 0)
{
COMMON_LOGGER_RESULT_WITH_LINE(result, line);
}
else
{
COMMON_LOGGER_RESULT(result);
}
}
}
void CommonLogger::ClearLog() void CommonLogger::ClearLog()
{ {
nn::os::CriticalSection::ScopedLock lock(m_CriticalSection); nn::os::CriticalSection::ScopedLock lock(m_CriticalSection);

View File

@ -23,27 +23,29 @@
#include "LogConsole.h" #include "LogConsole.h"
#define COMMON_LOGGER( ... ) (void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__) #define COMMON_LOGGER( ... ) (void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__)
#define COMMON_LOGGER_RESULT(result) \ #define COMMON_LOGGER_RESULT(result, func) \
(void)nn::dbg::PrintResult(result); \ (void)nn::dbg::PrintResult(result); \
(void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \
(void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \ (void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \
#define COMMON_LOGGER_RESULT_WITH_LINE(result, line) \ #define COMMON_LOGGER_RESULT_WITH_LINE(result, line, func) \
(void)nn::dbg::detail::Printf("%d\n", line); \ (void)nn::dbg::detail::Printf("%d\n", line); \
(void)nn::dbg::PrintResult(result); \ (void)nn::dbg::PrintResult(result); \
(void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \
(void)common::Logger::GetLoggerInstance()->PrintResult("line = %d\n", line); \ (void)common::Logger::GetLoggerInstance()->PrintResult("line = %d\n", line); \
(void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \ (void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \
#define COMMON_LOGGER_RESULT_IF_FAILED(result) \ #define COMMON_LOGGER_RESULT_IF_FAILED(result) \
if(result.IsFailure()) \ if(result.IsFailure()) \
{ \ { \
COMMON_LOGGER_RESULT(result); \ COMMON_LOGGER_RESULT(result, __func__); \
} \ } \
#define COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result) \ #define COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result) \
if(result.IsFailure()) \ if(result.IsFailure()) \
{ \ { \
COMMON_LOGGER_RESULT_WITH_LINE(result, __LINE__); \ COMMON_LOGGER_RESULT_WITH_LINE(result, __LINE__, __func__); \
} \ } \
namespace common namespace common
{ {
@ -62,7 +64,6 @@ public:
void Print(const char* fmt, ...); void Print(const char* fmt, ...);
void PrintResult(const char* fmt, ...); void PrintResult(const char* fmt, ...);
void PrintResultIfFailed(nn::Result result, u32 line = 0);
void ClearLog(); void ClearLog();
void ScrollUp(); void ScrollUp();
void ScrollDown(); void ScrollDown();

View File

@ -153,10 +153,7 @@ void PlayHistoryManager::Import()
} }
} }
else COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
{
COMMON_LOGGER_RESULT_WITH_LINE(result , __LINE__);
}
common::HeapManager::GetHeap()->Free(buf); common::HeapManager::GetHeap()->Free(buf);
} }