[Lldb-commits] [lldb] r117999 - in /lldb/trunk/source/Core: Value.cpp ValueObject.cpp ValueObjectChild.cpp

Greg Clayton gclayton at apple.com
Mon Nov 1 18:50:16 PDT 2010


Author: gclayton
Date: Mon Nov  1 20:50:16 2010
New Revision: 117999

URL: http://llvm.org/viewvc/llvm-project?rev=117999&view=rev
Log:
Print better error messages when memory reads fail when displaying variable
values.

Always show the variable types for the top level items when dumping program
variables.



Modified:
    lldb/trunk/source/Core/Value.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Core/ValueObjectChild.cpp

Modified: lldb/trunk/source/Core/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=117999&r1=117998&r2=117999&view=diff
==============================================================================
--- lldb/trunk/source/Core/Value.cpp (original)
+++ lldb/trunk/source/Core/Value.cpp Mon Nov  1 20:50:16 2010
@@ -498,7 +498,7 @@
     switch (m_value_type)
     {
     default:
-        error.SetErrorStringWithFormat("Invalid value type %i.\n", m_value_type);
+        error.SetErrorStringWithFormat("invalid value type %i", m_value_type);
         break;
 
     case eValueTypeScalar:
@@ -506,17 +506,17 @@
         data.SetAddressByteSize(sizeof(void *));
         if (m_value.GetData (data))
             return error;   // Success;
-        error.SetErrorStringWithFormat("Extracting data from value failed.\n");
+        error.SetErrorStringWithFormat("extracting data from value failed");
         break;
 
     case eValueTypeLoadAddress:
         if (exe_ctx == NULL)
         {
-            error.SetErrorString ("Can't read memory (no execution context).");
+            error.SetErrorString ("can't read memory (no execution context)");
         }
         else if (exe_ctx->process == NULL)
         {
-            error.SetErrorString ("Can't read memory (invalid process).");
+            error.SetErrorString ("can't read memory (invalid process)");
         }
         else
         {
@@ -564,7 +564,7 @@
                     }
                     else
                     {
-                        error.SetErrorStringWithFormat ("Unable to resolve the module for file address 0x%llx for variable '%s'.\n", file_addr, variable->GetName().AsCString(""));
+                        error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s'", file_addr, variable->GetName().AsCString(""));
                     }
                 }
                 else
@@ -576,7 +576,7 @@
             {
                 // Can't convert a file address to anything valid without more
                 // context (which Module it came from)
-                error.SetErrorString ("Can't read memory from file address without more context.");
+                error.SetErrorString ("can't read memory from file address without more context");
             }
         }
         break;
@@ -595,7 +595,7 @@
 
     if (address == LLDB_INVALID_ADDRESS)
     {
-        error.SetErrorStringWithFormat ("Invalid %s address.\n", address_type == eAddressTypeHost ? "host" : "load");
+        error.SetErrorStringWithFormat ("invalid %s address", address_type == eAddressTypeHost ? "host" : "load");
         return error;
     }
 
@@ -628,16 +628,18 @@
             {
                 if (error.Success())
                     error.SetErrorStringWithFormat("read %u bytes of memory from 0x%llx failed", (uint64_t)address, byte_size);
+                else
+                    error.SetErrorStringWithFormat("read memory from 0x%llx failed", (uint64_t)address);
             }
         }
         else
         {
-            error.SetErrorStringWithFormat ("Unsupported lldb::AddressType value (%i).\n", address_type);
+            error.SetErrorStringWithFormat ("unsupported lldb::AddressType value (%i)", address_type);
         }
     }
     else
     {
-        error.SetErrorStringWithFormat ("Out of memory.\n");
+        error.SetErrorStringWithFormat ("out of memory");
     }
 
     return error;

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=117999&r1=117998&r2=117999&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Nov  1 20:50:16 2010
@@ -990,7 +990,8 @@
 
             s.Indent();
 
-            if (show_types)
+            // Always show the type for the top level items.
+            if (show_types || curr_depth == 0)
                 s.Printf("(%s) ", valobj->GetTypeName().AsCString());
 
 
@@ -1021,7 +1022,7 @@
 
         if (err_cstr)
         {
-            s.Printf (" %s\n", err_cstr);
+            s.Printf (" error: %s\n", err_cstr);
         }
         else
         {

Modified: lldb/trunk/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=117999&r1=117998&r2=117999&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectChild.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectChild.cpp Mon Nov  1 20:50:16 2010
@@ -146,13 +146,27 @@
             {
                 uint32_t offset = 0;
                 m_value.GetScalar() = parent->GetDataExtractor().GetPointer(&offset);
-                // For pointers, m_byte_offset should only ever be set if we
-                // ValueObject::GetSyntheticArrayMemberFromPointer() was called
-                if (ClangASTContext::IsPointerType (parent->GetClangType()) && m_byte_offset)
-                    m_value.GetScalar() += m_byte_offset;
-                if (value_type == Value::eValueTypeScalar ||
-                    value_type == Value::eValueTypeFileAddress)
-                    m_value.SetValueType (Value::eValueTypeLoadAddress);
+
+                lldb::addr_t addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+
+                if (addr == LLDB_INVALID_ADDRESS)
+                {
+                    m_error.SetErrorString ("parent address is invalid.");
+                }
+                else if (addr == 0)
+                {
+                    m_error.SetErrorString ("parent is NULL");
+                }
+                else
+                {
+                    // For pointers, m_byte_offset should only ever be set if we
+                    // ValueObject::GetSyntheticArrayMemberFromPointer() was called
+                    if (ClangASTContext::IsPointerType (parent->GetClangType()) && m_byte_offset)
+                        m_value.GetScalar() += m_byte_offset;
+                    if (value_type == Value::eValueTypeScalar ||
+                        value_type == Value::eValueTypeFileAddress)
+                        m_value.SetValueType (Value::eValueTypeLoadAddress);
+                }
             }
             else
             {
@@ -163,14 +177,20 @@
                 case Value::eValueTypeHostAddress:
                     {
                         lldb::addr_t addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-                        if (addr == LLDB_INVALID_ADDRESS || addr == 0)
+                        if (addr == LLDB_INVALID_ADDRESS)
+                        {
+                            m_error.SetErrorString ("parent address is invalid.");
+                        }
+                        else if (addr == 0)
+                        {
+                            m_error.SetErrorString ("parent is NULL");
+                        }
+                        else
                         {
-                            m_error.SetErrorStringWithFormat("Parent address is invalid: 0x%llx.\n", addr);
-                            break;
+                            // Set this object's scalar value to the address of its
+                            // value be adding its byte offset to the parent address
+                            m_value.GetScalar() += GetByteOffset();
                         }
-                        // Set this object's scalar value to the address of its
-                        // value be adding its byte offset to the parent address
-                        m_value.GetScalar() += GetByteOffset();
                     }
                     break;
 





More information about the lldb-commits mailing list