[Lldb-commits] [lldb] r122800 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp

Sean Callanan scallanan at apple.com
Mon Jan 3 18:41:41 PST 2011


Author: spyffe
Date: Mon Jan  3 20:41:41 2011
New Revision: 122800

URL: http://llvm.org/viewvc/llvm-project?rev=122800&view=rev
Log:
Fixed a problem where constant results of expressions
were not being created in the proper way, meaning
results were getting lost.

Modified:
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=122800&r1=122799&r2=122800&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Jan  3 20:41:41 2011
@@ -129,7 +129,6 @@
 {
     assert (m_parser_vars.get());
 
-    
     clang::ASTContext *context(m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext());
     
     TypeFromUser user_type(ClangASTContext::CopyType(context, 
@@ -137,25 +136,32 @@
                                                      type.GetOpaqueQualType()),
                            context);
     
-    DataBufferHeap *heap_data_buf = new DataBufferHeap(ClangASTType::GetClangTypeBitWidth(user_type.GetASTContext(),
-                                                                                          user_type.GetOpaqueQualType()) / 8,
-                                                       '\0');
+    if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (name, 
+                                                                     user_type, 
+                                                                     m_parser_vars->m_exe_ctx->process->GetByteOrder(),
+                                                                     m_parser_vars->m_exe_ctx->process->GetAddressByteSize()))
+        return lldb::ClangExpressionVariableSP();
+    
+    ClangExpressionVariableSP pvar_sp (m_parser_vars->m_persistent_vars->GetVariable(name));
     
-    DataBufferSP data_sp(heap_data_buf);
+    if (!pvar_sp)
+        return lldb::ClangExpressionVariableSP();
+    
+    uint8_t *pvar_data = pvar_sp->GetValueBytes();
+    if (pvar_data == NULL)
+        return lldb::ClangExpressionVariableSP();
     
     uint64_t value64 = value.getLimitedValue();
     
     ByteOrder byte_order = m_parser_vars->m_exe_ctx->process->GetByteOrder();
     
     size_t num_val_bytes = sizeof(value64);
-    size_t num_data_bytes = heap_data_buf->GetByteSize();
+    size_t num_data_bytes = pvar_sp->GetByteSize();
     
     size_t num_bytes = num_val_bytes;
     if (num_bytes > num_data_bytes)
         num_bytes = num_data_bytes;
     
-    uint8_t *data_bytes = heap_data_buf->GetBytes();
-    
     for (off_t byte_idx = 0;
          byte_idx < num_bytes;
          ++byte_idx)
@@ -166,32 +172,23 @@
         
         switch (byte_order)
         {
-        case eByteOrderBig:
-            //                    High         Low
-            // Original:         |AABBCCDDEEFFGGHH|
-            // Target:                   |EEFFGGHH|
-            
-            data_bytes[num_data_bytes - (1 + byte_idx)] = cur_byte;
-            break;
-        case eByteOrderLittle:
-            // Target:                   |HHGGFFEE|
-            data_bytes[byte_idx] = cur_byte;
-            break;
-        default:
-            return lldb::ClangExpressionVariableSP();    
+            case eByteOrderBig:
+                //                    High         Low
+                // Original:         |AABBCCDDEEFFGGHH|
+                // Target:                   |EEFFGGHH|
+                
+                pvar_data[num_data_bytes - (1 + byte_idx)] = cur_byte;
+                break;
+            case eByteOrderLittle:
+                // Target:                   |HHGGFFEE|
+                pvar_data[byte_idx] = cur_byte;
+                break;
+            default:
+                return lldb::ClangExpressionVariableSP();    
         }
     }
-    
-    ValueObjectSP valobj_sp(new ValueObjectConstResult(user_type.GetASTContext(),
-                                                       user_type.GetOpaqueQualType(),
-                                                       name,
-                                                       data_sp,
-                                                       m_parser_vars->m_exe_ctx->process->GetByteOrder(), 
-                                                       m_parser_vars->m_exe_ctx->process->GetAddressByteSize()));
-    
-    ClangExpressionVariableSP var_sp(new ClangExpressionVariable(valobj_sp));
-    
-    return var_sp;
+
+    return pvar_sp;
 }
 
 bool 





More information about the lldb-commits mailing list