Revert "[2018-06] [System]: `MonoTlsStream` is now `IDisposable` and cleans up on...
[mono-project.git] / mono / tests / test_lldb.py
blobeb557108a6f0d9435330b2e4068177718b27b3a1
1 #!/usr/bin/python
3 import os
4 import sys
6 import unittest
7 import lldb
9 if len (sys.argv) == 1:
10 sys.stderr.write ('Usage: test_lldb.py <mono executable>\n')
11 sys.exit (1)
12 mono_exe = sys.argv [1]
13 test_exe = 'test-lldb.exe'
15 class TestLldb(unittest.TestCase):
17 def setUp (self):
18 self.dbg = lldb.SBDebugger.Create ()
20 self.dbg.SetAsync (False)
21 self.target = self.dbg.CreateTargetWithFileAndArch (mono_exe, lldb.LLDB_ARCH_DEFAULT)
22 self.process = None
23 #self.dbg.HandleCommand ('log enable lldb jit')
25 def tearDown (self):
26 if self.process != None:
27 self.process.Kill ()
29 def test_stacktraces (self):
30 bp = self.target.BreakpointCreateByName ('ves_icall_System_Threading_Thread_Sleep_internal')
31 self.assertEqual (bp.GetNumLocations (), 1)
33 process = self.target.LaunchSimple (['--debug', test_exe], ['MONO_LLDB=1'], os.getcwd())
34 self.process = process
35 self.assertNotEqual (process, None)
37 state = process.GetState ()
38 self.assertEqual (state, lldb.eStateStopped)
40 # Stopped in the Sleep icall
41 findex = 0
42 thread = process.GetThreadAtIndex (0)
43 frame = thread.GetFrameAtIndex (findex)
44 name = frame.GetSymbol().GetName ()
45 self.assertEqual (name, 'ves_icall_System_Threading_Thread_Sleep_internal')
46 findex += 1
48 frame = thread.GetFrameAtIndex (findex)
49 name = frame.GetSymbol().GetName ()
50 if name == 'ves_icall_System_Threading_Thread_Sleep_internal':
51 # inlined
52 findex += 1
53 frame = thread.GetFrameAtIndex (findex)
54 name = frame.GetSymbol().GetName ()
55 self.assertEqual (name, '(wrapper managed-to-native) System.Threading.Thread:SleepInternal (int)')
57 findex += 1
58 frame = thread.GetFrameAtIndex (findex)
59 name = frame.GetSymbol().GetName ()
60 self.assertEqual (name, 'System.Threading.Thread:Sleep (int)')
61 self.assertTrue (str (frame.GetLineEntry ().GetFileSpec()).find ('thread.cs') != -1)
62 findex += 1
64 frame = thread.GetFrameAtIndex (findex)
65 name = frame.GetSymbol().GetName ()
66 self.assertEqual (name, 'Tests:Main ()')
67 self.assertTrue (str (frame.GetLineEntry ().GetFileSpec()).find ('test-lldb.cs') != -1)
69 def test_breakpoints (self):
70 bp = self.target.BreakpointCreateByLocation ('test-lldb.cs', 9)
72 process = self.target.LaunchSimple (['--debug', test_exe], ['MONO_LLDB=1'], os.getcwd())
73 self.process = process
74 self.assertNotEqual (process, None)
76 state = process.GetState ()
77 self.assertEqual (state, lldb.eStateStopped)
78 # Stopped in foo ()
79 thread = process.GetThreadAtIndex (0)
80 frame = thread.GetFrameAtIndex (0)
81 name = frame.GetSymbol().GetName ()
82 self.assertEqual (name, 'Tests:Main ()')
84 if __name__ == '__main__':
85 suite = unittest.TestLoader().loadTestsFromTestCase(TestLldb)
86 unittest.TextTestRunner(verbosity=2).run(suite)