Skip to content

Commit

Permalink
Merge pull request #1632 from ergo720/remove_dbgprintfex
Browse files Browse the repository at this point in the history
Remove DBG_PRINTF_EX
  • Loading branch information
LukeUsher committed Jun 10, 2019
2 parents dab84b3 + 0eb57e2 commit 59d0f36
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/Cxbx.h
Expand Up @@ -85,7 +85,7 @@ extern bool g_bIsRetail;
/*! indicates ability to save on exit (needed for settings reset) */ /*! indicates ability to save on exit (needed for settings reset) */
extern bool g_SaveOnExit; extern bool g_SaveOnExit;


/*! runtime DBG_PRINTF toggle boolean */ /*! runtime logging toggle boolean */
extern volatile bool g_bPrintfOn; extern volatile bool g_bPrintfOn;


#ifdef _MSC_VER #ifdef _MSC_VER
Expand Down
11 changes: 5 additions & 6 deletions src/common/EmuEEPROM.cpp
Expand Up @@ -38,7 +38,6 @@ namespace xboxkrnl
#include <shlobj.h> // For HANDLE, CreateFile, CreateFileMapping, MapViewOfFile #include <shlobj.h> // For HANDLE, CreateFile, CreateFileMapping, MapViewOfFile
#include <random> #include <random>


#include "Cxbx.h" // For DBG_PRINTF_EX
#include "EmuEEPROM.h" // For EEPROMInfo, EEPROMInfos #include "EmuEEPROM.h" // For EEPROMInfo, EEPROMInfos
#include "core\kernel\support\Emu.h" // For EmuWarning #include "core\kernel\support\Emu.h" // For EmuWarning
#include "..\..\src\devices\LED.h" // For SetLEDSequence #include "..\..\src\devices\LED.h" // For SetLEDSequence
Expand Down Expand Up @@ -122,7 +121,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
/* hTemplateFile */nullptr); /* hTemplateFile */nullptr);
if (hFileEEPROM == INVALID_HANDLE_VALUE) if (hFileEEPROM == INVALID_HANDLE_VALUE)
{ {
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Couldn't create EEPROM.bin file!\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Couldn't create EEPROM.bin file!\n");
return nullptr; return nullptr;
} }
} }
Expand All @@ -140,7 +139,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
/**/nullptr); /**/nullptr);
if (hFileMappingEEPROM == NULL) if (hFileMappingEEPROM == NULL)
{ {
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Couldn't create EEPROM.bin file mapping!\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Couldn't create EEPROM.bin file mapping!\n");
return nullptr; return nullptr;
} }


Expand All @@ -161,7 +160,7 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
/* dwFileOffsetLow */0, /* dwFileOffsetLow */0,
EEPROM_SIZE); EEPROM_SIZE);
if (pEEPROM == nullptr) { if (pEEPROM == nullptr) {
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Couldn't map EEPROM.bin into memory!\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Couldn't map EEPROM.bin into memory!\n");
return nullptr; return nullptr;
} }


Expand All @@ -177,12 +176,12 @@ xboxkrnl::XBOX_EEPROM *CxbxRestoreEEPROM(char *szFilePath_EEPROM_bin)
// This must be done last to include all initialized data in the CRC // This must be done last to include all initialized data in the CRC
gen_section_CRCs(pEEPROM); gen_section_CRCs(pEEPROM);


DBG_PRINTF_EX(LOG_PREFIX_INIT, "Initialized default EEPROM\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Initialized default EEPROM\n");
} }
else else
{ {
XboxFactoryGameRegion = pEEPROM->EncryptedSettings.GameRegion; XboxFactoryGameRegion = pEEPROM->EncryptedSettings.GameRegion;
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Loaded EEPROM.bin\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Loaded EEPROM.bin\n");
} }


// Read the HDD (and eventually also the online) keys stored in the eeprom file. Users can input them in the eeprom menu // Read the HDD (and eventually also the online) keys stored in the eeprom file. Users can input them in the eeprom menu
Expand Down
9 changes: 1 addition & 8 deletions src/common/Logging.h
Expand Up @@ -391,14 +391,7 @@ extern thread_local std::string _logThreadPrefix;
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4477) #pragma warning(disable : 4477)
#endif #endif

#define DBG_PRINTF_EX(cxbxr_module, fmt, ...) { \
LOG_CHECK_ENABLED_EX(cxbxr_module, LOG_LEVEL::DEBUG) { \
CXBX_CHECK_INTEGRITY(); \
if(g_bPrintfOn) printf("[0x%.4X] %s"##fmt, GetCurrentThreadId(), g_EnumModules2String[to_underlying(cxbxr_module)], ##__VA_ARGS__); \
} \
}


#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
Expand Down
3 changes: 1 addition & 2 deletions src/core/kernel/exports/EmuKrnlKe.cpp
Expand Up @@ -329,8 +329,7 @@ void InitDpcThread()


