diff options
author | Greg Clayton <gclayton@apple.com> | 2013-05-01 23:41:30 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-05-01 23:41:30 +0000 |
commit | 7060f8976c39381b877971eb88da3fd346941484 (patch) | |
tree | 40a06148b0264f5cbbb6438d8f36ae031add0f67 /lldb/source/Target/Process.cpp | |
parent | 16f45ca6ba2ce662e4f8a02f6904bbf7f5019768 (diff) | |
download | bcm5719-llvm-7060f8976c39381b877971eb88da3fd346941484.tar.gz bcm5719-llvm-7060f8976c39381b877971eb88da3fd346941484.zip |
Return zero when we don't support the byte size. Previously is we were asked to read 3, 5, 6, or 7 byte integers, we would set the error, but still return that we read that number of bytes without populating the scalar.
llvm-svn: 180896
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 95abb7945b3..8e1ab7a3f47 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2644,32 +2644,26 @@ Process::ReadScalarIntegerFromMemory (addr_t addr, Scalar &scalar, Error &error) { - uint64_t uval; - - if (byte_size <= sizeof(uval)) + uint64_t uval = 0; + if (byte_size == 0) + { + error.SetErrorString ("byte size is zero"); + } + else if (byte_size & (byte_size - 1)) { - size_t bytes_read = ReadMemory (addr, &uval, byte_size, error); + error.SetErrorStringWithFormat ("byte size %u is not a power of 2", byte_size); + } + else if (byte_size <= sizeof(uval)) + { + const size_t bytes_read = ReadMemory (addr, &uval, byte_size, error); if (bytes_read == byte_size) { DataExtractor data (&uval, sizeof(uval), GetByteOrder(), GetAddressByteSize()); lldb::offset_t offset = 0; - - if (byte_size == 0) - { - error.SetErrorString ("byte size is zero"); - } - else if (byte_size & (byte_size - 1)) - { - error.SetErrorStringWithFormat ("byte size %u is not a power of 2", byte_size); - } + if (byte_size <= 4) + scalar = data.GetMaxU32 (&offset, byte_size); else - { - if (byte_size <= 4) - scalar = data.GetMaxU32 (&offset, byte_size); - else - scalar = data.GetMaxU64 (&offset, byte_size); - } - + scalar = data.GetMaxU64 (&offset, byte_size); if (is_signed) scalar.SignExtend(byte_size * 8); return bytes_read; |