[pykd] added : routine breakin ( Break into debugger )

git-svn-id: https://pykd.svn.codeplex.com/svn@69014 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-08-15 15:24:37 +00:00
parent 9e5fe5cab5
commit 3c2903218b
3 changed files with 92 additions and 150 deletions

View File

@ -15,8 +15,6 @@ dbgCommand( const std::string &command )
{ {
HRESULT hres; HRESULT hres;
try {
OutputReader outReader( dbgExt->client ); OutputReader outReader( dbgExt->client );
hres = dbgExt->control->Execute( DEBUG_OUTCTL_THIS_CLIENT, command.c_str(), 0 ); hres = dbgExt->control->Execute( DEBUG_OUTCTL_THIS_CLIENT, command.c_str(), 0 );
@ -25,17 +23,6 @@ dbgCommand( const std::string &command )
return std::string( outReader.Line() ); return std::string( outReader.Line() );
} }
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return "error";
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -43,21 +30,9 @@ dbgExtensionClass::dbgExtensionClass( const char* path ) : m_path(path)
{ {
HRESULT hres; HRESULT hres;
try {
hres = dbgExt->control->AddExtension( path, 0, &m_handle ); hres = dbgExt->control->AddExtension( path, 0, &m_handle );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugControl::AddExtension failed" ); throw DbgException( "IDebugControl::AddExtension failed" );
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -75,8 +50,6 @@ dbgExtensionClass::call( const std::string &command, const std::string params )
{ {
HRESULT hres; HRESULT hres;
try {
OutputReader outReader( dbgExt->client ); OutputReader outReader( dbgExt->client );
hres = dbgExt->control->CallExtension( m_handle, command.c_str(), params.c_str() ); hres = dbgExt->control->CallExtension( m_handle, command.c_str(), params.c_str() );
@ -85,40 +58,14 @@ dbgExtensionClass::call( const std::string &command, const std::string params )
return std::string( outReader.Line() ); return std::string( outReader.Line() );
} }
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return "error";
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
std::string std::string
dbgExtensionClass::print() const dbgExtensionClass::print() const
{
HRESULT status = S_OK;
try
{ {
return m_handle ? m_path : ""; return m_handle ? m_path : "";
} }
catch (std::exception & e)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch (...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return "";
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -128,8 +75,6 @@ evaluate( const std::string &expression )
HRESULT hres; HRESULT hres;
ULONG64 value = 0; ULONG64 value = 0;
try {
DEBUG_VALUE debugValue = {}; DEBUG_VALUE debugValue = {};
ULONG remainderIndex = 0; ULONG remainderIndex = 0;
@ -161,18 +106,24 @@ evaluate( const std::string &expression )
if ( remainderIndex == expression.length() ) if ( remainderIndex == expression.length() )
value = debugValue.I32; value = debugValue.I32;
} }
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return value; return value;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void
breakin()
{
HRESULT hres;
{
PyThread_StateRestore state;
hres = dbgExt->control->SetInterrupt( DEBUG_INTERRUPT_ACTIVE );
}
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::SetInterrupt" );
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -10,17 +10,15 @@ std::string
dbgCommand( const std::string &command ); dbgCommand( const std::string &command );
template <ULONG status> template <ULONG status>
bool void
setExecutionStatus() setExecutionStatus()
{ {
HRESULT hres; HRESULT hres;
try {
hres = dbgExt->control->SetExecutionStatus( status ); hres = dbgExt->control->SetExecutionStatus( status );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
return false; throw DbgException( "IDebugControl::SetExecutionStatus failed" );
ULONG currentStatus; ULONG currentStatus;
@ -34,29 +32,15 @@ setExecutionStatus()
} }
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugControl::SetExecutionStatus failed" ); throw DbgException( "IDebugControl::WaitForEvent failed" );
hres = dbgExt->control->GetExecutionStatus( &currentStatus ); hres = dbgExt->control->GetExecutionStatus( &currentStatus );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetExecutionStatus failed" ); throw DbgException( "IDebugControl::GetExecutionStatus failed" );
} while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE ); } while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE );
return true;
}
catch( std::exception &e )
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
}
catch(...)
{
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
}
return false;
} }
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@ -92,3 +76,8 @@ ULONG64
evaluate( const std::string &expression ); evaluate( const std::string &expression );
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
void
breakin();
/////////////////////////////////////////////////////////////////////////////////

View File

@ -75,6 +75,8 @@ BOOST_PYTHON_MODULE( pykd )
"Change debugger status to DEBUG_STATUS_STEP_INTO" ); "Change debugger status to DEBUG_STATUS_STEP_INTO" );
boost::python::def( "step", &setExecutionStatus<DEBUG_STATUS_STEP_OVER>, boost::python::def( "step", &setExecutionStatus<DEBUG_STATUS_STEP_OVER>,
"Change debugger status to DEBUG_STATUS_STEP_OVER" ); "Change debugger status to DEBUG_STATUS_STEP_OVER" );
boost::python::def( "breakin", &breakin,
"Break into debugger" );
boost::python::def( "expr", &evaluate, boost::python::def( "expr", &evaluate,
"Evaluate windbg expression" ); "Evaluate windbg expression" );
boost::python::def( "isWindbgExt", &isWindbgExt, boost::python::def( "isWindbgExt", &isWindbgExt,