Fixed LoggedModules bug + refactored log gui + allow to print debug messages also on release builds

This commit is contained in:
ergo720 2018-08-14 13:50:58 +02:00
parent 524fb1f06d
commit 82f429f3c9
17 changed files with 154 additions and 176 deletions

View File

@ -43,6 +43,22 @@ BEGIN
BOTTOMMARGIN, 207
END
IDD_CONTROLLER_CFG, DIALOG
BEGIN
END
IDD_VIDEO_CFG, DIALOG
BEGIN
END
IDD_AUDIO_CFG, DIALOG
BEGIN
END
IDD_EEPROM_CFG, DIALOG
BEGIN
END
IDD_LOGGING_CFG, DIALOG
BEGIN
BOTTOMMARGIN, 322
@ -331,7 +347,7 @@ BEGIN
PUSHBUTTON "Reset",IDC_EE_RESET,13,251,40,14,BS_FLAT
END
IDD_LOGGING_CFG DIALOGEX 0, 0, 259, 333
IDD_LOGGING_CFG DIALOGEX 0, 0, 259, 350
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Cxbx-Reloaded : Logging Configuration"
FONT 8, "Verdana", 0, 0, 0x1
@ -403,6 +419,8 @@ BEGIN
CONTROL "RTL",IDC_LOG_RTL,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,93,302,28,10
CONTROL "XC",IDC_LOG_XC,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,149,302,26,10
CONTROL "XE",IDC_LOG_XE,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,209,302,25,10
PUSHBUTTON "Cancel",IDC_LOG_CANCEL,161,327,40,14,BS_FLAT
PUSHBUTTON "Accept",IDC_LOG_ACCEPT,208,327,40,14,BS_FLAT
END

View File

@ -266,8 +266,6 @@ extern thread_local std::string _logThreadPrefix;
_logFuncPrefix = tmp.str(); \
}
#ifdef _DEBUG_TRACE
#define LOG_INIT \
LOG_THREAD_INIT \
LOG_FUNC_INIT(__func__)
@ -326,23 +324,6 @@ extern thread_local std::string _logThreadPrefix;
} } while (0); \
}
#else // _DEBUG_TRACE
#define LOG_FINIT
#define LOG_INIT
#define LOG_FUNC_BEGIN_NO_INIT
#define LOG_FUNC_BEGIN
#define LOG_FUNC_ARG(arg)
#define LOG_FUNC_ARG_TYPE(type, arg)
#define LOG_FUNC_ARG_OUT(arg)
#define LOG_FUNC_END
#define LOG_FUNC_RESULT(r)
#define LOG_FUNC_RESULT_TYPE(type, r)
#define LOG_FORWARD(cxbxr_module, arg)
#endif // _DEBUG_TRACE
// LOG_IGNORED indicates that Cxbx consiously ignores an api
#define LOG_IGNORED(cxbxr_module) \
do { \
@ -404,18 +385,12 @@ extern thread_local std::string _logThreadPrefix;
#pragma warning(disable : 4477)
#endif
/*! DbgPrintf enabled if _DEBUG_TRACE is set */
#ifdef _DEBUG_TRACE
#define DbgPrintf(cxbxr_module, fmt, ...) { \
LOG_CHECK_ENABLED(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__); \
} \
}
#else
inline void null_func(...) { }
#define DbgPrintf null_func
#endif
#ifdef _MSC_VER
#pragma warning(pop)

View File

@ -337,7 +337,7 @@ bool Settings::LoadConfig()
if (std::strncmp(si_list_iterator->pItem, "0x", 2) == 0) {
si_list_iterator->pItem += 2;
}
m_core.LoggedModules[index] = std::strtol(si_list_iterator->pItem, nullptr, 16);
m_core.LoggedModules[index] = std::strtoul(si_list_iterator->pItem, nullptr, 16);
index++;
}
}

View File

