target and host with different endianness

We have a big-endian target that we debug from LLDB running on Windows through a custom process plugin and communication protocol.

The target’s default byte order is set to eByteOrderBig in ‘g_core_definitions’ in ArchSpec.cpp.

Most features work correctly (registers, variables, breakpoints, disassembly), but expressions seem to ignore arch endianness:

For example:

(lldb) reg read pc
pc = 0x00400020 arithmetic.elf`main + 32 at main.c:12
(lldb) expr -f hex – $pc
(unsigned int) $2 = 0x20004000

Has this scenario (big-endian target and little-endian host) been tested/used ?


Most things are currently little endian, so you will probably be one of the first. There shouldn't be much that needs to be fixed. All data we extract from memory is done via DataExtractor objects and they do have the notion of big and little endian, so there shouldn't be much more work than making sure the byte order gets correctly placed into the appropriate DataExtractor objects so that values are extracted correctly. I would guess the lldb_private::ValueObject's m_data member doesn't have the right byte order. The ValueObject should have a execution context (target, process, thread, frame, any of which should be valid) and the byte order can be retrieved from the Target's ArchSpec.

Let me know if you need any help,

Greg Clayton