blob: 5e2928b6a83933fc619e8f572b236b89ef2e7303 [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 Chen30974392010-07-27 20:59:06 +000014 def test_load_unload(self):
Johnny Chen843f6892010-07-07 21:10:55 +000015 """Test breakpoint by name works correctly with dlopen'ing."""
Johnny Chen821a8c42010-09-03 23:52:15 +000016
17 # Invoke the default build rule.
18 self.buildDefault()
19
Johnny Chen843f6892010-07-07 21:10:55 +000020 exe = os.path.join(os.getcwd(), "a.out")
Johnny Chen029acae2010-08-20 21:03:09 +000021 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
Johnny Chen843f6892010-07-07 21:10:55 +000022
23 # Break by function name a_function (not yet loaded).
Johnny Chen029acae2010-08-20 21:03:09 +000024 self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED,
25 startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)")
Johnny Chen843f6892010-07-07 21:10:55 +000026
Johnny Chen1bb9f9a2010-08-27 23:47:36 +000027 self.runCmd("run", RUN_SUCCEEDED)
Johnny Chen843f6892010-07-07 21:10:55 +000028
29 # The stop reason of the thread should be breakpoint and at a_function.
Johnny Chen029acae2010-08-20 21:03:09 +000030 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
31 substrs = ['state is Stopped',
32 'a_function',
33 'a.c:14',
34 'stop reason = breakpoint'])
Johnny Chen843f6892010-07-07 21:10:55 +000035
36 # The breakpoint should have a hit count of 1.
Johnny Chen029acae2010-08-20 21:03:09 +000037 self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
38 substrs = [' resolved, hit count = 1'])
Johnny Chen843f6892010-07-07 21:10:55 +000039
Johnny Chen029acae2010-08-20 21:03:09 +000040# # Issue the 'contnue' command. We should stop agaian at a_function.
Johnny Chen843f6892010-07-07 21:10:55 +000041# # The stop reason of the thread should be breakpoint and at a_function.
Johnny Chen029acae2010-08-20 21:03:09 +000042# self.runCmd("continue")
43# self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
44# substrs = ['state is Stopped',
45# 'a_function',
46# 'a.c:14',
47# 'stop reason = breakpoint'])
48#
Johnny Chen843f6892010-07-07 21:10:55 +000049# # The breakpoint should have a hit count of 2.
Johnny Chen029acae2010-08-20 21:03:09 +000050# 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()