diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/lang')
195 files changed, 1219 insertions, 403 deletions
diff --git a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py index 6d5f61ebb8bba..930a09412eabf 100644 --- a/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py +++ b/packages/Python/lldbsuite/test/lang/c/anonymous/TestAnonymous.py @@ -88,7 +88,7 @@ class AnonymousTestCase(TestBase): self.dbg.SetAsync(False) # Create a target - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -150,7 +150,7 @@ class AnonymousTestCase(TestBase): self.dbg.SetAsync(False) # Create a target - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py b/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py index d4716de907c78..d14534db69cff 100644 --- a/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py +++ b/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py @@ -24,7 +24,7 @@ class ArrayTypesTestCase(TestBase): def test_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -85,7 +85,7 @@ class ArrayTypesTestCase(TestBase): def test_and_python_api(self): """Use Python APIs to inspect variables with array types.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py index 4d0eb48c3b5b1..22b8a29910013 100644 --- a/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py +++ b/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py @@ -27,7 +27,7 @@ class BitfieldsTestCase(TestBase): def test_and_run_command(self): """Test 'frame variable ...' on a variable with bitfields.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. @@ -123,7 +123,7 @@ class BitfieldsTestCase(TestBase): def test_and_python_api(self): """Use Python APIs to inspect a bitfields variable.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py b/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py index 4025635eec6fa..c7693c98f5455 100644 --- a/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py +++ b/packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py @@ -26,7 +26,7 @@ class BlocksTestCase(TestBase): def launch_common(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.is_started = False diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile index f8a04bd32b906..979cefe9b7fe5 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Makefile @@ -1,18 +1,16 @@ LEVEL := ../../../make -LD_EXTRAS := -L. -l$(LIB_PREFIX)One -l$(LIB_PREFIX)Two +LD_EXTRAS := -L. -LOne -l$(LIB_PREFIX)One -LTwo -l$(LIB_PREFIX)Two C_SOURCES := main.c -main.o : CFLAGS_EXTRAS += -g -O0 - include $(LEVEL)/Makefile.rules .PHONY: a.out: lib_One lib_Two lib_%: - $(MAKE) -f $*.mk + $(MAKE) VPATH=$(SRCDIR)/$* -I $(SRCDIR) -f $(SRCDIR)/$*.mk clean:: - $(MAKE) -f One.mk clean - $(MAKE) -f Two.mk clean + $(MAKE) -f $(SRCDIR)/One.mk clean + $(MAKE) -f $(SRCDIR)/Two.mk clean diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk index 04f894c595e8b..130c7dd511bb8 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One.mk @@ -1,12 +1,10 @@ LEVEL := ../../../make DYLIB_NAME := One -DYLIB_C_SOURCES := One/One.c One/OneConstant.c +DYLIB_C_SOURCES := One.c OneConstant.c DYLIB_ONLY := YES include $(LEVEL)/Makefile.rules -CFLAGS_EXTRAS += -fPIC - -One/OneConstant.o: One/OneConstant.c +OneConstant.o: OneConstant.c $(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@ diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h index b59f5ad13f22b..aae27571bb9ca 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/One/One.h @@ -1,4 +1,4 @@ #ifndef ONE_H #define ONE_H -void one(); +LLDB_TEST_API void one(); #endif diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py index 328c383b38fb0..fa14e5ef62e6d 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py @@ -18,15 +18,14 @@ class TestConflictingSymbols(TestBase): def setUp(self): TestBase.setUp(self) + lldbutil.mkdir_p(self.getBuildArtifact("One")) + lldbutil.mkdir_p(self.getBuildArtifact("Two")) - self.One_line = line_number('One/One.c', '// break here') - self.Two_line = line_number('Two/Two.c', '// break here') - self.main_line = line_number('main.c', '// break here') - + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") def test_conflicting_symbols(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") - target = self.dbg.CreateTarget("a.out") + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Register our shared libraries for remote targets so they get @@ -34,12 +33,12 @@ class TestConflictingSymbols(TestBase): environment = self.registerSharedLibrariesWithTarget( target, ['One', 'Two']) - lldbutil.run_break_set_command( - self, 'breakpoint set -f One.c -l %s' % (self.One_line)) - lldbutil.run_break_set_command( - self, 'breakpoint set -f Two.c -l %s' % (self.Two_line)) - lldbutil.run_break_set_by_file_and_line( - self, 'main.c', self.main_line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_source_regexp(self, '// break here', + extra_options='-f One.c', num_expected_locations=-2) + lldbutil.run_break_set_by_source_regexp(self, '// break here', + extra_options='-f Two.c', num_expected_locations=-2) + lldbutil.run_break_set_by_source_regexp(self, '// break here', + extra_options='-f main.c', num_expected_locations=1) process = target.LaunchSimple( None, environment, self.get_process_working_directory()) @@ -96,8 +95,8 @@ class TestConflictingSymbols(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr35043") def test_shadowed(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") - target = self.dbg.CreateTarget("a.out") + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) # Register our shared libraries for remote targets so they get @@ -105,7 +104,8 @@ class TestConflictingSymbols(TestBase): environment = self.registerSharedLibrariesWithTarget( target, ['One', 'Two']) - lldbutil.run_break_set_by_file_and_line(self, 'main.c', self.main_line) + lldbutil.run_break_set_by_source_regexp(self, '// break here', + extra_options='-f main.c', num_expected_locations=1) process = target.LaunchSimple( None, environment, self.get_process_working_directory()) diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk index 117d9e00d4436..ebe58cc743fcf 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two.mk @@ -1,12 +1,10 @@ LEVEL := ../../../make DYLIB_NAME := Two -DYLIB_C_SOURCES := Two/Two.c Two/TwoConstant.c +DYLIB_C_SOURCES := Two.c TwoConstant.c DYLIB_ONLY := YES include $(LEVEL)/Makefile.rules -CFLAGS_EXTRAS += -fPIC - -Two/TwoConstant.o: Two/TwoConstant.c +TwoConstant.o: TwoConstant.c $(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@ diff --git a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h index 8d5bd6a32330c..450fe5a3551fd 100644 --- a/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h +++ b/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/Two/Two.h @@ -1,4 +1,4 @@ #ifndef TWO_H #define TWO_H -void two(); +LLDB_TEST_API void two(); #endif diff --git a/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py b/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py index d54435a4c6771..bf86e03035ffd 100644 --- a/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py +++ b/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py @@ -38,7 +38,7 @@ class ConstVariableTestCase(TestBase): def test_and_run_command(self): """Test interpreted and JITted expressions on constant values.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. diff --git a/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py b/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py index b4ea9fae043ba..53ee2196aa42e 100644 --- a/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py +++ b/packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py @@ -24,7 +24,7 @@ class EnumTypesTestCase(TestBase): def test(self): """Test 'image lookup -t days' and check for correct display and enum value printing.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py index bbe5be67c08d7..75aef291cc49b 100644 --- a/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py +++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py @@ -33,7 +33,7 @@ class TestFindTypesOnStructType(TestBase): def do_test(self): """Make sure FindTypes actually finds 'struct typename' not just 'typename'.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py b/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py index 60e7073f146df..2537beb87df79 100644 --- a/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py +++ b/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py @@ -7,6 +7,7 @@ import os import time import lldb from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil @@ -14,10 +15,10 @@ class ForwardDeclarationTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test_and_run_command(self): + def do_test(self, dictionary=None): """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" - self.build() - exe = os.path.join(os.getcwd(), "a.out") + self.build(dictionary=dictionary) + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. @@ -53,3 +54,15 @@ class ForwardDeclarationTestCase(TestBase): '(bar)', '(int) a = 1', '(int) b = 2']) + + def test(self): + self.do_test() + + @no_debug_info_test + @skipIfDarwin + @skipIf(compiler=no_match("clang")) + @skipIf(compiler_version=["<", "7.0"]) + def test_debug_names(self): + """Test that we are able to find complete types when using DWARF v5 + accelerator tables""" + self.do_test(dict(CFLAGS_EXTRAS="-mllvm -accel-tables=Dwarf")) diff --git a/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py b/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py index 35e902e5bdcbc..7ed8a28546cb1 100644 --- a/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py +++ b/packages/Python/lldbsuite/test/lang/c/function_types/TestFunctionTypes.py @@ -66,7 +66,7 @@ class FunctionTypesTestCase(TestBase): startstr='(int) $2 = 12') def runToBreakpoint(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. diff --git a/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py b/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py index dd4da061fdcf8..36b684b60fb2f 100644 --- a/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py +++ b/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py @@ -22,12 +22,28 @@ class GlobalVariablesTestCase(TestBase): self.shlib_names = ["a"] @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") + @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr37301") + def test_without_process(self): + """Test that static initialized variables can be inspected without + process.""" + self.build() + + # Create a target by the debugger. + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + + self.assertTrue(target, VALID_TARGET) + self.expect("target variable g_ptr", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['(int *)']) + self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['42']) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_c_global_variables(self): """Test 'frame variable --scope --no-args' which omits args and shows scopes.""" self.build() # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Break inside the main. @@ -53,18 +69,28 @@ class GlobalVariablesTestCase(TestBase): self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, substrs=[' resolved, hit count = 1']) + # Test that the statically initialized variable can also be + # inspected *with* a process. + self.expect("target variable g_ptr", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['(int *)']) + self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['42']) + # Check that GLOBAL scopes are indicated for the variables. self.expect( "frame variable --show-types --scope --show-globals --no-args", VARIABLES_DISPLAYED_CORRECTLY, substrs=[ - 'GLOBAL: (int) g_file_global_int = 42', 'STATIC: (const int) g_file_static_int = 2', + 'STATIC: (const char *) g_func_static_cstr', 'GLOBAL: (const char *) g_file_global_cstr', '"g_file_global_cstr"', + 'GLOBAL: (int) g_file_global_int = 42', + 'GLOBAL: (int) g_common_1 = 21', + 'GLOBAL: (int *) g_ptr', 'STATIC: (const char *) g_file_static_cstr', - '"g_file_static_cstr"', - 'GLOBAL: (int) g_common_1 = 21']) + '"g_file_static_cstr"' + ]) # 'frame variable' should support address-of operator. self.runCmd("frame variable &g_file_global_int") @@ -95,3 +121,4 @@ class GlobalVariablesTestCase(TestBase): VARIABLES_DISPLAYED_CORRECTLY, matching=False, substrs=["can't be resolved"]) + diff --git a/packages/Python/lldbsuite/test/lang/c/global_variables/main.c b/packages/Python/lldbsuite/test/lang/c/global_variables/main.c index 499b2504774f9..b37c97bad9dbc 100644 --- a/packages/Python/lldbsuite/test/lang/c/global_variables/main.c +++ b/packages/Python/lldbsuite/test/lang/c/global_variables/main.c @@ -13,6 +13,7 @@ int g_file_global_int = 42; static const int g_file_static_int = 2; const char *g_file_global_cstr = "g_file_global_cstr"; static const char *g_file_static_cstr = "g_file_static_cstr"; +int *g_ptr = &g_file_global_int; extern int g_a; int main (int argc, char const *argv[]) @@ -20,5 +21,5 @@ int main (int argc, char const *argv[]) g_common_1 = g_file_global_int / g_file_static_int; static const char *g_func_static_cstr = "g_func_static_cstr"; printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr); - return g_file_global_int + g_a + g_common_1; // Set break point at this line. //// break $source:$line; continue; var -global g_a -global g_global_int + return g_file_global_int + g_a + g_common_1 + *g_ptr; // Set break point at this line. //// break $source:$line; continue; var -global g_a -global g_global_int } diff --git a/packages/Python/lldbsuite/test/lang/c/inlines/main.c b/packages/Python/lldbsuite/test/lang/c/inlines/main.c index 415f97aedbd49..8fe49180800bd 100644 --- a/packages/Python/lldbsuite/test/lang/c/inlines/main.c +++ b/packages/Python/lldbsuite/test/lang/c/inlines/main.c @@ -21,4 +21,5 @@ void test1(int a) { int main() { test2(42); test1(23); + return 0; } diff --git a/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py b/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py index af6c3a722e400..8d8d57bc9ca35 100644 --- a/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py +++ b/packages/Python/lldbsuite/test/lang/c/modules/TestCModules.py @@ -28,7 +28,7 @@ class CModulesTestCase(TestBase): @skipIf(macos_version=["<", "10.12"]) def test_expr(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py b/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py index 1f3ae3ffcb591..8221148c29afc 100644 --- a/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py +++ b/packages/Python/lldbsuite/test/lang/c/register_variables/TestRegisterVariables.py @@ -114,7 +114,7 @@ class RegisterVariableTestCase(TestBase): register_variables_count = 0 self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. diff --git a/packages/Python/lldbsuite/test/lang/c/register_variables/test.c b/packages/Python/lldbsuite/test/lang/c/register_variables/test.c index f7fb1af132205..2c69039d40a26 100644 --- a/packages/Python/lldbsuite/test/lang/c/register_variables/test.c +++ b/packages/Python/lldbsuite/test/lang/c/register_variables/test.c @@ -1,6 +1,6 @@ #include <stdio.h> -#if defined(__arm__) || defined(__aarch64__) || defined (__mips__) +#if defined(__arm__) || defined(__aarch64__) || defined (__mips__) || defined(__powerpc64__) // Clang does not accept regparm attribute on these platforms. // Fortunately, the default calling convention passes arguments in registers // anyway. diff --git a/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py b/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py index bb94f1c4182bd..14677fc548a2c 100644 --- a/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py +++ b/packages/Python/lldbsuite/test/lang/c/set_values/TestSetValues.py @@ -28,7 +28,7 @@ class SetValuesTestCase(TestBase): def test(self): """Test settings and readings of program variables.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set breakpoints on several places to set program variables. diff --git a/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile b/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile index 854002e64708f..35d712c3f17f2 100644 --- a/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile +++ b/packages/Python/lldbsuite/test/lang/c/shared_lib/Makefile @@ -3,6 +3,5 @@ LEVEL = ../../../make DYLIB_NAME := foo DYLIB_C_SOURCES := foo.c C_SOURCES := main.c -CFLAGS_EXTRAS += -fPIC include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py b/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py index 5505d15854d16..f53a19138356c 100644 --- a/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py +++ b/packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py @@ -45,7 +45,7 @@ class SharedLibTestCase(TestBase): """Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled""" self.common_test_expr(False) - @unittest2.expectedFailure("rdar://problem/10704639") + @unittest2.expectedFailure("llvm.org/PR36712") def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() @@ -73,7 +73,7 @@ class SharedLibTestCase(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) self.runCmd("settings set target.preload-symbols " + str(preload_symbols).lower()) diff --git a/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile b/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile index 51347d73f09c2..6d1f1071bf2fd 100644 --- a/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile +++ b/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/Makefile @@ -3,7 +3,6 @@ LEVEL = ../../../make DYLIB_NAME := foo DYLIB_C_SOURCES := foo.c C_SOURCES := main.c -CFLAGS_EXTRAS += -fPIC SPLIT_DEBUG_SYMBOLS = YES diff --git a/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py index 7b371a2a9a99d..3731d1a1eb657 100644 --- a/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py +++ b/packages/Python/lldbsuite/test/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py @@ -16,7 +16,7 @@ class SharedLibStrippedTestCase(TestBase): @expectedFailureAll(oslist=["windows"]) def test_expr(self): - """Test that types work when defined in a shared library and forward-declared in the main executable""" + """Test that types work when defined in a shared library and forwa/d-declared in the main executable""" if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion(): self.skipTest( "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") @@ -34,7 +34,7 @@ class SharedLibStrippedTestCase(TestBase): "other_element = 3"]) @expectedFailureAll(oslist=["windows"]) - @unittest2.expectedFailure("rdar://problem/10381325") + @unittest2.expectedFailure("llvm.org/PR36712") def test_frame_variable(self): """Test that types work when defined in a shared library and forward-declared in the main executable""" self.build() @@ -62,7 +62,7 @@ class SharedLibStrippedTestCase(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py b/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py index 90f07860afa7a..aeda9ff41eb2e 100644 --- a/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py +++ b/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py @@ -24,7 +24,7 @@ class TestStepTarget(TestBase): @add_test_categories(['pyapi']) def get_to_start(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -52,6 +52,7 @@ class TestStepTarget(TestBase): thread = threads[0] return thread + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_with_end_line(self): """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" @@ -63,6 +64,7 @@ class TestStepTarget(TestBase): self.assertTrue(frame.name == "lotsOfArgs", "Stepped to lotsOfArgs.") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_with_end_line_bad_name(self): """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" @@ -75,6 +77,7 @@ class TestStepTarget(TestBase): frame.line_entry.line == self.end_line, "Stepped to the block end.") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_with_end_line_deeper(self): """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" @@ -85,6 +88,7 @@ class TestStepTarget(TestBase): frame = thread.frames[0] self.assertTrue(frame.name == "modifyInt", "Stepped to modifyInt.") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_with_command_and_block(self): """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" @@ -100,6 +104,7 @@ class TestStepTarget(TestBase): frame = thread.frames[0] self.assertTrue(frame.name == "lotsOfArgs", "Stepped to lotsOfArgs.") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_with_command_and_block_and_bad_name(self): """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" diff --git a/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py b/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py index e1916a550a123..4a4052cfa3350 100644 --- a/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py +++ b/packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py @@ -28,7 +28,7 @@ class TestCStepping(TestBase): def test_and_python_api(self): """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py b/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py index c436000d882fb..62a0bf8e33eb9 100644 --- a/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py +++ b/packages/Python/lldbsuite/test/lang/c/stepping/TestThreadStepping.py @@ -34,7 +34,7 @@ class ThreadSteppingTestCase(TestBase): def test_step_out_with_run_command(self): """Exercise thread step-out and frame select followed by thread step-out.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Create a breakpoint inside function 'c'. diff --git a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py index 27821845e2803..b1c8a5ecf4bf8 100644 --- a/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py +++ b/packages/Python/lldbsuite/test/lang/c/strings/TestCStrings.py @@ -15,7 +15,7 @@ class CStringsTestCase(TestBase): def test_with_run_command(self): """Tests that C strings work as expected in expressions""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) line = line_number('main.c', '// breakpoint 1') lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile b/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile index 90affed8e3adb..0faad10b24af7 100644 --- a/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile +++ b/packages/Python/lldbsuite/test/lang/c/tls_globals/Makefile @@ -1,7 +1,6 @@ LEVEL = ../../../make C_SOURCES := main.c -CFLAGS_EXTRAS += -fPIC DYLIB_NAME := a DYLIB_C_SOURCES := a.c diff --git a/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py b/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py index 4388d95840ebe..b76cd411b5cae 100644 --- a/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py +++ b/packages/Python/lldbsuite/test/lang/c/tls_globals/TestTlsGlobals.py @@ -29,10 +29,10 @@ class TlsGlobalTestCase(TestBase): "=" + os.environ["LD_LIBRARY_PATH"] + ":" + - os.getcwd()) + self.getBuildDir()) else: self.runCmd("settings set target.env-vars " + - self.dylibPath + "=" + os.getcwd()) + self.dylibPath + "=" + self.getBuildDir()) self.addTearDownHook( lambda: self.runCmd( "settings remove target.env-vars " + @@ -48,7 +48,7 @@ class TlsGlobalTestCase(TestBase): def test(self): """Test thread-local storage.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) if self.platformIsDarwin(): self.registerSharedLibrariesWithTarget(target, ['liba.dylib']) diff --git a/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py b/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py index 71d00c5a9a671..bbae76b5752a9 100644 --- a/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py +++ b/packages/Python/lldbsuite/test/lang/c/typedef/Testtypedef.py @@ -26,7 +26,7 @@ class TypedefTestCase(TestBase): def image_lookup_for_multiple_typedefs(self): """Test 'image lookup -t a' at different scopes and check for correct display.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) typearray = ( "float", diff --git a/packages/Python/lldbsuite/test/lang/c/unicode/Makefile b/packages/Python/lldbsuite/test/lang/c/unicode/Makefile new file mode 100644 index 0000000000000..efabc4d4335ce --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/c/unicode/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS += -finput-charset=UTF-8 -fextended-identifiers -std=c99 + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py b/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py new file mode 100644 index 0000000000000..b2c9bbb83c0fe --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/c/unicode/TestUnicodeSymbols.py @@ -0,0 +1,20 @@ +# coding=utf8 +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * + + +class TestUnicodeSymbols(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test_union_members(self): + self.build() + spec = lldb.SBModuleSpec() + spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact("a.out"))) + module = lldb.SBModule(spec) + self.assertTrue(module.IsValid()) + mytype = module.FindFirstType("foobár") + self.assertTrue(mytype.IsValid()) + self.assertTrue(mytype.IsPointerType()) diff --git a/packages/Python/lldbsuite/test/lang/c/unicode/main.c b/packages/Python/lldbsuite/test/lang/c/unicode/main.c new file mode 100644 index 0000000000000..ae44dd0edfa82 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/c/unicode/main.c @@ -0,0 +1,5 @@ +typedef void *foob\u00E1r; +foob\u00E1r X = 0; +int main() { + return (long)X; +} diff --git a/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py b/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py index 496398b1d0acc..4965df2d80915 100644 --- a/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py +++ b/packages/Python/lldbsuite/test/lang/c/unions/TestUnionMembers.py @@ -40,14 +40,12 @@ class TestUnionMembers(TestBase): def _load_exe(self): self.build() - cwd = os.getcwd() - - src_file = os.path.join(cwd, "main.c") + src_file = os.path.join(self.getSourceDir(), "main.c") self.src_file_spec = lldb.SBFileSpec(src_file) self.assertTrue(self.src_file_spec.IsValid(), "breakpoint file") # Get the path of the executable - exe_path = os.path.join(cwd, 'a.out') + exe_path = self.getBuildArtifact("a.out") # Load the executable self.target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py b/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py index 1fb7a5217495c..b10b4986d3789 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py +++ b/packages/Python/lldbsuite/test/lang/cpp/auto/TestCPPAuto.py @@ -18,7 +18,7 @@ class CPPAutoTestCase(TestBase): def test_with_run_command(self): """Test that auto types work in the expression parser""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) line = line_number('main.cpp', '// break here') lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp index 76fb95e0a34c1..6aee25c216087 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/auto/main.cpp @@ -12,5 +12,10 @@ int main() { std::string helloworld("hello world"); + + // Ensure std::string copy constructor is present in the binary, as we will + // use it in an expression. + std::string other = helloworld; + return 0; // break here } diff --git a/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py b/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py index 01f8cbacc3601..27ea773c5dbfa 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py +++ b/packages/Python/lldbsuite/test/lang/cpp/bool/TestCPPBool.py @@ -13,7 +13,7 @@ class CPPBoolTestCase(TestBase): def test_with_run_command(self): """Test that bool types work in the expression parser""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) line = line_number('main.cpp', '// breakpoint 1') lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py b/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py index 81787e1e22607..a12051014dab3 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py +++ b/packages/Python/lldbsuite/test/lang/cpp/breakpoint-commands/TestCPPBreakpointCommands.py @@ -35,7 +35,7 @@ class CPPBreakpointCommandsTestCase(TestBase): """Test a sequence of breakpoint command add, list, and delete.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py b/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py index b86cd2ac9c773..9b227bc8d3c87 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py +++ b/packages/Python/lldbsuite/test/lang/cpp/call-function/TestCallCPPFunction.py @@ -22,7 +22,7 @@ class CallCPPFunctionTestCase(TestBase): def test_with_run_command(self): """Test calling a function by basename""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py b/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py index 0145bee3fc5cd..a344c4f7d18a0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py +++ b/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py @@ -18,9 +18,7 @@ class TestCppChainedCalls(TestBase): self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py index bf8605106adb9..e37e76ae9c0df 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py +++ b/packages/Python/lldbsuite/test/lang/cpp/char1632_t/TestChar1632T.py @@ -32,7 +32,7 @@ class Char1632TestCase(TestBase): def test(self): """Test that the C++11 support for char16_t and char32_t works correctly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py b/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py index d167f0a5591d0..97b0bfd8aee06 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py @@ -27,7 +27,7 @@ class StaticVariableTestCase(TestBase): def test_with_run_command(self): """Test that file and class static variables display correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) @@ -39,7 +39,7 @@ class StaticVariableTestCase(TestBase): substrs=['stopped', 'stop reason = breakpoint']) - # global variables are no longer displayed with the "frame variable" + # Global variables are no longer displayed with the "frame variable" # command. self.expect( 'target variable A::g_points', @@ -63,11 +63,57 @@ class StaticVariableTestCase(TestBase): compiler=["clang"], compiler_version=["<", "3.9"], bugnumber='llvm.org/pr20550') + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") + def test_with_run_command_complete(self): + """ + Test that file and class static variables display correctly with + complete debug information. + """ + self.build() + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.assertTrue(target, VALID_TARGET) + + # Global variables are no longer displayed with the "frame variable" + # command. + self.expect( + 'target variable A::g_points', + VARIABLES_DISPLAYED_CORRECTLY, + patterns=[ + '\(PointType \[[1-9]*\]\) A::g_points = {', '(x = 1, y = 2)', + '(x = 11, y = 22)' + ]) + + # Ensure that we take the context into account and only print + # A::g_points. + self.expect( + 'target variable A::g_points', + VARIABLES_DISPLAYED_CORRECTLY, + matching=False, + patterns=['(x = 3, y = 4)', '(x = 33, y = 44)']) + + # Finally, ensure that we print both points when not specifying a + # context. + self.expect( + 'target variable g_points', + VARIABLES_DISPLAYED_CORRECTLY, + substrs=[ + '(PointType [2]) g_points', '(x = 1, y = 2)', + '(x = 11, y = 22)', '(x = 3, y = 4)', '(x = 33, y = 44)' + ]) + + @expectedFailureAll( + compiler=["gcc"], + bugnumber="Compiler emits incomplete debug info") + @expectedFailureAll( + compiler=["clang"], + compiler_version=["<", "3.9"], + bugnumber='llvm.org/pr20550') @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_with_python_api(self): """Test Python APIs on file and class static variables.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py index c915e4b32fad9..759da716b1872 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypes.py @@ -24,7 +24,7 @@ class ClassTypesTestCase(TestBase): def test_with_run_command(self): """Test 'frame variable this' when stopped on a class constructor.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on the ctor function of class C. @@ -61,7 +61,7 @@ class ClassTypesTestCase(TestBase): def test_with_python_api(self): """Use Python APIs to create a breakpoint by (filespec, line).""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -72,7 +72,8 @@ class ClassTypesTestCase(TestBase): fsDir = os.path.normpath(filespec.GetDirectory()) fsFile = filespec.GetFilename() - self.assertTrue(fsDir == os.getcwd() and fsFile == "a.out", + self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact()) + and fsFile == "a.out", "FileSpec matches the executable") bpfilespec = lldb.SBFileSpec("main.cpp", False) @@ -119,7 +120,7 @@ class ClassTypesTestCase(TestBase): def test_with_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # rdar://problem/8516141 @@ -176,7 +177,7 @@ class ClassTypesTestCase(TestBase): def test_with_constructor_name(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -187,7 +188,8 @@ class ClassTypesTestCase(TestBase): fsDir = os.path.normpath(filespec.GetDirectory()) fsFile = filespec.GetFilename() - self.assertTrue(fsDir == os.getcwd() and fsFile == "a.out", + self.assertTrue(fsDir == os.path.dirname(self.getBuildArtifact()) + and fsFile == "a.out", "FileSpec matches the executable") bpfilespec = lldb.SBFileSpec("main.cpp", False) diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py index bc85ba5181e52..c838178747533 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/TestClassTypesDisassembly.py @@ -78,7 +78,7 @@ class IterateFrameAndDisassembleTestCase(TestBase): def breakOnCtor(self): """Setup/run the program so it stops on C's constructor.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on the ctor function of class C. diff --git a/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp index 251e66c3c9f7b..2d02cbe0f0558 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/class_types/main.cpp @@ -90,7 +90,7 @@ public: B(ai, bi), m_c_int(ci) { - printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. + std::printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. } //virtual diff --git a/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py b/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py index c6f9d85cd2c8c..c1d0d23626840 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py +++ b/packages/Python/lldbsuite/test/lang/cpp/diamond/TestDiamond.py @@ -13,7 +13,7 @@ class CPPTestDiamondInheritance(TestBase): def test_with_run_command(self): """Test that virtual base classes work in when SBValue objects are used to explore the variable value""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile new file mode 100644 index 0000000000000..314f1cb2f077b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py new file mode 100644 index 0000000000000..358b3b2d93ae8 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/TestDynamicValueSameBase.py @@ -0,0 +1,66 @@ +""" +Make sure if we have two classes with the same base name the +dynamic value calculator doesn't confuse them +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +class DynamicValueSameBaseTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + # If your test case doesn't stress debug info, the + # set this to true. That way it won't be run once for + # each debug info format. + NO_DEBUG_INFO_TESTCASE = True + + def test_same_basename_this(self): + """Test that the we use the full name to resolve dynamic types.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + self.sample_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def sample_test(self): + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "Break here to get started", self.main_source_file) + + # Set breakpoints in the two class methods and run to them: + namesp_bkpt = target.BreakpointCreateBySourceRegex("namesp function did something.", self.main_source_file) + self.assertEqual(namesp_bkpt.GetNumLocations(), 1, "Namespace breakpoint invalid") + + virtual_bkpt = target.BreakpointCreateBySourceRegex("Virtual function did something.", self.main_source_file) + self.assertEqual(virtual_bkpt.GetNumLocations(), 1, "Virtual breakpoint invalid") + + threads = lldbutil.continue_to_breakpoint(process, namesp_bkpt) + self.assertEqual(len(threads), 1, "Didn't stop at namespace breakpoint") + + frame = threads[0].frame[0] + namesp_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget) + # Clang specifies the type of this as "T *", gcc as "T * const". This + # erases the difference. + namesp_type = namesp_this.GetType().GetUnqualifiedType() + self.assertEqual(namesp_type.GetName(), "namesp::Virtual *", "Didn't get the right dynamic type") + + threads = lldbutil.continue_to_breakpoint(process, virtual_bkpt) + self.assertEqual(len(threads), 1, "Didn't stop at virtual breakpoint") + + frame = threads[0].frame[0] + virtual_this = frame.FindVariable("this", lldb.eDynamicCanRunTarget) + virtual_type = virtual_this.GetType().GetUnqualifiedType() + self.assertEqual(virtual_type.GetName(), "Virtual *", "Didn't get the right dynamic type") + + + diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/main.cpp new file mode 100644 index 0000000000000..38e46c03f41ed --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/main.cpp @@ -0,0 +1,32 @@ +#include <stdio.h> + +namespace namesp +{ + class Virtual { + public: + virtual void doSomething() { + printf ("namesp function did something.\n"); + } + }; +} + +class Virtual { + public: + virtual void doSomething() { + printf("Virtual function did something.\n"); + } +}; + +int +main() +{ + namesp::Virtual my_outer; + Virtual my_virtual; + + // Break here to get started + my_outer.doSomething(); + my_virtual.doSomething(); + + return 0; +} + diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py index 74b94517fa0f1..497f17f4454c5 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestCppValueCast.py @@ -19,8 +19,7 @@ class CppValueCastTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @unittest2.expectedFailure( - "rdar://problem/10808472 SBValue::Cast test case is failing (virtual inheritance)") + @skipIf(bugnumber="llvm.org/PR36714") @add_test_categories(['pyapi']) def test_value_cast_with_virtual_inheritance(self): """Test SBValue::Cast(SBType) API for C++ types with virtual inheritance.""" @@ -51,7 +50,7 @@ class CppValueCastTestCase(TestBase): def do_sbvalue_cast(self, exe_name): """Test SBValue::Cast(SBType) API for C++ types.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py index 42db14f21e0c3..acda4261b1135 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/TestDynamicValue.py @@ -37,7 +37,7 @@ class DynamicValueTestCase(TestBase): def test_get_dynamic_vals(self): """Test fetching C++ dynamic values from pointers & references.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py b/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py index 82e44fb1759fc..b6bb2e8f30911 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/enum_types/TestCPP11EnumTypes.py @@ -6,6 +6,7 @@ from __future__ import print_function import os import time import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil @@ -14,6 +15,7 @@ class CPP11EnumTypesTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int8_t(self): """Test C++11 enumeration class types as int8_t types.""" self.build( @@ -21,6 +23,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int8_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int16_t(self): """Test C++11 enumeration class types as int16_t types.""" self.build( @@ -28,6 +31,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int16_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int32_t(self): """Test C++11 enumeration class types as int32_t types.""" self.build( @@ -35,6 +39,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int32_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_int64_t(self): """Test C++11 enumeration class types as int64_t types.""" self.build( @@ -42,6 +47,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=int64_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint8_t(self): """Test C++11 enumeration class types as uint8_t types.""" self.build( @@ -49,6 +55,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint8_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint16_t(self): """Test C++11 enumeration class types as uint16_t types.""" self.build( @@ -56,6 +63,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint16_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint32_t(self): """Test C++11 enumeration class types as uint32_t types.""" self.build( @@ -63,6 +71,7 @@ class CPP11EnumTypesTestCase(TestBase): 'CFLAGS_EXTRAS': '"-DTEST_BLOCK_CAPTURED_VARS=uint32_t"'}) self.image_lookup_for_enum_type() + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr36527') def test_uint64_t(self): """Test C++11 enumeration class types as uint64_t types.""" self.build( @@ -78,7 +87,7 @@ class CPP11EnumTypesTestCase(TestBase): def image_lookup_for_enum_type(self): """Test C++11 enumeration class types.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. diff --git a/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py b/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py index 4bc33205319cf..d1aea00b0e8f5 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py +++ b/packages/Python/lldbsuite/test/lang/cpp/exceptions/TestCPPExceptionBreakpoints.py @@ -30,7 +30,7 @@ class CPPBreakpointTestCase(TestBase): def test(self): """Test lldb exception breakpoint command for CPP.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py b/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py index c37107e898c23..6352b68e7d753 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/frame-var-anon-unions/TestFrameVariableAnonymousUnions.py @@ -13,7 +13,7 @@ class FrameVariableAnonymousUnionsTestCase(TestBase): def test_with_run_command(self): """Tests that frame variable looks into anonymous unions""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) line = line_number('main.cpp', '// break here') lldbutil.run_break_set_by_file_and_line( 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 index 810aefee0f07d..b90f74656cdf0 100644 --- 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 @@ -1,6 +1,12 @@ from lldbsuite.test import lldbinline from lldbsuite.test import decorators +# https://bugs.llvm.org/show_bug.cgi?id=35920 +# This test stresses expression evaluation support for template functions. +# Currently the support is rudimentary, and running this test causes assertion +# failures in clang. This test cannot be XFAIL'ed because the test harness +# treats assertion failures as unexpected events. For now, the test must be +# skipped. lldbinline.MakeInlineTest( __file__, globals(), [ - decorators.expectedFailureAll(bugnumber="rdar://problem/32096064")]) + decorators.skipIf]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py b/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py index 21d86f973a357..fa68d0a15021a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py +++ b/packages/Python/lldbsuite/test/lang/cpp/global_operators/TestCppGlobalOperators.py @@ -20,9 +20,7 @@ class TestCppGlobalOperators(TestBase): self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/Makefile b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/Makefile new file mode 100644 index 0000000000000..0497d78fec3cd --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +CXX_SOURCES = main.cpp +# CFLAGS_EXTRAS += $(MODULE_DEBUG_INFO_FLAGS) + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py new file mode 100644 index 0000000000000..69d04636d86b6 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/TestGModules.py @@ -0,0 +1,6 @@ +import lldbsuite.test.lldbinline as lldbinline +from lldbsuite.test.decorators import * + +lldbinline.MakeInlineTest(__file__, globals(), [ + expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr36107", + debug_info="gmodules")]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/a.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/a.h new file mode 100644 index 0000000000000..7384f230801a7 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/a.h @@ -0,0 +1,7 @@ +#include "memory.h" + +class MemoryBuffer { int buffer = 42; }; + +struct SrcBuffer { + my_std::unique_ptr<MemoryBuffer> Buffer; +}; diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/b.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/b.h new file mode 100644 index 0000000000000..b777e8e34739a --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/b.h @@ -0,0 +1,6 @@ +#include "a.h" +#include "memory.h" + +class Module { + my_std::unique_ptr<MemoryBuffer> MBptr; +}; diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/main.cpp new file mode 100644 index 0000000000000..df75261657006 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/main.cpp @@ -0,0 +1,9 @@ +#include "b.h" + +int main(int argc, const char * argv[]) +{ + Module m; + // Test that the type Module which contains a field that is a + // template instantiation can be fully resolved. + return 0; //% self.assertTrue(self.frame().FindVariable('m').GetChildAtIndex(0).GetChildAtIndex(0).GetChildAtIndex(0).GetName() == 'buffer', 'find template specializations in imported modules') +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/memory.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/memory.h new file mode 100644 index 0000000000000..1d59dc0bbf0b2 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/memory.h @@ -0,0 +1,8 @@ +#ifndef MEMORY_H +#define MEMORY_H +namespace my_std { + template<class T> class unique_ptr { + T t; + }; +} +#endif diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/module.modulemap b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/module.modulemap new file mode 100644 index 0000000000000..2f05073a0b857 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules-templates/module.modulemap @@ -0,0 +1,11 @@ +module A { + header "a.h" +} + +module B { + header "b.h" +} + +module std { + header "memory.h" +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py b/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py index dcc9206867b3c..20207c54db903 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py @@ -9,17 +9,17 @@ class TestWithGmodulesDebugInfo(TestBase): mydir = TestBase.compute_mydir(__file__) + @skipIf(bugnumber="llvm.org/pr36146", oslist=["linux"], archs=["i386"]) @add_test_categories(["gmodules"]) def test_specialized_typedef_from_pch(self): self.build() - cwd = os.getcwd() - src_file = os.path.join(cwd, "main.cpp") + src_file = os.path.join(self.getSourceDir(), "main.cpp") src_file_spec = lldb.SBFileSpec(src_file) self.assertTrue(src_file_spec.IsValid(), "breakpoint file") # Get the path of the executable - exe_path = os.path.join(cwd, 'a.out') + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) @@ -69,3 +69,26 @@ class TestWithGmodulesDebugInfo(TestBase): 42, memberValue.GetValueAsSigned(), "Member value incorrect") + + testValue = frame.EvaluateExpression("bar") + self.assertTrue( + testValue.GetError().Success(), + "Test expression value invalid: %s" % + (testValue.GetError().GetCString())) + self.assertTrue( + testValue.GetTypeName() == "Foo::Bar", + "Test expression type incorrect") + + memberValue = testValue.GetChildMemberWithName("i") + self.assertTrue( + memberValue.GetError().Success(), + "Member value missing or invalid: %s" % + (testValue.GetError().GetCString())) + self.assertTrue( + memberValue.GetTypeName() == "int", + "Member type incorrect") + self.assertEqual( + 123, + memberValue.GetValueAsSigned(), + "Member value incorrect") + diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp index aa4013685171c..588a3a8e01fea 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/main.cpp @@ -1,5 +1,8 @@ +class Foo::Bar { int i = 123; }; + int main(int argc, const char * argv[]) { IntContainer test(42); + Foo::Bar bar; return 0; // break here } diff --git a/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h b/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h index a6c59b94c896f..dba4fee9a8c21 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h +++ b/packages/Python/lldbsuite/test/lang/cpp/gmodules/pch.h @@ -10,3 +10,8 @@ class GenericContainer { }; typedef GenericContainer<int> IntContainer; + +struct Foo { + class Bar; + Bar *bar; +}; diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile index bea4bf96e601e..2ce96e90d2d8e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile @@ -19,16 +19,16 @@ nolimit: main.o length_nolimit.o a.o $(CXX) main.o length_nolimit.o a.o -o nolimit $(LDFLAGS) main.o: main.cpp - $(CXX) $(CFLAGS_LIMIT) main.cpp -o main.o + $(CXX) $(CFLAGS_LIMIT) $(SRCDIR)/main.cpp -o main.o length_limit.o: length.cpp - $(CXX) $(CFLAGS_LIMIT) length.cpp -o length_limit.o + $(CXX) $(CFLAGS_LIMIT) $(SRCDIR)/length.cpp -o length_limit.o length_nolimit.o: length.cpp - $(CXX) $(CFLAGS_NO_LIMIT) length.cpp -o length_nolimit.o + $(CXX) $(CFLAGS_NO_LIMIT) $(SRCDIR)/length.cpp -o length_nolimit.o a.o: a.cpp - $(CXX) $(CFLAGS_NO_DEBUG) -c a.cpp -o a.o + $(CXX) $(CFLAGS_NO_DEBUG) -c $(SRCDIR)/a.cpp -o a.o clean: OBJECTS += limit nolimit length_limit.o length_nolimit.o length_limit.dwo length_nolimit.dwo diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py index 505a27a0a67ac..92b58ce11d773 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py @@ -48,36 +48,8 @@ class TestCppIncompleteTypes(TestBase): # Get main source file src_file = "main.cpp" src_file_spec = lldb.SBFileSpec(src_file) - self.assertTrue(src_file_spec.IsValid(), "Main source file") - - # Get the path of the executable - cwd = os.getcwd() - exe_path = os.path.join(cwd, exe) - - # Load the executable - target = self.dbg.CreateTarget(exe_path) - self.assertTrue(target.IsValid(), VALID_TARGET) - - # Break on main function - main_breakpoint = target.BreakpointCreateBySourceRegex( - "break here", src_file_spec) - self.assertTrue( - main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, - VALID_BREAKPOINT) - - # Launch the process - args = None - env = None - process = target.LaunchSimple( - args, env, self.get_process_working_directory()) - self.assertTrue(process.IsValid(), PROCESS_IS_VALID) - - # Get the thread of the process - self.assertTrue( - process.GetState() == lldb.eStateStopped, - PROCESS_STOPPED) - thread = lldbutil.get_stopped_thread( - process, lldb.eStopReasonBreakpoint) + (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", src_file_spec, exe_name = exe) # Get frame for current thread return thread.GetSelectedFrame() diff --git a/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py b/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py index 2dc72981c14f4..f7b92e8328e8f 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py +++ b/packages/Python/lldbsuite/test/lang/cpp/inlines/TestInlines.py @@ -39,7 +39,7 @@ class InlinesTestCase(TestBase): startstr='(int) $0 =') def runToBreakpoint(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the main. diff --git a/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py b/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py index 89086e7a64bc4..ae50d3d396606 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py +++ b/packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py @@ -12,14 +12,12 @@ class TestWithLimitDebugInfo(TestBase): def test_limit_debug_info(self): self.build() - cwd = os.getcwd() - - src_file = os.path.join(cwd, "main.cpp") + src_file = os.path.join(self.getSourceDir(), "main.cpp") src_file_spec = lldb.SBFileSpec(src_file) self.assertTrue(src_file_spec.IsValid(), "breakpoint file") # Get the path of the executable - exe_path = os.path.join(cwd, 'a.out') + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py index 977ad7ddea110..011cf4992915b 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py +++ b/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py @@ -221,7 +221,7 @@ class TestMembersAndLocalsWithSameName(TestBase): self.assertTrue(self.src_file_spec.IsValid(), "breakpoint file") # Get the path of the executable - exe_path = os.path.join(cwd, 'a.out') + exe_path = self.getBuildArtifact("a.out") # Load the executable self.target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py index f0bc12ce98326..593911b15dd2d 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py @@ -31,7 +31,7 @@ class NamespaceBreakpointTestCase(TestBase): "A::func(int)"] # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) module_list = lldb.SBFileSpecList() @@ -48,6 +48,7 @@ class NamespaceBreakpointTestCase(TestBase): "make sure breakpoint locations are correct for 'func' with eFunctionNameTypeAuto") @expectedFailureAll(bugnumber="llvm.org/pr28548", compiler="gcc") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") def test_breakpoints_func_full(self): """Test that we can set breakpoints correctly by fullname to find all functions whose fully qualified name is "func" (no namespaces).""" @@ -56,7 +57,7 @@ class NamespaceBreakpointTestCase(TestBase): names = ["func()", "func(int)"] # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) module_list = lldb.SBFileSpecList() @@ -81,7 +82,7 @@ class NamespaceBreakpointTestCase(TestBase): names = ["A::func()", "A::func(int)"] # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) module_list = lldb.SBFileSpecList() @@ -132,7 +133,7 @@ class NamespaceTestCase(TestBase): def test_with_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py index 18e45d9798aec..2837cfd9244e0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py @@ -50,7 +50,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_lookup_with_run_command(self): """Test scope lookup of functions in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -151,7 +151,7 @@ class NamespaceLookupTestCase(TestBase): def test_function_scope_lookup_with_run_command(self): """Test scope lookup of functions in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -188,7 +188,7 @@ class NamespaceLookupTestCase(TestBase): def test_file_scope_lookup_with_run_command(self): """Test file scope lookup in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -208,7 +208,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_lookup_before_using_with_run_command(self): """Test scope lookup before using in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -238,7 +238,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_after_using_directive_lookup_with_run_command(self): """Test scope lookup after using directive in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -260,7 +260,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_after_using_declaration_lookup_with_run_command(self): """Test scope lookup after using declaration in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -279,7 +279,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_ambiguity_after_using_lookup_with_run_command(self): """Test scope lookup ambiguity after using in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, @@ -305,7 +305,7 @@ class NamespaceLookupTestCase(TestBase): def test_scope_lookup_shadowed_by_using_with_run_command(self): """Test scope lookup shadowed by using in lldb.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp index 560ec40f4733b..9f5eb06cccd43 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/main.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include <cstdarg> +#include <cstdlib> #include "ns.h" namespace { @@ -23,7 +24,7 @@ namespace { variadic_sum (int arg_count...) { int sum = 0; - va_list args; + std::va_list args; va_start(args, arg_count); for (int i = 0; i < arg_count; i++) diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp index 9e5637d02b4b1..bb7731cf87b81 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.cpp @@ -11,22 +11,22 @@ int foo() { - printf("global foo()\n"); - return 42; + std::printf("global foo()\n"); + return 42; } int func() { - printf("global func()\n"); - return 1; + std::printf("global func()\n"); + return 1; } int func(int a) { - printf("global func(int)\n"); - return a + 1; + std::printf("global func(int)\n"); + return a + 1; } void test_lookup_at_global_scope() { - // BP_global_scope - printf("at global scope: foo() = %d\n", foo()); // eval foo(), exp: 42 - printf("at global scope: func() = %d\n", func()); // eval func(), exp: 1 + // BP_global_scope + std::printf("at global scope: foo() = %d\n", foo()); // eval foo(), exp: 42 + std::printf("at global scope: func() = %d\n", func()); // eval func(), exp: 1 } diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h index a07b600efa306..a0f9be88216a2 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include <stdio.h> +#include <cstdio> void test_lookup_at_global_scope(); void test_lookup_at_file_scope(); @@ -15,22 +15,20 @@ void test_lookup_before_using_directive(); void test_lookup_after_using_directive(); int func(int a); namespace A { - int foo(); - int func(int a); - inline int func() - { - printf("A::func()\n"); - return 3; - } - inline int func2() - { - printf("A::func2()\n"); - return 3; - } - void test_lookup_at_ns_scope(); - namespace B { - int func(); - void test_lookup_at_nested_ns_scope(); - void test_lookup_at_nested_ns_scope_after_using(); - } +int foo(); +int func(int a); +inline int func() { + std::printf("A::func()\n"); + return 3; +} +inline int func2() { + std::printf("A::func2()\n"); + return 3; } +void test_lookup_at_ns_scope(); +namespace B { +int func(); +void test_lookup_at_nested_ns_scope(); +void test_lookup_at_nested_ns_scope_after_using(); +} // namespace B +} // namespace A diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp index 04046ad9b7f4d..0051d478395db 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns2.cpp @@ -11,26 +11,26 @@ static int func() { - printf("static m2.cpp func()\n"); - return 2; + std::printf("static m2.cpp func()\n"); + return 2; } void test_lookup_at_file_scope() { - // BP_file_scope - printf("at file scope: func() = %d\n", func()); // eval func(), exp: 2 - printf("at file scope: func(10) = %d\n", func(10)); // eval func(10), exp: 11 + // BP_file_scope + std::printf("at file scope: func() = %d\n", func()); // eval func(), exp: 2 + std::printf("at file scope: func(10) = %d\n", func(10)); // eval func(10), exp: 11 } namespace A { namespace B { int func() { - printf("A::B::func()\n"); - return 4; + std::printf("A::B::func()\n"); + return 4; } void test_lookup_at_nested_ns_scope() { // BP_nested_ns_scope - printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 4 + std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 4 //printf("func(10) = %d\n", func(10)); // eval func(10), exp: 13 // NOTE: Under the rules of C++, this test would normally get an error @@ -42,24 +42,24 @@ namespace A { { // BP_nested_ns_scope_after_using using A::func; - printf("at nested ns scope after using: func() = %d\n", func()); // eval func(), exp: 3 + std::printf("at nested ns scope after using: func() = %d\n", func()); // eval func(), exp: 3 } } } int A::foo() { - printf("A::foo()\n"); - return 42; + std::printf("A::foo()\n"); + return 42; } int A::func(int a) { - printf("A::func(int)\n"); - return a + 3; + std::printf("A::func(int)\n"); + return a + 3; } void A::test_lookup_at_ns_scope() { - // BP_ns_scope - printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 3 - printf("at nested ns scope: func(10) = %d\n", func(10)); // eval func(10), exp: 13 - printf("at nested ns scope: foo() = %d\n", foo()); // eval foo(), exp: 42 + // BP_ns_scope + std::printf("at nested ns scope: func() = %d\n", func()); // eval func(), exp: 3 + std::printf("at nested ns scope: func(10) = %d\n", func(10)); // eval func(10), exp: 13 + std::printf("at nested ns scope: foo() = %d\n", foo()); // eval foo(), exp: 42 } diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp index 10b0df784225b..205e1931f3e05 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace/ns3.cpp @@ -13,15 +13,15 @@ extern int func(); // Note: the following function must be before the using. void test_lookup_before_using_directive() { - // BP_before_using_directive - printf("before using directive: func() = %d\n", func()); // eval func(), exp: 1 + // BP_before_using_directive + std::printf("before using directive: func() = %d\n", func()); // eval func(), exp: 1 } using namespace A; void test_lookup_after_using_directive() { - // BP_after_using_directive - //printf("func() = %d\n", func()); // eval func(), exp: error, amiguous - printf("after using directive: func2() = %d\n", func2()); // eval func2(), exp: 3 - printf("after using directive: ::func() = %d\n", ::func()); // eval ::func(), exp: 1 - printf("after using directive: B::func() = %d\n", B::func()); // eval B::func(), exp: 4 + // BP_after_using_directive + //printf("func() = %d\n", func()); // eval func(), exp: error, amiguous + std::printf("after using directive: func2() = %d\n", func2()); // eval func2(), exp: 3 + std::printf("after using directive: ::func() = %d\n", ::func()); // eval ::func(), exp: 1 + std::printf("after using directive: B::func() = %d\n", B::func()); // eval B::func(), exp: 4 } diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile index 0041add935a61..9e52bacd5fc9c 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/Makefile @@ -9,11 +9,11 @@ include $(LEVEL)/Makefile.rules a.out: lib_a lib_b lib_%: - $(MAKE) -f $*.mk + $(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/$*.mk hidden_lib_d: $(MAKE) -C hidden clean:: - $(MAKE) -f a.mk clean - $(MAKE) -f b.mk clean + $(MAKE) -f $(SRCDIR)/a.mk clean + $(MAKE) -f $(SRCDIR)/b.mk clean diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py index 7160dddf45489..1f3fbd8b7f73e 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py @@ -46,7 +46,7 @@ class NamespaceDefinitionsTestCase(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk index 5943e5077c54d..e53570873a3ad 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/a.mk @@ -4,6 +4,4 @@ DYLIB_NAME := a DYLIB_CXX_SOURCES := a.cpp DYLIB_ONLY := YES -CXXFLAGS += -fPIC - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk index 8ee2a13b1291b..54a1d8dea5a65 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk +++ b/packages/Python/lldbsuite/test/lang/cpp/namespace_definitions/b.mk @@ -4,6 +4,4 @@ DYLIB_NAME := b DYLIB_CXX_SOURCES := b.cpp DYLIB_ONLY := YES -CXXFLAGS += -fPIC - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py b/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py index fd19de7086dab..f42d194cd6207 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py +++ b/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py @@ -16,14 +16,12 @@ class TestCppNsImport(TestBase): self.build() # Get main source file - src_file = "main.cpp" + src_file = os.path.join(self.getSourceDir(), "main.cpp") src_file_spec = lldb.SBFileSpec(src_file) self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile new file mode 100644 index 0000000000000..bd8116b91c3c4 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../../make + +CXX_SOURCES = a.cpp b.cpp + +include $(LEVEL)/Makefile.rules + +a.o: a.cpp + $(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@ diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py new file mode 100644 index 0000000000000..f541a6617e3a4 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/TestOperatorOverload.py @@ -0,0 +1,22 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestOperatorOverload(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def test_overload(self): + self.build() + (target, process, thread, + main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", lldb.SBFileSpec("b.cpp")) + frame = thread.GetSelectedFrame() + value = frame.EvaluateExpression("x == nil") + self.assertTrue(str(value.GetError()) + .find("comparison between NULL and non-pointer ('Tinky' and NULL)") + != -1) + self.assertTrue(str(value.GetError()) + .find("invalid operands to binary expression ('Tinky' and") + != -1) + self.assertFalse(value.GetError().Success()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp new file mode 100644 index 0000000000000..77b2f6ace82ea --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/a.cpp @@ -0,0 +1,9 @@ +class Patatino { +public: + double _blah; + Patatino(int blah) : _blah(blah) {} +}; + +bool operator==(const Patatino& a, const Patatino& b) { + return a._blah < b._blah; +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp new file mode 100644 index 0000000000000..c0eb29bb79f8e --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/operator-overload/b.cpp @@ -0,0 +1,10 @@ +class Tinky { +public: + int _meh; + Tinky(int meh) : _meh(meh) {} +}; + +int main(void) { + Tinky x(12); + return 0; // break here +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py b/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py index 3d8788fa79073..7f68eb8923eba 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py +++ b/packages/Python/lldbsuite/test/lang/cpp/overloaded-functions/TestOverloadedFunctions.py @@ -8,7 +8,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class CPPStaticMethodsTestCase(TestBase): +class OverloadedFunctionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,7 +22,7 @@ class CPPStaticMethodsTestCase(TestBase): def test_with_run_command(self): """Test that functions with the same name are resolved correctly""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py b/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py index 38ebe1a9a9c46..3dfe4f29d18c3 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py +++ b/packages/Python/lldbsuite/test/lang/cpp/printf/TestPrintf.py @@ -4,4 +4,4 @@ from lldbsuite.test import decorators lldbinline.MakeInlineTest( __file__, globals(), [ decorators.expectedFailureAll( - bugnumber="rdar://problem/24599697")]) + bugnumber="llvm.org/PR36715")]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py b/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py index 11d221e171a92..cc79366c71492 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py +++ b/packages/Python/lldbsuite/test/lang/cpp/rvalue-references/TestRvalueReferences.py @@ -22,7 +22,7 @@ class RvalueReferencesTestCase(TestBase): def test_with_run_command(self): """Test that rvalues are supported in the C++ expression parser""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) diff --git a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py index d5ff93f0cc1f5..5cd9e4ed1b4f0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py +++ b/packages/Python/lldbsuite/test/lang/cpp/scope/TestCppScope.py @@ -23,14 +23,12 @@ class TestCppScopes(TestBase): self.build() # Get main source file - src_file = "main.cpp" + src_file = os.path.join(self.getSourceDir(), "main.cpp") src_file_spec = lldb.SBFileSpec(src_file) self.assertTrue(src_file_spec.IsValid(), "Main source file") # Get the path of the executable - cwd = os.getcwd() - exe_file = "a.out" - exe_path = os.path.join(cwd, exe_file) + exe_path = self.getBuildArtifact("a.out") # Load the executable target = self.dbg.CreateTarget(exe_path) diff --git a/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py b/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py index 5925b10143e07..2b67bb4c35e59 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py @@ -9,6 +9,7 @@ import os import time import re import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil @@ -25,6 +26,7 @@ class SignedTypesTestCase(TestBase): self.line = line_number( self.source, '// Set break point at this line.') + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") def test(self): """Test that variables with signed types display correctly.""" self.build() @@ -33,7 +35,7 @@ class SignedTypesTestCase(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py b/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py index 16b5675881612..b8c777f417a9a 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py +++ b/packages/Python/lldbsuite/test/lang/cpp/static_members/TestCPPStaticMembers.py @@ -21,7 +21,7 @@ class CPPStaticMembersTestCase(TestBase): def test_with_run_command(self): """Test that member variables have the correct layout, scope and qualifiers when stopped inside and outside C++ methods""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) diff --git a/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py b/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py index 9c263053879e5..404ef22a0b8cb 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py +++ b/packages/Python/lldbsuite/test/lang/cpp/static_methods/TestCPPStaticMethods.py @@ -20,7 +20,7 @@ class CPPStaticMethodsTestCase(TestBase): def test_with_run_command(self): """Test that static methods are properly distinguished from regular methods""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py index ce5869742f47f..42c372489c631 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py @@ -26,11 +26,11 @@ class STLTestCase(TestBase): self.line = line_number( self.source, '// Set break point at this line.') - @expectedFailureAll(bugnumber="rdar://problem/10400981") + @expectedFailureAll(bugnumber="llvm.org/PR36713") def test(self): """Test some expressions involving STL data types.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # The following two lines, if uncommented, will enable loggings. #self.ci.HandleCommand("log enable -f /tmp/lldb.log lldb default", res) @@ -38,9 +38,6 @@ class STLTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # rdar://problem/8543077 - # test/stl: clang built binaries results in the breakpoint locations = 3, - # is this a problem with clang generated debug info? lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) @@ -60,8 +57,6 @@ class STLTestCase(TestBase): self.runCmd( 'expr for (int i = 0; i < hello_world.length(); ++i) { (void)printf("%c\\n", hello_world[i]); }') - # rdar://problem/10373783 - # rdar://problem/10400981 self.expect('expr associative_array.size()', substrs=[' = 3']) self.expect('expr associative_array.count(hello_world)', @@ -78,7 +73,7 @@ class STLTestCase(TestBase): def test_SBType_template_aspects(self): """Test APIs for getting template arguments from an SBType.""" self.build() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py index 47fdf59a27ee7..23e94e9addc03 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py @@ -31,7 +31,7 @@ class StdCXXDisassembleTestCase(TestBase): def test_stdcxx_disasm(self): """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # rdar://problem/8543077 diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py index b59f966236bb0..054bc93c31899 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py +++ b/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py @@ -19,7 +19,7 @@ class TemplateArgsTestCase(TestBase): self.build() # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -83,6 +83,35 @@ class TemplateArgsTestCase(TestBase): expr_result.GetType().GetName() == "int", 'expr_result.GetType().GetName() == "int"') + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") + def test_template_template_args(self): + frame = self.prepareProcess() + + c1 = frame.FindVariable('c1') + self.assertTrue( + c1.IsValid(), + 'make sure we find a local variabble named "c1"') + self.assertTrue(c1.GetType().GetName() == 'C<float, T1>') + f1 = c1.GetChildMemberWithName("V").GetChildAtIndex(0).GetChildMemberWithName("f") + self.assertTrue(f1.GetType().GetName() == 'float') + self.assertTrue(f1.GetValue() == '1.5') + + c2 = frame.FindVariable('c2') + self.assertTrue( + c2.IsValid(), + 'make sure we find a local variabble named "c2"') + self.assertTrue(c2.GetType().GetName() == 'C<double, T1, T2>') + f2 = c2.GetChildMemberWithName("V").GetChildAtIndex(0).GetChildMemberWithName("f") + self.assertTrue(f2.GetType().GetName() == 'double') + self.assertTrue(f2.GetValue() == '1.5') + f3 = c2.GetChildMemberWithName("V").GetChildAtIndex(1).GetChildMemberWithName("f") + self.assertTrue(f3.GetType().GetName() == 'double') + self.assertTrue(f3.GetValue() == '2.5') + f4 = c2.GetChildMemberWithName("V").GetChildAtIndex(1).GetChildMemberWithName("i") + self.assertTrue(f4.GetType().GetName() == 'int') + self.assertTrue(f4.GetValue() == '42') + + # Gcc does not generate the necessary DWARF attribute for enum template # parameters. @expectedFailureAll(bugnumber="llvm.org/pr28354", compiler="gcc") diff --git a/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp index 9c33a64209126..40825cd7c1a69 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp +++ b/packages/Python/lldbsuite/test/lang/cpp/template/main.cpp @@ -6,6 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#include <tuple> template <int Arg> class TestObj @@ -62,11 +63,17 @@ public: } }; +template <typename FLOAT> struct T1 { FLOAT f = 1.5; }; +template <typename FLOAT> struct T2 { FLOAT f = 2.5; int i = 42; }; +template <typename FLOAT, template <typename> class ...Args> class C { std::tuple<Args<FLOAT>...> V; }; + int main(int argc, char **argv) { TestObj<1> testpos; TestObj<-1> testneg; EnumTemplate<EnumType::Member> member(123); EnumTemplate<EnumType::Subclass> subclass(123*2); + C<float, T1> c1; + C<double, T1, T2> c2; return testpos.getArg() - testneg.getArg() + member.getMember()*2 - subclass.getMember(); // Breakpoint 1 } diff --git a/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py b/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py index ed2e257dc3105..43b00f97d8fef 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py +++ b/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py @@ -24,7 +24,7 @@ class CPPThisTestCase(TestBase): def test_with_run_command(self): """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.set_breakpoint(line_number('main.cpp', '// breakpoint 1')) self.set_breakpoint(line_number('main.cpp', '// breakpoint 2')) diff --git a/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile new file mode 100644 index 0000000000000..314f1cb2f077b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py new file mode 100644 index 0000000000000..2aae7dc89d346 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py @@ -0,0 +1,74 @@ +""" +Test that we work properly with classes with the trivial_abi attribute +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTrivialABI(TestBase): + + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + @skipUnlessSupportedTypeAttribute("trivial_abi") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995") + def test_call_trivial(self): + """Test that we can print a variable & call a function with a trivial ABI class.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + self.expr_test(True) + + @skipUnlessSupportedTypeAttribute("trivial_abi") + @expectedFailureAll(bugnumber="llvm.org/pr36870") + def test_call_nontrivial(self): + """Test that we can print a variable & call a function on the same class w/o the trivial ABI marker.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + self.expr_test(False) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def check_value(self, test_var, ivar_value): + self.assertTrue(test_var.GetError().Success(), "Invalid valobj: %s"%(test_var.GetError().GetCString())) + ivar = test_var.GetChildMemberWithName("ivar") + self.assertTrue(test_var.GetError().Success(), "Failed to fetch ivar") + self.assertEqual(ivar_value, ivar.GetValueAsSigned(), "Got the right value for ivar") + + def check_frame(self, thread): + frame = thread.frames[0] + inVal_var = frame.FindVariable("inVal") + self.check_value(inVal_var, 10) + + options = lldb.SBExpressionOptions() + inVal_expr = frame.EvaluateExpression("inVal", options) + self.check_value(inVal_expr, 10) + + thread.StepOut() + outVal_ret = thread.GetStopReturnValue() + self.check_value(outVal_ret, 30) + + def expr_test(self, trivial): + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + "Set a breakpoint here", self.main_source_file) + + # Stop in a function that takes a trivial value, and try both frame var & expr to get its value: + if trivial: + self.check_frame(thread) + return + + # Now continue to the same thing without the trivial_abi and see if we get that right: + threads = lldbutil.continue_to_breakpoint(process, bkpt) + self.assertEqual(len(threads), 1, "Hit my breakpoint the second time.") + + self.check_frame(threads[0]) diff --git a/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/main.cpp new file mode 100644 index 0000000000000..cdf593e8b4036 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/main.cpp @@ -0,0 +1,35 @@ +struct __attribute__((trivial_abi)) S_Trivial { + ~S_Trivial() {} + int ivar = 10; +}; + +S_Trivial takeTrivial(S_Trivial inVal) +{ + S_Trivial ret_val = inVal; + ret_val.ivar = 30; + return ret_val; // Set a breakpoint here +} + +struct S_NotTrivial { + ~S_NotTrivial() {} + int ivar = 10; +}; + +S_NotTrivial takeNotTrivial(S_NotTrivial inVal) +{ + S_NotTrivial ret_val = inVal; + ret_val.ivar = 30; + return ret_val; // Set a breakpoint here +} + +int +main() +{ + S_Trivial inVal, outVal; + outVal = takeTrivial(inVal); + + S_NotTrivial inNotVal, outNotVal; + outNotVal = takeNotTrivial(outNotVal); + + return 0; // Set another for return value +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile new file mode 100644 index 0000000000000..99bfa7e03b479 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py new file mode 100644 index 0000000000000..94d52e368e8cc --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestCppTypeLookup.py @@ -0,0 +1,94 @@ +""" +Test that we can lookup types correctly in the expression parser +""" + +from __future__ import print_function + + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test import decorators + +class TestCppTypeLookup(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def check_value(self, value, ivar_name, ivar_value): + self.assertTrue(value.GetError().Success(), + "Invalid valobj: %s" % ( + value.GetError().GetCString())) + ivar = value.GetChildMemberWithName(ivar_name) + self.assertTrue(ivar.GetError().Success(), + "Failed to fetch ivar named '%s'" % (ivar_name)) + self.assertEqual(ivar_value, + ivar.GetValueAsSigned(), + "Got the right value for ivar") + + def test_namespace_only(self): + """ + Test that we fail to lookup a struct type that exists only in a + namespace. + """ + self.build() + self.main_source_file = lldb.SBFileSpec("main.cpp") + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Set a breakpoint here", self.main_source_file) + + # Get frame for current thread + frame = thread.GetSelectedFrame() + + # We are testing LLDB's type lookup machinery, but if we inject local + # variables, the types for those will be found because they have been + # imported through the variable, not because the type lookup worked. + self.runCmd("settings set target.experimental.inject-local-vars false") + + # Make sure we don't accidentally accept structures that exist only + # in namespaces when evaluating expressions with top level types. + # Prior to the revision that added this test, we would accidentally + # accept types from namespaces, so this will ensure we don't regress + # to that behavior again + expr_result = frame.EvaluateExpression("*((namespace_only *)&i)") + self.assertTrue(expr_result.GetError().Fail(), + "'namespace_only' exists in namespace only") + + # Make sure we can find the correct type in a namespace "a" + expr_result = frame.EvaluateExpression("*((a::namespace_only *)&i)") + self.check_value(expr_result, "a", 123) + # Make sure we can find the correct type in a namespace "b" + expr_result = frame.EvaluateExpression("*((b::namespace_only *)&i)") + self.check_value(expr_result, "b", 123) + + # Make sure we can find the correct type in the root namespace + expr_result = frame.EvaluateExpression("*((namespace_and_file *)&i)") + self.check_value(expr_result, "ff", 123) + # Make sure we can find the correct type in a namespace "a" + expr_result = frame.EvaluateExpression( + "*((a::namespace_and_file *)&i)") + self.check_value(expr_result, "aa", 123) + # Make sure we can find the correct type in a namespace "b" + expr_result = frame.EvaluateExpression( + "*((b::namespace_and_file *)&i)") + self.check_value(expr_result, "bb", 123) + + # Make sure we don't accidentally accept structures that exist only + # in namespaces when evaluating expressions with top level types. + # Prior to the revision that added this test, we would accidentally + # accept types from namespaces, so this will ensure we don't regress + # to that behavior again + expr_result = frame.EvaluateExpression("*((in_contains_type *)&i)") + self.assertTrue(expr_result.GetError().Fail(), + "'in_contains_type' exists in struct only") + + # Make sure we can find the correct type in the root namespace + expr_result = frame.EvaluateExpression( + "*((contains_type::in_contains_type *)&i)") + self.check_value(expr_result, "fff", 123) + # Make sure we can find the correct type in a namespace "a" + expr_result = frame.EvaluateExpression( + "*((a::contains_type::in_contains_type *)&i)") + self.check_value(expr_result, "aaa", 123) + # Make sure we can find the correct type in a namespace "b" + expr_result = frame.EvaluateExpression( + "*((b::contains_type::in_contains_type *)&i)") + self.check_value(expr_result, "bbb", 123) diff --git a/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp new file mode 100644 index 0000000000000..b244e80962c8f --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp @@ -0,0 +1,67 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// In this test, we define struct that exist might exist at the different +// levels in the code and test that we can properly locate these types with +// a varienty of different expressions. + +namespace a { + struct namespace_only { + int a; + }; + struct namespace_and_file { + int aa; + }; + struct contains_type { + struct in_contains_type { + int aaa; + }; + }; +}; +namespace b { + struct namespace_only { + int b; + }; + struct namespace_and_file { + int bb; + }; + struct contains_type { + struct in_contains_type { + int bbb; + }; + }; +}; + +struct namespace_and_file { + int ff; +}; + +struct contains_type { + struct in_contains_type { + int fff; + }; +}; + + +int main (int argc, char const *argv[]) { + a::namespace_only a_namespace_only = { 1 }; + a::namespace_and_file a_namespace_and_file = { 2 }; + a::contains_type::in_contains_type a_in_contains_type = { 3 }; + b::namespace_only b_namespace_only = { 11 }; + b::namespace_and_file b_namespace_and_file = { 22 }; + b::contains_type::in_contains_type b_in_contains_type = { 33 }; + namespace_and_file file_namespace_and_file = { 44 }; + contains_type::in_contains_type file_in_contains_type = { 55 }; + int i = 123; // Provide an integer that can be used for casting + // Take address of "i" to ensure it is in memory + if (&i == &argc) { + i = -1; + } + return i == -1; // Set a breakpoint here +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py index 842d03ae51974..216f86064dcac 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unicode-literals/TestUnicodeLiterals.py @@ -69,7 +69,7 @@ class UnicodeLiteralsTestCase(TestBase): self.skipTest( "Skipping because this test is known to crash on i386") - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py b/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py index 3afac33ab39fb..3e4fee0b49bc0 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unique-types/TestUniqueTypes.py @@ -28,12 +28,8 @@ class UniqueTypesTestCase(TestBase): compiler = self.getCompiler() compiler_basename = os.path.basename(compiler) - if "clang" in compiler_basename and int( - self.getCompilerVersion().split('.')[0]) < 3: - self.skipTest( - "rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py b/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py index 0189a65bec39d..27b2a0b357af4 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py +++ b/packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py @@ -27,13 +27,13 @@ class UnsignedTypesTestCase(TestBase): def test(self): """Test that variables with unsigned types display correctly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # GCC puts a breakpoint on the last line of a multi-line expression, so # if GCC is the target compiler, we cannot rely on an exact line match. need_exact = "gcc" not in self.getCompiler() - # Break on line 19 in main() aftre the variables are assigned values. + # Break on line 19 in main() after the variables are assigned values. lldbutil.run_break_set_by_file_and_line( self, "main.cpp", diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/Makefile b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/Makefile new file mode 100644 index 0000000000000..314f1cb2f077b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/TestVirtualOverload.py b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/TestVirtualOverload.py new file mode 100644 index 0000000000000..1311a14932621 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/TestVirtualOverload.py @@ -0,0 +1,3 @@ +from lldbsuite.test import lldbinline + +lldbinline.MakeInlineTest(__file__, globals()) diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/main.cpp new file mode 100644 index 0000000000000..79c482352f93b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual-overload/main.cpp @@ -0,0 +1,17 @@ +// Test that lldb doesn't get confused by an overload of a virtual +// function of the same name. +struct Base { + virtual void f(int i) {} + virtual ~Base() {} +}; + +struct Derived : Base { + virtual void f(int i, int j) {} +}; + +int main(int argc, char **argv) { + Derived obj; + obj.f(1, 2); //% self.expect("fr var", "not crashing", substrs = ["obj"]) + return 0; +} + diff --git a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py index 7356484e69a42..b3fe9c40c1983 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py +++ b/packages/Python/lldbsuite/test/lang/cpp/virtual/TestVirtual.py @@ -45,7 +45,7 @@ class CppVirtualMadness(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Create the breakpoint inside function 'main'. diff --git a/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py b/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py index f17ba6f4a229c..f31ba9b5c8b4f 100644 --- a/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py +++ b/packages/Python/lldbsuite/test/lang/cpp/wchar_t/TestCxxWCharT.py @@ -28,7 +28,7 @@ class CxxWCharTTestCase(TestBase): def test(self): """Test that C++ supports wchar_t correctly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py b/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py index 306b00840dfdd..963e0676100d1 100644 --- a/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py +++ b/packages/Python/lldbsuite/test/lang/go/expressions/TestExpressions.py @@ -15,6 +15,7 @@ class TestGoUserExpression(TestBase): @add_test_categories(['pyapi']) @skipIfRemote # Not remote test suit ready + @skipIfFreeBSD # Test hanging on FreeBSD - llvm.org/pr37194 @skipUnlessGoInstalled def test_with_dsym_and_python_api(self): """Test GoASTUserExpress.""" @@ -40,7 +41,7 @@ class TestGoUserExpression(TestBase): self.assertEqual(size, t.size) def launchProcess(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py b/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py index c48cd1f6af08f..b31ac35be46c1 100644 --- a/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py +++ b/packages/Python/lldbsuite/test/lang/go/formatters/TestGoFormatters.py @@ -31,7 +31,7 @@ class TestGoLanguage(TestBase): self.break_line = line_number(self.main_source, '// stop here') def launchProcess(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.py b/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.py index e0cf9e8d77592..027fb3adc0cfa 100644 --- a/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.py +++ b/packages/Python/lldbsuite/test/lang/go/goroutines/TestGoroutines.py @@ -36,7 +36,7 @@ class TestGoASTContext(TestBase): self.break_line3 = line_number(self.main_source, '// stop3') def launchProcess(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime b/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime index 30381ccd24c0d..b06aa656aaa36 100644 --- a/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime +++ b/packages/Python/lldbsuite/test/lang/go/runtime/TestGoLanguageRuntime @@ -30,7 +30,7 @@ class TestGoLanguageRuntime(TestBase): def launchProcess(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py b/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py index 9571e259629ff..8fb56b9577afd 100644 --- a/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py +++ b/packages/Python/lldbsuite/test/lang/go/types/TestGoASTContext.py @@ -46,7 +46,7 @@ class TestGoASTContext(TestBase): self.assertEqual(size, t.size) def launchProcess(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py b/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py index e7615c8e9d8fe..2ba57e61349fc 100644 --- a/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py +++ b/packages/Python/lldbsuite/test/lang/mixed/TestMixedLanguages.py @@ -17,7 +17,7 @@ class MixedLanguagesTestCase(TestBase): def test_language_of_frame(self): """Test that the language defaults to the language of the current frame.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Execute the cleanup function during test case tear down diff --git a/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py index 4a3311fb5f6d3..c0d006ee53a87 100644 --- a/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py +++ b/packages/Python/lldbsuite/test/lang/objc/bitfield_ivars/TestBitfieldIvars.py @@ -5,8 +5,8 @@ lldbinline.MakeInlineTest( __file__, globals(), [ - decorators.skipIfFreeBSD, - decorators.skipIfLinux, - decorators.skipIfWindows, + # This is a Darwin-only failure related to incorrect expression- + # evaluation for single-bit ObjC bitfields. + decorators.skipUnlessDarwin, decorators.expectedFailureAll( bugnumber="rdar://problem/17990991")]) diff --git a/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py b/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py index 74e4f3bc880de..d69a171bc7b82 100644 --- a/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py +++ b/packages/Python/lldbsuite/test/lang/objc/blocks/TestObjCIvarsInBlocks.py @@ -31,7 +31,7 @@ class TestObjCIvarsInBlocks(TestBase): def test_with_python_api(self): """Test printing the ivars of the self when captured in blocks""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile index 2d6de6f1514b5..346fc4b1fbc5b 100644 --- a/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile +++ b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Makefile @@ -1,38 +1,23 @@ LEVEL = ../../../make -CC ?= clang -ifeq "$(ARCH)" "" - ARCH = x86_64 -endif +LD_EXTRAS = -lobjc -framework Foundation -ifeq "$(OS)" "" - OS = $(shell uname -s) -endif +include $(LEVEL)/Makefile.rules -CFLAGS ?= -g -O0 - -ifeq "$(OS)" "Darwin" - CFLAGS += -arch $(ARCH) -endif - -LDFLAGS = $(CFLAGS) -lobjc -framework Foundation - -all: a.out libTest.dylib libTestExt.dylib +all: a.out libTest.dylib: Test/Test.m - $(CC) $(CFLAGS) -I. -c -o Test.o Test/Test.m - $(CC) $(LDFLAGS) -shared -o libTest.dylib Test.o - dsymutil libTest.dylib + mkdir -p Test + $(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/Test/Test.mk all libTestExt.dylib: TestExt/TestExt.m - $(CC) $(CFLAGS) -I. -c -o TestExt.o TestExt/TestExt.m - $(CC) $(LDFLAGS) -L. -lTest -shared -o libTestExt.dylib TestExt.o - dsymutil libTestExt.dylib + mkdir -p TestExt + $(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/TestExt/TestExt.mk all a.out: main.m libTest.dylib libTestExt.dylib - $(CC) $(LDFLAGS) -I. -L. -lTest -lTestExt -o a.out main.m - -.PHONY: clean + $(CC) $(LDFLAGS) -I$(SRCDIR) -L. -lTest -lTestExt -o a.out $< -clean: - rm -rf libTest.dylib libTestExt.dylib a.out Test.o TestExt.o libTest.dylib.dSYM libTest.dylib.dSYM +clean:: + rm -rf libTest.dylib libTestExt.dylib a.out Test.o TestExt.o libTest.dylib.dSYM libTestExt.dylib.dSYM + $(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/Test/Test.mk clean + $(MAKE) MAKE_DSYM=YES VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/TestExt/TestExt.mk clean diff --git a/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.mk b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.mk new file mode 100644 index 0000000000000..be758ac07d85d --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/Test/Test.mk @@ -0,0 +1,10 @@ +LEVEL = ../../../make + +DYLIB_NAME := Test +DYLIB_ONLY := YES +CFLAGS_EXTRAS = -I$(SRCDIR)/.. +LD_EXTRAS = -lobjc -framework Foundation + +DYLIB_OBJC_SOURCES = Test/Test.m + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py index df3a41fedf608..264a17c379601 100644 --- a/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py +++ b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestConflictingDefinition.py @@ -46,7 +46,7 @@ class TestRealDefinition(TestBase): "42"]) def common_setup(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.registerSharedLibrariesWithTarget(target, self.shlib_names) diff --git a/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.mk b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.mk new file mode 100644 index 0000000000000..285d7262ce82e --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/conflicting-definition/TestExt/TestExt.mk @@ -0,0 +1,10 @@ +LEVEL = ../../../make + +DYLIB_NAME := TestExt +DYLIB_ONLY := YES +CFLAGS_EXTRAS = -I$(SRCDIR)/.. +LD_EXTRAS = -L. -lTest -lobjc -framework Foundation + +DYLIB_OBJC_SOURCES = TestExt/TestExt.m + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py b/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py index aa2b659b84b31..218d73c72fdb7 100644 --- a/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py +++ b/packages/Python/lldbsuite/test/lang/objc/forward-decl/TestForwardDecl.py @@ -23,12 +23,11 @@ class ForwardDeclTestCase(TestBase): self.line = line_number(self.source, '// Set breakpoint 0 here.') self.shlib_names = ["Container"] - @skipUnlessDarwin - def test_expr(self): - self.build() + def do_test(self, dictionary=None): + self.build(dictionary=dictionary) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Create the breakpoint inside function 'main'. @@ -57,3 +56,17 @@ class ForwardDeclTestCase(TestBase): # This should display correctly. self.expect("expression [j getMember]", VARIABLES_DISPLAYED_CORRECTLY, substrs=["= 0x"]) + + @skipUnlessDarwin + def test_expr(self): + self.do_test() + + @no_debug_info_test + @skipUnlessDarwin + @skipIf(compiler=no_match("clang")) + @skipIf(compiler_version=["<", "7.0"]) + def test_debug_names(self): + """Test that we are able to find complete types when using DWARF v5 + accelerator tables""" + self.do_test( + dict(CFLAGS_EXTRAS="-dwarf-version=5 -mllvm -accel-tables=Dwarf")) diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py index 2a81c42eb5036..95c5575385c54 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestConstStrings.py @@ -32,7 +32,7 @@ class ConstStringTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(self.d) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py index 51d9d22bf44a0..345e41b2b04ea 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestFoundationDisassembly.py @@ -32,7 +32,7 @@ class FoundationDisassembleTestCase(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Now launch the process, and do not stop at entry point. @@ -76,7 +76,7 @@ class FoundationDisassembleTestCase(TestBase): self.build() # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) print(target) diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py index d636458ce1aa6..42535ca44af00 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods.py @@ -35,7 +35,7 @@ class FoundationTestCase(TestBase): def test_break(self): """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at +[NSString stringWithFormat:]. @@ -117,7 +117,7 @@ class FoundationTestCase(TestBase): def test_data_type_and_expr(self): """Lookup objective-c data types and evaluate expressions.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString description]. @@ -230,7 +230,7 @@ class FoundationTestCase(TestBase): self.build() # See: <rdar://problem/8717050> lldb needs to use the ObjC runtime symbols for ivar offsets # Only fails for the ObjC 2.0 runtime. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -280,7 +280,7 @@ class FoundationTestCase(TestBase): def test_expression_lookups_objc(self): """Test running an expression detect spurious debug info lookups (DWARF).""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString initWithNSString:]. @@ -296,7 +296,7 @@ class FoundationTestCase(TestBase): # Log any DWARF lookups ++file_index logfile = os.path.join( - os.getcwd(), + self.getBuildDir(), "dwarf-lookups-" + self.getArchitecture() + "-" + diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py index ce7e7742bfe82..2b967e9888565 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py @@ -47,7 +47,7 @@ class FoundationTestCase2(TestBase): def test_more_expr_commands(self): """More expression commands for objective-c.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Create a bunch of breakpoints. @@ -84,7 +84,7 @@ class FoundationTestCase2(TestBase): def test_NSArray_expr_commands(self): """Test expression commands for NSArray.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside Test_NSArray: @@ -111,7 +111,7 @@ class FoundationTestCase2(TestBase): def test_NSString_expr_commands(self): """Test expression commands for NSString.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside Test_NSString: @@ -141,7 +141,7 @@ class FoundationTestCase2(TestBase): def test_MyString_dump_with_runtime(self): """Test dump of a known Objective-C object by dereferencing it.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) line = self.lines[4] @@ -162,7 +162,7 @@ class FoundationTestCase2(TestBase): def test_runtime_types(self): """Test commands that require runtime types""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside Test_NSString: @@ -190,7 +190,7 @@ class FoundationTestCase2(TestBase): def test_NSError_p(self): """Test that p of the result of an unknown method does require a cast.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) line = self.lines[4] diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py index 8ef9f39434e3d..82e08584702f4 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjectDescriptionAPI.py @@ -34,7 +34,7 @@ class ObjectDescriptionAPITestCase(TestBase): d = {'EXE': 'b.out'} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), 'b.out') + exe = self.getBuildArtifact('b.out') # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py index 334ebba8e642b..c52ac8c2e6d02 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py @@ -28,7 +28,7 @@ class RuntimeTypesTestCase(TestBase): self.skipTest("This only applies to the v2 runtime") self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Stop at -[MyString description]. diff --git a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py b/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py index 6e5bc4d9fb0f7..bfb9e0b4479d3 100644 --- a/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py +++ b/packages/Python/lldbsuite/test/lang/objc/foundation/TestSymbolTable.py @@ -36,7 +36,7 @@ class FoundationSymtabTestCase(TestBase): def test_with_python_api(self): """Test symbol table access with Python APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py index bcd4a41e0df31..dcabd72dd0c0a 100644 --- a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py +++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py @@ -25,7 +25,7 @@ class TestObjCGlobalVar(TestBase): def test_with_python_api(self): """Test that a global ObjC object found before the process is started updates correctly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py b/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py index ee21189ab7c0e..2fad51eefd570 100644 --- a/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py +++ b/packages/Python/lldbsuite/test/lang/objc/hidden-ivars/TestHiddenIvars.py @@ -84,15 +84,19 @@ class HiddenIvarsTestCase(TestBase): if strip: self.assertTrue(subprocess.call( - ['/usr/bin/strip', '-Sx', 'libInternalDefiner.dylib']) == 0, 'stripping dylib succeeded') - self.assertTrue(subprocess.call(['/bin/rm', - '-rf', - 'libInternalDefiner.dylib.dSYM']) == 0, - 'remove dylib dSYM file succeeded') + ['/usr/bin/strip', '-Sx', + self.getBuildArtifact('libInternalDefiner.dylib')]) == 0, + 'stripping dylib succeeded') self.assertTrue(subprocess.call( - ['/usr/bin/strip', '-Sx', 'a.out']) == 0, 'stripping a.out succeeded') + ['/bin/rm', '-rf', + self.getBuildArtifact('libInternalDefiner.dylib.dSYM')]) == 0, + 'remove dylib dSYM file succeeded') + self.assertTrue(subprocess.call(['/usr/bin/strip', '-Sx', + self.getBuildArtifact("a.out") + ]) == 0, + 'stripping a.out succeeded') # Create a target by the debugger. - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # Create the breakpoint inside function 'main'. @@ -109,7 +113,7 @@ class HiddenIvarsTestCase(TestBase): None, environment, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile index bd940ab148c98..f69da9a64be07 100644 --- a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile @@ -19,8 +19,8 @@ endif all: aout aout: - $(CC) $(CFLAGS_NO_DEBUG) myclass.m -c -o myclass.o - $(CC) $(CFLAGS) myclass.o repro.m -framework Foundation + $(CC) $(CFLAGS_NO_DEBUG) $(SRCDIR)/myclass.m -c -o myclass.o + $(CC) $(CFLAGS) myclass.o $(SRCDIR)/repro.m -framework Foundation clean:: rm -f myclass.o diff --git a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py index d29476727bd62..ad7f96c0ac8b4 100644 --- a/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py +++ b/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py @@ -35,7 +35,7 @@ class ObjCiVarIMPTestCase(TestBase): def test_imp_ivar_type(self): """Test that dynamically discovered ivars of type IMP do not crash LLDB""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile b/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile index e42b59f9518ce..ca099e1e96116 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile +++ b/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile @@ -1,6 +1,6 @@ LEVEL = ../../../make OBJC_SOURCES := main.m -CFLAGS += -fmodules -gmodules -g +CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py b/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py index f01cc12bb4a62..264631805ed2a 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py @@ -29,7 +29,7 @@ class ObjCModulesAutoImportTestCase(TestBase): @skipIf(macos_version=["<", "10.12"]) def test_expr(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile b/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile new file mode 100644 index 0000000000000..00cb9b6be34a4 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +OBJC_SOURCES := main.m +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py b/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py new file mode 100644 index 0000000000000..0cff6916e7f10 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py @@ -0,0 +1,41 @@ +"""Test that the clang modules cache directory can be controlled.""" + +from __future__ import print_function + + +import unittest2 +import os +import time +import platform +import shutil + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ObjCModulesTestCase(TestBase): + NO_DEBUG_INFO_TESTCASE = True + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + + @skipUnlessDarwin + def test_expr(self): + self.build() + self.main_source_file = lldb.SBFileSpec("main.m") + self.runCmd("settings set target.auto-import-clang-modules true") + mod_cache = self.getBuildArtifact("my-clang-modules-cache") + if os.path.isdir(mod_cache): + shutil.rmtree(mod_cache) + self.assertFalse(os.path.isdir(mod_cache), + "module cache should not exist") + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' % mod_cache) + self.runCmd('settings set target.clang-module-search-paths "%s"' + % self.getSourceDir()) + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Set breakpoint here", self.main_source_file) + self.runCmd("expr @import Foo") + self.assertTrue(os.path.isdir(mod_cache), "module cache exists") diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h b/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h new file mode 100644 index 0000000000000..56757a701bf5c --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h @@ -0,0 +1 @@ +void f() {} diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m b/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m new file mode 100644 index 0000000000000..6009d28d81b9a --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m @@ -0,0 +1,5 @@ +#include "f.h" +int main() { + f(); // Set breakpoint here. + return 0; +} diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap b/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap new file mode 100644 index 0000000000000..f54534a1c0706 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap @@ -0,0 +1,3 @@ +module Foo { + header "f.h" +} diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile index cbd95de007d83..b8462bc818caf 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile @@ -4,5 +4,5 @@ OBJC_SOURCES := main.m myModule.m include $(LEVEL)/Makefile.rules -CFLAGS += -fmodules -I$(PWD) +CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) LDFLAGS += -framework Foundation diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py index 367eeb2638d16..7bde8fc968960 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py @@ -23,14 +23,11 @@ class IncompleteModulesTestCase(TestBase): self.line = line_number('main.m', '// Set breakpoint 0 here.') @skipUnlessDarwin - @unittest2.expectedFailure("rdar://20416388") - @skipIf(macos_version=["<", "10.12"]) + @skipIf(debug_info=no_match(["gmodules"])) def test_expr(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break inside the foo function which takes a bar_ptr argument. lldbutil.run_break_set_by_file_and_line( self, "main.m", self.line, num_expected_locations=1, loc_exact=True) @@ -47,21 +44,21 @@ class IncompleteModulesTestCase(TestBase): self.runCmd( "settings set target.clang-module-search-paths \"" + - os.getcwd() + + self.getSourceDir() + "\"") self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY, substrs=["int", "3"]) self.expect( - "expr [myObject privateMethod]", + "expr private_func()", VARIABLES_DISPLAYED_CORRECTLY, substrs=[ "int", "5"]) - self.expect("expr MIN(2,3)", "#defined macro was found", + self.expect("expr MY_MIN(2,3)", "#defined macro was found", substrs=["int", "2"]) - self.expect("expr MAX(2,3)", "#undefd macro was correcltly not found", + self.expect("expr MY_MAX(2,3)", "#undefd macro was correctly not found", error=True) diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m index 8ebfb0c1f11a4..bfa0b06f1a14d 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/main.m @@ -1,11 +1,7 @@ -@import Foundation; @import myModule; +@import minmax; -int main() -{ - @autoreleasepool - { - MyClass *myObject = [MyClass alloc]; - [myObject publicMethod]; // Set breakpoint 0 here. - } +int main(int argc, char **argv) { + public_func(); // Set breakpoint 0 here. + return 0; } diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/minmax.h b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/minmax.h new file mode 100644 index 0000000000000..efad1201695f1 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/minmax.h @@ -0,0 +1,2 @@ +#define MY_MIN(A, B) (((A) < (B)) ? (A) : (B)) +#define MY_MAX(A, B) (((A) < (B)) ? (B) : (A)) diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map index 2ef8064d15b45..0dd9fadb26213 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/module.map @@ -2,3 +2,8 @@ module myModule { header "myModule.h" export * } + +module minmax { + header "minmax.h" + export * +} diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h index d03dde0d07aa4..04ec3885c8384 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.h @@ -1,8 +1,5 @@ -@import Foundation; +@import minmax; -#undef MAX +#undef MY_MAX -@interface MyClass : NSObject { -}; --(void)publicMethod; -@end +extern void public_func(); diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m index d6a2619d8016b..372a328893228 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m +++ b/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/myModule.m @@ -1,14 +1,8 @@ #include "myModule.h" -#include "stdio.h" -@implementation MyClass { -}; --(void)publicMethod { - printf("Hello public!\n"); -} --(int)privateMethod { - printf("Hello private!\n"); +void public_func() {} + +int private_func() { return 5; } -@end diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile index 6ad9e0010bb0d..320e13ed5c5fb 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile +++ b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile @@ -6,4 +6,4 @@ OBJC_SOURCES := main.m include $(LEVEL)/Makefile.rules -CFLAGS += -fmodules -I$(PWD) +CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) -I$(PWD) diff --git a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py index 328335dfe2c97..29d386253fb42 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py @@ -27,10 +27,10 @@ class ModulesInlineFunctionsTestCase(TestBase): self.line = line_number('main.m', '// Set breakpoint here.') @skipUnlessDarwin - @skipIf(macos_version=["<", "10.12"]) + @skipIf(macos_version=["<", "10.12"], debug_info=no_match(["gmodules"])) def test_expr(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. @@ -50,7 +50,7 @@ class ModulesInlineFunctionsTestCase(TestBase): self.runCmd( "settings set target.clang-module-search-paths \"" + - os.getcwd() + + self.getSourceDir() + "\"") self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY, diff --git a/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py b/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py index 526b4a70e60c8..8f5c407000c8f 100644 --- a/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py +++ b/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py @@ -26,14 +26,10 @@ class ObjCModulesTestCase(TestBase): self.line = line_number('main.m', '// Set breakpoint 0 here.') @skipUnlessDarwin - @unittest2.expectedFailure("rdar://20416388") @skipIf(macos_version=["<", "10.12"]) def test_expr(self): - if not self.applies(): - return - self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py b/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py index 5b91f9848a92b..996ec6ccdac85 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc++/TestObjCXX.py @@ -24,7 +24,7 @@ class ObjCXXTestCase(TestBase): self.skipTest("requires Objective-C 2.0 runtime") self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py b/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py index 0f82cc68df854..7bba071922ce6 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-baseclass-sbtype/TestObjCBaseClassSBType.py @@ -33,7 +33,7 @@ class ObjCDynamicValueTestCase(TestBase): self.skipTest("Dynamic types for ObjC V1 runtime not implemented") self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py b/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py index d92daab80351f..0aa831850198c 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-builtin-types/TestObjCBuiltinTypes.py @@ -29,7 +29,7 @@ class TestObjCBuiltinTypes(TestBase): def test_with_python_api(self): """Test expression parser respect for ObjC built-in types.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py b/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py index 1bd8f1af23005..644cd87305e94 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-checker/TestObjCCheckers.py @@ -33,7 +33,7 @@ class ObjCCheckerTestCase(TestBase): self.skipTest("requires Objective-C 2.0 runtime") self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py b/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py index 562c0cfc1e7ab..8470d77db9b24 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-class-method/TestObjCClassMethod.py @@ -28,7 +28,7 @@ class TestObjCClassMethod(TestBase): def test_with_python_api(self): """Test calling functions in class methods.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py b/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py index 8b3f444b27afa..6e95b4fa4b967 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-dyn-sbtype/TestObjCDynamicSBType.py @@ -34,7 +34,7 @@ class ObjCDynamicSBTypeTestCase(TestBase): self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py b/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py index a115d4f15733a..e9df6be81cdbd 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py @@ -43,7 +43,7 @@ class ObjCDynamicValueTestCase(TestBase): self.skipTest("Dynamic types for ObjC V1 runtime not implemented") self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py b/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py new file mode 100644 index 0000000000000..804905106dfc7 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/TestNSDictionary0.py @@ -0,0 +1,6 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.skipIfFreeBSD, decorators.skipIfLinux, decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/main.m b/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/main.m new file mode 100644 index 0000000000000..14a792b3776d0 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/objc-foundation-dictionary-empty/main.m @@ -0,0 +1,7 @@ +#import <Foundation/Foundation.h> + +int main(void) +{ + NSDictionary *emptyDictionary = [[NSDictionary alloc] init]; + return 0; //% self.expect("frame var emptyDictionary", substrs = ["0 key/value pairs"]); +} diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py index 03121e6f956a9..6b928450ceaea 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-offsets/TestObjCIvarOffsets.py @@ -28,7 +28,7 @@ class TestObjCIvarOffsets(TestBase): def test_with_python_api(self): """Test printing ObjC objects that use unbacked properties""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile index 4365ed9ae9367..b93a8a13379d8 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile +++ b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/Makefile @@ -3,7 +3,7 @@ LEVEL = ../../../make OBJC_SOURCES := main.m LDFLAGS = $(CFLAGS) -lobjc -framework Foundation -default: a.out.stripped +all: a.out.stripped a.out.stripped: a.out.dSYM strip -o a.out.stripped a.out diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py index dde9ebadba4f9..f5997eb389fd6 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py @@ -31,12 +31,12 @@ class TestObjCIvarStripped(TestBase): def test_with_python_api(self): """Test that we can find stripped Objective-C ivars in the runtime""" self.build() - exe = os.path.join(os.getcwd(), "a.out.stripped") + exe = self.getBuildArtifact("a.out.stripped") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - self.dbg.HandleCommand("add-dsym a.out.dSYM") + self.dbg.HandleCommand("add-dsym "+self.getBuildArtifact("a.out.dSYM")) breakpoint = target.BreakpointCreateByLocation( self.main_source, self.stop_line) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py b/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py index 84b12579166d9..74256345a0d5f 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py @@ -28,7 +28,7 @@ class ObjCNewSyntaxTestCase(TestBase): def runToBreakpoint(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py b/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py index 08e9594be69ff..340d8849efa9a 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py @@ -34,7 +34,7 @@ class ObjcOptimizedTestCase(TestBase): def test_break(self): """Test 'expr member' continues to work for optimized build.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_symbol( diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py b/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py index 790bc9c086190..2a9a5afc35035 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py @@ -33,7 +33,7 @@ class ObjCPropertyTestCase(TestBase): self.skipTest("requires modern objc runtime") self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target from the debugger. diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py b/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py index 65dc5ace544eb..ed969414c1223 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-static-method-stripped/TestObjCStaticMethodStripped.py @@ -34,7 +34,7 @@ class TestObjCStaticMethodStripped(TestBase): if self.getArchitecture() == 'i386': self.skipTest("requires modern objc runtime") self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py b/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py index 9f74d86d63361..37b41cd13fda9 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-static-method/TestObjCStaticMethod.py @@ -29,7 +29,7 @@ class TestObjCStaticMethod(TestBase): def test_with_python_api(self): """Test calling functions in static methods.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py b/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py index 95eb6e5a212df..9e949dc627b2d 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py @@ -36,7 +36,7 @@ class TestObjCStepping(TestBase): def test_with_python_api(self): """Test stepping through ObjC method dispatch in various forms.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py b/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py index 650923a729e46..4195f60cf60e8 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/TestObjCStructArgument.py @@ -29,7 +29,7 @@ class TestObjCStructArgument(TestBase): def test_with_python_api(self): """Test passing structs to Objective-C methods.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m b/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m index 337ab3408ce28..6b13a3a3d5951 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m +++ b/packages/Python/lldbsuite/test/lang/objc/objc-struct-argument/test.m @@ -32,7 +32,7 @@ int main() struct things_to_sum tts = { 2, 3, 4 }; int ret = [summer sumThings:tts]; NSRect rect = {{0, 0}, {10, 20}}; - // The Objective C V1 runtime won't read types from metadata so we need + // The Objective-C V1 runtime won't read types from metadata so we need // NSValue in our debug info to use it in our test. NSValue *v = [NSValue valueWithRect:rect]; return rect.origin.x; // Set breakpoint here. diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py b/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py index 6e56c06e8ae8b..6f6fd92992f9b 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-struct-return/TestObjCStructReturn.py @@ -28,7 +28,7 @@ class TestObjCClassMethod(TestBase): def test_with_python_api(self): """Test calling functions in class methods.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py b/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py index d1d755e289cdb..5b10bc5b81d65 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-super/TestObjCSuper.py @@ -28,7 +28,7 @@ class TestObjCSuperMethod(TestBase): def test_with_python_api(self): """Test calling methods on super.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/orderedset/Makefile b/packages/Python/lldbsuite/test/lang/objc/orderedset/Makefile new file mode 100644 index 0000000000000..a1608fe5a664c --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/orderedset/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +OBJC_SOURCES := main.m +LDFLAGS = $(CFLAGS) -lobjc -framework Foundation + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/objc/orderedset/TestOrderedSet.py b/packages/Python/lldbsuite/test/lang/objc/orderedset/TestOrderedSet.py new file mode 100644 index 0000000000000..90c6bc32f7722 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/orderedset/TestOrderedSet.py @@ -0,0 +1,18 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestOrderedSet(TestBase): + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessDarwin + def test_ordered_set(self): + self.build() + src_file = "main.m" + src_file_spec = lldb.SBFileSpec(src_file) + (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "break here", src_file_spec, exe_name = "a.out") + frame = thread.GetSelectedFrame() + self.expect("expr -d run -- orderedSet", substrs=["3 elements"]) + self.expect("expr -d run -- *orderedSet", substrs=["(int)1", "(int)2", "(int)3"]) diff --git a/packages/Python/lldbsuite/test/lang/objc/orderedset/main.m b/packages/Python/lldbsuite/test/lang/objc/orderedset/main.m new file mode 100644 index 0000000000000..e3f016226932b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objc/orderedset/main.m @@ -0,0 +1,8 @@ +#import <Foundation/Foundation.h> + +int main() { + NSOrderedSet *orderedSet = + [NSOrderedSet orderedSetWithArray:@[@1,@2,@3,@1]]; + NSLog(@"%@",orderedSet); + return 0; // break here +} diff --git a/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py b/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py index 288f912dc79ef..57a572c6bb4b5 100644 --- a/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py +++ b/packages/Python/lldbsuite/test/lang/objc/print-obj/TestPrintObj.py @@ -38,7 +38,7 @@ class PrintObjTestCase(TestBase): d = {'EXE': 'b.out'} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), 'b.out') + exe = self.getBuildArtifact('b.out') target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py index e5633156cd189..74d08f70cafa7 100644 --- a/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py +++ b/packages/Python/lldbsuite/test/lang/objc/ptr_refs/TestPtrRefsObjC.py @@ -19,8 +19,7 @@ class TestPtrRefsObjC(TestBase): 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) + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py b/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py index fe7d5d48ca7ed..737b0dc328675 100644 --- a/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py +++ b/packages/Python/lldbsuite/test/lang/objc/radar-9691614/TestObjCMethodReturningBOOL.py @@ -33,7 +33,7 @@ class MethodReturningBOOLTestCase(TestBase): self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py b/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py index 1375a78f87a58..ed60e5f98c2f5 100644 --- a/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-10967107/TestRdar10967107.py @@ -33,7 +33,7 @@ class Rdar10967107TestCase(TestBase): self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py b/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py index d1956d46e7b6a..8619ce1ebd387 100644 --- a/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-11355592/TestRdar11355592.py @@ -33,7 +33,7 @@ class Rdar10967107TestCase(TestBase): self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py index d431e98ba7973..00fffc8176abd 100644 --- a/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py +++ b/packages/Python/lldbsuite/test/lang/objc/rdar-12408181/TestRdar12408181.py @@ -13,6 +13,11 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +# TODO: The Jenkins testers on OS X fail running this test because they don't +# have access to WindowServer so NSWindow doesn't work. We should disable this +# test if WindowServer isn't available. +# Note: Simply applying the @skipIf decorator here confuses the test harness +# and gives a spurious failure. @skipUnlessDarwin class Rdar12408181TestCase(TestBase): @@ -29,11 +34,14 @@ class Rdar12408181TestCase(TestBase): def test_nswindow_count(self): """Test that we are able to find out how many children NSWindow has.""" + + self.skipTest("Skipping this test due to timeout flakiness") + d = {'EXE': self.exe_name} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py b/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py index 820ddcd9ec6ac..d4760079814a2 100644 --- a/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py +++ b/packages/Python/lldbsuite/test/lang/objc/real-definition/TestRealDefinition.py @@ -92,7 +92,7 @@ class TestRealDefinition(TestBase): "foo->_bar->_hidden_ivar = 0x"]) def common_setup(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py b/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py index 48c4313375c1e..81d6b79ad5353 100644 --- a/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py +++ b/packages/Python/lldbsuite/test/lang/objc/self/TestObjCSelf.py @@ -15,7 +15,7 @@ class ObjCSelfTestCase(TestBase): def test_with_run_command(self): """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.set_breakpoint(line_number('main.m', '// breakpoint 1')) self.set_breakpoint(line_number('main.m', '// breakpoint 2')) diff --git a/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py index 54011db1a120c..21f0892044ad0 100644 --- a/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py +++ b/packages/Python/lldbsuite/test/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py @@ -30,7 +30,7 @@ class ObjCSingleEntryDictionaryTestCase(TestBase): @expectedFailureAll(oslist=['watchos'], bugnumber="rdar://problem/34642736") # bug in NSDictionary formatting on watchos def test_single_entry_dict(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside the foo function which takes a bar_ptr argument. diff --git a/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/Makefile b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/Makefile new file mode 100644 index 0000000000000..579600704dcdf --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make +OBJCXX_SOURCES := main.mm myobject.mm +include $(LEVEL)/Makefile.rules + +# myobject.o needs to be built without debug info +myobject.o: myobject.mm + $(CXX) -c -o $@ $< diff --git a/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/TestNameClash.py b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/TestNameClash.py new file mode 100644 index 0000000000000..9b0c1f5eaef1a --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/TestNameClash.py @@ -0,0 +1,6 @@ +from lldbsuite.test import decorators +from lldbsuite.test import lldbinline + +lldbinline.MakeInlineTest( + __file__, globals(), [ + decorators.skipIfFreeBSD, decorators.skipIfLinux, decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/main.mm b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/main.mm new file mode 100644 index 0000000000000..b74871f427056 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/main.mm @@ -0,0 +1,21 @@ +#import <Foundation/Foundation.h> + +namespace NS { + class MyObject { int i = 42; }; + NS::MyObject globalObject; +} + +@interface MyObject: NSObject +@end + +int main () +{ + @autoreleasepool + { + MyObject *o = [MyObject alloc]; + return 0; //% self.expect("fr var o", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["(MyObject"]); + //% self.expect("fr var globalObject", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"]); + } +} + + diff --git a/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/myobject.mm b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/myobject.mm new file mode 100644 index 0000000000000..051c4e5eb1d58 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/objcxx/class-name-clash/myobject.mm @@ -0,0 +1,7 @@ +#import <Foundation/Foundation.h> + +@interface MyObject : NSObject +@end + +@implementation MyObject +@end |