[Lldb-commits] [lldb] r114118 - in /lldb/trunk/test: foundation/Makefile foundation/TestObjCMethods.py foundation/main.m make/Makefile.rules

Johnny Chen johnny.chen at apple.com
Thu Sep 16 13:54:06 PDT 2010


Author: johnny
Date: Thu Sep 16 15:54:06 2010
New Revision: 114118

URL: http://llvm.org/viewvc/llvm-project?rev=114118&view=rev
Log:
Added a simple test case to set breakpoints on objc class/instance methods.
Modified Makefile.rules to allow for overwriting the ARCH make variable.

Added:
    lldb/trunk/test/foundation/TestObjCMethods.py
Modified:
    lldb/trunk/test/foundation/Makefile
    lldb/trunk/test/foundation/main.m
    lldb/trunk/test/make/Makefile.rules

Modified: lldb/trunk/test/foundation/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/Makefile?rev=114118&r1=114117&r2=114118&view=diff
==============================================================================
--- lldb/trunk/test/foundation/Makefile (original)
+++ lldb/trunk/test/foundation/Makefile Thu Sep 16 15:54:06 2010
@@ -1,125 +1,6 @@
-#----------------------------------------------------------------------
-# Fill in the source files to build
-#----------------------------------------------------------------------
-C_SOURCES :=
-CXX_SOURCES :=
-OBJC_SOURCES :=main.m
-OBJCXX_SOURCES :=
+LEVEL = ../make
 
-# Uncomment line below for debugging shell commands
-# SHELL = /bin/sh -x
-
-#----------------------------------------------------------------------
-# Change any build/tool options needed
-#----------------------------------------------------------------------
-DS := /usr/bin/dsymutil
-DSFLAGS =
-CFLAGS ?=-arch x86_64 -g -O0
-CPLUSPLUSFLAGS +=$(CFLAGS)
-CPPFLAGS +=$(CFLAGS)
-LD = gcc
+OBJC_SOURCES := main.m
 LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
