reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
from __future__ import print_function
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
from gdbclientutils import *


class TestWriteMemory(GDBRemoteTestBase):

    def setUp(self):
        super(TestWriteMemory, self).setUp()
        self._initial_platform = lldb.DBG.GetSelectedPlatform()

    def tearDown(self):
        lldb.DBG.SetSelectedPlatform(self._initial_platform)
        super(TestWriteMemory, self).tearDown()


    def test(self):

        class MyResponder(MockGDBServerResponder):
            def setBreakpoint(self, packet):
                return "OK"

        self.server.responder = MyResponder()
        target = self.dbg.CreateTargetWithFileAndTargetTriple('', 'x86_64-pc-linux')
        process = self.connect(target)

        bp = target.BreakpointCreateByAddress(0x1000)
        self.assertTrue(bp.IsValid())
        self.assertEqual(bp.GetNumLocations(), 1)
        bp.SetEnabled(True)
        self.assertTrue(bp.IsEnabled())

        err = lldb.SBError()
        data = str("\x01\x02\x03\x04")
        result = process.WriteMemory(0x1000, data, err)
        self.assertEqual(result, 4)