Hand over the job of laying out the argument structure
authorSean Callanan <scallanan@apple.com>
Thu, 11 Apr 2013 21:16:36 +0000 (21:16 +0000)
committerSean Callanan <scallanan@apple.com>
Thu, 11 Apr 2013 21:16:36 +0000 (21:16 +0000)
to the Materializer.  Materialization is still done by
the ClangExpressionDeclMap; this will be the next thing
to move.

Also fixed a layout bug that this uncovered.

llvm-svn: 179318

lldb/include/lldb/Expression/Materializer.h
lldb/source/Expression/ClangExpressionDeclMap.cpp
lldb/source/Expression/Materializer.cpp

index 4171503..ac4d766 100644 (file)
@@ -58,7 +58,15 @@ public:
     uint32_t AddSymbol (const Symbol &symbol_sp, Error &err);
     uint32_t AddRegister (const RegisterInfo &register_info, Error &err);
     
-    uint32_t GetStructAlignment ();
+    uint32_t GetStructAlignment ()
+    {
+        return m_struct_alignment;
+    }
+    
+    uint32_t GetStructByteSize ()
+    {
+        return m_current_offset;
+    }
 
     class Entity
     {
index b52afc3..cc1c103 100644 (file)
@@ -586,21 +586,31 @@ ClangExpressionDeclMap::AddValueToStruct
     
     if (m_parser_vars->m_materializer)
     {
+        uint32_t offset = 0;
+
         Error err;
 
         if (is_persistent_variable)
         {
-            m_parser_vars->m_materializer->AddPersistentVariable(var_sp, err);
+            offset = m_parser_vars->m_materializer->AddPersistentVariable(var_sp, err);
         }
         else
         {
             if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
-                m_parser_vars->m_materializer->AddSymbol(*sym, err);
+                offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
             else if (const RegisterInfo *reg_info = var_sp->GetRegisterInfo())
-                m_parser_vars->m_materializer->AddRegister(*reg_info, err);
+                offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
             else if (parser_vars->m_lldb_var)
-                m_parser_vars->m_materializer->AddVariable(parser_vars->m_lldb_var, err);
+                offset = m_parser_vars->m_materializer->AddVariable(parser_vars->m_lldb_var, err);
         }
+        
+        if (!err.Success())
+            return false;
+        
+        if (log)
+            log->Printf("Placed at 0x%llx", (unsigned long long)offset);
+        
+        jit_vars->m_offset = offset; // TODO DoStructLayout() should not change this.
     }
     
     return true;
@@ -614,6 +624,14 @@ ClangExpressionDeclMap::DoStructLayout ()
     if (m_struct_vars->m_struct_laid_out)
         return true;
     
+    if (m_parser_vars->m_materializer)
+    {
+        m_struct_vars->m_struct_alignment = m_parser_vars->m_materializer->GetStructAlignment();
+        m_struct_vars->m_struct_size = m_parser_vars->m_materializer->GetStructByteSize();
+        m_struct_vars->m_struct_laid_out = true;
+        return true;
+    }
+    
     off_t cursor = 0;
     
     m_struct_vars->m_struct_alignment = 0;
index 549e777..8cfcd70 100644 (file)
@@ -25,7 +25,7 @@ Materializer::AddStructMember (Entity &entity)
     
     uint32_t ret;
     
-    if (!m_current_offset)
+    if (m_current_offset == 0)
         m_struct_alignment = alignment;
     
     if (m_current_offset % alignment)
@@ -95,17 +95,9 @@ public:
         Entity(),
         m_variable_sp(variable_sp)
     {
-        Type *type = variable_sp->GetType();
-        
-        assert(type);
-        
-        if (type)
-        {
-            ClangASTType clang_type(type->GetClangAST(),
-                                    type->GetClangLayoutType());
-            
-            SetSizeAndAlignmentFromType(clang_type);
-        }
+        // Hard-coding to maximum size of a pointer since all varaibles are materialized by reference
+        m_size = 8;
+        m_alignment = 8;
     }
     
     virtual void Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err)