This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fixed incorrect endianness when evaluating certain expressions
Needs RevisionPublic

Authored by cameron314 on Jun 14 2016, 9:55 AM.

Details

Summary

The EntityVariable materializer was, under certain conditions, taking the bytes of a DataExtractor that were potentially in host order (e.g. little endian) and putting them in the IRMemoryMap (which assumes all values are in target order, e.g. big endian). This caused certain values to have the wrong endianness during expression evaluation.

On our platform, this manifested as certain expressions yielding incorrect results when the variables were in registers (e.g. argc + 1 would give 0x01000001).

Diff Detail

Event Timeline

cameron314 updated this revision to Diff 60694.Jun 14 2016, 9:55 AM
cameron314 retitled this revision from to [lldb] Fixed incorrect endianness when evaluating certain expressions.
cameron314 updated this object.
cameron314 added reviewers: spyffe, zturner, clayborg.
cameron314 added a subscriber: lldb-commits.
clayborg accepted this revision.Jun 20 2016, 5:17 PM
clayborg edited edge metadata.

Sean Callanan needs to OK this as well.

This revision is now accepted and ready to land.Jun 20 2016, 5:17 PM

@spyffe, do you have a minute to look this over?

Sorry to bug you again, but @spyffe, could you have a look when you have a sec?

@spyffe, do you have a minute today?

spyffe requested changes to this revision.Jul 25 2016, 10:53 AM
spyffe edited edge metadata.

This looks fine. How tricky would it be to make a test case for a reproduction scenario?

This revision now requires changes to proceed.Jul 25 2016, 10:54 AM

Hmm, I don't think this is easily testable at all. We happened to see it on our (out-of-tree) big-endian architecture when debugging remotely on Windows, but only for variables backed by registers. I was thus able to trace the problem back to this code, fix it, and verify it locally. But I can't reproduce this for other architectures because they likely don't follow the same code path (plus I don't have the hardware/simulator setup required). And trying to unit test this would be... quite a challenge, I feel, considering all the layers involved.

mamai added a subscriber: mamai.Mar 25 2021, 11:46 AM