blob: 33baaa559abdc3d21451a2f6b3477c34e0720785 [file] [log] [blame]
Pavel Labath3bf11252015-10-14 12:59:37 +00001"""
2Tests the binary ($x) and hex ($m) memory read packets of the remote stub
3"""
4
5import os
6import unittest2
7import lldb
8from lldbtest import *
9import lldbutil
10import binascii
11
12
13class MemoryReadTestCase(TestBase):
14
15 mydir = TestBase.compute_mydir(__file__)
16
17 @skipUnlessPlatform(getDarwinOSTriples()+["linux"])
18 def test_memory_read(self):
19 self.build()
20 exe = os.path.join (os.getcwd(), "a.out")
21
22 target = self.dbg.CreateTarget(exe)
23 lldbutil.run_break_set_by_symbol(self, "main")
24
25 process = target.LaunchSimple (None, None, self.get_process_working_directory())
26 self.assertTrue(process, PROCESS_IS_VALID)
27 self.assertEqual(process.GetState(), lldb.eStateStopped, "Process is stopped")
28
29 pc = process.GetSelectedThread().GetSelectedFrame().GetPC()
30 for size in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]:
31 error = lldb.SBError()
32 memory = process.ReadMemory(pc, size, error)
33 self.assertTrue(error.Success())
34 self.match("process plugin packet send x%x,%x" % (pc, size), ["response:", memory])
35 self.match("process plugin packet send m%x,%x" % (pc, size), ["response:", binascii.hexlify(memory)])
36
37 process.Continue()
38 self.assertEqual(process.GetState(), lldb.eStateExited, "Process exited")
39
40
41if __name__ == '__main__':
42 import atexit
43 lldb.SBDebugger.Initialize()
44 atexit.register(lambda: lldb.SBDebugger.Terminate())
45 unittest2.main()