[Lldb-commits] [lldb] r119836 - in /lldb/trunk/test/signed_types: Makefile TestSignedTypes.py main.cpp

Johnny Chen johnny.chen at apple.com
Fri Nov 19 12:35:15 PST 2010


Author: johnny
Date: Fri Nov 19 14:35:15 2010
New Revision: 119836

URL: http://llvm.org/viewvc/llvm-project?rev=119836&view=rev
Log:
Add TestSignedTypes.py to test that variables with signed types display correctly.

Added:
    lldb/trunk/test/signed_types/TestSignedTypes.py
Modified:
    lldb/trunk/test/signed_types/Makefile
    lldb/trunk/test/signed_types/main.cpp

Modified: lldb/trunk/test/signed_types/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/signed_types/Makefile?rev=119836&r1=119835&r2=119836&view=diff
==============================================================================
--- lldb/trunk/test/signed_types/Makefile (original)
+++ lldb/trunk/test/signed_types/Makefile Fri Nov 19 14:35:15 2010
@@ -1,125 +1,5 @@
-#----------------------------------------------------------------------
-# Fill in the source files to build
-#----------------------------------------------------------------------
-C_SOURCES :=
-CXX_SOURCES :=main.cpp
-OBJC_SOURCES :=
-OBJCXX_SOURCES :=
-
-# 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 -gdwarf-2 -O0
-CPLUSPLUSFLAGS +=$(CFLAGS)
-CPPFLAGS +=$(CFLAGS)
-LD = gcc
-LDFLAGS = $(CFLAGS)
-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)
-
+LEVEL = ../make
 
+CXX_SOURCES := main.cpp
 
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/signed_types/TestSignedTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/signed_types/TestSignedTypes.py?rev=119836&view=auto
==============================================================================
--- lldb/trunk/test/signed_types/TestSignedTypes.py (added)
+++ lldb/trunk/test/signed_types/TestSignedTypes.py Fri Nov 19 14:35:15 2010
@@ -0,0 +1,69 @@
+"""
+Test that variables with signed types display correctly.
+"""
+
+import os, time
+import re
+import unittest2
+import lldb
+from lldbtest import *
+
+class UnsignedTypesTestCase(TestBase):
+
+    mydir = "signed_types"
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    def test_with_dsym(self):
+        """Test that variables with signed types display correctly."""
+        self.buildDsym()
+        self.signed_types()
+
+    def test_with_dwarf(self):
+        """Test that variables with signed types display correctly."""
+        self.buildDwarf()
+        self.signed_types()
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to break inside main().
+        self.line = line_number('main.cpp', '// Set break point at this line.')
+
+    def signed_types(self):
+        """Test that variables with signed types display correctly."""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # Break on line 22 in main() aftre the variables are assigned values.
+        self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" %
+                        self.line)
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # The stop reason of the thread should be breakpoint.
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['state is stopped', 'stop reason = breakpoint'])
+
+        # The breakpoint should have a hit count of 1.
+        self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+            substrs = [' resolved, hit count = 1'])
+
+        # Execute the assignment statement.
+        self.runCmd("thread step-over")
+
+        # Test that signed types display correctly.
+        self.expect("frame variable -t -a", VARIABLES_DISPLAYED_CORRECTLY,
+            patterns = ["\((short int|short)\) the_signed_short = 99"],
+            substrs = ["(signed char) the_signed_char = 'c'",
+                       "(int) the_signed_int = 99",
+                       "(long int) the_signed_long = 99",
+                       "(long long int) the_signed_long_long = 99"])
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Modified: lldb/trunk/test/signed_types/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/signed_types/main.cpp?rev=119836&r1=119835&r2=119836&view=diff
==============================================================================
--- lldb/trunk/test/signed_types/main.cpp (original)
+++ lldb/trunk/test/signed_types/main.cpp Fri Nov 19 14:35:15 2010
@@ -10,7 +10,7 @@
 {
     char the_char = 'c';
     short the_short = 'c';
-    wchar_t the_whar_t = 'c';
+    wchar_t the_wchar_t = 'c';
     int the_int = 'c';
     long the_long = 'c';
     long long the_long_long = 'c';
@@ -19,7 +19,7 @@
     signed short the_signed_short = 'c';
     signed int the_signed_int = 'c';
     signed long the_signed_long = 'c';
-    signed long long the_signed_long_long = 'c';
+    signed long long the_signed_long_long = 'c';    // Set break point at this line.
 
     return  the_char        - the_signed_char +
             the_short       - the_signed_short +





More information about the lldb-commits mailing list