Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test that breakpoint by symbol name works correctly dlopen'ing a dynamic lib. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
Johnny Chen | 75e28f9 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 6 | import unittest2 |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 7 | import lldb |
Johnny Chen | d85dae5 | 2010-08-09 23:44:24 +0000 | [diff] [blame] | 8 | from lldbtest import * |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 9 | |
Johnny Chen | 1c42e86 | 2010-09-01 19:59:58 +0000 | [diff] [blame] | 10 | class LoadUnloadTestCase(TestBase): |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 11 | |
| 12 | mydir = "load_unload" |
| 13 | |
Johnny Chen | 14df3d4 | 2010-10-04 16:58:16 +0000 | [diff] [blame] | 14 | # rdar://problem/8508987 |
| 15 | @unittest2.expectedFailure |
Johnny Chen | 3097439 | 2010-07-27 20:59:06 +0000 | [diff] [blame] | 16 | def test_load_unload(self): |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 17 | """Test breakpoint by name works correctly with dlopen'ing.""" |
Johnny Chen | 821a8c4 | 2010-09-03 23:52:15 +0000 | [diff] [blame] | 18 | |
| 19 | # Invoke the default build rule. |
| 20 | self.buildDefault() |
| 21 | |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 22 | exe = os.path.join(os.getcwd(), "a.out") |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 23 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 24 | |
| 25 | # Break by function name a_function (not yet loaded). |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 26 | self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED, |
| 27 | startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)") |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 28 | |
Johnny Chen | 1bb9f9a | 2010-08-27 23:47:36 +0000 | [diff] [blame] | 29 | self.runCmd("run", RUN_SUCCEEDED) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 30 | |
| 31 | # The stop reason of the thread should be breakpoint and at a_function. |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 32 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
Johnny Chen | 8a87d52 | 2010-10-18 15:44:42 +0000 | [diff] [blame] | 33 | substrs = ['state is stopped', |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 34 | 'a_function', |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 35 | 'stop reason = breakpoint']) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 36 | |
| 37 | # The breakpoint should have a hit count of 1. |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 38 | self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, |
| 39 | substrs = [' resolved, hit count = 1']) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 40 | |
Johnny Chen | 14df3d4 | 2010-10-04 16:58:16 +0000 | [diff] [blame] | 41 | # 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 Chen | c958be4 | 2010-10-20 21:56:26 +0000 | [diff] [blame^] | 44 | |
| 45 | # rdar://problem/8508987 |
| 46 | # The a_function breakpoint should be encountered twice. |
Johnny Chen | 14df3d4 | 2010-10-04 16:58:16 +0000 | [diff] [blame] | 47 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
Johnny Chen | 8a87d52 | 2010-10-18 15:44:42 +0000 | [diff] [blame] | 48 | substrs = ['state is stopped', |
Johnny Chen | 14df3d4 | 2010-10-04 16:58:16 +0000 | [diff] [blame] | 49 | '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 Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 55 | |
| 56 | |
| 57 | if __name__ == '__main__': |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 58 | import atexit |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 59 | lldb.SBDebugger.Initialize() |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 60 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
Johnny Chen | 75e28f9 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 61 | unittest2.main() |