@skipIfReproducer
def test_access_my_int(self):
    "Test access 'my_int' using Python SBProcess.GetByteOrder() and other APIs."
    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_int', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    if (not val.GetLocation().startswith('0x')):
        return
    location = int(val.GetLocation(), 16)
    from lldbsuite.test.lldbutil import int_to_bytearray, bytearray_to_int
    byteSize = val.GetByteSize()
    bytes = int_to_bytearray(256, byteSize)
    byteOrder = process.GetByteOrder()
    if (byteOrder == lldb.eByteOrderBig):
        bytes.reverse()
    elif (byteOrder == lldb.eByteOrderLittle):
        pass
    else:
        return
    error = lldb.SBError()
    result = process.WriteMemory(location, bytes, error)
    if ((not error.Success()) or (result != byteSize)):
        self.fail('SBProcess.WriteMemory() failed')
    self.expect(val.GetValue(), "SBProcess.ReadMemory() successfully writes (int)256 to the memory location for 'my_int'", exe=False, startstr='256')
    val = frame.FindValue('my_int', lldb.eValueTypeVariableGlobal)
    self.expect(val.GetValue(), "SBProcess.ReadMemory() successfully writes (int)256 to the memory location for 'my_int'", exe=False, startstr='256')
    content = process.ReadMemory(location, byteSize, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadMemory() failed')
    if (byteOrder == lldb.eByteOrderBig):
        content = bytearray(content, 'ascii')
        content.reverse()
    new_value = bytearray_to_int(content, byteSize)
    if (new_value != 256):
        self.fail("Memory content read from 'my_int' does not match (int)256")
    if self.TraceOn():
        for i in content:
            print('byte:', i)
Test access 'my_int' using Python SBProcess.GetByteOrder() and other APIs.
@skipIfReproducer
def test_access_my_int(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_int', lldb.eValueTypeVariableGlobal)
    self.DebugSBValue(val)
    if (not val.GetLocation().startswith('0x')):
        return
    location = int(val.GetLocation(), 16)
    from lldbsuite.test.lldbutil import int_to_bytearray, bytearray_to_int
    byteSize = val.GetByteSize()
    bytes = int_to_bytearray(256, byteSize)
    byteOrder = process.GetByteOrder()
    if (byteOrder == lldb.eByteOrderBig):
        bytes.reverse()
    elif (byteOrder == lldb.eByteOrderLittle):
        pass
    else:
        return
    error = lldb.SBError()
    result = process.WriteMemory(location, bytes, error)
    if ((not error.Success()) or (result != byteSize)):
        self.fail('SBProcess.WriteMemory() failed')
    self.expect(val.GetValue(), "SBProcess.ReadMemory() successfully writes (int)256 to the memory location for 'my_int'", exe=False, startstr='256')
    val = frame.FindValue('my_int', lldb.eValueTypeVariableGlobal)
    self.expect(val.GetValue(), "SBProcess.ReadMemory() successfully writes (int)256 to the memory location for 'my_int'", exe=False, startstr='256')
    content = process.ReadMemory(location, byteSize, error)
    if (not error.Success()):
        self.fail('SBProcess.ReadMemory() failed')
    if (byteOrder == lldb.eByteOrderBig):
        content = bytearray(content, 'ascii')
        content.reverse()
    new_value = bytearray_to_int(content, byteSize)
    if (new_value != 256):
        self.fail("Memory content read from 'my_int' does not match (int)256")
    if self.TraceOn():
        for i in content:
            print('byte:', i)