mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +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,51 +8,88 @@
|
||||
#include "dbgeventcb.h"
|
||||
#include "dbgsession.h"
|
||||
#include "dbgsystem.h"
|
||||
#include "dbgcmd.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string
|
||||
dbgLoadDump( const std::string &fileName )
|
||||
bool
|
||||
dbgLoadDump( const std::wstring &fileName )
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
try {
|
||||
|
||||
std::vector<wchar_t> fileNameW( fileName.size()+ 1 );
|
||||
|
||||
MultiByteToWideChar(
|
||||
CP_ACP,
|
||||
0,
|
||||
fileName.c_str(),
|
||||
(ULONG)fileName.size() + 1,
|
||||
&fileNameW[0],
|
||||
(ULONG)fileName.size() + 1 );
|
||||
|
||||
hres = dbgExt->client4->OpenDumpFileWide( &fileNameW[0], NULL );
|
||||
|
||||
if ( !dbgSessionStarted )
|
||||
dbgCreateSession();
|
||||
|
||||
hres = dbgExt->client4->OpenDumpFileWide( fileName.c_str(), NULL );
|
||||
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
||||
|
||||
hres = dbgExt->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||
|
||||
setDbgSessionStarted();
|
||||
|
||||
return "loaded ok";
|
||||
return true;
|
||||
}
|
||||
catch( std::exception& )
|
||||
{
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||
}
|
||||
catch( std::exception& )
|
||||
{
|
||||
//g_Ext->Out( "pykd error: %s\n", e.what() );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
//g_Ext->Out( "pykd unexpected error\n" );
|
||||
}
|
||||
|
||||
std::string result = "failed to open dump ";
|
||||
result += fileName;
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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
|
||||
dbgLoadDump( const std::string &dumpName );
|
||||
bool
|
||||
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( "step", &setExecutionStatus<DEBUG_STATUS_STEP_OVER> );
|
||||
boost::python::def( "expr", &evaluate );
|
||||
boost::python::def( "createSession", &dbgCreateSession );
|
||||
boost::python::def( "createSession", &dbgCreateSession ); // deprecated
|
||||
boost::python::def( "isSessionStart", &dbgIsSessionStart );
|
||||
boost::python::def( "symbolsPath", &dbgSymPath );
|
||||
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( "loadDump", &dbgLoadDump );
|
||||
boost::python::def( "startProcess", &startProcess );
|
||||
boost::python::def( "dbgCommand", &dbgCommand );
|
||||
boost::python::def( "isValid", &isOffsetValid );
|
||||
boost::python::def( "is64bitSystem", &is64bitSystem );
|
||||
|
Loading…
Reference in New Issue
Block a user