[0.1.x] updated : something fixed

git-svn-id: https://pykd.svn.codeplex.com/svn@70116 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-09-29 07:53:45 +00:00 committed by Mikhail I. Izmestev
parent dbb9782404
commit d7132015d7
6 changed files with 52 additions and 14 deletions

View File

@ -8,8 +8,8 @@ namespace pykd {
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
DebugClient primaryClient; DebugClientPtr g_dbgClient( new DebugClient );
DebugClient *g_dbgClient = &primaryClient;
void loadDump( const std::wstring &fileName ) { void loadDump( const std::wstring &fileName ) {
g_dbgClient->loadDump( fileName ); g_dbgClient->loadDump( fileName );

View File

@ -4,6 +4,8 @@
#include <dbgeng.h> #include <dbgeng.h>
#include <dbghelp.h> #include <dbghelp.h>
#include <boost\smart_ptr\scoped_ptr.hpp>
#include "dbgexcept.h" #include "dbgexcept.h"
#include "module.h" #include "module.h"
@ -13,6 +15,11 @@ namespace pykd {
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
class DebugClient;
typedef boost::shared_ptr<DebugClient> DebugClientPtr;
/////////////////////////////////////////////////////////////////////////////////
class DebugClient { class DebugClient {
public: public:
@ -21,6 +28,11 @@ public:
virtual ~DebugClient() {} virtual ~DebugClient() {}
static
DebugClientPtr createDbgClient() {
return DebugClientPtr( new DebugClient() );
}
void loadDump( const std::wstring &fileName ); void loadDump( const std::wstring &fileName );
void startProcess( const std::wstring &processName ); void startProcess( const std::wstring &processName );
@ -46,9 +58,11 @@ private:
CComPtr<IDebugSymbols3> m_symbols; CComPtr<IDebugSymbols3> m_symbols;
}; };
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
extern DebugClient *g_dbgClient; extern DebugClientPtr g_dbgClient;
void loadDump( const std::wstring &fileName ); void loadDump( const std::wstring &fileName );

View File

@ -88,7 +88,7 @@ static python::dict genDict(const pyDia::Symbol::ValueNameEntry srcValues[], siz
BOOST_PYTHON_MODULE( pykd ) BOOST_PYTHON_MODULE( pykd )
{ {
python::class_<pykd::DebugClient>("dbgClient", "Class representing a debugging session" ) python::class_<pykd::DebugClient, pykd::DebugClientPtr>("dbgClient", "Class representing a debugging session", python::no_init )
.def( "loadDump", &pykd::DebugClient::loadDump, .def( "loadDump", &pykd::DebugClient::loadDump,
"Load crash dump" ) "Load crash dump" )
.def( "startProcess", &pykd::DebugClient::startProcess, .def( "startProcess", &pykd::DebugClient::startProcess,
@ -102,6 +102,8 @@ BOOST_PYTHON_MODULE( pykd )
.def( "findModule", &pykd::DebugClient::findModule, .def( "findModule", &pykd::DebugClient::findModule,
"Return instance of the Module class which posseses specified address" ); "Return instance of the Module class which posseses specified address" );
boost::python::def( "createDbgClient", pykd::DebugClient::createDbgClient,
"create a new instance of the dbgClient class" );
boost::python::def( "loadDump", &loadDump, boost::python::def( "loadDump", &loadDump,
"Load crash dump (only for console)"); "Load crash dump (only for console)");
boost::python::def( "startProcess", &startProcess, boost::python::def( "startProcess", &startProcess,
@ -130,8 +132,15 @@ BOOST_PYTHON_MODULE( pykd )
"Return the full path to the module's pdb file ( symbol information )" ) "Return the full path to the module's pdb file ( symbol information )" )
.def("reload", &pykd::Module::reloadSymbols, .def("reload", &pykd::Module::reloadSymbols,
"(Re)load symbols for the module" ) "(Re)load symbols for the module" )
.def("symbols", &pykd::Module::getSymbols, .def("offset", &pykd::Module::getSymbol,
"Return list of all symbols of the module" ); "Return offset of the symbol" )
.def("rva", &pykd::Module::getSymbolRva,
"Return rva of the symbol" )
.def("__getattr__", &pykd::Module::getSymbol,
"Return address of the symbol" );
//.def("symbols", &pykd::Module::getSymbols,
// "Return list of all symbols of the module" );
python::def( "diaLoadPdb", &pyDia::GlobalScope::loadPdb, python::def( "diaLoadPdb", &pyDia::GlobalScope::loadPdb,
@ -255,7 +264,7 @@ BOOST_PYTHON_MODULE( pykd )
DEF_PY_CONST_ULONG(LocInMetaData); DEF_PY_CONST_ULONG(LocInMetaData);
DEF_PY_CONST_ULONG(LocIsConstant); DEF_PY_CONST_ULONG(LocIsConstant);
python::scope().attr("diaLocTypeName") = python::scope().attr("diaLocTypeName") =
genDict(pyDia::Symbol::symTagName, _countof(pyDia::Symbol::locTypeName)); genDict(pyDia::Symbol::locTypeName, _countof(pyDia::Symbol::locTypeName));
DEF_PY_CONST_ULONG(btNoType); DEF_PY_CONST_ULONG(btNoType);
DEF_PY_CONST_ULONG(btVoid); DEF_PY_CONST_ULONG(btVoid);

View File

@ -42,15 +42,30 @@ public:
void void
reloadSymbols(); reloadSymbols();
ULONG64
getSymbol( const std::string &symbolname ) {
python::list
getSymbols() {
if ( !m_dia ) if ( !m_dia )
m_dia = pyDia::GlobalScope::loadPdb( getPdbName() ); m_dia = pyDia::GlobalScope::loadPdb( getPdbName() );
return m_dia->findChildrenEx( SymTagNull, "*", nsRegularExpression ); pyDia::SymbolPtr sym = m_dia->getChildByName( symbolname );
return m_base + sym->getRva();
} }
ULONG
getSymbolRva( const std::string &symbolname ) {
if ( !m_dia )
m_dia = pyDia::GlobalScope::loadPdb( getPdbName() );
pyDia::SymbolPtr sym = m_dia->getChildByName( symbolname );
return sym->getRva();
}
private: private:
std::string m_name; std::string m_name;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9.00" Version="9,00"
Name="pykd" Name="pykd"
ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}" ProjectGUID="{FE961905-666F-4908-A212-961465F46F13}"
RootNamespace="pykd" RootNamespace="pykd"

View File

@ -46,6 +46,6 @@ class ModuleTest( unittest.TestCase ):
try: pykd.findModule( target.module.end() + 0x10) try: pykd.findModule( target.module.end() + 0x10)
except pykd.BaseException: pass except pykd.BaseException: pass
def testSymbols( self ): def testSymbol( self ):
syms = target.module.symbols() self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() )
self.assertNotEqual( 0, len( syms ) ) self.assertEqual( target.module.rva("FuncWithName0"), target.module.FuncWithName0 - target.module.begin() )