[Lldb-commits] [lldb] r151581 - in /lldb/trunk/source/Core: DataExtractor.cpp ValueObject.cpp

Greg Clayton gclayton at apple.com
Mon Feb 27 15:00:14 PST 2012


Author: gclayton
Date: Mon Feb 27 17:00:14 2012
New Revision: 151581

URL: http://llvm.org/viewvc/llvm-project?rev=151581&view=rev
Log:
<rdar://problem/10017623> 

Fixed an error where if we tried to format a ValueObject using a format
that was incorrect for a variable, then it would set ValueObject::m_error
to an error state and stop the value from being able to be updated. We now
leave m_error alone and only let the update value code change that. Any errors
in formatting will return a valid value as C string that contains an error 
string. This lets us then modify the format and redisplay without any issues.


Modified:
    lldb/trunk/source/Core/DataExtractor.cpp
    lldb/trunk/source/Core/ValueObject.cpp

Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=151581&r1=151580&r2=151581&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Mon Feb 27 17:00:14 2012
@@ -1422,7 +1422,13 @@
         switch (item_format)
         {
         case eFormatBoolean:
-            s->Printf ("%s", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset) ? "true" : "false");
+            if (item_byte_size <= 8)
+                s->Printf ("%s", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset) ? "true" : "false");
+            else
+            {
+                s->Printf("error: unsupported byte size (%u) for boolean format", item_byte_size);
+                return offset;
+            }
             break;
 
         case eFormatBinary:
@@ -1505,6 +1511,7 @@
             }
             break;
 
+        case eFormatEnum:       // Print enum value as a signed integer when we don't get the enum type
         case eFormatDecimal:
             if (item_byte_size <= 8)
                 s->Printf ("%lld", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
@@ -1568,11 +1575,6 @@
             }
             break;
             
-        case eFormatEnum:
-            // Print enum value as a signed integer when we don't get the enum type
-            s->Printf ("%lld", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
-            break;
-
         case eFormatCString:
             {
                 const char *cstr = GetCStr(&offset);
@@ -1631,6 +1633,11 @@
                     s->Printf("%llu", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
                     s->Printf(" + %llui", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
                 }
+                else
+                {
+                    s->Printf("error: unsupported byte size (%u) for complex integer format", item_byte_size);
+                    return offset;
+                }
             }
             break;
 
@@ -1660,8 +1667,8 @@
             }
             else
             {
-                s->Printf ("unsupported complex float byte size %u", item_byte_size);
-                return start_offset;
+                s->Printf("error: unsupported byte size (%u) for complex float format", item_byte_size);
+                return offset;
             }
             break;
 
@@ -1707,14 +1714,19 @@
             {
                 s->Printf ("%Lg", GetLongDouble(&offset));
             }
+            else
+            {
+                s->Printf("error: unsupported byte size (%u) for float format", item_byte_size);
+                return offset;
+            }
             break;
 
         case eFormatUnicode16:
-            s->Printf("0x%4.4x", GetU16 (&offset));
+            s->Printf("U+%4.4x", GetU16 (&offset));
             break;
 
         case eFormatUnicode32:
-            s->Printf("0x%8.8x", GetU32 (&offset));
+            s->Printf("U+0x%8.8x", GetU32 (&offset));
             break;
 
         case eFormatAddressInfo:
@@ -1757,8 +1769,8 @@
             }
             else
             {
-                s->Printf ("unsupported hex float byte size %u", item_byte_size);
-                return start_offset;
+                s->Printf("error: unsupported byte size (%u) for hex float format", item_byte_size);
+                return offset;
             }
             break;
 

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=151581&r1=151580&r2=151581&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Feb 27 17:00:14 2012
@@ -1135,24 +1135,26 @@
                             }
                             StreamString sstr;
                             ExecutionContext exe_ctx (GetExecutionContextRef());
-                            if (ClangASTType::DumpTypeValue (GetClangAST(),            // The clang AST
-                                                             clang_type,               // The clang type to display
-                                                             &sstr,
-                                                             my_format,                   // Format to display this type with
-                                                             m_data,                   // Data to extract from
-                                                             0,                        // Byte offset into "m_data"
-                                                             GetByteSize(),            // Byte size of item in "m_data"
-                                                             GetBitfieldBitSize(),     // Bitfield bit size
-                                                             GetBitfieldBitOffset(),
-                                                             exe_ctx.GetBestExecutionContextScope()))  // Bitfield bit offset
-                                m_value_str.swap(sstr.GetString());
-                            else
-                            {
-                                m_error.SetErrorStringWithFormat ("unsufficient data for value (only %lu of %lu bytes available)", 
-                                                                  m_data.GetByteSize(),
-                                                                  GetByteSize());
+                            ClangASTType::DumpTypeValue (GetClangAST(),             // The clang AST
+                                                         clang_type,                // The clang type to display
+                                                         &sstr,
+                                                         my_format,                 // Format to display this type with
+                                                         m_data,                    // Data to extract from
+                                                         0,                         // Byte offset into "m_data"
+                                                         GetByteSize(),             // Byte size of item in "m_data"
+                                                         GetBitfieldBitSize(),      // Bitfield bit size
+                                                         GetBitfieldBitOffset(),    // Bitfield bit offset
+                                                         exe_ctx.GetBestExecutionContextScope()); 
+                            // Don't set the m_error to anything here otherwise
+                            // we won't be able to re-format as anything else. The
+                            // code for ClangASTType::DumpTypeValue() should always
+                            // return something, even if that something contains
+                            // an error messsage. "m_error" is used to detect errors
+                            // when reading the valid object, not for formatting errors.
+                            if (sstr.GetString().empty())
                                 m_value_str.clear();
-                            }
+                            else
+                                m_value_str.swap(sstr.GetString());
                         }
                     }
                     break;





More information about the lldb-commits mailing list