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 |
| 8 | import lldbtest |
| 9 | |
Johnny Chen | 3097439 | 2010-07-27 20:59:06 +0000 | [diff] [blame] | 10 | class TestLoadUnload(lldbtest.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.""" |
| 16 | res = self.res |
| 17 | exe = os.path.join(os.getcwd(), "a.out") |
| 18 | self.ci.HandleCommand("file " + exe, res) |
| 19 | self.assertTrue(res.Succeeded()) |
| 20 | |
| 21 | # Break by function name a_function (not yet loaded). |
| 22 | self.ci.HandleCommand("breakpoint set -n a_function", res) |
| 23 | self.assertTrue(res.Succeeded()) |
| 24 | self.assertTrue(res.GetOutput().startswith( |
| 25 | "Breakpoint created: 1: name = 'a_function', locations = 0 " |
| 26 | "(pending)" |
| 27 | )) |
| 28 | |
| 29 | self.ci.HandleCommand("run", res) |
| 30 | time.sleep(0.1) |
| 31 | self.assertTrue(res.Succeeded()) |
| 32 | |
| 33 | # The stop reason of the thread should be breakpoint and at a_function. |
| 34 | self.ci.HandleCommand("thread list", res) |
| 35 | output = res.GetOutput() |
| 36 | self.assertTrue(res.Succeeded()) |
| 37 | self.assertTrue(output.find('state is Stopped') > 0 and |
| 38 | output.find('a_function') > 0 and |
| 39 | output.find('a.c:14') > 0 and |
| 40 | output.find('stop reason = breakpoint') > 0) |
| 41 | |
| 42 | # The breakpoint should have a hit count of 1. |
| 43 | self.ci.HandleCommand("breakpoint list", res) |
| 44 | self.assertTrue(res.Succeeded()) |
| 45 | self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0) |
| 46 | |
| 47 | self.ci.HandleCommand("continue", res) |
| 48 | self.assertTrue(res.Succeeded()) |
| 49 | |
| 50 | # # We should stop agaian at a_function. |
| 51 | # # The stop reason of the thread should be breakpoint and at a_function. |
| 52 | # self.ci.HandleCommand("thread list", res) |
| 53 | # output = res.GetOutput() |
| 54 | # self.assertTrue(res.Succeeded()) |
| 55 | # self.assertTrue(output.find('state is Stopped') > 0 and |
| 56 | # output.find('a_function') > 0 and |
| 57 | # output.find('a.c:14') > 0 and |
| 58 | # output.find('stop reason = breakpoint') > 0) |
| 59 | |
| 60 | # # The breakpoint should have a hit count of 2. |
| 61 | # self.ci.HandleCommand("breakpoint list", res) |
| 62 | # self.assertTrue(res.Succeeded()) |
| 63 | # self.assertTrue(res.GetOutput().find(' resolved, hit count = 2') > 0) |
| 64 | |
| 65 | # self.ci.HandleCommand("continue", res) |
| 66 | # self.assertTrue(res.Succeeded()) |
| 67 | |
| 68 | |
| 69 | if __name__ == '__main__': |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 70 | import atexit |
Johnny Chen | 843f689 | 2010-07-07 21:10:55 +0000 | [diff] [blame] | 71 | lldb.SBDebugger.Initialize() |
Johnny Chen | 88f8304 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 72 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
Johnny Chen | 75e28f9 | 2010-08-05 23:42:46 +0000 | [diff] [blame^] | 73 | unittest2.main() |