From e44a8c41f1ca51ac7639c5930727f596df503049 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Tue, 13 Dec 2011 14:49:11 +0000 Subject: [PATCH] [0.1.x] added : getPdbFile routine git-svn-id: https://pykd.svn.codeplex.com/svn@72299 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgclient.cpp | 33 +++++++++++++++++++++++++++++++++ pykd/dbgclient.h | 4 ++++ pykd/dbgext.cpp | 4 ++++ test/scripts/clienttest.py | 3 +++ 4 files changed, 44 insertions(+) diff --git a/pykd/dbgclient.cpp b/pykd/dbgclient.cpp index f02d338..b66fe23 100644 --- a/pykd/dbgclient.cpp +++ b/pykd/dbgclient.cpp @@ -285,6 +285,39 @@ ULONG64 getOffset( const std::wstring symbolname ) /////////////////////////////////////////////////////////////////////////////////// +std::string DebugClient::getPdbFile( ULONG64 moduleBase ) +{ + HRESULT hres; + IMAGEHLP_MODULEW64 imageHelpInfo = { 0 }; + + hres = + m_advanced->GetSymbolInformation( + DEBUG_SYMINFO_IMAGEHLP_MODULEW64, + moduleBase, + 0, + &imageHelpInfo, + sizeof( imageHelpInfo ), + NULL, + NULL, + 0, + NULL ); + + if ( FAILED( hres ) ) + throw DbgException( "IDebugAdvanced2::GetSymbolInformation failed" ); + + char fileName[ 256 ]; + WideCharToMultiByte( CP_ACP, 0, imageHelpInfo.LoadedPdbName, 256, fileName, 256, NULL, NULL ); + + return std::string( fileName ); +} + +std::string getPdbFile( ULONG64 moduleBase ) +{ + return g_dbgClient->getPdbFile( moduleBase ); +} + +/////////////////////////////////////////////////////////////////////////////////// + void DebugClient::setExecutionStatus( ULONG status ) { HRESULT hres; diff --git a/pykd/dbgclient.h b/pykd/dbgclient.h index 2514edf..c03c010 100644 --- a/pykd/dbgclient.h +++ b/pykd/dbgclient.h @@ -95,6 +95,8 @@ public: ULONG64 getOffset( const std::wstring symbolname ); + std::string getPdbFile( ULONG64 moduleBase ); + template void changeDebuggerStatus(); @@ -271,6 +273,8 @@ ULONG getExecutionStatus(); ULONG64 getOffset( const std::wstring symbolname ); +std::string getPdbFile( ULONG64 moduleBase ); + bool is64bitSystem(); bool isKernelDebugging(); diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index bb8e9ea..e6f7191 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -164,6 +164,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return information about the execution status of the debugger" ) .def( "getOffset", &DebugClient::getOffset, "Return traget virtual address for specified symbol" ) + .def( "getPdbFile", &DebugClient::getPdbFile, + "Return full path to PDB (Program DataBase, debug information) file" ) .def( "go", &DebugClient::changeDebuggerStatus, "Change debugger status to DEBUG_STATUS_GO" ) .def( "is64bitSystem", &DebugClient::is64bitSystem, @@ -287,6 +289,8 @@ BOOST_PYTHON_MODULE( pykd ) "Return information about the execution status of the debugger" ); python::def( "getOffset", &getOffset, "Return traget virtual address for specified symbol" ); + python::def( "getPdbFile", &getPdbFile, + "Return full path to PDB (Program DataBase, debug information) file" ); python::def( "go", &changeDebuggerStatus, "Change debugger status to DEBUG_STATUS_GO" ); python::def( "is64bitSystem", &is64bitSystem, diff --git a/test/scripts/clienttest.py b/test/scripts/clienttest.py index 50aac4d..14e3bd0 100644 --- a/test/scripts/clienttest.py +++ b/test/scripts/clienttest.py @@ -21,6 +21,9 @@ class DbgClientTest( unittest.TestCase ): pykd.setExecutionStatus( pykd.DEBUG_STATUS_GO ) pykd.waitForEvent() self.assertEqual( pykd.DEBUG_STATUS_BREAK, pykd.getExecutionStatus() ) + + def testPdbFile( self ): + self.assertNotEqual( '', target.module )