diff options
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; |