16-bit address support?

In my explorations of using clang/llvm to target small ARM MCUs (Cortex M0/M4), I came across this set of slides, wherein they note that lldb doesn’t support 2-byte addresses, and they show the modifications necessary to do so (slides 19 & 20). The slides are quite old (2016), so I took a look at the current lldb source, and found it has changed substantially (e.g. DWARFCompileUnit.cpp no longer references m_addr_size). Grepping through the source, I found that DWARFUnit.cpp still does, and still seems to only expect 32- and 64-bit addresses.

Is this assessment correct? What would it take to get 16-bit support into mainline?

Note: I realize M0/M4 are 32-bit, and I admittedly went down a rabbit hole with this, but it seems this support should be in there.

The code in DWARFUnitHeader::extract seems wrong to me. There’s nothing in the DWARF standard that says that 4 and 8 are the only valid address size values. That said, it is possible that there’s other places in LLDB that still make similar assumptions and the goal was to fail early with a somewhat meaningful error message (although I would’ve preferred different wording in that case).

Personally I would be fine with removing that piece of code.

Probably the easiest way to find out is trying to debug a target with 2-byte addresses like the Codeplay folks did and fixing all the bugs you find that way. I’m a little surprised they didn’t upstream those fixes.

1 Like