@skipIfReproducer
def test_write_memory(self):
    'Test Python SBProcess.WriteMemory() API.'
    self.build()
    exe = self.getBuildArtifact('a.out')
    target = self.dbg.CreateTarget(exe)
    self.assertTrue(target, VALID_TARGET)
    breakpoint = target.BreakpointCreateByLocation('main.cpp', self.line)
    self.assertTrue(breakpoint, VALID_BREAKPOINT)
    process = target.LaunchSimple(None, None, self.get_process_working_directory())
    thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
    self.assertTrue(thread.IsValid(), 'There should be a thread stopped due to breakpoint')
    frame = thread.GetFrameAtIndex(0)
    val = frame.FindValue('my_char', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    if (not val.GetLocation().startswith('0x')):
        return
    location = int(val.GetLocation(), 16)
    error = lldb.SBError()
    result = process.WriteMemory(location, 'a', error)
    if ((not error.Success()) or (result != 1)):
        self.fail('SBProcess.WriteMemory() failed')
    content = process.ReadMemory(location, 1, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadMemory() failed')
    if self.TraceOn():
        print('memory content:', content)
    self.expect(content, "Result from SBProcess.ReadMemory() matches our expected output: 'a'", exe=False, startstr=b'a')
Test Python SBProcess.WriteMemory() API.
@skipIfReproducer
def test_write_memory(self):
    
    self.build()
    exe = self.getBuildArtifact('a.out')
    target = self.dbg.CreateTarget(exe)
    self.assertTrue(target, VALID_TARGET)
    breakpoint = target.BreakpointCreateByLocation('main.cpp', self.line)
    self.assertTrue(breakpoint, VALID_BREAKPOINT)
    process = target.LaunchSimple(None, None, self.get_process_working_directory())
    thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
    self.assertTrue(thread.IsValid(), 'There should be a thread stopped due to breakpoint')
    frame = thread.GetFrameAtIndex(0)
    val = frame.FindValue('my_char', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    if (not val.GetLocation().startswith('0x')):
        return
    location = int(val.GetLocation(), 16)
    error = lldb.SBError()
    result = process.WriteMemory(location, 'a', error)
    if ((not error.Success()) or (result != 1)):
        self.fail('SBProcess.WriteMemory() failed')
    content = process.ReadMemory(location, 1, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadMemory() failed')
    if self.TraceOn():
        print('memory content:', content)
    self.expect(content, "Result from SBProcess.ReadMemory() matches our expected output: 'a'", exe=False, startstr=b'a')