mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.1.x] ~ python thread state restore for create process and load dump
git-svn-id: https://pykd.svn.codeplex.com/svn@75087 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
7eb1b48220
commit
1503c4e7f6
@ -168,11 +168,10 @@ void DebugClient::loadDump( const std::wstring &fileName )
|
|||||||
hres = m_client->OpenDumpFileWide( fileName.c_str(), NULL );
|
hres = m_client->OpenDumpFileWide( fileName.c_str(), NULL );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
||||||
|
|
||||||
hres = m_control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
hres = safeWaitForEvent();
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadDump( const std::wstring &fileName ) {
|
void loadDump( const std::wstring &fileName ) {
|
||||||
@ -184,7 +183,7 @@ void loadDump( const std::wstring &fileName ) {
|
|||||||
void DebugClient::startProcess( const std::wstring &processName )
|
void DebugClient::startProcess( const std::wstring &processName )
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
ULONG opt;
|
ULONG opt;
|
||||||
hres = m_control->GetEngineOptions( &opt );
|
hres = m_control->GetEngineOptions( &opt );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
@ -202,13 +201,13 @@ void DebugClient::startProcess( const std::wstring &processName )
|
|||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient4::CreateProcessWide failed" );
|
throw DbgException( "IDebugClient4::CreateProcessWide failed" );
|
||||||
|
|
||||||
hres = m_control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
hres = safeWaitForEvent();
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void startProcess( const std::wstring &processName ) {
|
void startProcess( const std::wstring &processName ) {
|
||||||
g_dbgClient->startProcess( processName );
|
g_dbgClient->startProcess( processName );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -366,7 +365,6 @@ void DebugClient::setExecutionStatus( ULONG status )
|
|||||||
|
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::SetExecutionStatus failed" );
|
throw DbgException( "IDebugControl::SetExecutionStatus failed" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExecutionStatus( ULONG status )
|
void setExecutionStatus( ULONG status )
|
||||||
@ -376,15 +374,17 @@ void setExecutionStatus( ULONG status )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
HRESULT DebugClient::safeWaitForEvent(ULONG timeout /*= INFINITE*/, ULONG flags /*= DEBUG_WAIT_DEFAULT*/)
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( m_pyThreadState );
|
||||||
|
return m_control->WaitForEvent( flags, timeout );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DebugClient::waitForEvent()
|
void DebugClient::waitForEvent()
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres = safeWaitForEvent();
|
||||||
|
|
||||||
do {
|
|
||||||
PyThread_StateRestore pyThreadRestore( m_pyThreadState );
|
|
||||||
hres = m_control->WaitForEvent( 0, INFINITE );
|
|
||||||
|
|
||||||
} while( false );
|
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
{
|
{
|
||||||
|
@ -352,6 +352,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
HRESULT safeWaitForEvent(ULONG timeout = INFINITE, ULONG flags = DEBUG_WAIT_DEFAULT);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
python::list
|
python::list
|
||||||
loadArray( ULONG64 offset, ULONG count, bool phyAddr );
|
loadArray( ULONG64 offset, ULONG count, bool phyAddr );
|
||||||
|
Loading…
Reference in New Issue
Block a user