[Lldb-commits] [lldb] r180888 - Fixed Process::ReadScalarIntegerFromMemory()

Sean Callanan scallanan at apple.com
Wed May 1 15:01:40 PDT 2013


Author: spyffe
Date: Wed May  1 17:01:40 2013
New Revision: 180888

URL: http://llvm.org/viewvc/llvm-project?rev=180888&view=rev
Log:
Fixed Process::ReadScalarIntegerFromMemory()
to report proper errors when the size is not
correct.

<rdar://problem/13784456>

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=180888&r1=180887&r2=180888&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Wed May  1 17:01:40 2013
@@ -2653,10 +2653,22 @@ Process::ReadScalarIntegerFromMemory (ad
         {
             DataExtractor data (&uval, sizeof(uval), GetByteOrder(), GetAddressByteSize());
             lldb::offset_t offset = 0;
-            if (byte_size <= 4)
-                scalar = data.GetMaxU32 (&offset, byte_size);
+            
+            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);
+            }
             else
-                scalar = data.GetMaxU64 (&offset, byte_size);
+            {
+                if (byte_size <= 4)
+                    scalar = data.GetMaxU32 (&offset, byte_size);
+                else
+                    scalar = data.GetMaxU64 (&offset, byte_size);
+            }
 
             if (is_signed)
                 scalar.SignExtend(byte_size * 8);





More information about the lldb-commits mailing list