This is an archive of the discontinued LLVM Phabricator instance.

Simplify reading of Linux notes to correctly handle endianess.
ClosedPublic

Authored by hhellyer on Dec 8 2016, 5:12 AM.

Details

Summary

This patch changes and simplifies the way notes are read from Linux Elf cores.
The current implementation copies the bytes from the notes directly over the lldb structure for 64 bit cores and reads field by field for 32 bit cores. Reading the bytes directly only works if the endianess of the core dump and the platform that lldb are running on matches. The case statements for s390x and x86_64 would would only work on big endian systems and little endian systems respectively. That meant that x86_64 generally worked but s390x didn't unless you were on s390x or another big endian platform.
This patch just reads field by field on all platform and updates the field by field version to allow for those fields which are word size instead of fixed size. It should also slightly simplify adding support for a new Linux platform.

This patch also re-enables the s390x test case in TestLinuxCore.py on all non-s390x platforms as it now passes.

Event Timeline

hhellyer updated this revision to Diff 80747.Dec 8 2016, 5:12 AM
hhellyer retitled this revision from to Simplify reading of Linux notes to correctly handle endianess..
hhellyer updated this object.

I spotted this when looking at why https://reviews.llvm.org/D26676 didn't quite fix reading the z/Linux core dump. Do I need to raise a bug to track this as well or is this sufficient?

uweigand edited edge metadata.Dec 14 2016, 5:27 AM

As far as I can see, this should work fine everywhere. Looks good to me.

clayborg edited edge metadata.Dec 14 2016, 10:31 AM

The main question is why is the s390 core file test failing on any architectures? That seems like a bug.

packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
41

Why is this test skipped for any architectures? If we have a core file we should be good to go? How can this test pass on some architectures but not others?

hhellyer added inline comments.Dec 15 2016, 1:47 AM
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
41

I've just reset the skip annotations to match the annotations on test_i386 and test_x86_64.
It looks like the annotations for Windows and mips were added globally under https://reviews.llvm.org/rL283380 and https://reviews.llvm.org/rL283739 respectively so if they are still required I think they should probably be included on this test.

clayborg accepted this revision.Dec 16 2016, 10:42 AM
clayborg edited edge metadata.

Ok, lets get this in for now, but all core files should work on all systems as long as the Process plug-in they use are compiled into the binary.

This revision is now accepted and ready to land.Dec 16 2016, 10:42 AM
hhellyer closed this revision.Jan 3 2017, 3:13 AM