mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00
[+] added: getThreadList routine; returns thread object's ptr list
git-svn-id: https://pykd.svn.codeplex.com/svn@58073 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
347a43d194
commit
b6eaf03db1
@ -28,6 +28,7 @@
|
||||
#include "dbgstack.h"
|
||||
#include "dbgpath.h"
|
||||
#include "dbginput.h"
|
||||
#include "dbgprocess.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -134,6 +135,7 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
boost::python::def( "getPdbFile", &getPdbFile );
|
||||
boost::python::def( "getImplicitThread", &getImplicitThread );
|
||||
boost::python::def( "setImplicitThread", &setImplicitThread );
|
||||
boost::python::def( "getThreadList", &getThreadList );
|
||||
boost::python::class_<typedVarClass>( "typedVarClass" )
|
||||
.def("getAddress", &typedVarClass::getAddress )
|
||||
.def("sizeof", &typedVarClass::size );
|
||||
@ -214,6 +216,7 @@ SetupDebugEngine( IDebugClient4 *client, DbgExt *dbgExt )
|
||||
|
||||
client->QueryInterface( __uuidof(IDebugAdvanced2), (void **)&dbgExt->advanced2 );
|
||||
|
||||
client->QueryInterface( __uuidof(IDebugSystemObjects), (void**)&dbgExt->system );
|
||||
client->QueryInterface( __uuidof(IDebugSystemObjects2), (void**)&dbgExt->system2 );
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ struct DbgExt {
|
||||
|
||||
IDebugAdvanced2 *advanced2;
|
||||
|
||||
IDebugSystemObjects *system;
|
||||
IDebugSystemObjects2 *system2;
|
||||
};
|
||||
|
||||
|
69
pykd/dbgprocess.cpp
Normal file
69
pykd/dbgprocess.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "dbgprocess.h"
|
||||
#include "dbgext.h"
|
||||
#include "dbgexcept.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
boost::python::object
|
||||
getThreadList()
|
||||
{
|
||||
HRESULT hres;
|
||||
PULONG ids = NULL;
|
||||
ULONG i;
|
||||
ULONG oldThreadId = 0;
|
||||
|
||||
try {
|
||||
|
||||
ULONG threadCount;
|
||||
hres = dbgExt->system->GetNumberThreads( &threadCount );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSystemObjects::GetNumberThreads failed" );
|
||||
|
||||
ids = new ULONG[threadCount];
|
||||
hres = dbgExt->system->GetThreadIdsByIndex( 0, threadCount, ids, NULL );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSystemObjects::GetThreadIdsByIndex failed" );
|
||||
|
||||
hres = dbgExt->system->GetCurrentThreadId( &oldThreadId );
|
||||
|
||||
boost::python::list threadList;
|
||||
|
||||
for ( i = 0; i < threadCount; ++i )
|
||||
{
|
||||
dbgExt->system->SetCurrentThreadId( ids[i] );
|
||||
|
||||
ULONG64 threadOffset;
|
||||
hres = dbgExt->system->GetCurrentThreadDataOffset( &threadOffset );
|
||||
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugSystemObjects::GetCurrentThreadDataOffset failed" );
|
||||
|
||||
threadList.append( threadOffset );
|
||||
}
|
||||
|
||||
if ( ids )
|
||||
delete[] ids;
|
||||
|
||||
return threadList;
|
||||
}
|
||||
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" );
|
||||
}
|
||||
|
||||
if ( oldThreadId )
|
||||
dbgExt->system->SetCurrentThreadId( oldThreadId );
|
||||
|
||||
if ( ids )
|
||||
delete[] ids;
|
||||
|
||||
return boost::python::list();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
11
pykd/dbgprocess.h
Normal file
11
pykd/dbgprocess.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/object.hpp>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
boost::python::object
|
||||
getThreadList();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
@ -383,6 +383,10 @@
|
||||
RelativePath=".\dbgprint.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dbgprocess.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dbgreg.cpp"
|
||||
>
|
||||
@ -493,6 +497,10 @@
|
||||
RelativePath=".\dbgprint.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dbgprocess.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dbgreg.h"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user