-OBJECTS =
-EXE=a.out
-DSYM=$(EXE).dSYM
-
-#----------------------------------------------------------------------
-# Check if we have any C source files
-#----------------------------------------------------------------------
-ifneq "$(strip $(C_SOURCES))" ""
-	OBJECTS +=$(strip $(C_SOURCES:.c=.o))
-endif
-
-#----------------------------------------------------------------------
-# Check if we have any C++ source files
-#----------------------------------------------------------------------
-ifneq "$(strip $(CXX_SOURCES))" ""
-	OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
-	LD = g++
-endif
-
-#----------------------------------------------------------------------
-# Check if we have any ObjC source files
-#----------------------------------------------------------------------
-ifneq "$(strip $(OBJC_SOURCES))" ""
-	OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))
-	LDFLAGS +=-lobjc
-endif
-
-#----------------------------------------------------------------------
-# Check if we have any ObjC++ source files
-#----------------------------------------------------------------------
-ifneq "$(strip $(OBJCXX_SOURCES))" ""
-	OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
-	LD = g++
-	ifeq $(findstring lobjc,$(LDFLAGS)) ""
-		LDFLAGS +=-lobjc
-	endif
-endif
-
-
-#----------------------------------------------------------------------
-# Make the dSYM file from the executable
-#----------------------------------------------------------------------
-$(DSYM) : $(EXE)
-	$(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
-
-#----------------------------------------------------------------------
-# Compile the executable from all the objects (default rule) with no
-# dsym file.
-#----------------------------------------------------------------------
-$(EXE) : $(OBJECTS)
-	$(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)"
-
-
-#----------------------------------------------------------------------
-# Automatic variables based on items already entered. Below we create
-# an objects lists from the list of sources by replacing all entries
-# that end with .c with .o, and we also create a list of prerequisite
-# files by replacing all .c files with .d.
-#----------------------------------------------------------------------
-PREREQS := $(OBJECTS:.o=.d)
-
-#----------------------------------------------------------------------
-# Rule for Generating Prerequisites Automatically using .d files and
-# the compiler -MM option. The -M option will list all system headers,
-# and the -MM option will list all non-system dependencies.
-#----------------------------------------------------------------------
-%.d: %.c
-	@set -e; rm -f $@; \
-	$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
-
-%.d: %.cpp
-	@set -e; rm -f $@; \
-	$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
-
-%.d: %.m
-	@set -e; rm -f $@; \
-	$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
-
-%.d: %.mm
-	@set -e; rm -f $@; \
-	$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
-	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
-	rm -f $@.$$$$
-
-#----------------------------------------------------------------------
-# Include all of the makefiles for each source file so we don't have
-# to manually track all of the prerequisites for each source file.
-#----------------------------------------------------------------------
-sinclude $(PREREQS)
-
-.PHONY: clean
-dsym:	$(DSYM)
-all:	$(EXE) $(DSYM)
-clean:
-	rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS)
-
-
 
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/foundation/TestObjCMethods.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=114118&view=auto
==============================================================================
--- lldb/trunk/test/foundation/TestObjCMethods.py (added)
+++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Sep 16 15:54:06 2010
@@ -0,0 +1,53 @@
+"""Set breakpoint on objective-c class and instance methods in foundation."""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+ at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+class FoundationTestCase(TestBase):
+
+    mydir = "foundation"
+
+    def test_with_dsym(self):
+        """Test 'image lookup -t days' and check for correct display."""
+        self.buildDsym()
+        self.break_on_objc_methods()
+
+    def test_with_dwarf(self):
+        """Test 'image lookup -t days' and check for correct display."""
+        self.buildDwarf()
+        self.break_on_objc_methods()
+
+    def break_on_objc_methods(self):
+        """Test setting objc breakpoints using regexp-break."""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # Stop at +[NSString stringWithFormat:].
+        self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1")
+
+        # Stop at -[NSAutoreleasePool release].
+        self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 2: name = '-[NSAutoreleasePool release]', locations = 1")
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # First stop is +[NSString stringWithFormat:].
+        self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]",
+            substrs = ["Foundation`+[NSString stringWithFormat:]"])
+
+        self.runCmd("process continue")
+
+        # Followed by -[NSAutoreleasePool release].
+        self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]",
+            substrs = ["Foundation`-[NSAutoreleasePool release]"])
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Modified: lldb/trunk/test/foundation/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=114118&r1=114117&r2=114118&view=diff
==============================================================================
--- lldb/trunk/test/foundation/main.m (original)
+++ lldb/trunk/test/foundation/main.m Thu Sep 16 15:54:06 2010
@@ -10,6 +10,8 @@
     printf("sizeof(id) = %zu\n", sizeof(id));
     printf("sizeof(Class) = %zu\n", sizeof(Class));
     printf("sizeof(SEL) = %zu\n", sizeof(SEL));
+    printf("[str length] = %zu\n", [str length]);
+    printf("str = '%s'\n", [str cStringUsingEncoding: [NSString defaultCStringEncoding]]);
     [pool release];
     return 0;
 }

Modified: lldb/trunk/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=114118&r1=114117&r2=114118&view=diff
==============================================================================
--- lldb/trunk/test/make/Makefile.rules (original)
+++ lldb/trunk/test/make/Makefile.rules Thu Sep 16 15:54:06 2010
@@ -11,12 +11,19 @@
 # SHELL = /bin/sh -x
 
 #----------------------------------------------------------------------
+# If ARCH is not defined, default to x86_64.
+#----------------------------------------------------------------------
+ifeq "$(ARCH)" ""
+	ARCH = x86_64
+endif
+
+#----------------------------------------------------------------------
 # Change any build/tool options needed
 #----------------------------------------------------------------------
 DS := /usr/bin/dsymutil
 DSFLAGS =
 CC = gcc
-CFLAGS ?=-arch x86_64 -gdwarf-2 -O0
+CFLAGS ?=-arch $(ARCH) -gdwarf-2 -O0
 CPLUSPLUSFLAGS +=$(CFLAGS)
 CPPFLAGS +=$(CFLAGS)
 LD = $(CC)





More information about the lldb-commits mailing list