def test_allocate_deallocate_memory(self):
    'Test Python SBProcess.AllocateMemory() and SBProcess.DeallocateMemory() APIs.'
    self.build()
    (target, process, main_thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self, '// Set break point at this line', lldb.SBFileSpec('main.cpp'))
    error = lldb.SBError()
    addr = process.AllocateMemory(16384, lldb.ePermissionsReadable, error)
    if ((not error.Success()) or (addr == lldb.LLDB_INVALID_ADDRESS)):
        self.fail('SBProcess.AllocateMemory() failed')
    result = process.WriteMemory(addr, 'a', error)
    if ((not error.Success()) or (result != 1)):
        self.fail('SBProcess.WriteMemory() failed')
    content = process.ReadMemory(addr, 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')
    frame = main_thread.GetFrameAtIndex(0)
    val = frame.EvaluateExpression('test_read(reinterpret_cast<char *>({:#x}))'.format(addr))
    self.expect(val.GetValue(), "Result of test_read() matches expected output 'a'", exe=False, startstr="'a'")
    val = frame.EvaluateExpression("test_write(reinterpret_cast<char *>({:#x}), 'b')".format(addr))
    if val.GetError().Success():
        self.fail('test_write() to allocated memory without write permission unexpectedly succeeded')
    error = process.DeallocateMemory(addr)
    if (not error.Success()):
        self.fail('SBProcess.DeallocateMemory() failed')
Test Python SBProcess.AllocateMemory() and SBProcess.DeallocateMemory() APIs.
def test_allocate_deallocate_memory(self):
    
    self.build()
    (target, process, main_thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self, '// Set break point at this line', lldb.SBFileSpec('main.cpp'))
    error = lldb.SBError()
    addr = process.AllocateMemory(16384, lldb.ePermissionsReadable, error)
    if ((not error.Success()) or (addr == lldb.LLDB_INVALID_ADDRESS)):
        self.fail('SBProcess.AllocateMemory() failed')
    result = process.WriteMemory(addr, 'a', error)
    if ((not error.Success()) or (result != 1)):
        self.fail('SBProcess.WriteMemory() failed')
    content = process.ReadMemory(addr, 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')
    frame = main_thread.GetFrameAtIndex(0)
    val = frame.EvaluateExpression('test_read(reinterpret_cast<char *>({:#x}))'.format(addr))
    self.expect(val.GetValue(), "Result of test_read() matches expected output 'a'", exe=False, startstr="'a'")
    val = frame.EvaluateExpression("test_write(reinterpret_cast<char *>({:#x}), 'b')".format(addr))
    if val.GetError().Success():
        self.fail('test_write() to allocated memory without write permission unexpectedly succeeded')
    error = process.DeallocateMemory(addr)
    if (not error.Success()):
        self.fail('SBProcess.DeallocateMemory() failed')