mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[!] restored revisions: 62086 and 62085
git-svn-id: https://pykd.svn.codeplex.com/svn@62092 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
45bc63ea23
commit
b720184b4e
@ -8,27 +8,22 @@
|
|||||||
#include "dbgeventcb.h"
|
#include "dbgeventcb.h"
|
||||||
#include "dbgsession.h"
|
#include "dbgsession.h"
|
||||||
#include "dbgsystem.h"
|
#include "dbgsystem.h"
|
||||||
|
#include "dbgcmd.h"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string
|
bool
|
||||||
dbgLoadDump( const std::string &fileName )
|
dbgLoadDump( const std::wstring &fileName )
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
std::vector<wchar_t> fileNameW( fileName.size()+ 1 );
|
if ( !dbgSessionStarted )
|
||||||
|
dbgCreateSession();
|
||||||
|
|
||||||
MultiByteToWideChar(
|
hres = dbgExt->client4->OpenDumpFileWide( fileName.c_str(), NULL );
|
||||||
CP_ACP,
|
|
||||||
0,
|
|
||||||
fileName.c_str(),
|
|
||||||
(ULONG)fileName.size() + 1,
|
|
||||||
&fileNameW[0],
|
|
||||||
(ULONG)fileName.size() + 1 );
|
|
||||||
|
|
||||||
hres = dbgExt->client4->OpenDumpFileWide( &fileNameW[0], NULL );
|
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
||||||
|
|
||||||
@ -36,23 +31,65 @@ dbgLoadDump( const std::string &fileName )
|
|||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
|
|
||||||
setDbgSessionStarted();
|
return true;
|
||||||
|
|
||||||
return "loaded ok";
|
|
||||||
}
|
}
|
||||||
catch( std::exception& )
|
catch( std::exception& )
|
||||||
{
|
{
|
||||||
//g_Ext->Out( "pykd error: %s\n", e.what() );
|
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
//g_Ext->Out( "pykd unexpected error\n" );
|
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string result = "failed to open dump ";
|
return false;
|
||||||
result += fileName;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool
|
||||||
|
startProcess( const std::wstring &processName )
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if ( !dbgSessionStarted )
|
||||||
|
dbgCreateSession();
|
||||||
|
|
||||||
|
ULONG opt;
|
||||||
|
hres = dbgExt->control->GetEngineOptions( &opt );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::GetEngineOptions failed" );
|
||||||
|
|
||||||
|
opt |= DEBUG_ENGOPT_INITIAL_BREAK;
|
||||||
|
hres = dbgExt->control->SetEngineOptions( opt );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::SetEngineOptions failed" );
|
||||||
|
|
||||||
|
std::vector< std::wstring::value_type> cmdLine( processName.size() + 1 );
|
||||||
|
wcscpy_s( &cmdLine[0], cmdLine.size(), processName.c_str() );
|
||||||
|
|
||||||
|
hres = dbgExt->client4->CreateProcessWide( 0, &cmdLine[0], DEBUG_PROCESS | DETACHED_PROCESS );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugClient4::CreateProcessWide failed" );
|
||||||
|
|
||||||
|
hres = dbgExt->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
@ -4,7 +4,10 @@
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string
|
bool
|
||||||
dbgLoadDump( const std::string &dumpName );
|
dbgLoadDump( const std::wstring &dumpName );
|
||||||
|
|
||||||
|
bool
|
||||||
|
startProcess( const std::wstring &processName );
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -91,12 +91,13 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
boost::python::def( "trace", &setExecutionStatus<DEBUG_STATUS_STEP_INTO> );
|
boost::python::def( "trace", &setExecutionStatus<DEBUG_STATUS_STEP_INTO> );
|
||||||
boost::python::def( "step", &setExecutionStatus<DEBUG_STATUS_STEP_OVER> );
|
boost::python::def( "step", &setExecutionStatus<DEBUG_STATUS_STEP_OVER> );
|
||||||
boost::python::def( "expr", &evaluate );
|
boost::python::def( "expr", &evaluate );
|
||||||
boost::python::def( "createSession", &dbgCreateSession );
|
boost::python::def( "createSession", &dbgCreateSession ); // deprecated
|
||||||
boost::python::def( "isSessionStart", &dbgIsSessionStart );
|
boost::python::def( "isSessionStart", &dbgIsSessionStart );
|
||||||
boost::python::def( "symbolsPath", &dbgSymPath );
|
boost::python::def( "symbolsPath", &dbgSymPath );
|
||||||
boost::python::def( "dprint", &DbgPrint::dprint, dprint( boost::python::args( "str", "dml" ), "" ) );
|
boost::python::def( "dprint", &DbgPrint::dprint, dprint( boost::python::args( "str", "dml" ), "" ) );
|
||||||
boost::python::def( "dprintln", &DbgPrint::dprintln, dprintln( boost::python::args( "str", "dml" ), "" ) );
|
boost::python::def( "dprintln", &DbgPrint::dprintln, dprintln( boost::python::args( "str", "dml" ), "" ) );
|
||||||
boost::python::def( "loadDump", &dbgLoadDump );
|
boost::python::def( "loadDump", &dbgLoadDump );
|
||||||
|
boost::python::def( "startProcess", &startProcess );
|
||||||
boost::python::def( "dbgCommand", &dbgCommand );
|
boost::python::def( "dbgCommand", &dbgCommand );
|
||||||
boost::python::def( "isValid", &isOffsetValid );
|
boost::python::def( "isValid", &isOffsetValid );
|
||||||
boost::python::def( "is64bitSystem", &is64bitSystem );
|
boost::python::def( "is64bitSystem", &is64bitSystem );
|
||||||
|
Loading…
Reference in New Issue
Block a user