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 | 3097439 | 2010-07-27 20:59:06 +0000 | [diff] [blame] | 14 | def test_load_unload(self): |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 15 | """Test breakpoint by name works correctly with dlopen'ing.""" |
Johnny Chen | 821a8c4 | 2010-09-03 23:52:15 +0000 | [diff] [blame^] | 16 | |
| 17 | # Invoke the default build rule. |
| 18 | self.buildDefault() |
| 19 | |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 20 | exe = os.path.join(os.getcwd(), "a.out") |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 21 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 22 | |
| 23 | # Break by function name a_function (not yet loaded). |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 24 | self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED, |
| 25 | startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)") |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 26 | |
Johnny Chen | 1bb9f9a | 2010-08-27 23:47:36 +0000 | [diff] [blame] | 27 | self.runCmd("run", RUN_SUCCEEDED) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 28 | |
| 29 | # 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] | 30 | 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 Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 35 | |
| 36 | # The breakpoint should have a hit count of 1. |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 37 | self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, |
| 38 | substrs = [' resolved, hit count = 1']) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 39 | |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 40 | # # Issue the 'contnue' command. We should stop agaian at a_function. |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 41 | # # 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] | 42 | # 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 Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 49 | # # The breakpoint should have a hit count of 2. |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 50 | # self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, |
| 51 | # substrs = [' resolved, hit count = 2']) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 52 | |
| 53 | |
| 54 | if __name__ == '__main__': |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 55 | import atexit |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 56 | lldb.SBDebugger.Initialize() |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 57 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
Johnny Chen | 75e28f9 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 58 | unittest2.main() |