Pavel Labath | 3bf1125 | 2015-10-14 12:59:37 +0000 | [diff] [blame] | 1 | """ |
| 2 | Tests the binary ($x) and hex ($m) memory read packets of the remote stub |
| 3 | """ |
| 4 | |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame^] | 5 | import lldb_shared |
| 6 | |
Pavel Labath | 3bf1125 | 2015-10-14 12:59:37 +0000 | [diff] [blame] | 7 | import os |
Pavel Labath | 3bf1125 | 2015-10-14 12:59:37 +0000 | [diff] [blame] | 8 | import lldb |
| 9 | from lldbtest import * |
| 10 | import lldbutil |
| 11 | import binascii |
| 12 | |
| 13 | |
| 14 | class MemoryReadTestCase(TestBase): |
| 15 | |
| 16 | mydir = TestBase.compute_mydir(__file__) |
| 17 | |
| 18 | @skipUnlessPlatform(getDarwinOSTriples()+["linux"]) |
| 19 | def test_memory_read(self): |
| 20 | self.build() |
| 21 | exe = os.path.join (os.getcwd(), "a.out") |
| 22 | |
| 23 | target = self.dbg.CreateTarget(exe) |
| 24 | lldbutil.run_break_set_by_symbol(self, "main") |
| 25 | |
| 26 | process = target.LaunchSimple (None, None, self.get_process_working_directory()) |
| 27 | self.assertTrue(process, PROCESS_IS_VALID) |
| 28 | self.assertEqual(process.GetState(), lldb.eStateStopped, "Process is stopped") |
| 29 | |
| 30 | pc = process.GetSelectedThread().GetSelectedFrame().GetPC() |
| 31 | for size in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]: |
| 32 | error = lldb.SBError() |
| 33 | memory = process.ReadMemory(pc, size, error) |
| 34 | self.assertTrue(error.Success()) |
| 35 | self.match("process plugin packet send x%x,%x" % (pc, size), ["response:", memory]) |
| 36 | self.match("process plugin packet send m%x,%x" % (pc, size), ["response:", binascii.hexlify(memory)]) |
| 37 | |
| 38 | process.Continue() |
| 39 | self.assertEqual(process.GetState(), lldb.eStateExited, "Process exited") |