1
0
Fork 0

DBG: added suspend/resume all threads

This commit is contained in:
Mr. eXoDia 2014-12-11 17:49:36 +01:00
parent 11bc98c371
commit 90c7c2393a
8 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>resumeallthreads/threadresumeall</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
html,body {
/* Default Font */
font-family: Courier New;
font-size: 11pt;
}
</style>
</head>
<body>
<P><STRONG>resumeallthreads[,threadresumeall]<BR></STRONG>Resume all threads in the debuggee.</P>
<P class=rvps3>
<SPAN class=rvts11>
<U>
arguments
</U>&nbsp;
<BR>
</SPAN>
<SPAN class=rvts9 >
This command has no arguments.</SPAN></P>
<P class=rvps3 >
<SPAN class=rvts11>
<U>result <BR></U></SPAN><SPAN
class=rvts9>This command does not set any result
variables.</SPAN></P>
<P>&nbsp;</P></body>
</html>

View File

@ -0,0 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>suspendallthreads/threadsuspendall</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
html,body {
/* Default Font */
font-family: Courier New;
font-size: 11pt;
}
</style>
</head>
<body>
<P><STRONG>suspendallthreads[,threadsuspendall]<BR></STRONG>Suspend&nbsp;all threads in the debuggee.</P>
<P class=rvps3><SPAN class=rvts11><U>arguments</U>&nbsp;<BR></SPAN><SPAN
class=rvts9>This command has no arguments.</SPAN></P>
<P class=rvps3><SPAN class=rvts11><U>result <BR></U></SPAN><SPAN
class=rvts9>This command does not set any result
variables.</SPAN></P></body>
</html>

Binary file not shown.

View File

@ -1090,6 +1090,24 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[])
return STATUS_ERROR;
}
CMDRESULT cbDebugSuspendAllThreads(int argc, char* argv[])
{
int threadCount = threadgetcount();
int suspendedCount = threadsuspendall();
dprintf("%d/%d thread(s) suspended\n", suspendedCount, threadCount);
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
CMDRESULT cbDebugResumeAllThreads(int argc, char* argv[])
{
int threadCount = threadgetcount();
int resumeCount = threadresumeall();
dprintf("%d/%d thread(s) resumed\n", resumeCount, threadCount);
GuiUpdateAllViews();
return STATUS_CONTINUE;
}
CMDRESULT cbDebugSetPriority(int argc, char* argv[])
{
if(argc < 3)

View File

@ -50,6 +50,8 @@ CMDRESULT cbDebugGetJITAuto(int argc, char* argv[]);
CMDRESULT cbDebugSetJITAuto(int argc, char* argv[]);
CMDRESULT cbDebugSuspendthread(int argc, char* argv[]);
CMDRESULT cbDebugKillthread(int argc, char* argv[]);
CMDRESULT cbDebugSuspendAllThreads(int argc, char* argv[]);
CMDRESULT cbDebugResumeAllThreads(int argc, char* argv[]);
CMDRESULT cbDebugSetPriority(int argc, char* argv[]);
CMDRESULT cbDebugGetCmdline(int argc, char* argv[]);
CMDRESULT cbDebugSetCmdline(int argc, char* argv[]);

View File

@ -50,6 +50,7 @@ void threadclear()
static THREADWAITREASON GetThreadWaitReason(DWORD dwThreadId)
{
//TODO: implement this
return _Executive;
}
@ -126,4 +127,29 @@ DWORD threadgetid(HANDLE hThread)
if(threadList.at(i).hThread == hThread)
return threadList.at(i).dwThreadId;
return 0;
}
int threadgetcount()
{
return (int)threadList.size();
}
int threadsuspendall()
{
CriticalSectionLocker locker(LockThreads);
int count = 0;
for(unsigned int i = 0; i < threadList.size(); i++)
if(SuspendThread(threadList.at(i).hThread) != -1)
count++;
return count;
}
int threadresumeall()
{
CriticalSectionLocker locker(LockThreads);
int count = 0;
for(unsigned int i = 0; i < threadList.size(); i++)
if(ResumeThread(threadList.at(i).hThread) != -1)
count++;
return count;
}

View File

@ -13,5 +13,8 @@ bool threadisvalid(DWORD dwThreadId);
bool threadsetname(DWORD dwTHreadId, const char* name);
HANDLE threadgethandle(DWORD dwThreadId);
DWORD threadgetid(HANDLE hThread);
int threadgetcount();
int threadsuspendall();
int threadresumeall();
#endif //_THREAD_H

View File

@ -74,6 +74,8 @@ static void registercommands()
dbgcmdnew("suspendthread\1threadsuspend", cbDebugSuspendthread, true); //suspend thread
dbgcmdnew("resumethread\1threadresume", cbDebugResumethread, true); //resume thread
dbgcmdnew("killthread\1threadkill", cbDebugKillthread, true); //kill thread
dbgcmdnew("suspendallthreads\1threadsuspendall", cbDebugSuspendAllThreads, true); //suspend all threads
dbgcmdnew("resumeallthreads\1threadresumeall", cbDebugResumeAllThreads, true); //resume all threads
dbgcmdnew("setthreadpriority\1setprioritythread\1threadsetpriority", cbDebugSetPriority, true); //set thread priority
dbgcmdnew("symdownload\1downloadsym", cbDebugDownloadSymbol, true); //download symbols
dbgcmdnew("setjit\1jitset", cbDebugSetJIT, false); //set JIT