OpenBarnyard
 
Loading...
Searching...
No Matches
TDebug_Win.cpp File Reference
#include "ToshiPCH.h"
#include "Toshi/TDebug.h"
#include "Thread/T2Mutex.h"
#include <Windows.h>
#include <Core/TMemoryDebugOn.h>
#include "resource.h"

Go to the source code of this file.

Functions

void TDebug_AcquireMutex ()
 
void TDebug_ReleaseMutex ()
 
TBOOL TDebug_IsValidAddress (const void *a_pPtr)
 
void TDebug_FinalPrintf (const TCHAR *a_szFormat,...)
 
void TDebug_FinalVPrintf (const TCHAR *a_szFormat, va_list a_Args)
 
void TDebug_FinalSPrintf (const TCHAR *a_szFormat,...)
 
void TDebug_FinalVSPrintf (const TCHAR *a_szFormat, va_list a_Args)
 
void TDebug_OutputDebugString (const TCHAR *a_szString)
 
void TDebug_BroadcastDebugString (const TCHAR *a_szString)
 
BOOL CALLBACK TDebug_AssertionDlgProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
TINT TDebug_AssertHandler (const TCHAR *a_szExpression, const TCHAR *a_szFileName, TUINT a_uiLineNumber, const TCHAR *a_szDescription)
 

Variables

TCHAR TDebug_ScratchMem [4096]
 
BOOL TDebug_IsMutexCreated
 
T2Mutex TDebug_Mutex
 
const TCHARTDebug_szAssertFilename
 
const TCHARTDebug_szAssertExpression
 
TUINT TDebug_uiAssertLineNumber
 

Function Documentation

◆ TDebug_AcquireMutex()

void TDebug_AcquireMutex ( )

Definition at line 19 of file TDebug_Win.cpp.

20{
21 if ( TDebug_IsMutexCreated == FALSE )
22 {
23 TDebug_Mutex.Create();
25 }
26
27 TDebug_Mutex.Lock();
28}
BOOL TDebug_IsMutexCreated
T2Mutex TDebug_Mutex

◆ TDebug_AssertHandler()

TINT TDebug_AssertHandler ( const TCHAR * a_szExpression,
const TCHAR * a_szFileName,
TUINT a_uiLineNumber,
const TCHAR * a_szDescription )

Definition at line 141 of file TDebug_Win.cpp.

142{
143 TDebug_szAssertFilename = a_szFileName;
144 TDebug_szAssertExpression = a_szExpression;
145 TDebug_uiAssertLineNumber = a_uiLineNumber;
146
147 TERROR( "Assertion (%s) failed ('%s', at line %u)\n", a_szExpression, a_szFileName, a_uiLineNumber );
148
149 HWND hWnd = GetActiveWindow();
150
151 if ( hWnd != NULL )
152 hWnd = GetLastActivePopup( hWnd );
153
154 INT_PTR result = DialogBoxParamA(
155 GetModuleHandleA( NULL ),
156 MAKEINTRESOURCEA( IDD_ASSERT ),
157 hWnd,
159 NULL
160 );
161
162 return ( result != -1 ) ? result : 1;
163}
BOOL CALLBACK TDebug_AssertionDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
const TCHAR * TDebug_szAssertExpression
const TCHAR * TDebug_szAssertFilename
TUINT TDebug_uiAssertLineNumber
#define TERROR(...)
Definition Defines.h:153

◆ TDebug_AssertionDlgProc()

BOOL CALLBACK TDebug_AssertionDlgProc ( HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam )

Definition at line 97 of file TDebug_Win.cpp.

98{
99 switch ( Message )
100 {
101 case WM_INITDIALOG:
102 {
103 ShowCursor( TRUE );
104 SetActiveWindow( hwnd );
105 SetForegroundWindow( hwnd );
106 SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
107
109 TDebug_szAssertFilename = "***INVALID***";
110
112 TDebug_szAssertExpression = "***INVALID***";
113
114 SetDlgItemTextA( hwnd, 8204, TDebug_szAssertFilename );
115 SetDlgItemInt( hwnd, 8205, TDebug_uiAssertLineNumber, TRUE );
116 SetDlgItemTextA( hwnd, 8206, TDebug_szAssertExpression );
117 return TRUE;
118 }
119 case WM_COMMAND:
120 switch ( LOWORD( wParam ) )
121 {
122 case 8200: // Quit
123 ExitProcess( 1 );
124 break;
125 case 8201: // Debug
126 EndDialog( hwnd, 1 );
127 break;
128 case 8202: // Ignore
129 ShowCursor( FALSE );
130 EndDialog( hwnd, 0 );
131 break;
132 }
133 break;
134 default:
135 return FALSE;
136 }
137
138 return TRUE;
139}