InitializeCriticalSection(&(g_DpcData.Lock)); InitializeCriticalSection(&(g_DpcData.Lock));
InitializeListHead(&(g_DpcData.DpcQueue)); InitializeListHead(&(g_DpcData.DpcQueue));

EmuLogEx(CXBXR_MODULE::INIT, LOG_LEVEL::DEBUG, "Creating DPC event\n");
DBG_PRINTF_EX(CXBXR_MODULE::INIT, "Creating DPC event\n");
g_DpcData.DpcEvent = CreateEvent(/*lpEventAttributes=*/nullptr, /*bManualReset=*/FALSE, /*bInitialState=*/FALSE, /*lpName=*/nullptr); g_DpcData.DpcEvent = CreateEvent(/*lpEventAttributes=*/nullptr, /*bManualReset=*/FALSE, /*bInitialState=*/FALSE, /*lpName=*/nullptr);
} }


Expand Down
14 changes: 7 additions & 7 deletions src/core/kernel/init/CxbxKrnl.cpp
Expand Up @@ -1462,7 +1462,7 @@ __declspec(noreturn) void CxbxKrnlInit
CxbxRegisterDeviceHostPath(DeviceHarddisk0Partition7, CxbxBasePath + "Partition7"); CxbxRegisterDeviceHostPath(DeviceHarddisk0Partition7, CxbxBasePath + "Partition7");


