DBG: fixed some stuff with the CriticalSectionLocker
This commit is contained in:
parent
d89228bf74
commit
620fa50ae9
|
@ -1,4 +1,7 @@
|
|||
#include "console.h"
|
||||
#include "threading.h"
|
||||
|
||||
static char msg[66000] = "";
|
||||
|
||||
void dputs(const char* text)
|
||||
{
|
||||
|
@ -7,9 +10,9 @@ void dputs(const char* text)
|
|||
|
||||
void dprintf(const char* format, ...)
|
||||
{
|
||||
CriticalSectionLocker locker(LockDprintf);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
Memory<char*> msg(66000);
|
||||
vsnprintf(msg, msg.size(), format, args);
|
||||
vsnprintf(msg, sizeof(msg), format, args);
|
||||
GuiAddLogMessage(msg);
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@ bool waitislocked(WAIT_ID id)
|
|||
return waitarray[id];
|
||||
}
|
||||
|
||||
static CRITICAL_SECTION locks[LockLast] = {};
|
||||
static bool bInitDone = false;
|
||||
CRITICAL_SECTION CriticalSectionLocker::locks[LockLast] = {};
|
||||
bool CriticalSectionLocker::bInitDone = false;
|
||||
|
||||
static void CriticalSectionInitializeLocks()
|
||||
void CriticalSectionLocker::Initialize()
|
||||
{
|
||||
if(bInitDone)
|
||||
return;
|
||||
|
@ -40,18 +40,21 @@ static void CriticalSectionInitializeLocks()
|
|||
bInitDone = true;
|
||||
}
|
||||
|
||||
void CriticalSectionDeleteLocks()
|
||||
void CriticalSectionLocker::Deinitialize()
|
||||
{
|
||||
if(!bInitDone)
|
||||
return;
|
||||
for(int i = 0; i < LockLast; i++)
|
||||
{
|
||||
EnterCriticalSection(&locks[i]); //obtain ownership
|
||||
DeleteCriticalSection(&locks[i]);
|
||||
}
|
||||
bInitDone = false;
|
||||
}
|
||||
|
||||
CriticalSectionLocker::CriticalSectionLocker(CriticalSectionLock lock)
|
||||
{
|
||||
CriticalSectionInitializeLocks(); //initialize critical sections
|
||||
Initialize(); //initialize critical sections
|
||||
gLock = lock;
|
||||
|
||||
EnterCriticalSection(&locks[gLock]);
|
||||
|
|
|
@ -31,20 +31,24 @@ enum CriticalSectionLock
|
|||
LockBreakpoints,
|
||||
LockPatches,
|
||||
LockThreads,
|
||||
LockDprintf,
|
||||
LockLast
|
||||
};
|
||||
|
||||
void CriticalSectionDeleteLocks();
|
||||
|
||||
class CriticalSectionLocker
|
||||
{
|
||||
public:
|
||||
static void Deinitialize();
|
||||
CriticalSectionLocker(CriticalSectionLock lock);
|
||||
~CriticalSectionLocker();
|
||||
void unlock();
|
||||
void relock();
|
||||
|
||||
private:
|
||||
static void Initialize();
|
||||
static bool bInitDone;
|
||||
static CRITICAL_SECTION locks[LockLast];
|
||||
|
||||
CriticalSectionLock gLock;
|
||||
bool Locked;
|
||||
};
|
||||
|
|
|
@ -312,7 +312,7 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
|
|||
}
|
||||
else
|
||||
DeleteFileA(alloctrace);
|
||||
CriticalSectionDeleteLocks();
|
||||
CriticalSectionLocker::Deinitialize();
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT bool _dbg_dbgcmddirectexec(const char* cmd)
|
||||
|
|
Loading…
Reference in New Issue