Page MenuHomePhabricator

Fix bug with register values byte order in expression evaluation
ClosedPublic

Authored by mamai on Feb 11 2016, 1:21 PM.

Details

Summary

The evaluation of expressions containing register values was broken for targets for which endianness differs from host.

This patch fixes issues like:
(lldb) reg read pc

pc = 0x00400020  arithmetic.elf`main + 32 at main.c:12

(lldb) expr -f hex -- $pc
(unsigned int) $2 = 0x20004000

Where the second command will now give the right value (0x00400020).

Diff Detail

Repository
rL LLVM

Event Timeline

mamai updated this revision to Diff 47708.Feb 11 2016, 1:21 PM
mamai retitled this revision from to Fix bug with register values byte order in expression evaluation.
mamai updated this object.
mamai added a reviewer: spyffe.
mamai set the repository for this revision to rL LLVM.
mamai added subscribers: phlav, lldb-commits.
clayborg resigned from this revision.Feb 18 2016, 4:42 PM
clayborg removed a reviewer: clayborg.

I will defer to Sean Callanan.

spyffe requested changes to this revision.Feb 18 2016, 5:11 PM
spyffe edited edge metadata.

Looks fine to me, but let's put in an assertion to make sure our assumptions in making this change are not violated.

source/Expression/Materializer.cpp
1282 ↗(On Diff #47708)

Let's put an lldbassert in here to make sure scalar.GetByteSize() == register_data.GetByteSize().
I know it ought to be, but I'm a little bit wary of that code.

This revision now requires changes to proceed.Feb 18 2016, 5:11 PM
mamai updated this revision to Diff 48486.Feb 19 2016, 6:53 AM
mamai edited edge metadata.

I have updated the patch to add the assertion.

mamai added a comment.Feb 26 2016, 7:52 AM

Are the changes correct? And if so, could someone commit it for me? I don't have commit access.

ADodds accepted this revision.Feb 26 2016, 9:44 AM
ADodds added a reviewer: ADodds.
ADodds added a subscriber: ADodds.

I am happy to commit this for you since you have addressed the concerns raised by Sean.

This revision was automatically updated to reflect the committed changes.