@skipIfReproducer
def test_read_memory(self):
    'Test Python SBProcess.ReadMemory() 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)
    error = lldb.SBError()
    self.assertFalse(val.TypeIsPointerType())
    content = process.ReadMemory(val.AddressOf().GetValueAsUnsigned(), 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: 'x'", exe=False, startstr=b'x')
    val = frame.FindValue('my_char_ptr', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    cstring = process.ReadCStringFromMemory(val.GetValueAsUnsigned(), 256, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadCStringFromMemory() failed')
    if self.TraceOn():
        print('cstring read is:', cstring)
    self.expect(cstring, 'Result from SBProcess.ReadCStringFromMemory() matches our expected output', exe=False, startstr='Does it work?')
    val = frame.FindValue('my_cstring', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    self.assertFalse(val.TypeIsPointerType())
    cstring = process.ReadCStringFromMemory(val.AddressOf().GetValueAsUnsigned(), 256, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadCStringFromMemory() failed')
    if self.TraceOn():
        print('cstring read is:', cstring)
    self.expect(cstring, 'Result from SBProcess.ReadCStringFromMemory() matches our expected output', exe=False, startstr='lldb.SBProcess.ReadCStringFromMemory() works!')
    val = frame.FindValue('my_uint32', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    self.assertFalse(val.TypeIsPointerType())
    my_uint32 = process.ReadUnsignedFromMemory(val.AddressOf().GetValueAsUnsigned(), 4, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadCStringFromMemory() failed')
    if self.TraceOn():
        print('uint32 read is:', my_uint32)
    if (my_uint32 != 12345):
        self.fail('Result from SBProcess.ReadUnsignedFromMemory() does not match our expected output')
Test Python SBProcess.ReadMemory() API.
@skipIfReproducer
def test_read_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)
    error = lldb.SBError()
    self.assertFalse(val.TypeIsPointerType())
    content = process.ReadMemory(val.AddressOf().GetValueAsUnsigned(), 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: 'x'", exe=False, startstr=b'x')
    val = frame.FindValue('my_char_ptr', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    cstring = process.ReadCStringFromMemory(val.GetValueAsUnsigned(), 256, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadCStringFromMemory() failed')
    if self.TraceOn():
        print('cstring read is:', cstring)
    self.expect(cstring, 'Result from SBProcess.ReadCStringFromMemory() matches our expected output', exe=False, startstr='Does it work?')
    val = frame.FindValue('my_cstring', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    self.assertFalse(val.TypeIsPointerType())
    cstring = process.ReadCStringFromMemory(val.AddressOf().GetValueAsUnsigned(), 256, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadCStringFromMemory() failed')
    if self.TraceOn():
        print('cstring read is:', cstring)
    self.expect(cstring, 'Result from SBProcess.ReadCStringFromMemory() matches our expected output', exe=False, startstr='lldb.SBProcess.ReadCStringFromMemory() works!')
    val = frame.FindValue('my_uint32', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    self.assertFalse(val.TypeIsPointerType())
    my_uint32 = process.ReadUnsignedFromMemory(val.AddressOf().GetValueAsUnsigned(), 4, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadCStringFromMemory() failed')
    if self.TraceOn():
        print('uint32 read is:', my_uint32)
    if (my_uint32 != 12345):
        self.fail('Result from SBProcess.ReadUnsignedFromMemory() does not match our expected output')