[Lldb-commits] [lldb] r179318 - Hand over the job of laying out the argument structure

Sean Callanan scallanan at apple.com
Thu Apr 11 14:16:36 PDT 2013


Author: spyffe
Date: Thu Apr 11 16:16:36 2013
New Revision: 179318

URL: http://llvm.org/viewvc/llvm-project?rev=179318&view=rev
Log:
Hand over the job of laying out the argument structure
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.

Modified:
    lldb/trunk/include/lldb/Expression/Materializer.h
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/Materializer.cpp

Modified: lldb/trunk/include/lldb/Expression/Materializer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/Materializer.h?rev=179318&r1=179317&r2=179318&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/Materializer.h (original)
+++ lldb/trunk/include/lldb/Expression/Materializer.h Thu Apr 11 16:16:36 2013
@@ -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
     {

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=179318&r1=179317&r2=179318&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Apr 11 16:16:36 2013
@@ -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;

Modified: lldb/trunk/source/Expression/Materializer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=179318&r1=179317&r2=179318&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Thu Apr 11 16:16:36 2013
@@ -25,7 +25,7 @@ Materializer::AddStructMember (Entity &e
     
     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)





More information about the lldb-commits mailing list