pykd
1"""Tests of thread context"""
2
3import unittest4import target5import pykd6
7class ThreadContextTest( unittest.TestCase ):8def testCurrentThreadContext( self ):9"""Some checks of current thread context content"""10ctx = pykd.getContext()11# for reg in ctx:
12# regName = ""
13# if ctx.processorType() == "X86":
14# regName = pykd.diaI386Regs[ reg[0] ]
15# else:
16# regName = pykd.diaAmd64Regs[ reg[0] ]
17# pykd.dprint( "\n" + regName + ": 0x%x " % reg[1])
18self.assertNotEqual( 0, len(ctx) )19self.assertNotEqual( 0, ctx.ip() )20self.assertNotEqual( 0, ctx.csp() )21
22def testComplexRegisters( self ):23"""Test of "sub-"registers"""24ctx = pykd.getContext()25self.assertEqual( (ctx.get(pykd.CV_REG_AH) << 8) | ctx.get(pykd.CV_REG_AL), ctx.get(pykd.CV_REG_AX) )26self.assertEqual( ctx.get(pykd.CV_REG_AX), ctx.get(pykd.CV_REG_EAX) & 0xffff )27if ctx.processorType() == "X64":28self.assertEqual( ctx.get(pykd.CV_REG_EAX), ctx.get(pykd.CV_AMD64_RAX) & 0xffffffff )29
30self.assertEqual( (ctx.get(pykd.CV_REG_DH) << 8) | ctx.get(pykd.CV_REG_DL), ctx.get(pykd.CV_REG_DX) )31self.assertEqual( ctx.get(pykd.CV_REG_DX), ctx.get(pykd.CV_REG_EDX) & 0xffff )32if ctx.processorType() == "X64":33self.assertEqual( ctx.get(pykd.CV_REG_EDX), ctx.get(pykd.CV_AMD64_RDX) & 0xffffffff )34