[lldb-dev] [RFC] Contributing platform support for Linux on SystemZ

Ulrich Weigand via lldb-dev lldb-dev at lists.llvm.org
Fri Apr 8 10:00:39 PDT 2016


I've been working on adding support for Linux on SystemZ as a target (and
host) platform for LLDB, and now have a patch set ready that I'd like to
submit for upstream inclusion.

For reference, I've attached the patch set as a quilt stack.
(See attached file: patches-lldb-s390x.tar.bz2)
I'd be happy to split it out into one email per patch or use Phabricator,
whatever you prefer.  I'd also appreciate suggestions for potential
reviewers I could list on Phabricator revisions for each of the affected
areas.  This is my first contribution to LLDB, and I'm not really familiar
with the community yet.

There's a number of separate changes implemented by the patch set.   First
of all, I ran into three problems that seem to be platform-independent, but
are related to version and implementation details of the linker and libc
library in use on the system, which is why they may not show up everywhere
(but they certainly caused many test case failures on my system).  These

- LLDB was unable to find the .plt section and therefore did not identify
PLT call stubs (see diff-pltsection)
- LLDB would sometimes not find DWARF CFI entries if the PC points one
beyond the end of a function (see diff-tailcall)
- LLDB would fail expression evaluation if clang asks for an identifier
that exists both as type name and variable name (see diff-typelookup)

Next, I had to add one new member routine to the ABI class.  This was
necessary since on SystemZ, the CFA does not equal the incoming stack
pointer value (like LLDB unwind code assumes), but instead is offset by a
constant, i.e. CFA = incoming SP + 160.  The new ABI member CFAOffset
allows a platform to provide this offset of the CFA relative to the SP to
common unwind code (see diff-cfaoffset).

The patch diff-s390x then adds all the new back-end code to support Linux
on SystemZ.  Its only strict pre-requisite is diff-cfaoffset.  Changes
includes in this patch are:
- A new ArchSpec value of eCore_s390x_generic
- A new directory Plugins/ABI/SysV-s390x providing an ABI implementation
- Register context support
- Native Linux support including watchpoint support
- ELF core file support
- Misc. support throughout the code base (e.g. breakpoint opcodes)
- Test case updates to support the platform

This should provide complete support for debugging the base SystemZ
platform. Not yet supported are optional features like transaction support
(zEC12) or SIMD vector support (z13).  Note that there is no instruction
emulation, since our ABI requires that all code provides correct DWARF CFI
in .eh_frame to support unwinding.

However, after that there are still many failing test cases due to various
bugs in common code.  The patch diff-signedchar fixes a number of problems
caused by LLDB assuming a plain "char" type is signed; this is actually
platform-specific, and on SystemZ, char is in fact unsigned.

The remaining patches fix many problems throughout the code base affecting
big-endian platforms (like SystemZ).   The biggest problem was that pretty
much every access to APInt.getRawData (mostly via the Scalar class, but in
a couple of other places as well) was incorrect on big-endian systems.
This is fixed in diff-endian-scalar, which requires diff-getbytes-const as
pre-requisite, a patch that changes RegisterValue so as to allow
Scalar.getBytes to be made const.  Other endian related issues were:
- Bit field numbering didn't work correctly (see diff-endian-bitfield)
- Some smaller miscellaneous issues (see diff-endian-misc)
- ARM instruction emulation tests wouldn't work on big-endian host systems
(see diff-endian-armemu)
- Misc. test cases made byte order assumptions (see diff-endian-tests)

With the full patch stack applied on a current LLDB code base (rev.
265656), I'm getting a clean test suite run on the platform:

Test Result Summary
Test Methods:       1684
Reruns:                0
Success:            1046
Expected Failure:    114
Failure:               0
Error:                 0
Exceptional Exit:      0
Unexpected Success:   21
Skip:                503
Timeout:               0
Expected Timeout:      0

Looking forward to working with you on getting SystemZ support upstream!
I'd also be happy to take on ongoing maintenance (setting up a build bot,
fixing issues as they come up, etc ...).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160408/ec1275ea/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patches-lldb-s390x.tar.bz2
Type: application/octet-stream
Size: 38700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160408/ec1275ea/attachment-0001.obj>

More information about the lldb-dev mailing list