tberghammer added a comment.

Hi,

I checked out the implementation of RegisterValue and this is my understanding 
what is happening:

- When we call RegisterValue::SetUInt it will be creating a 32bit unsigned 
llvm::APInt
- The llvm::APInt will store the data in a uint64_t
- Calling RegisterValue::GetBytes() will return with APInt::getRawData() what 
will return a pointer to the uint64_t

The problem is that the pointer returned from getRawData isn't pointing to the 
32bit data of the underlying storage but it points to the full 64bit storage 
slot.

I don't know what is the best solution in the current situation but using 
SetBytes directly and managing the endianness by hand looks like a bad solution 
for me because then we practically say that SetUInt (and all other similar 
functions) are not big endian compatible (what should be fixed or they should 
be removed).

I see 2 option at the moment but none of them is perfect:

- Add a new function to llvm::APInt what returns the pointer to the actual data 
in case of both endian (possibly the best option)
- Don't use llvm::APInt inside Scalar as we don't need most of it's 
functionality and just have a big enough byte buffer in RegisterValue

Cheers,
Tamas


Repository:
  rL LLVM

http://reviews.llvm.org/D14633



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to