[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;
try {
OutputReader outReader( dbgExt->client );
hres = dbgExt->control->Execute( DEBUG_OUTCTL_THIS_CLIENT, command.c_str(), 0 );
@ -24,17 +22,6 @@ dbgCommand( const std::string &command )
throw DbgException( "IDebugControl::Execute failed" );
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;
try {
hres = dbgExt->control->AddExtension( path, 0, &m_handle );
if ( FAILED( hres ) )
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;
try {
OutputReader outReader( dbgExt->client );
hres = dbgExt->control->CallExtension( m_handle, command.c_str(), params.c_str() );
@ -84,17 +57,6 @@ dbgExtensionClass::call( const std::string &command, const std::string params )
throw DbgException( "IDebugControl::CallExtension failed" );
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";
}
///////////////////////////////////////////////////////////////////////////////
@ -102,22 +64,7 @@ dbgExtensionClass::call( const std::string &command, const std::string params )
std::string
dbgExtensionClass::print() const
{
HRESULT status = S_OK;
try
{
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;
ULONG64 value = 0;
try {
DEBUG_VALUE debugValue = {};
ULONG remainderIndex = 0;
@ -161,18 +106,24 @@ evaluate( const std::string &expression )
if ( remainderIndex == expression.length() )
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;
}
///////////////////////////////////////////////////////////////////////////////
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 );
template <ULONG status>
bool
void
setExecutionStatus()
{
HRESULT hres;
try {
hres = dbgExt->control->SetExecutionStatus( status );
if ( FAILED( hres ) )
return false;
throw DbgException( "IDebugControl::SetExecutionStatus failed" );
ULONG currentStatus;
@ -34,29 +32,15 @@ setExecutionStatus()
}
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::SetExecutionStatus failed" );
throw DbgException( "IDebugControl::WaitForEvent failed" );
hres = dbgExt->control->GetExecutionStatus( &currentStatus );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::GetExecutionStatus failed" );
} 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 );
/////////////////////////////////////////////////////////////////////////////////
void
breakin();
/////////////////////////////////////////////////////////////////////////////////

View File

@ -75,6 +75,8 @@ BOOST_PYTHON_MODULE( pykd )
"Change debugger status to DEBUG_STATUS_STEP_INTO" );
boost::python::def( "step", &setExecutionStatus<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,
"Evaluate windbg expression" );
boost::python::def( "isWindbgExt", &isWindbgExt,