// Create default symbolic links : // Create default symbolic links :
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Creating default symbolic links.\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Creating default symbolic links.\n");
{ {
// TODO: DriveD should always point to the Xbe Path // TODO: DriveD should always point to the Xbe Path
// This is the only symbolic link the Xbox Kernel sets, the rest are set by the application, usually via XAPI. // This is the only symbolic link the Xbox Kernel sets, the rest are set by the application, usually via XAPI.
Expand Down Expand Up @@ -1526,7 +1526,7 @@ __declspec(noreturn) void CxbxKrnlInit


// Make sure the Xbox1 code runs on one core (as the box itself has only 1 CPU, // Make sure the Xbox1 code runs on one core (as the box itself has only 1 CPU,
// this will better aproximate the environment with regard to multi-threading) : // this will better aproximate the environment with regard to multi-threading) :
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Determining CPU affinity.\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Determining CPU affinity.\n");
{ {
if (!GetProcessAffinityMask(g_CurrentProcessHandle, &g_CPUXbox, &g_CPUOthers)) if (!GetProcessAffinityMask(g_CurrentProcessHandle, &g_CPUXbox, &g_CPUOthers))
CxbxKrnlCleanupEx(LOG_PREFIX_INIT, "GetProcessAffinityMask failed."); CxbxKrnlCleanupEx(LOG_PREFIX_INIT, "GetProcessAffinityMask failed.");
Expand All @@ -1545,7 +1545,7 @@ __declspec(noreturn) void CxbxKrnlInit
} }


// initialize graphics // initialize graphics
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Initializing render window.\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Initializing render window.\n");
XTL::CxbxInitWindow(true); XTL::CxbxInitWindow(true);


// Now process the boot flags to see if there are any special conditions to handle // Now process the boot flags to see if there are any special conditions to handle
Expand Down Expand Up @@ -1592,7 +1592,7 @@ __declspec(noreturn) void CxbxKrnlInit


if (!bLLE_GPU) if (!bLLE_GPU)
{ {
DBG_PRINTF_EX(LOG_PREFIX_INIT, "Initializing Direct3D.\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Initializing Direct3D.\n");
XTL::EmuD3DInit(); XTL::EmuD3DInit();
} }


Expand Down Expand Up @@ -1634,13 +1634,13 @@ __declspec(noreturn) void CxbxKrnlInit
TimerObject* KernelClockThr = Timer_Create(CxbxKrnlClockThread, nullptr, "Kernel clock thread", &g_CPUOthers); TimerObject* KernelClockThr = Timer_Create(CxbxKrnlClockThread, nullptr, "Kernel clock thread", &g_CPUOthers);
Timer_Start(KernelClockThr, SCALE_MS_IN_NS); Timer_Start(KernelClockThr, SCALE_MS_IN_NS);


DBG_PRINTF_EX(LOG_PREFIX_INIT, "Calling XBE entry point...\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "Calling XBE entry point...\n");
CxbxLaunchXbe(Entry); CxbxLaunchXbe(Entry);


// FIXME: Wait for Cxbx to exit or error fatally // FIXME: Wait for Cxbx to exit or error fatally
Sleep(INFINITE); Sleep(INFINITE);


DBG_PRINTF_EX(LOG_PREFIX_INIT, "XBE entry point returned\n"); EmuLogEx(LOG_PREFIX_INIT, LOG_LEVEL::DEBUG, "XBE entry point returned\n");
fflush(stdout); fflush(stdout);


// EmuShared::Cleanup(); FIXME: commenting this line is a bad workaround for issue #617 (https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/617) // EmuShared::Cleanup(); FIXME: commenting this line is a bad workaround for issue #617 (https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/617)
Expand Down Expand Up @@ -1698,7 +1698,7 @@ __declspec(noreturn) void CxbxKrnlCleanupEx(CXBXR_MODULE cxbxr_module, const cha
vsprintf(szBuffer2, szErrorMessage, argp); vsprintf(szBuffer2, szErrorMessage, argp);
va_end(argp); va_end(argp);


CxbxPopupMessageEx(cxbxr_module, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, "Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also DBG_PRINTF CxbxPopupMessageEx(cxbxr_module, LOG_LEVEL::FATAL, CxbxMsgDlgIcon_Error, "Received Fatal Message:\n\n* %s\n", szBuffer2); // Will also EmuLogEx
} }


printf("[0x%.4X] MAIN: Terminating Process\n", GetCurrentThreadId()); printf("[0x%.4X] MAIN: Terminating Process\n", GetCurrentThreadId());
Expand Down
10 changes: 5 additions & 5 deletions src/core/kernel/support/EmuFS.cpp
Expand Up @@ -492,7 +492,7 @@ void EmuInitFS()
fsInstructions.push_back({ { 0x64, 0xA1, 0x58, 0x00, 0x00, 0x00 }, &EmuFS_MovEaxFs58 }); // mov eax, large fs:58 fsInstructions.push_back({ { 0x64, 0xA1, 0x58, 0x00, 0x00, 0x00 }, &EmuFS_MovEaxFs58 }); // mov eax, large fs:58
fsInstructions.push_back({ { 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovFs00Eax }); // mov large fs:0, eax fsInstructions.push_back({ { 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovFs00Eax }); // mov large fs:0, eax


DBG_PRINTF_EX(CXBXR_MODULE::INIT, "Patching FS Register Accesses\n"); EmuLogEx(CXBXR_MODULE::INIT, LOG_LEVEL::DEBUG, "Patching FS Register Accesses\n");
DWORD sizeOfImage = CxbxKrnl_XbeHeader->dwSizeofImage; DWORD sizeOfImage = CxbxKrnl_XbeHeader->dwSizeofImage;
long numberOfInstructions = fsInstructions.size(); long numberOfInstructions = fsInstructions.size();


Expand All @@ -502,7 +502,7 @@ void EmuInitFS()
continue; continue;
} }


DBG_PRINTF_EX(CXBXR_MODULE::INIT, "Searching for FS Instruction in section %s\n", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]); EmuLogEx(CXBXR_MODULE::INIT, LOG_LEVEL::DEBUG, "Searching for FS Instruction in section %s\n", CxbxKrnl_Xbe->m_szSectionName[sectionIndex]);
xbaddr startAddr = CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwVirtualAddr; xbaddr startAddr = CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwVirtualAddr;
xbaddr endAddr = startAddr + CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwSizeofRaw; xbaddr endAddr = startAddr + CxbxKrnl_Xbe->m_SectionHeader[sectionIndex].dwSizeofRaw;
for (xbaddr addr = startAddr; addr < endAddr; addr++) for (xbaddr addr = startAddr; addr < endAddr; addr++)
Expand All @@ -519,7 +519,7 @@ void EmuInitFS()


if (memcmp((void*)addr, &fsInstructions[i].data[0], sizeOfData) == 0) if (memcmp((void*)addr, &fsInstructions[i].data[0], sizeOfData) == 0)
{ {
DBG_PRINTF_EX(CXBXR_MODULE::INIT, "Patching FS Instruction at 0x%.8X\n", addr); EmuLogEx(CXBXR_MODULE::INIT, LOG_LEVEL::DEBUG, "Patching FS Instruction at 0x%.8X\n", addr);


// Write Call opcode // Write Call opcode
*(uint8_t*)addr = OPCODE_CALL_E8; *(uint8_t*)addr = OPCODE_CALL_E8;
Expand All @@ -535,7 +535,7 @@ void EmuInitFS()
} }
} }


DBG_PRINTF_EX(CXBXR_MODULE::INIT, "Done patching FS Register Accesses\n"); EmuLogEx(CXBXR_MODULE::INIT, LOG_LEVEL::DEBUG, "Done patching FS Register Accesses\n");
} }


// generate fs segment selector // generate fs segment selector
Expand Down Expand Up @@ -584,7 +584,7 @@ void EmuGenerateFS(Xbe::TLS *pTLS, void *pTLSData)
EmuLog(LOG_LEVEL::DEBUG, "0x%.8X:", (xbaddr)bByte); EmuLog(LOG_LEVEL::DEBUG, "0x%.8X:", (xbaddr)bByte);
} }


// Note : Use printf instead of DBG_PRINTF here, which prefixes with GetCurrentThreadId() : // Note : Use printf instead of EmuLog here, which prefixes with GetCurrentThreadId() :
printf(" %.2X", *bByte); printf(" %.2X", *bByte);
} }


Expand Down

0 comments on commit 59d0f36

Please sign in to comment.