[Lldb-commits] [lldb] r180896 - 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.
Greg Clayton
gclayton at apple.com
Wed May 1 16:41:30 PDT 2013
Author: gclayton
Date: Wed May 1 18:41:30 2013
New Revision: 180896
URL: http://llvm.org/viewvc/llvm-project?rev=180896&view=rev
Log:
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.
Modified:
lldb/trunk/source/Target/Process.cpp
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=180896&r1=180895&r2=180896&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Wed May 1 18:41:30 2013
@@ -2644,32 +2644,26 @@ Process::ReadScalarIntegerFromMemory (ad
Scalar &scalar,
Error &error)
{
- uint64_t uval;
-
- if (byte_size <= sizeof(uval))
+ uint64_t uval = 0;
+ if (byte_size == 0)
{
- size_t bytes_read = ReadMemory (addr, &uval, byte_size, error);
+ 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);
+ }
+ 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;
More information about the lldb-commits
mailing list