blob: 33a6832981ee1fc1f9bdd3eb692e1c67041c82c7 [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 Turner77db4a82015-10-22 20:06:20 +00005import lldb_shared
6
Pavel Labath3bf11252015-10-14 12:59:37 +00007import os
Pavel Labath3bf11252015-10-14 12:59:37 +00008import lldb
9from lldbtest import *
10import lldbutil
11import binascii
12
13
14class 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")