@ -151,7 +151,7 @@ public:
char szKrnlDebug[MAX_PATH] = "";
char szStorageLocation[MAX_PATH] = "";
bool allowAdminPrivilege;
int LoggedModules[NUM_INTEGERS_LOG];
uint LoggedModules[NUM_INTEGERS_LOG];
int LogLevel = 1;
bool Reserved2 = 0;
bool Reserved3 = 0;

View File

@ -73,12 +73,6 @@ typedef u32 xbaddr;
#define xbnull 0
#ifdef _DEBUG
/*! define this to track vertex buffers */
#define _DEBUG_TRACK_VB
/*! define this to track vertex shaders */
#define _DEBUG_TRACK_VS
/*! define this to track pixel shaders */
#define _DEBUG_TRACK_PS
/*! define this to track memory allocations */
//#define _DEBUG_ALLOC
#endif
@ -86,8 +80,6 @@ typedef u32 xbaddr;
#ifdef _DEBUG
#define _DEBUG_TRACE 1
#endif
/*! define this to trace warnings */
#define _DEBUG_WARNINGS
/*! define this to trace vertex shader constants */
#define _DEBUG_TRACK_VS_CONST
/*! define this to print current configuration at kernel startup */

View File

@ -121,7 +121,7 @@ INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM
int counter;
int index;
int TempLevel;
int LoggedModules[NUM_INTEGERS_LOG];
uint LoggedModules[NUM_INTEGERS_LOG];
int LogLevel;
// Set window icon
@ -184,7 +184,7 @@ INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM
}
}
if (counter == to_underlying(CXBXR_MODULE::MAX)) {
if (counter == (to_underlying(CXBXR_MODULE::MAX) - to_underlying(CXBXR_MODULE::KRNL))) {
for (index = to_underlying(CXBXR_MODULE::KRNL); index < to_underlying(CXBXR_MODULE::MAX); index++) {
EnableWindow(GetDlgItem(hWndDlg, g_DlgIndexes[index]), FALSE);
}
@ -206,9 +206,26 @@ INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM
break;
case WM_CLOSE:
{
PostMessage(hWndDlg, WM_COMMAND, IDC_LOG_CANCEL, 0);
}
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_LOG_CANCEL:
{
g_ChildWnd = NULL;
EndDialog(hWndDlg, wParam);
}
break;
case IDC_LOG_ACCEPT:
{
if (g_bHasChanges) {
int LoggedModules[NUM_INTEGERS_LOG] = { 0 };
uint LoggedModules[NUM_INTEGERS_LOG] = { 0 };
HWND hControl = GetDlgItem(hWndDlg, IDC_EVENT_LV);
int LogLevel = SendMessage(hControl, CB_GETITEMDATA, SendMessage(hControl, CB_GETCURSEL, 0, 0), 0);
@ -247,16 +264,10 @@ INT_PTR CALLBACK DlgLogConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM
SendMessage(g_ChildWnd, WM_COPYDATA, reinterpret_cast<WPARAM>(hWndDlg), reinterpret_cast<LPARAM>(&CopyData));
}
}
g_ChildWnd = NULL;
EndDialog(hWndDlg, wParam);
PostMessage(hWndDlg, WM_COMMAND, IDC_LOG_CANCEL, 0);
}
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_EVENT_LV:
if (HIWORD(wParam) == CBN_SELCHANGE) {
g_bHasChanges = true;

View File

@ -20,6 +20,8 @@
#define IDS_UEM 123
#define IDD_CONTROLLER_HOST_MAPPING 131
#define IDD_VIRTUAL_SBC_FEEDBACK 133
#define IDC_LOG_CANCEL 892
#define IDC_LOG_ACCEPT 893
#define IDC_LOG_ENABLE_GENERAL 894
#define IDC_LOG_DISABLE_GENERAL 895
#define IDC_LOG_ENABLE_KERNEL 896

View File

@ -110,7 +110,6 @@ void DbgConsole::Reset()
m_szInput[0] = '\0';
}
#if defined(_DEBUG_TRACK_VB)
typedef enum _ETAction
{
ETA_ENABLE = 0,
@ -170,7 +169,6 @@ static void EnableTracker(ResourceTracker &trackTotal, ResourceTracker &tracker,
return;
}
#endif
void DbgConsole::ParseCommand()
{
@ -193,12 +191,12 @@ void DbgConsole::ParseCommand()
printf("CxbxDbg: Quit/Exit [Q] : Stop Emulation\n");
printf("CxbxDbg: Trace [T] : Toggle Debug Trace\n");
#ifdef _DEBUG_TRACK_VB
LOG_CHECK_ENABLED(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) {
printf("CxbxDbg: ListVB [LVB] : List Active Vertex Buffers\n");
printf("CxbxDbg: DisableVB [DVB #] : Disable Active Vertex Buffer(s)\n");
printf("CxbxDbg: EnableVB [EVB #] : Enable Active Vertex Buffer(s)\n");
printf("CxbxDbg: DumpStreamCache [DSC] : Dumps the patched streams cache\n");
#endif
}
#ifdef _DEBUG_ALLOC
printf("CxbxDbg: DumpMem [DMEM] : Dump the heap allocation tracking table\n");
@ -219,16 +217,16 @@ void DbgConsole::ParseCommand()
g_bPrintfOn = !g_bPrintfOn;
printf("CxbxDbg: Trace is now %s\n", g_bPrintfOn ? "ON" : "OFF");
}
#ifdef _DEBUG_TRACK_VB
else if(_stricmp(szCmd, "lvb") == 0 || _stricmp(szCmd, "ListVB") == 0)
{
int v=0;
LOG_CHECK_ENABLED(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) {
int v = 0;
g_VBTrackTotal.Lock();
RTNode *cur = g_VBTrackTotal.getHead();
while(cur != NULL && cur->pNext != NULL)
while (cur != NULL && cur->pNext != NULL)
{
bool enabled = g_VBTrackDisable.exists(cur->pResource);
@ -239,17 +237,19 @@ void DbgConsole::ParseCommand()
g_VBTrackTotal.Unlock();
}
}
else if(_stricmp(szCmd, "dvb") == 0 || _stricmp(szCmd, "DisableVB") == 0)
{
int n=0, m=0;
LOG_CHECK_ENABLED(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) {
int n = 0, m = 0;
int c = sscanf(m_szInput, "%*s %d-%d", &n, &m);
if(c == 1)
if (c == 1)
{
EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, n, ETA_DISABLE);
}
else if(c == 2)
else if (c == 2)
{
EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, m, ETA_DISABLE);
}
@ -258,17 +258,19 @@ void DbgConsole::ParseCommand()
printf("CxbxDbg: Syntax Incorrect (dvb #)\n");
}
}
}
else if(_stricmp(szCmd, "evb") == 0 || _stricmp(szCmd, "EnableVB") == 0)
{
int n=0, m=0;
LOG_CHECK_ENABLED(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) {
int n = 0, m = 0;
int c = sscanf(m_szInput, "%*s %d-%d", &n, &m);
if(c == 1)
if (c == 1)
{
EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, n, ETA_ENABLE);
}
else if(c == 2)
else if (c == 2)
{
EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, m, ETA_ENABLE);
}
@ -277,7 +279,7 @@ void DbgConsole::ParseCommand()
printf("CxbxDbg: Syntax Incorrect (dvb #)\n");
}
}
#endif
}
#ifdef _DEBUG_ALLOC
else if(_stricmp(szCmd, "dmem") == 0 || _stricmp(szCmd, "DumpMem") == 0)
{

View File

@ -102,7 +102,6 @@ std::string FormatTitleId(uint32_t title_id)
}
// print out a warning message to the kernel debug log file
#ifdef _DEBUG_WARNINGS
void NTAPI EmuLog(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, const char *szWarningMessage, ...)
{
if (szWarningMessage == NULL) {
@ -132,7 +131,6 @@ void NTAPI EmuLog(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, const char *szWarn
}
}
}
#endif
std::string EIPToString(xbaddr EIP)
{

View File

@ -42,11 +42,7 @@
#include <multimon.h>
// print out a log message to the kernel debug log file if level is high enough
#ifdef _DEBUG_WARNINGS
void NTAPI EmuLog(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, const char *szWarningMessage, ...);
#else
inline void NTAPI EmuLog(CXBXR_MODULE cxbxr_module, LOG_LEVEL level, const char *szWarningMessage, ...) { }
#endif
std::string FormatTitleId(uint32_t title_id);

View File

@ -211,25 +211,15 @@ struct EmuD3D8CreateDeviceProxyData
}
g_EmuCDPD = {0};
#ifdef _DEBUG_TRACE
#define DEBUG_D3DRESULT(hRet, message) \
do { \
LOG_CHECK_ENABLED(CXBXR_MODULE::D3D8, LOG_LEVEL::DEBUG) { \
if (FAILED(hRet)) \
if(g_bPrintfOn) \
printf("%s%s : %s D3D error (0x%.08X: %s)\n", _logThreadPrefix.c_str(), _logFuncPrefix.c_str(), message, hRet, D3DErrorString(hRet)); \
} \
} while (0)
#else
#define DEBUG_D3DRESULT(hRet, message) \
do { \
if (FAILED(hRet)) \
if(g_bPrintfOn) \
DbgPrintf(LOG_PREFIX, "%s : %s D3D error (0x%.08X: %s)\n", __func__, message, hRet, D3DErrorString(hRet)); \
} while (0)
#endif
// TODO: This should be a D3DDevice structure
DWORD* g_XboxD3DDevice;

