blob: 0980b45a3fe02451c55bfab99174acff7ca22652 [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
Zachary Turner35d017f2015-10-23 17:04:29 +00005from __future__ import print_function
6
Zachary Turner77db4a82015-10-22 20:06:20 +00007import lldb_shared
8
Pavel Labath3bf11252015-10-14 12:59:37 +00009import os
Pavel Labath3bf11252015-10-14 12:59:37 +000010import lldb
11from lldbtest import *
12import lldbutil
13import binascii
14
15
16class MemoryReadTestCase(TestBase):
17
18 mydir = TestBase.compute_mydir(__file__)
19
20 @skipUnlessPlatform(getDarwinOSTriples()+["linux"])
21 def test_memory_read(self):
22 self.build()
23 exe = os.path.join (os.getcwd(), "a.out")
24
25 target = self.dbg.CreateTarget(exe)
26 lldbutil.run_break_set_by_symbol(self, "main")
27
28 process = target.LaunchSimple (None, None, self.get_process_working_directory())
29 self.assertTrue(process, PROCESS_IS_VALID)
30 self.assertEqual(process.GetState(), lldb.eStateStopped, "Process is stopped")
31
32 pc = process.GetSelectedThread().GetSelectedFrame().GetPC()
33 for size in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]:
34 error = lldb.SBError()
35 memory = process.ReadMemory(pc, size, error)
36 self.assertTrue(error.Success())
37 self.match("process plugin packet send x%x,%x" % (pc, size), ["response:", memory])
38 self.match("process plugin packet send m%x,%x" % (pc, size), ["response:", binascii.hexlify(memory)])
39
40 process.Continue()
41 self.assertEqual(process.GetState(), lldb.eStateExited, "Process exited")