blob: bc1b4e7ce1481b94ce2112e82d4d88da18c615d0 [file] [log] [blame]
Johnny Chen843f6892010-07-07 21:10:55 +00001"""
2Test that breakpoint by symbol name works correctly dlopen'ing a dynamic lib.
3"""
4
5import os, time
Johnny Chen75e28f92010-08-05 23:42:46 +00006import unittest2
Johnny Chen843f6892010-07-07 21:10:55 +00007import lldb
Johnny Chend85dae52010-08-09 23:44:24 +00008from lldbtest import *
Johnny Chen843f6892010-07-07 21:10:55 +00009
Johnny Chen1c42e862010-09-01 19:59:58 +000010class LoadUnloadTestCase(TestBase):
Johnny Chen843f6892010-07-07 21:10:55 +000011
12 mydir = "load_unload"
13
Johnny Chen14df3d42010-10-04 16:58:16 +000014 # rdar://problem/8508987
15 @unittest2.expectedFailure
Johnny Chen30974392010-07-27 20:59:06 +000016 def test_load_unload(self):
Johnny Chen843f6892010-07-07 21:10:55 +000017 """Test breakpoint by name works correctly with dlopen'ing."""
Johnny Chen821a8c42010-09-03 23:52:15 +000018
19 # Invoke the default build rule.
20 self.buildDefault()
21
Johnny Chen843f6892010-07-07 21:10:55 +000022 exe = os.path.join(os.getcwd(), "a.out")
Johnny Chen029acae2010-08-20 21:03:09 +000023 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
Johnny Chen843f6892010-07-07 21:10:55 +000024
25 # Break by function name a_function (not yet loaded).
Johnny Chen029acae2010-08-20 21:03:09 +000026 self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED,
27 startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)")
Johnny Chen843f6892010-07-07 21:10:55 +000028
Johnny Chen1bb9f9a2010-08-27 23:47:36 +000029 self.runCmd("run", RUN_SUCCEEDED)
Johnny Chen843f6892010-07-07 21:10:55 +000030
31 # The stop reason of the thread should be breakpoint and at a_function.
Johnny Chen029acae2010-08-20 21:03:09 +000032 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
Johnny Chen8a87d522010-10-18 15:44:42 +000033 substrs = ['state is stopped',
Johnny Chen029acae2010-08-20 21:03:09 +000034 'a_function',
Johnny Chen029acae2010-08-20 21:03:09 +000035 'stop reason = breakpoint'])
Johnny Chen843f6892010-07-07 21:10:55 +000036
37 # The breakpoint should have a hit count of 1.
Johnny Chen029acae2010-08-20 21:03:09 +000038 self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
39 substrs = [' resolved, hit count = 1'])
Johnny Chen843f6892010-07-07 21:10:55 +000040
Johnny Chen14df3d42010-10-04 16:58:16 +000041 # Issue the 'contnue' command. We should stop agaian at a_function.
42 # The stop reason of the thread should be breakpoint and at a_function.
43 self.runCmd("continue")
Johnny Chenc958be42010-10-20 21:56:26 +000044
45 # rdar://problem/8508987
46 # The a_function breakpoint should be encountered twice.
Johnny Chen14df3d42010-10-04 16:58:16 +000047 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
Johnny Chen8a87d522010-10-18 15:44:42 +000048 substrs = ['state is stopped',
Johnny Chen14df3d42010-10-04 16:58:16 +000049 'a_function',
50 'stop reason = breakpoint'])
51
52 # The breakpoint should have a hit count of 2.
53 self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
54 substrs = [' resolved, hit count = 2'])
Johnny Chen843f6892010-07-07 21:10:55 +000055
56
57if __name__ == '__main__':
Johnny Chen88f83042010-08-05 21:23:45 +000058 import atexit
Johnny Chen843f6892010-07-07 21:10:55 +000059 lldb.SBDebugger.Initialize()
Johnny Chen88f83042010-08-05 21:23:45 +000060 atexit.register(lambda: lldb.SBDebugger.Terminate())
Johnny Chen75e28f92010-08-05 23:42:46 +000061 unittest2.main()