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 | d85dae5 | 2010-08-09 23:44:24 +0000 | [diff] [blame] | 10 | class TestLoadUnload(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 | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 16 | exe = os.path.join(os.getcwd(), "a.out") |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame^] | 17 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 18 | |
| 19 | # Break by function name a_function (not yet loaded). |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame^] | 20 | self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED, |
| 21 | startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)") |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 22 | |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame^] | 23 | self.runCmd("run", RUN_STOPPED) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 24 | |
| 25 | # 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^] | 26 | 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 Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 31 | |
| 32 | # The breakpoint should have a hit count of 1. |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame^] | 33 | self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, |
| 34 | substrs = [' resolved, hit count = 1']) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 35 | |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame^] | 36 | # # Issue the 'contnue' command. We should stop agaian at a_function. |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 37 | # # 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^] | 38 | # 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 Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 45 | # # The breakpoint should have a hit count of 2. |
Johnny Chen | 029acae | 2010-08-20 21:03:09 +0000 | [diff] [blame^] | 46 | # self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, |
| 47 | # substrs = [' resolved, hit count = 2']) |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 48 | |
| 49 | |
| 50 | if __name__ == '__main__': |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 51 | import atexit |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 52 | lldb.SBDebugger.Initialize() |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 53 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
Johnny Chen | 75e28f9 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 54 | unittest2.main() |