9 if len (sys
.argv
) == 1:
10 sys
.stderr
.write ('Usage: test_lldb.py <mono executable>\n')
12 mono_exe
= sys
.argv
[1]
13 test_exe
= 'test-lldb.exe'
15 class TestLldb(unittest
.TestCase
):
18 self
.dbg
= lldb
.SBDebugger
.Create ()
20 self
.dbg
.SetAsync (False)
21 self
.target
= self
.dbg
.CreateTargetWithFileAndArch (mono_exe
, lldb
.LLDB_ARCH_DEFAULT
)
23 #self.dbg.HandleCommand ('log enable lldb jit')
26 if self
.process
!= None:
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
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')
48 frame
= thread
.GetFrameAtIndex (findex
)
49 name
= frame
.GetSymbol().GetName ()
50 if name
== 'ves_icall_System_Threading_Thread_Sleep_internal':
53 frame
= thread
.GetFrameAtIndex (findex
)
54 name
= frame
.GetSymbol().GetName ()
55 self
.assertEqual (name
, '(wrapper managed-to-native) System.Threading.Thread:SleepInternal (int)')
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)
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
)
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
)