[lldb-dev] target and host with different endianness

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Feb 11 17:39:45 PST 2016


> On Feb 11, 2016, at 7:55 AM, Philippe Lavoie via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> 
> 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
> (lldb)
> 
> 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



More information about the lldb-dev mailing list