View File

@ -88,6 +88,12 @@ typedef uint8_t uint8; // TODO : Remove
#include <process.h>
#include <locale.h>
#define DbgPshPrintf \
LOG_CHECK_ENABLED(LOG_PREFIX, LOG_LEVEL::DEBUG) \
if(g_bPrintfOn) printf
//#include "EmuD3DPixelShader.h"
/*---------------------------------------------------------------------------*/

View File

@ -49,11 +49,4 @@ VOID DxbxUpdateActivePixelShader(); // NOPATCH
// TODO: Remove this once the Render State code has been fully ported from Dxbx/Wip_LessVertexPatching
extern DWORD TemporaryPixelShaderRenderStates[X_D3DRS_PSTEXTUREMODES + 1];
#ifdef _DEBUG_TRACK_PS
#define DbgPshPrintf if(g_bPrintfOn) printf
#else
inline void null_func_psh(...) { }
#define DbgPshPrintf XTL::null_func_psh
#endif
#endif // PIXELSHADER_H

View File

@ -52,6 +52,10 @@
//#define CXBX_USE_VS30 // Separate the port to Vertex Shader model 3.0 from the port to Direct3D9
#endif
#define DbgVshPrintf \
LOG_CHECK_ENABLED(LOG_PREFIX, LOG_LEVEL::DEBUG) \
if(g_bPrintfOn) printf
// ****************************************************************************
// * Vertex shader function recompiler
// ****************************************************************************

View File

@ -96,11 +96,4 @@ inline CxbxVertexShader *MapXboxVertexShaderHandleToCxbxVertexShader(DWORD Handl
return nullptr;
}
#ifdef _DEBUG_TRACK_VS
#define DbgVshPrintf if(g_bPrintfOn) printf
#else
inline void null_func_vsh(...) { }
#define DbgVshPrintf XTL::null_func_vsh
#endif
#endif

View File

@ -37,7 +37,6 @@
#define LOG_PREFIX CXBXR_MODULE::LOG
#ifdef _DEBUG
// prevent name collisions
namespace xboxkrnl
{
@ -454,4 +453,3 @@ LOGRENDER(UNICODE_STRING)
}
}; // end of namespace xboxkrnl;
#endif

View File

@ -61,7 +61,7 @@ enum {
#define LOG_ID 1
struct LogData {
int Level;
int LoggedModules[NUM_INTEGERS_LOG];
uint LoggedModules[NUM_INTEGERS_LOG];
};
// ******************************************************************