blob: 18c761d097c4fedd2f53c1fd6ece5f875815c7f0 [file] [log] [blame]
Johnny Chen7ea9aee2010-10-07 21:38:28 +00001"""
2Test SBprocess and SBThread APIs with printing of the stack traces.
3"""
4
5import os, time
6import re
7import unittest2
8import lldb
9from lldbtest import *
10
11class ThreadsStackTracesTestCase(TestBase):
12
13 mydir = "threads"
14
15 def test_stack_traces(self):
16 """Test SBprocess and SBThread APIs with printing of the stack traces."""
17 self.buildDefault()
18 self.break_and_print_stacktraces()
19
20 def break_and_print_stacktraces(self):
21 """Break at main.cpp:68 and do a threads dump"""
22 exe = os.path.join(os.getcwd(), "a.out")
23
24 target = self.dbg.CreateTarget(exe)
25 self.assertTrue(target.IsValid(), VALID_TARGET)
26
27 breakpoint = target.BreakpointCreateByLocation("main.cpp", 68)
28 self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
29
30 # Now launch the process, and do not stop at entry point.
31 rc = lldb.SBError()
32 self.process = target.Launch([''], [''], os.ctermid(), 0, False, rc)
33
34 if not rc.Success() or not self.process.IsValid():
35 self.fail("SBTarget.LaunchProcess() failed")
36
37 if self.process.GetState() != lldb.eStateStopped:
38 self.fail("Process should be in the 'Stopped' state, "
39 "instead the actual state is: '%s'" %
Johnny Chen28ae2942010-10-07 22:15:58 +000040 lldbutil.StateTypeString(self.process.GetState()))
Johnny Chen7ea9aee2010-10-07 21:38:28 +000041
42 import lldbutil
43 lldbutil.PrintStackTraces(self.process)
44
45
46if __name__ == '__main__':
47 import atexit
48 lldb.SBDebugger.Initialize()
49 atexit.register(lambda: lldb.SBDebugger.Terminate())
50 unittest2.main()