diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
commit | b76161e41bc2c07cd47f9c61f875d1be95e26d10 (patch) | |
tree | d03c19ce10dec6419f97df1d4dac9d47eb88982f /packages/Python/lldbsuite/test/lang | |
parent | 8b4000f13b303cc154136abc74c55670673e2a96 (diff) | |
download | src-b76161e41bc2c07cd47f9c61f875d1be95e26d10.tar.gz src-b76161e41bc2c07cd47f9c61f875d1be95e26d10.zip |
Vendor import of lldb trunk r303197:vendor/lldb/lldb-trunk-r303197
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=318378
svn path=/vendor/lldb/lldb-trunk-r303197/; revision=318379; tag=vendor/lldb/lldb-trunk-r303197
Diffstat (limited to 'packages/Python/lldbsuite/test/lang')
9 files changed, 200 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/Makefile b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/Makefile new file mode 100644 index 000000000000..99bfa7e03b47 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py new file mode 100644 index 000000000000..aad2ea20c133 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py @@ -0,0 +1,9 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.expectedFailureAll( + oslist=["windows"], bugnumber="llvm.org/pr24764"), + decorators.expectedFailureAll( + compiler="gcc")]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp new file mode 100644 index 000000000000..90e63b40f417 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp @@ -0,0 +1,61 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LIDENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +template <class T, int... Args> struct C { + T member; + bool isSixteenThirtyTwo() { return false; } +}; + +template <> struct C<int, 16> { + int member; + bool isSixteenThirtyTwo() { return false; } +}; + +template <> struct C<int, 16, 32> : C<int, 16> { + bool isSixteenThirtyTwo() { return true; } +}; + +template <class T, typename... Args> struct D { + T member; + bool isIntBool() { return false; } +}; + +template <> struct D<int, int> { + int member; + bool isIntBool() { return false; } +}; + +template <> struct D<int, int, bool> : D<int, int> { + bool isIntBool() { return true; } +}; + +int main (int argc, char const *argv[]) +{ + C<int,16,32> myC; + C<int,16> myLesserC; + myC.member = 64; + (void)C<int,16,32>().isSixteenThirtyTwo(); + (void)C<int,16>().isSixteenThirtyTwo(); + (void)(myC.member != 64); //% self.expect("expression -- myC", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"]) + //% self.expect("expression -- C<int, 16>().isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) + //% self.expect("expression -- C<int, 16, 32>().isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) + //% self.expect("expression -- myLesserC.isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) + //% self.expect("expression -- myC.isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) + + D<int,int,bool> myD; + D<int,int> myLesserD; + myD.member = 64; + (void)D<int,int,bool>().isIntBool(); + (void)D<int,int>().isIntBool(); + return myD.member != 64; //% self.expect("expression -- myD", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"]) + //% self.expect("expression -- D<int, int>().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) + //% self.expect("expression -- D<int, int, bool>().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) + //% self.expect("expression -- myLesserD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) + //% self.expect("expression -- myD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile new file mode 100644 index 000000000000..99bfa7e03b47 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py new file mode 100644 index 000000000000..810aefee0f07 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py @@ -0,0 +1,6 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.expectedFailureAll(bugnumber="rdar://problem/32096064")]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp new file mode 100644 index 000000000000..e802d40e5f8b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp @@ -0,0 +1,24 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LIDENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +template <class T> int staticSizeof() { + return sizeof(T); +} + +template <class T1, class T2, class... Ts> int staticSizeof() { + return staticSizeof<T2, Ts...>() + sizeof(T1); +} + +int main (int argc, char const *argv[]) +{ + int sz = staticSizeof<long, int, char>(); + return staticSizeof<long, int, char>() != sz; //% self.expect("expression -- sz == staticSizeof<long, int, char>()", "staticSizeof<long, int, char> worked", substrs = ["true"]) + //% self.expect("expression -- sz == staticSizeof<long, int>() + sizeof(char)", "staticSizeof<long, int> worked", substrs = ["true"]) + //% self.expect("expression -- sz == staticSizeof<long>() + sizeof(int) + sizeof(char)", "staticSizeof<long> worked", substrs = ["true"]) +} diff --git a/packages/Python/lldbsuite/test/lang/objc/ptr_refs/Makefile b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/Makefile new file mode 100644 index 000000000000..b05ff34b739b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py new file mode 100644 index 000000000000..e5633156cd18 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py @@ -0,0 +1,50 @@ +""" +Test the ptr_refs tool on Darwin with Objective-C +""" + +from __future__ import print_function + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestPtrRefsObjC(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test_ptr_refs(self): + """Test the ptr_refs tool on Darwin with Objective-C""" + self.build() + exe_name = 'a.out' + exe = os.path.join(os.getcwd(), exe_name) + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + main_file_spec = lldb.SBFileSpec('main.m') + breakpoint = target.BreakpointCreateBySourceRegex( + 'break', main_file_spec) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + # Frame #0 should be on self.line1 and the break condition should hold. + thread = lldbutil.get_stopped_thread( + process, lldb.eStopReasonBreakpoint) + self.assertTrue( + thread.IsValid(), + "There should be a thread stopped due to breakpoint condition") + + frame = thread.GetFrameAtIndex(0) + + self.dbg.HandleCommand("script import lldb.macosx.heap") + self.expect("ptr_refs self", substrs=["malloc", "stack"]) + diff --git a/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m new file mode 100644 index 000000000000..8203165e4971 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/main.m @@ -0,0 +1,39 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import <Foundation/Foundation.h> + +@interface MyClass : NSObject { +}; +-(void)test; +@end + +@implementation MyClass +-(void)test { + printf("%p\n", self); // break here +} +@end + +@interface MyOwner : NSObject { + @public id ownedThing; // should be id, to test <rdar://problem/31363513> +}; +@end + +@implementation MyOwner +@end + +int main (int argc, char const *argv[]) { + @autoreleasepool { + MyOwner *owner = [[MyOwner alloc] init]; + owner->ownedThing = [[MyClass alloc] init]; + [(MyClass*)owner->ownedThing test]; + } + return 0; +} + |