◆ TDebug_BroadcastDebugString()

void TDebug_BroadcastDebugString ( const TCHAR * a_szString)

Definition at line 86 of file TDebug_Win.cpp.

87{
88 //TIMPLEMENT();
89}

◆ TDebug_FinalPrintf()

void TDebug_FinalPrintf ( const TCHAR * a_szFormat,
... )

Definition at line 49 of file TDebug_Win.cpp.

50{
51 va_list args;
52 va_start( args, a_szFormat );
53 TDebug_FinalVPrintf( a_szFormat, args );
54 va_end( args );
55}
void TDebug_FinalVPrintf(const TCHAR *a_szFormat, va_list a_Args)

◆ TDebug_FinalSPrintf()

void TDebug_FinalSPrintf ( const TCHAR * a_szFormat,
... )

Definition at line 63 of file TDebug_Win.cpp.

64{
65 va_list args;
66 va_start( args, a_szFormat );
67 TDebug_FinalVSPrintf( a_szFormat, args );
68 va_end( args );
69}
void TDebug_FinalVSPrintf(const TCHAR *a_szFormat, va_list a_Args)

◆ TDebug_FinalVPrintf()

void TDebug_FinalVPrintf ( const TCHAR * a_szFormat,
va_list a_Args )

Definition at line 57 of file TDebug_Win.cpp.

58{
59 TDebug_FinalVSPrintf( a_szFormat, a_Args );
61}
TCHAR TDebug_ScratchMem[4096]
void TDebug_OutputDebugString(const TCHAR *a_szString)

◆ TDebug_FinalVSPrintf()

void TDebug_FinalVSPrintf ( const TCHAR * a_szFormat,
va_list a_Args )

Definition at line 71 of file TDebug_Win.cpp.

72{
74 vsprintf( TDebug_ScratchMem, a_szFormat, a_Args );
76}
void TDebug_AcquireMutex()
void TDebug_ReleaseMutex()

◆ TDebug_IsValidAddress()

TBOOL TDebug_IsValidAddress ( const void * a_pPtr)

Definition at line 35 of file TDebug_Win.cpp.

36{
37 if ( a_pPtr != TNULL &&
38 a_pPtr != (void*)0xcdcdcdcd &&
39 a_pPtr != (void*)0xdeaddead &&
40 a_pPtr != (void*)0xbeefbeef &&
41 a_pPtr >= (void*)0x4f )
42 {
43 return TTRUE;
44 }
45
46 return TFALSE;
47}
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25

◆ TDebug_OutputDebugString()

void TDebug_OutputDebugString ( const TCHAR * a_szString)

Definition at line 78 of file TDebug_Win.cpp.

79{
80 OutputDebugStringA( a_szString );
81 printf( "%s", a_szString );
82
83 TDebug_BroadcastDebugString( a_szString );
84}
void TDebug_BroadcastDebugString(const TCHAR *a_szString)

◆ TDebug_ReleaseMutex()

void TDebug_ReleaseMutex ( )

Definition at line 30 of file TDebug_Win.cpp.

31{
32 TDebug_Mutex.Unlock();
33}

Variable Documentation

◆ TDebug_IsMutexCreated

BOOL TDebug_IsMutexCreated

Definition at line 16 of file TDebug_Win.cpp.

◆ TDebug_Mutex

T2Mutex TDebug_Mutex

Definition at line 17 of file TDebug_Win.cpp.

◆ TDebug_ScratchMem

TCHAR TDebug_ScratchMem[4096]

Definition at line 15 of file TDebug_Win.cpp.

◆ TDebug_szAssertExpression

const TCHAR* TDebug_szAssertExpression

Definition at line 94 of file TDebug_Win.cpp.

◆ TDebug_szAssertFilename

const TCHAR* TDebug_szAssertFilename

Definition at line 93 of file TDebug_Win.cpp.

◆ TDebug_uiAssertLineNumber

TUINT TDebug_uiAssertLineNumber

Definition at line 95 of file TDebug_Win.cpp.