8
class StackTest(unittest.TestCase):
11
self.processId = pykd.startProcess( target.appPath + " stacktest" )
12
pykd.go() # skip initial breakpoint
15
pykd.killProcess( self.processId )
17
def testGetStack(self):
20
'targetapp!stackTestClass::stackMethod',
21
'targetapp!stackTestRun2',
22
'targetapp!stackTestRun1',
23
'targetapp!stackTestRun']
26
for frame in pykd.getStack():
27
moduleName, symbolName, disp = pykd.findSymbolAndDisp( frame.ip )
28
realStack.append( "%s!%s" % ( moduleName, symbolName ) )
30
self.assertEqual( expectedStack, realStack[0:4])
32
def testGetParams(self):
34
frame0 = pykd.getFrame()
35
self.assertEqual( ["this", "a", "b"], [ name for name, param in frame0.getParams() ] )
37
frame1 = pykd.getStack()[1]
38
self.assertEqual( ["a", "b", "c"], [ name for name, param in frame1.getParams() ] )
39
self.assertEqual( 10, frame1.getParam("a") )
40
self.assertEqual( 10, frame1.params["a"] )
42
frame2 = pykd.getStack()[2]
43
self.assertEqual( 10, frame2.params["a"] )
44
self.assertEqual( 10, frame2.getParam("a") )
46
def testGetLocals(self):
47
expectedLocals = ["localDouble", "localFloat", "localChars"]
48
frame2 = pykd.getStack()[2]
49
self.assertEqual( expectedLocals, [name for name, param in frame2.getLocals() ] )
50
self.assertEqual( 0.0, frame2.locals["localDouble"] )
52
def testGetParamsNoSymbol(self):
53
topFrame = pykd.getStack()[-1]
54
self.assertEqual(0, len(topFrame.getParams()))
56
def testGetLocalsNoSymbol(self):
57
topFrame = pykd.getStack()[-1]
58
self.assertEqual(0, len(topFrame.getLocals()))
61
class InlineStackTest(unittest.TestCase):
64
dumpDir = os.path.join( os.path.dirname(sys.argv[0]), r"..\..\kdlibcpp\kdlib\tests\dumps\targetapp_stacktest_x64_release")
65
dump_file = os.path.join( dumpDir, "targetapp_stacktest_x64_release.cab" )
66
self.symbolPath = pykd.getSymbolPath()
67
symbolPath = self.symbolPath + ";" + dumpDir
68
pykd.setSymbolPath(symbolPath)
69
self.dump_id = pykd.loadDump( dump_file )
72
pykd.closeDump( self.dump_id )
73
pykd.setSymbolPath(self.symbolPath)
75
def testGetStack(self):
78
'targetapp!stackTestClass::stackMethod',
79
'targetapp!stackTestRun2',
80
'targetapp!stackTestRun1',
81
'targetapp!stackTestRun']
84
for frame in pykd.getStack(inlineFrames = True):
85
moduleName, symbolName, disp = frame.findSymbol()
86
realStack.append( "%s!%s" % ( moduleName, symbolName ) )
88
self.assertEqual( expectedStack, realStack[0:4])
90
def testFrameIsInline(self):
91
self.assertEqual([True, True, False, True],
92
[fr.isInline() for fr in pykd.getStack(inlineFrames = True)][:4]
95
def testGetSourceLine(self):
97
expectedStack = ['targetapp.cpp+129', 'targetapp.cpp+144', 'targetapp.cpp+172', 'targetapp.cpp+185']
100
for frame in pykd.getStack(inlineFrames = True)[:4]:
101
fileName, lineNo = frame.getSourceLine()
102
realStack.append("%s+%s" % ( os.path.basename(fileName), lineNo ) )
104
self.assertEqual( expectedStack, realStack)
106
class DiaRegToRegRelativeI386Test(unittest.TestCase):
108
dumpDir = os.path.join( os.path.dirname(sys.argv[0]), r"..\..\kdlibcpp\kdlib\tests\dumps\targetapp_test_cv_allreg_i386")
109
dump_file = os.path.join( dumpDir, "targetapp_test_cv_allreg_i386.cab" )
110
self.symbolPath = pykd.getSymbolPath()
111
symbolPath = self.symbolPath + ";" + dumpDir
112
pykd.setSymbolPath(symbolPath)
113
self.dump_id = pykd.loadDump( dump_file )
116
pykd.closeDump( self.dump_id )
117
pykd.setSymbolPath(self.symbolPath)
119
def testParams(self):
120
params = pykd.getFrame().getParams()
121
self.assertNotEqual(0, len(params))
123
class DiaRegToRegRelativeAmd64Test(unittest.TestCase):
125
dumpDir = os.path.join( os.path.dirname(sys.argv[0]), r"..\..\kdlibcpp\kdlib\tests\dumps\targetapp_test_cv_allreg_amd64")
126
dump_file = os.path.join( dumpDir, "targetapp_test_cv_allreg_amd64.cab" )
127
self.symbolPath = pykd.getSymbolPath()
128
symbolPath = self.symbolPath + ";" + dumpDir
129
pykd.setSymbolPath(symbolPath)
130
self.dump_id = pykd.loadDump( dump_file )
133
pykd.closeDump( self.dump_id )
134
pykd.setSymbolPath(self.symbolPath)
136
def testLocals(self):
137
locals = pykd.getFrame().getLocals()
138
self.assertNotEqual(0, len(locals))