mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:53:23 +08:00
[0.1.x] fixed : not integer regsiter not supported now
git-svn-id: https://pykd.svn.codeplex.com/svn@73535 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
fc083db186
commit
3902000ae8
@ -17,6 +17,31 @@ CpuReg::CpuReg( IDebugClient4 *client, const std::string ®Name ) :
|
|||||||
hres = m_registers->GetIndexByName( m_name.c_str(), &m_index );
|
hres = m_registers->GetIndexByName( m_name.c_str(), &m_index );
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetIndexByName", hres );
|
throw DbgException( "IDebugRegister::GetIndexByName", hres );
|
||||||
|
|
||||||
|
DEBUG_REGISTER_DESCRIPTION desc = {};
|
||||||
|
|
||||||
|
hres =
|
||||||
|
m_registers->GetDescription(
|
||||||
|
m_index,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
&desc );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugRegister::GetDescription", hres );
|
||||||
|
|
||||||
|
switch ( desc.Type )
|
||||||
|
{
|
||||||
|
case DEBUG_VALUE_INT8:
|
||||||
|
case DEBUG_VALUE_INT16:
|
||||||
|
case DEBUG_VALUE_INT32:
|
||||||
|
case DEBUG_VALUE_INT64:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw DbgException( "Unsupported register type ( not integer )" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -42,6 +67,7 @@ CpuReg::CpuReg( IDebugClient4 *client, ULONG index ) :
|
|||||||
throw DbgException( "IDebugRegister::GetDescription", hres );
|
throw DbgException( "IDebugRegister::GetDescription", hres );
|
||||||
|
|
||||||
std::vector<char> nameBuffer(nameSize);
|
std::vector<char> nameBuffer(nameSize);
|
||||||
|
DEBUG_REGISTER_DESCRIPTION desc = {};
|
||||||
|
|
||||||
hres =
|
hres =
|
||||||
m_registers->GetDescription(
|
m_registers->GetDescription(
|
||||||
@ -49,11 +75,23 @@ CpuReg::CpuReg( IDebugClient4 *client, ULONG index ) :
|
|||||||
&nameBuffer[0],
|
&nameBuffer[0],
|
||||||
nameSize,
|
nameSize,
|
||||||
NULL,
|
NULL,
|
||||||
NULL );
|
&desc );
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetDescription", hres );
|
throw DbgException( "IDebugRegister::GetDescription", hres );
|
||||||
|
|
||||||
|
switch ( desc.Type )
|
||||||
|
{
|
||||||
|
case DEBUG_VALUE_INT8:
|
||||||
|
case DEBUG_VALUE_INT16:
|
||||||
|
case DEBUG_VALUE_INT32:
|
||||||
|
case DEBUG_VALUE_INT64:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw DbgException( "Unsupported register type ( not integer )" );
|
||||||
|
}
|
||||||
|
|
||||||
m_name = std::string( &nameBuffer[0] );
|
m_name = std::string( &nameBuffer[0] );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -170,3 +170,4 @@ class IntBaseTest( unittest.TestCase ):
|
|||||||
self.assertEqual( "100", "%d" % intBase(100) )
|
self.assertEqual( "100", "%d" % intBase(100) )
|
||||||
self.assertEqual( "64", "%x" % intBase(100) )
|
self.assertEqual( "64", "%x" % intBase(100) )
|
||||||
|
|
||||||
|
|
@ -1,34 +1,50 @@
|
|||||||
|
|
||||||
#import unittest
|
import unittest
|
||||||
#import pykd
|
import target
|
||||||
#import target
|
import pykd
|
||||||
|
|
||||||
#class CpuRegTest( unittest.TestCase ):
|
class CpuRegTest( unittest.TestCase ):
|
||||||
|
|
||||||
# def testBasic(self):
|
def testCtor(self):
|
||||||
# try:
|
if pykd.is64bitSystem():
|
||||||
# reg = pykd.cpuReg(0)
|
pykd.reg("rax")
|
||||||
# self.assertTrue(True)
|
else:
|
||||||
# except pykd.BaseException:
|
pykd.reg("eax")
|
||||||
# pass
|
|
||||||
|
pykd.reg( 0 )
|
||||||
|
|
||||||
|
def testFormat(self):
|
||||||
|
self.assertEqual( "%d" % int(pykd.reg(0)), "%d" % pykd.reg(0) )
|
||||||
|
self.assertEqual( "%x" % int(pykd.reg(0)), "%x" % pykd.reg(0) )
|
||||||
|
|
||||||
|
def testGpr(self):
|
||||||
|
if pykd.is64bitSystem():
|
||||||
|
pykd.reg("rax")
|
||||||
|
pykd.reg("rbx")
|
||||||
|
pykd.reg("rcx")
|
||||||
|
pykd.reg("rdx")
|
||||||
|
pykd.reg("rdi")
|
||||||
|
pykd.reg("rsi")
|
||||||
|
pykd.reg("rbp")
|
||||||
|
pykd.reg("rsp")
|
||||||
|
pykd.reg("rip")
|
||||||
|
else:
|
||||||
|
pykd.reg("eax")
|
||||||
|
pykd.reg("ebx")
|
||||||
|
pykd.reg("ecx")
|
||||||
|
pykd.reg("edx")
|
||||||
|
pykd.reg("edi")
|
||||||
|
pykd.reg("esi")
|
||||||
|
pykd.reg("ebp")
|
||||||
|
pykd.reg("esp")
|
||||||
|
pykd.reg("eip")
|
||||||
|
|
||||||
|
|
||||||
# def testGPR(self):
|
def testFloatRegister(self):
|
||||||
|
"TODO: support float point regsiters"
|
||||||
# if pykd.is64bitSystem():
|
self.assertRaises( pykd.BaseException, pykd.reg, "st0" )
|
||||||
|
|
||||||
# rax = pykd.cpuReg("rax")
|
|
||||||
# self.assertEqual( rax, pykd.reg("rax") )
|
|
||||||
|
|
||||||
# rip = pykd.cpuReg("rip")
|
|
||||||
# self.assertEqual( rip, pykd.reg("rip") )
|
|
||||||
|
|
||||||
# else:
|
|
||||||
|
|
||||||
# eax = pykd.cpuReg("eax")
|
|
||||||
# self.assertEqual( eax, pykd.reg("eax") )
|
|
||||||
|
|
||||||
# eip = pykd.cpuReg("eip")
|
|
||||||
# self.assertEqual( eip, pykd.reg("eip") )
|
|
||||||
|
|
||||||
|
def testMmxRegister(self):
|
||||||
|
"TODO: support MMX regsiters"
|
||||||
|
self.assertRaises( pykd.BaseException, pykd.reg, "mmx0" )
|
||||||
|
|
Loading…
Reference in New Issue
Block a user