[Lldb-commits] [PATCH] D17167: Fix bug with register values byte order in expression evaluation

Marianne Mailhot-Sarrasin via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 11 13:21:09 PST 2016

mamai created this revision.
mamai added a reviewer: spyffe.
mamai added subscribers: phlav, lldb-commits.
mamai set the repository for this revision to rL LLVM.

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).




Index: source/Expression/Materializer.cpp
--- source/Expression/Materializer.cpp
+++ source/Expression/Materializer.cpp
@@ -1275,9 +1275,12 @@
         m_register_contents.reset(new DataBufferHeap(register_data.GetDataStart(), register_data.GetByteSize()));
         Error write_error;
-        map.WriteMemory(load_addr, register_data.GetDataStart(), register_data.GetByteSize(), write_error);
+        Scalar scalar;
+        reg_value.GetScalarValue(scalar);
+        map.WriteScalarToMemory(load_addr, scalar, scalar.GetByteSize(), write_error);
         if (!write_error.Success())
             err.SetErrorStringWithFormat("couldn't write the contents of register %s: %s", m_register_info.name, write_error.AsCString());

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17167.47708.patch
Type: text/x-patch
Size: 842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160211/a5a723f4/attachment.bin>

More information about the lldb-commits mailing list