1
0
Fork 0

don't halt (#1007)

This commit is contained in:
Torusrxxx 2016-08-25 14:23:59 +00:00 committed by Duncan Ogilvie
parent bb3e172efb
commit 430746b32e
4 changed files with 22 additions and 3 deletions

View File

@ -120,10 +120,17 @@ CMDRESULT cbDebugStop(int argc, char* argv[])
StopDebug();
//history
HistoryClear();
DWORD BeginTick = GetTickCount();
while(waitislocked(WAITID_STOP)) //custom waiting
{
unlock(WAITID_RUN);
Sleep(1);
Sleep(100);
DWORD CurrentTick = GetTickCount();
if(CurrentTick - BeginTick > 10000)
{
dputs(QT_TRANSLATE_NOOP("DBG", "The debuggee does not stop after 10 seconds. The debugger state may be corrupted."));
return STATUS_ERROR;
}
}
return STATUS_CONTINUE;
}

View File

@ -13,6 +13,11 @@ void wait(WAIT_ID id)
WaitForSingleObject(waitArray[id], INFINITE);
}
bool waitfor(WAIT_ID id, unsigned int Milliseconds)
{
return WaitForSingleObject(waitArray[id], Milliseconds) == 0;
}
void lock(WAIT_ID id)
{
ResetEvent(waitArray[id]);

View File

@ -13,6 +13,7 @@ enum WAIT_ID
//functions
void waitclear();
void wait(WAIT_ID id);
bool waitfor(WAIT_ID id, unsigned int Milliseconds);
void lock(WAIT_ID id);
void unlock(WAIT_ID id);
bool waitislocked(WAIT_ID id);

View File

@ -585,14 +585,20 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
return nullptr;
}
/**
@brief This function is called when the user closes the debugger.
*/
extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
{
dputs(QT_TRANSLATE_NOOP("DBG", "Stopping running debuggee..."));
cbDebugStop(0, 0);
dputs(QT_TRANSLATE_NOOP("DBG", "Waiting for the debuggee to be stopped..."));
if(!waitfor(WAITID_STOP, 10000)) //after this, debugging stopped
{
dputs(QT_TRANSLATE_NOOP("DBG", "The debuggee does not close after 10 seconds. Probably the debugger state has been corrupted."));
}
dputs(QT_TRANSLATE_NOOP("DBG", "Aborting scripts..."));
scriptabort();
dputs(QT_TRANSLATE_NOOP("DBG", "Waiting for the debuggee to be stopped..."));
wait(WAITID_STOP); //after this, debugging stopped
dputs(QT_TRANSLATE_NOOP("DBG", "Unloading plugins..."));
pluginunload();
dputs(QT_TRANSLATE_NOOP("DBG", "Stopping command thread..."));