diff options
-rw-r--r-- | lldb/test/signed_types/Makefile | 126 | ||||
-rw-r--r-- | lldb/test/signed_types/TestSignedTypes.py | 69 | ||||
-rw-r--r-- | lldb/test/signed_types/main.cpp | 4 |
3 files changed, 74 insertions, 125 deletions
diff --git a/lldb/test/signed_types/Makefile b/lldb/test/signed_types/Makefile index fb5e33230e9..d4bc9c68904 100644 --- a/lldb/test/signed_types/Makefile +++ b/lldb/test/signed_types/Makefile @@ -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 diff --git a/lldb/test/signed_types/TestSignedTypes.py b/lldb/test/signed_types/TestSignedTypes.py new file mode 100644 index 00000000000..f3389aaf41f --- /dev/null +++ b/lldb/test/signed_types/TestSignedTypes.py @@ -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() diff --git a/lldb/test/signed_types/main.cpp b/lldb/test/signed_types/main.cpp index fa86e7b4970..3e40f3aa3dc 100644 --- a/lldb/test/signed_types/main.cpp +++ b/lldb/test/signed_types/main.cpp @@ -10,7 +10,7 @@ int main (int argc, char const *argv[]) { 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 @@ int main (int argc, char const *argv[]) 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 + |