blob: cdd26487ecace7a9a328f05008d632a2464df70c [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 Chend85dae52010-08-09 23:44:24 +000010class TestLoadUnload(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 Chen843f6892010-07-07 21:10:55 +000016 exe = os.path.join(os.getcwd(), "a.out")
Johnny Chen029acae2010-08-20 21:03:09 +000017 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
Johnny Chen843f6892010-07-07 21:10:55 +000018
19 # Break by function name a_function (not yet loaded).
Johnny Chen029acae2010-08-20 21:03:09 +000020 self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED,
21 startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)")
Johnny Chen843f6892010-07-07 21:10:55 +000022
Johnny Chen1bb9f9a2010-08-27 23:47:36 +000023 self.runCmd("run", RUN_SUCCEEDED)
Johnny Chen843f6892010-07-07 21:10:55 +000024
25 # The stop reason of the thread should be breakpoint and at a_function.
Johnny Chen029acae2010-08-20 21:03:09 +000026 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
27 substrs = ['state is Stopped',
28 'a_function',
29 'a.c:14',
30 'stop reason = breakpoint'])
Johnny Chen843f6892010-07-07 21:10:55 +000031
32 # The breakpoint should have a hit count of 1.
Johnny Chen029acae2010-08-20 21:03:09 +000033 self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
34 substrs = [' resolved, hit count = 1'])
Johnny Chen843f6892010-07-07 21:10:55 +000035
Johnny Chen029acae2010-08-20 21:03:09 +000036# # Issue the 'contnue' command. We should stop agaian at a_function.
Johnny Chen843f6892010-07-07 21:10:55 +000037# # The stop reason of the thread should be breakpoint and at a_function.
Johnny Chen029acae2010-08-20 21:03:09 +000038# self.runCmd("continue")
39# self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
40# substrs = ['state is Stopped',
41# 'a_function',
42# 'a.c:14',
43# 'stop reason = breakpoint'])
44#
Johnny Chen843f6892010-07-07 21:10:55 +000045# # The breakpoint should have a hit count of 2.
Johnny Chen029acae2010-08-20 21:03:09 +000046# self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
47# substrs = [' resolved, hit count = 2'])
Johnny Chen843f6892010-07-07 21:10:55 +000048
49
50if __name__ == '__main__':
Johnny Chen88f83042010-08-05 21:23:45 +000051 import atexit
Johnny Chen843f6892010-07-07 21:10:55 +000052 lldb.SBDebugger.Initialize()
Johnny Chen88f83042010-08-05 21:23:45 +000053 atexit.register(lambda: lldb.SBDebugger.Terminate())
Johnny Chen75e28f92010-08-05 23:42:46 +000054 unittest2.main()