[Lldb-commits] [lldb] r242687 - Eliminated a potential infinite recursion in structure layout when the origin

Sean Callanan scallanan at apple.com
Mon Jul 20 09:55:19 PDT 2015


Author: spyffe
Date: Mon Jul 20 11:55:19 2015
New Revision: 242687

URL: http://llvm.org/viewvc/llvm-project?rev=242687&view=rev
Log:
Eliminated a potential infinite recursion in structure layout when the origin
for a CXXRecordDecl gets pointed at that record.  This can happen when a type is
imported out of and then into the target's AST context without being laid out.

Also added a testcase that covers this scenario.

<rdar://problem/21844453>

Added:
    lldb/trunk/test/expression_command/persistent_types/TestNestedPersistentTypes.py
Modified:
    lldb/trunk/source/Symbol/ClangASTImporter.cpp

Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=242687&r1=242686&r2=242687&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Mon Jul 20 11:55:19 2015
@@ -763,7 +763,8 @@ ClangASTImporter::Minion::Imported (clan
             if (to_context_md->m_origins.find(to) == to_context_md->m_origins.end() ||
                 user_id != LLDB_INVALID_UID)
             {
-                to_context_md->m_origins[to] = origin_iter->second;
+                if (origin_iter->second.ctx != &to->getASTContext())
+                    to_context_md->m_origins[to] = origin_iter->second;
             }
                 
             MinionSP direct_completer = m_master.GetMinion(&to->getASTContext(), origin_iter->second.ctx);

Added: lldb/trunk/test/expression_command/persistent_types/TestNestedPersistentTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_types/TestNestedPersistentTypes.py?rev=242687&view=auto
==============================================================================
--- lldb/trunk/test/expression_command/persistent_types/TestNestedPersistentTypes.py (added)
+++ lldb/trunk/test/expression_command/persistent_types/TestNestedPersistentTypes.py Mon Jul 20 11:55:19 2015
@@ -0,0 +1,43 @@
+"""
+Test that nested persistent types work.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class NestedPersistentTypesTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def test_persistent_types(self):
+        """Test that nested persistent types work."""
+        self.buildDefault()
+
+        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+        self.runCmd("breakpoint set --name main")
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        self.runCmd("expression struct $foo { int a; int b; };")
+
+        self.runCmd("expression struct $bar { struct $foo start; struct $foo end; };")
+
+        self.runCmd("expression struct $bar $my_bar = {{ 2, 3 }, { 4, 5 }};")
+
+        self.expect("expression $my_bar",
+                    substrs = ['a = 2', 'b = 3', 'a = 4', 'b = 5'])
+
+        self.expect("expression $my_bar.start.b",
+                    substrs = ['(int)', '3'])
+
+        self.expect("expression $my_bar.end.b",
+                    substrs = ['(int)', '5'])
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()





More information about the lldb-commits mailing list