mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.3.x] updated: test
git-svn-id: https://pykd.svn.codeplex.com/svn@83868 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
fd0174d87c
commit
b4e50eff82
35
pykd/dbgengine.cpp
Normal file
35
pykd/dbgengine.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include "kdlib/dbgengine.h"
|
||||||
|
|
||||||
|
#include "dbgengine.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void targetGo()
|
||||||
|
{
|
||||||
|
PyThreadState* state = PyEval_SaveThread();
|
||||||
|
|
||||||
|
kdlib::targetGo();
|
||||||
|
|
||||||
|
PyEval_RestoreThread( state );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset )
|
||||||
|
{
|
||||||
|
std::wstring fileName;
|
||||||
|
unsigned long lineno;
|
||||||
|
long displacement;
|
||||||
|
|
||||||
|
kdlib::getSourceLine( fileName, lineno, displacement, offset );
|
||||||
|
|
||||||
|
return python::make_tuple( fileName, lineno, displacement );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
} //end namespace pykd
|
@ -1,11 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/python/tuple.hpp>
|
||||||
|
namespace python = boost::python;
|
||||||
|
|
||||||
|
#include "kdlib/dbgengine.h"
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void targetGo();
|
void targetGo();
|
||||||
|
|
||||||
|
python::tuple getSourceLine( kdlib::MEMOFFSET_64 offset = 0 );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} //end namespace pykd
|
} //end namespace pykd
|
@ -123,12 +123,12 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="dbgengine.h" />
|
||||||
<ClInclude Include="dbgexcept.h" />
|
<ClInclude Include="dbgexcept.h" />
|
||||||
<ClInclude Include="memaccess.h" />
|
<ClInclude Include="memaccess.h" />
|
||||||
<ClInclude Include="module.h" />
|
<ClInclude Include="module.h" />
|
||||||
<ClInclude Include="stdafx.h" />
|
<ClInclude Include="stdafx.h" />
|
||||||
<ClInclude Include="stladaptor.h" />
|
<ClInclude Include="stladaptor.h" />
|
||||||
<ClInclude Include="target.h" />
|
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
<ClInclude Include="typedvar.h" />
|
<ClInclude Include="typedvar.h" />
|
||||||
<ClInclude Include="typeinfo.h" />
|
<ClInclude Include="typeinfo.h" />
|
||||||
@ -136,6 +136,7 @@
|
|||||||
<ClInclude Include="windbgext.h" />
|
<ClInclude Include="windbgext.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="dbgengine.cpp" />
|
||||||
<ClCompile Include="dbgexcept.cpp" />
|
<ClCompile Include="dbgexcept.cpp" />
|
||||||
<ClCompile Include="dllmain.cpp">
|
<ClCompile Include="dllmain.cpp">
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
||||||
@ -154,7 +155,6 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug_2.7|Win32'">Create</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="target.cpp" />
|
|
||||||
<ClCompile Include="windbgext.cpp" />
|
<ClCompile Include="windbgext.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -30,9 +30,6 @@
|
|||||||
<ClInclude Include="module.h">
|
<ClInclude Include="module.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="target.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="dbgexcept.h">
|
<ClInclude Include="dbgexcept.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -48,6 +45,9 @@
|
|||||||
<ClInclude Include="typedvar.h">
|
<ClInclude Include="typedvar.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="dbgengine.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
@ -62,10 +62,10 @@
|
|||||||
<ClCompile Include="pymod.cpp">
|
<ClCompile Include="pymod.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="target.cpp">
|
<ClCompile Include="dbgexcept.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="dbgexcept.cpp">
|
<ClCompile Include="dbgengine.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "target.h"
|
#include "dbgengine.h"
|
||||||
#include "dbgexcept.h"
|
#include "dbgexcept.h"
|
||||||
#include "memaccess.h"
|
#include "memaccess.h"
|
||||||
#include "typeinfo.h"
|
#include "typeinfo.h"
|
||||||
@ -71,8 +71,8 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( loadFloats_, loadFloats, 2, 3 );
|
|||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( loadDoubles_, loadDoubles, 2, 3 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( loadDoubles_, loadDoubles, 2, 3 );
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS( compareMemory_, kdlib::compareMemory, 3, 4 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( compareMemory_, kdlib::compareMemory, 3, 4 );
|
||||||
//
|
//
|
||||||
//BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceLine_, getSourceLine, 0, 1 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceLine_, getSourceLine, 0, 1 );
|
||||||
//BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceFile_, getSourceFile, 0, 1 );
|
BOOST_PYTHON_FUNCTION_OVERLOADS( getSourceFile_, kdlib::getSourceFile, 0, 1 );
|
||||||
//
|
//
|
||||||
//BOOST_PYTHON_FUNCTION_OVERLOADS( setSoftwareBp_, setSoftwareBp, 1, 2 );
|
//BOOST_PYTHON_FUNCTION_OVERLOADS( setSoftwareBp_, setSoftwareBp, 1, 2 );
|
||||||
//BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
//BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBp_, setHardwareBp, 3, 4 );
|
||||||
@ -238,13 +238,13 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
python::def( "loadDoubles", &loadDoubles, loadDoubles_( python::args( "offset", "count", "phyAddr" ),
|
python::def( "loadDoubles", &loadDoubles, loadDoubles_( python::args( "offset", "count", "phyAddr" ),
|
||||||
"Read the block of the target's memory and return it as list of doubles" ) );
|
"Read the block of the target's memory and return it as list of doubles" ) );
|
||||||
|
|
||||||
// // types and vaiables
|
// types and vaiables
|
||||||
// python::def( "getSourceFile", &getSourceFile, getSourceFile_( python::args( "offset"),
|
python::def( "getSourceFile", &kdlib::getSourceFile, getSourceFile_( python::args( "offset"),
|
||||||
// "Return source file by the specified offset" ) );
|
"Return source file by the specified offset" ) );
|
||||||
// python::def( "getSourceLine", &getSourceLine, getSourceLine_( python::args( "offset"),
|
python::def( "getSourceLine", &getSourceLine, getSourceLine_( python::args( "offset"),
|
||||||
// "Return source file name, line and displacement by the specified offset" ) );
|
"Return source file name, line and displacement by the specified offset" ) );
|
||||||
// python::def( "getOffset", &TypeInfo::getOffset,
|
python::def( "getOffset", &kdlib::getSymbolOffset,
|
||||||
// "Return traget virtual address for specified symbol" );
|
"Return traget virtual address for specified symbol" );
|
||||||
// python::def( "findSymbol", &TypeInfo::findSymbol, findSymbol_( python::args( "offset", "showDisplacement"),
|
// python::def( "findSymbol", &TypeInfo::findSymbol, findSymbol_( python::args( "offset", "showDisplacement"),
|
||||||
// "Find symbol by the target virtual memory offset" ) );
|
// "Find symbol by the target virtual memory offset" ) );
|
||||||
// python::def("findSymbolAndDisp", &pysupport::findSymbolAndDisp,
|
// python::def("findSymbolAndDisp", &pysupport::findSymbolAndDisp,
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
#include "kdlib/dbgengine.h"
|
|
||||||
|
|
||||||
#include "target.h"
|
|
||||||
|
|
||||||
namespace pykd {
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void targetGo()
|
|
||||||
{
|
|
||||||
PyThreadState* state = PyEval_SaveThread();
|
|
||||||
|
|
||||||
kdlib::targetGo();
|
|
||||||
|
|
||||||
PyEval_RestoreThread( state );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
} //end namespace pykd
|
|
@ -107,8 +107,8 @@ class MemoryTest( unittest.TestCase ):
|
|||||||
self.assertTrue( True )
|
self.assertTrue( True )
|
||||||
|
|
||||||
def testPtrFloat(self):
|
def testPtrFloat(self):
|
||||||
self.assertTrue( math.fabs( pykd.ptrFloat( target.module.g_float) - 5.123456 ) < 0.001 )
|
self.assertTrue( math.fabs( pykd.ptrFloat( target.module.floatVar) + 5.99 ) < 0.001 )
|
||||||
self.assertTrue( math.fabs( pykd.ptrDouble( target.module.g_double) - 5.1234567891 ) < 0.0000001 )
|
self.assertTrue( math.fabs( pykd.ptrDouble( target.module.doubleVar) - 6.00000001 ) < 0.0000001 )
|
||||||
|
|
||||||
def testLoadFloats(self):
|
def testLoadFloats(self):
|
||||||
testArray = [ 1.0, 0.001, -199.999, 20000.01, 0.111111 ];
|
testArray = [ 1.0, 0.001, -199.999, 20000.01, 0.111111 ];
|
||||||
|
@ -49,9 +49,9 @@ class ModuleTest( unittest.TestCase ):
|
|||||||
self.assertRaises( pykd.DbgException, pykd.module, target.module.end() + 0x10 )
|
self.assertRaises( pykd.DbgException, pykd.module, target.module.end() + 0x10 )
|
||||||
|
|
||||||
def testSymbol( self ):
|
def testSymbol( self ):
|
||||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() )
|
self.assertEqual( target.module.rva("FastcallFunc"), target.module.offset("FastcallFunc") - target.module.begin() )
|
||||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.FuncWithName0 - target.module.begin() )
|
self.assertEqual( target.module.rva("FastcallFunc"), target.module.FastcallFunc - target.module.begin() )
|
||||||
self.assertEqual( target.module.rva("FuncWithName0"), pykd.getOffset( target.module.name() + "!FuncWithName0") - target.module.begin() )
|
self.assertEqual( target.module.rva("FastcallFunc"), pykd.getOffset( target.module.name() + "!FastcallFunc") - target.module.begin() )
|
||||||
|
|
||||||
def testFindSymbol( self ):
|
def testFindSymbol( self ):
|
||||||
self.assertEqual( "LocalStaticFunc", target.module.findSymbol( target.module.offset("LocalStaticFunc") ) )
|
self.assertEqual( "LocalStaticFunc", target.module.findSymbol( target.module.offset("LocalStaticFunc") ) )
|
||||||
@ -59,9 +59,6 @@ class ModuleTest( unittest.TestCase ):
|
|||||||
self.assertEqual( "StdcallFunc", target.module.findSymbol( target.module.offset("StdcallFunc") ) )
|
self.assertEqual( "StdcallFunc", target.module.findSymbol( target.module.offset("StdcallFunc") ) )
|
||||||
self.assertEqual( "FastcallFunc", target.module.findSymbol( target.module.offset("FastcallFunc") ) )
|
self.assertEqual( "FastcallFunc", target.module.findSymbol( target.module.offset("FastcallFunc") ) )
|
||||||
self.assertEqual( "_UnderscoreFunc", target.module.findSymbol( target.module.offset("_UnderscoreFunc") ) )
|
self.assertEqual( "_UnderscoreFunc", target.module.findSymbol( target.module.offset("_UnderscoreFunc") ) )
|
||||||
|
|
||||||
#self.assertEqual( "FuncWithName0", target.module.findSymbol( target.module.offset("FuncWithName0") ) )
|
|
||||||
#self.assertEqual( "_FuncWithName2", target.module.findSymbol( target.module.offset("_FuncWithName2") ) )
|
|
||||||
#self.assertEqual( "targetapp!FuncWithName0", pykd.findSymbol( target.module.offset("FuncWithName0") ) )
|
#self.assertEqual( "targetapp!FuncWithName0", pykd.findSymbol( target.module.offset("FuncWithName0") ) )
|
||||||
#self.assertEqual( "targetapp!_FuncWithName2", pykd.findSymbol( target.module.offset("_FuncWithName2") ) )
|
#self.assertEqual( "targetapp!_FuncWithName2", pykd.findSymbol( target.module.offset("_FuncWithName2") ) )
|
||||||
#self.assertEqual( "_FuncWithName2+10", target.module.findSymbol( target.module.offset("_FuncWithName2") + 0x10 ) )
|
#self.assertEqual( "_FuncWithName2+10", target.module.findSymbol( target.module.offset("_FuncWithName2") + 0x10 ) )
|
||||||
@ -83,14 +80,14 @@ class ModuleTest( unittest.TestCase ):
|
|||||||
self.assertEqual( "structTest", target.module.type("g_structTest").name() );
|
self.assertEqual( "structTest", target.module.type("g_structTest").name() );
|
||||||
|
|
||||||
def testSourceFile( self ):
|
def testSourceFile( self ):
|
||||||
fileName = pykd.getSourceFile(target.module.FuncWithName0 )
|
fileName = pykd.getSourceFile(target.module.CdeclFunc )
|
||||||
self.assertTrue( re.search('targetapp\\.cpp', fileName ) )
|
self.assertTrue( re.search('testfunc\\.cpp', fileName ) )
|
||||||
fileName, lineNo, displacement = pykd.getSourceLine( target.module.FuncWithName0 + 2)
|
fileName, lineNo, displacement = pykd.getSourceLine( target.module.CdeclFunc + 2)
|
||||||
self.assertEqual( 421, lineNo )
|
self.assertEqual( 15, lineNo )
|
||||||
self.assertTrue( re.search('targetapp\\.cpp', fileName ) )
|
self.assertTrue( re.search('testfunc\\.cpp', fileName ) )
|
||||||
self.assertEqual( 2, displacement )
|
self.assertEqual( 2, displacement )
|
||||||
fileName, lineNo, displacement = pykd.getSourceLine()
|
#fileName, lineNo, displacement = pykd.getSourceLine()
|
||||||
self.assertEqual( 698, lineNo )
|
#self.assertEqual( 698, lineNo )
|
||||||
|
|
||||||
def testEnumSymbols( self ):
|
def testEnumSymbols( self ):
|
||||||
lst = target.module.enumSymbols()
|
lst = target.module.enumSymbols()
|
||||||
|
Loading…
Reference in New Issue
Block a user