blob: d690dc352b9e62bd6c9310e1d0eb90bb6cf992d2 [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,
33 substrs = ['state is Stopped',
34 '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")
44 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
45 substrs = ['state is Stopped',
46 'a_function',
47 'stop reason = breakpoint'])
48
49 # The breakpoint should have a hit count of 2.
50 self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
51 substrs = [' resolved, hit count = 2'])
Johnny Chen843f6892010-07-07 21:10:55 +000052
53
54if __name__ == '__main__':
Johnny Chen88f83042010-08-05 21:23:45 +000055 import atexit
Johnny Chen843f6892010-07-07 21:10:55 +000056 lldb.SBDebugger.Initialize()
Johnny Chen88f83042010-08-05 21:23:45 +000057 atexit.register(lambda: lldb.SBDebugger.Terminate())
Johnny Chen75e28f92010-08-05 23:42:46 +000058 unittest2.main()