[Lldb-commits] [lldb] r155515 - in /lldb/trunk: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp test/lang/objc/objc++/ test/lang/objc/objc++/Makefile test/lang/objc/objc++/TestObjC++.py test/lang/objc/objc++/main test/lang/objc/objc++/main.mm

Sean Callanan scallanan at apple.com
Tue Apr 24 18:03:57 PDT 2012


Author: spyffe
Date: Tue Apr 24 20:03:57 2012
New Revision: 155515

URL: http://llvm.org/viewvc/llvm-project?rev=155515&view=rev
Log:
Recognize Objective-C classes with runtime class
ObjCPlusPlus as Objective-C classes.  Really the
compiler should say they have Objective-C runtime
class, but we should be a little more resilient
(we were refusing to find ivars in those classes
before).

Also added a test case.

Added:
    lldb/trunk/test/lang/objc/objc++/
    lldb/trunk/test/lang/objc/objc++/Makefile
    lldb/trunk/test/lang/objc/objc++/TestObjC++.py
    lldb/trunk/test/lang/objc/objc++/main   (with props)
    lldb/trunk/test/lang/objc/objc++/main.mm
Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=155515&r1=155514&r2=155515&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Apr 24 20:03:57 2012
@@ -5247,7 +5247,8 @@
                         is_forward_declaration = true;
                     }
 
-                    if (class_language == eLanguageTypeObjC)
+                    if (class_language == eLanguageTypeObjC ||
+                        class_language == eLanguageTypeObjC_plus_plus)
                     {
                         if (!is_complete_objc_class && Supports_DW_AT_APPLE_objc_complete_type(dwarf_cu))
                         {
@@ -5444,7 +5445,8 @@
                             // declaration context for a contained class or type without the need
                             // to complete that type..
                             
-                            if (class_language != eLanguageTypeObjC)
+                            if (class_language != eLanguageTypeObjC &&
+                                class_language != eLanguageTypeObjC_plus_plus)
                                 ast.StartTagDeclarationDefinition (clang_type);
 
                             // Leave this as a forward declaration until we need

Added: lldb/trunk/test/lang/objc/objc++/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc%2B%2B/Makefile?rev=155515&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/objc++/Makefile (added)
+++ lldb/trunk/test/lang/objc/objc++/Makefile Tue Apr 24 20:03:57 2012
@@ -0,0 +1,10 @@
+LEVEL = ../../../make
+
+OBJCXX_SOURCES := main.mm
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
+
+main.o:	main.mm
+	$(CXX) $(CXXFLAGS) -c -o main.o main.mm

Added: lldb/trunk/test/lang/objc/objc++/TestObjC++.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc%2B%2B/TestObjC%2B%2B.py?rev=155515&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/objc++/TestObjC++.py (added)
+++ lldb/trunk/test/lang/objc/objc++/TestObjC++.py Tue Apr 24 20:03:57 2012
@@ -0,0 +1,47 @@
+"""
+Make sure that ivars of Objective-C++ classes are visible in LLDB.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class ObjCXXTestCase(TestBase):
+
+    mydir = os.path.join("lang", "objc", "objc++")
+
+    @dsym_test
+    def test_break_with_dsym(self):
+        """Test ivars of Objective-C++ classes"""
+        if self.getArchitecture() == 'i386':
+            self.skipTest("requires Objective-C 2.0 runtime")
+        self.buildDsym()
+        self.do_testObjCXXClasses()
+
+    @dwarf_test
+    def test_break_with_dwarf(self):
+        """Test ivars of Objective-C++ classes"""
+        if self.getArchitecture() == 'i386':
+            self.skipTest("requires Objective-C 2.0 runtime")
+        self.buildDwarf()
+        self.do_testObjCXXClasses()
+
+    def do_testObjCXXClasses(self):
+        """Test ivars of Objective-C++ classes"""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        self.expect("breakpoint set -p 'breakpoint 1'", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created")
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        self.expect("expr f->f", "Found ivar in class",
+            substrs = ["= 3"])
+        
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/lang/objc/objc++/main
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc%2B%2B/main?rev=155515&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lldb/trunk/test/lang/objc/objc++/main
------------------------------------------------------------------------------
    svn:executable = *

Propchange: lldb/trunk/test/lang/objc/objc++/main
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lldb/trunk/test/lang/objc/objc++/main.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc%2B%2B/main.mm?rev=155515&view=auto
==============================================================================
--- lldb/trunk/test/lang/objc/objc++/main.mm (added)
+++ lldb/trunk/test/lang/objc/objc++/main.mm Tue Apr 24 20:03:57 2012
@@ -0,0 +1,19 @@
+#include <Foundation/NSObject.h>
+
+ at interface F : NSObject
+ at end
+
+ at implementation F
+{
+ at public
+    int f;
+}
+
+ at end
+
+int main(int argc, char* argv[])
+{
+    F* f = [F new];
+    f->f = 3;
+    return 0; // breakpoint 1
+}





More information about the lldb-commits mailing list