diff options
Diffstat (limited to 'packages/Python/lldbsuite')
795 files changed, 7844 insertions, 5516 deletions
diff --git a/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py b/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py index c038c0726c278..5eff454c3bfb2 100644 --- a/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py +++ b/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py @@ -19,7 +19,7 @@ class DefaultCacheLineSizeTestCase(TestBase): @skipUnlessPlatform(['android']) def test_cache_line_size(self): self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") diff --git a/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py b/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py index dd6dbe0a37ed8..20fd3030721a1 100644 --- a/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py +++ b/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py @@ -16,11 +16,11 @@ from lldbsuite.test import lldbutil class SBDirCheckerCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): TestBase.setUp(self) self.source = 'main.cpp' - self.exe_name = 'a.out' self.generateSource(self.source) @skipIfNoSBHeaders @@ -34,16 +34,19 @@ class SBDirCheckerCase(TestBase): self.skipTest( "LLDB is 64-bit and cannot be linked to 32-bit test program.") - self.buildDriver(self.source, self.exe_name) - self.sanity_check_executable(self.exe_name) + exe_name = self.getBuildArtifact("a.out") + self.buildDriver(self.source, exe_name) + self.sanity_check_executable(exe_name) def sanity_check_executable(self, exe_name): """Sanity check executable compiled from the auto-generated program.""" - exe = os.path.join(os.getcwd(), exe_name) + exe_name = self.getBuildArtifact("a.out") + exe = self.getBuildArtifact(exe_name) self.runCmd("file %s" % exe, CURRENT_EXECUTABLE_SET) + # This test uses a generated source file, so it's in the build directory. self.line_to_break = line_number( - self.source, '// Set breakpoint here.') + self.getBuildArtifact(self.source), '// Set breakpoint here.') env_cmd = "settings set target.env-vars %s=%s" % ( self.dylibPath, self.getLLDBLibraryEnvVal()) diff --git a/packages/Python/lldbsuite/test/api/listeners/TestListener.py b/packages/Python/lldbsuite/test/api/listeners/TestListener.py index 65232f0141026..6b6a37e5a6b8d 100644 --- a/packages/Python/lldbsuite/test/api/listeners/TestListener.py +++ b/packages/Python/lldbsuite/test/api/listeners/TestListener.py @@ -23,10 +23,10 @@ class ListenToModuleLoadedEvents (TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) - self.build() def test_receiving_breakpoint_added(self): """Test that we get breakpoint added events, waiting on event classes on the debugger""" + self.build() my_listener = lldb.SBListener("test_listener") @@ -35,7 +35,7 @@ class ListenToModuleLoadedEvents (TestBase): lldb.SBTarget.GetBroadcasterClassName(), lldb.SBTarget.eBroadcastBitBreakpointChanged) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py b/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py index dc1a0d19f83ef..27bd472caf995 100644 --- a/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py +++ b/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py @@ -18,26 +18,18 @@ class TestMultipleSimultaneousDebuggers(TestBase): mydir = TestBase.compute_mydir(__file__) + # This test case fails non-deterministically. @skipIfNoSBHeaders - @expectedFailureAll(bugnumber="rdar://30564102") - @expectedFailureAll( - archs="i[3-6]86", - bugnumber="multi-process-driver.cpp creates an x64 target") - @expectedFailureAll( - oslist=[ - "windows", - "linux", - "freebsd"], - bugnumber="llvm.org/pr20282") + @expectedFailureAll(bugnumber="llvm.org/pr20282") def test_multiple_debuggers(self): env = {self.dylibPath: self.getLLDBLibraryEnvVal()} - self.driver_exe = os.path.join(os.getcwd(), "multi-process-driver") + self.driver_exe = self.getBuildArtifact("multi-process-driver") self.buildDriver('multi-process-driver.cpp', self.driver_exe) self.addTearDownHook(lambda: os.remove(self.driver_exe)) self.signBinary(self.driver_exe) - self.inferior_exe = os.path.join(os.getcwd(), "testprog") + self.inferior_exe = self.getBuildArtifact("testprog") self.buildDriver('testprog.cpp', self.inferior_exe) self.addTearDownHook(lambda: os.remove(self.inferior_exe)) diff --git a/packages/Python/lldbsuite/test/api/multiple-targets/TestMultipleTargets.py b/packages/Python/lldbsuite/test/api/multiple-targets/TestMultipleTargets.py index decb3fd4f0c59..f4e166955acc9 100644 --- a/packages/Python/lldbsuite/test/api/multiple-targets/TestMultipleTargets.py +++ b/packages/Python/lldbsuite/test/api/multiple-targets/TestMultipleTargets.py @@ -26,7 +26,7 @@ class TestMultipleTargets(TestBase): def test_multiple_targets(self): env = {self.dylibPath: self.getLLDBLibraryEnvVal()} - self.driver_exe = os.path.join(os.getcwd(), "multi-target") + self.driver_exe = self.getBuildArtifact("multi-target") self.buildDriver('main.cpp', self.driver_exe) self.addTearDownHook(lambda: os.remove(self.driver_exe)) self.signBinary(self.driver_exe) diff --git a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py index 0d6a6002d5221..4e550c9c24db7 100644 --- a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py +++ b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py @@ -15,6 +15,8 @@ import subprocess class SBBreakpointCallbackCase(TestBase): + NO_DEBUG_INFO_TESTCASE = True + def setUp(self): TestBase.setUp(self) self.generateSource('driver.cpp') @@ -87,16 +89,20 @@ class SBBreakpointCallbackCase(TestBase): self.inferior = 'inferior_program' self.buildProgram('inferior.cpp', self.inferior) - self.addTearDownHook(lambda: os.remove(self.inferior)) + self.addTearDownHook(lambda: + os.remove(self.getBuildArtifact(self.inferior))) self.buildDriver(sources, test_name) - self.addTearDownHook(lambda: os.remove(test_name)) + self.addTearDownHook(lambda: + os.remove(self.getBuildArtifact(test_name))) - test_exe = os.path.join(os.getcwd(), test_name) + test_exe = self.getBuildArtifact(test_name) self.signBinary(test_exe) - exe = [test_exe, self.inferior] + exe = [test_exe, self.getBuildArtifact(self.inferior)] env = {self.dylibPath: self.getLLDBLibraryEnvVal()} + if 'LLDB_DEBUGSERVER_PATH' in os.environ: + env['LLDB_DEBUGSERVER_PATH'] = os.environ['LLDB_DEBUGSERVER_PATH'] if self.TraceOn(): print("Running test %s" % " ".join(exe)) check_call(exe, env=env) diff --git a/packages/Python/lldbsuite/test/arm/breakpoint-it/TestBreakpointIt.py b/packages/Python/lldbsuite/test/arm/breakpoint-it/TestBreakpointIt.py index 1abab39b1da3a..30510638f0966 100644 --- a/packages/Python/lldbsuite/test/arm/breakpoint-it/TestBreakpointIt.py +++ b/packages/Python/lldbsuite/test/arm/breakpoint-it/TestBreakpointIt.py @@ -21,7 +21,7 @@ class TestBreakpointIt(TestBase): @skipIf(archs=no_match(["arm"])) def test_false(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("target create %s" % exe) lldbutil.run_break_set_by_symbol(self, "bkpt_false", @@ -34,7 +34,7 @@ class TestBreakpointIt(TestBase): @skipIf(archs=no_match(["arm"])) def test_true(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("target create %s" % exe) bpid = lldbutil.run_break_set_by_symbol(self, "bkpt_true", diff --git a/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile new file mode 100644 index 0000000000000..ea79c55cd4a9b --- /dev/null +++ b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS = -mthumb + +include $(LEVEL)/Makefile.rules
\ No newline at end of file diff --git a/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py new file mode 100644 index 0000000000000..f020a65385257 --- /dev/null +++ b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py @@ -0,0 +1,35 @@ +""" +Test that breakpoints correctly work in an thumb function in an arbitrary +named codesection. +""" +from __future__ import print_function + + +import lldb +import os +import time +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestBreakpointThumbCodesection(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIf(archs=no_match(["arm"])) + def test_breakpoint(self): + self.build() + exe = self.getBuildArtifact("a.out") + line = line_number('main.c', '// Set break point at this line.') + + self.runCmd("target create %s" % exe) + bpid = lldbutil.run_break_set_by_file_and_line(self, "main.c", line) + + self.runCmd("run") + + self.assertIsNotNone(lldbutil.get_one_thread_stopped_at_breakpoint_id( + self.process(), bpid), "Process is not stopped at breakpoint") + + self.process().Continue() + self.assertEqual(self.process().GetState(), lldb.eStateExited, PROCESS_EXITED) diff --git a/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c new file mode 100644 index 0000000000000..38ea7be6bfcd2 --- /dev/null +++ b/packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/main.c @@ -0,0 +1,8 @@ +__attribute__((section("__codesection"))) +int f(int a) { + return a + 1; // Set break point at this line. +} + +int main() { + return f(10); +} diff --git a/packages/Python/lldbsuite/test/arm/emulation/TestEmulations.py b/packages/Python/lldbsuite/test/arm/emulation/TestEmulations.py index 4ddda525537ce..8e9244f3a3e98 100644 --- a/packages/Python/lldbsuite/test/arm/emulation/TestEmulations.py +++ b/packages/Python/lldbsuite/test/arm/emulation/TestEmulations.py @@ -19,8 +19,7 @@ class ARMEmulationTestCase(TestBase): @no_debug_info_test def test_thumb_emulations(self): - current_dir = os.getcwd() - test_dir = os.path.join(current_dir, "new-test-files") + test_dir = os.path.join(self.getSourceDir(), "new-test-files") files = os.listdir(test_dir) thumb_files = list() for f in files: @@ -33,8 +32,7 @@ class ARMEmulationTestCase(TestBase): @no_debug_info_test def test_arm_emulations(self): - current_dir = os.getcwd() - test_dir = os.path.join(current_dir, "new-test-files") + test_dir = os.path.join(self.getSourceDir(), "new-test-files") files = os.listdir(test_dir) arm_files = list() for f in files: diff --git a/packages/Python/lldbsuite/test/bench-history b/packages/Python/lldbsuite/test/bench-history deleted file mode 100644 index 471332b252212..0000000000000 --- a/packages/Python/lldbsuite/test/bench-history +++ /dev/null @@ -1,206 +0,0 @@ -config: MacBook Pro (10.7.2) - 2.8 GHz Intel Core 2 Duo - 4 GB 1067 MHz DDR3 - -r142707 (Oct 21, 2011): -[17:45:55] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.104274 (Laps: 30, Total Elapsed Time: 3.128214) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102216 (Laps: 30, Total Elapsed Time: 3.066470) -lldb frame variable benchmark: Avg: 1.649162 (Laps: 20, Total Elapsed Time: 32.983245) -lldb stepping benchmark: Avg: 0.104409 (Laps: 50, Total Elapsed Time: 5.220461) -lldb expr cmd benchmark: Avg: 0.206774 (Laps: 25, Total Elapsed Time: 5.169350) -lldb disassembly benchmark: Avg: 0.089086 (Laps: 10, Total Elapsed Time: 0.890859) - -r142868 (Oct 24, 2011): -[15:53:34] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.105384 (Laps: 30, Total Elapsed Time: 3.161530) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102334 (Laps: 30, Total Elapsed Time: 3.070012) -lldb frame variable benchmark: Avg: 1.661701 (Laps: 20, Total Elapsed Time: 33.234026) -lldb stepping benchmark: Avg: 0.107101 (Laps: 50, Total Elapsed Time: 5.355043) -lldb expr cmd benchmark: Avg: 0.209475 (Laps: 25, Total Elapsed Time: 5.236863) -lldb disassembly benchmark: Avg: 0.005543 (Laps: 10, Total Elapsed Time: 0.055426) -[16:09:20] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103826 (Laps: 30, Total Elapsed Time: 3.114768) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102312 (Laps: 30, Total Elapsed Time: 3.069371) -lldb frame variable benchmark: Avg: 1.602898 (Laps: 20, Total Elapsed Time: 32.057950) -lldb stepping benchmark: Avg: 0.104091 (Laps: 50, Total Elapsed Time: 5.204557) -lldb expr cmd benchmark: Avg: 0.207095 (Laps: 25, Total Elapsed Time: 5.177363) -lldb disassembly benchmark: Avg: 0.001531 (Laps: 10, Total Elapsed Time: 0.015311) - -r143065 (Oct 26, 2011): -# Establish a baseline by using a fixed lldb executable as the inferior program -# for the lldb debugger to operate on. The fixed lldb executable corresponds to -# r142902. -[15:50:34] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103774 (Laps: 30, Total Elapsed Time: 3.113226) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102230 (Laps: 30, Total Elapsed Time: 3.066896) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.448635 (Laps: 30, Total Elapsed Time: 13.459048) -lldb frame variable benchmark: Avg: 1.615647 (Laps: 20, Total Elapsed Time: 32.312934) -lldb stepping benchmark: Avg: 0.138386 (Laps: 50, Total Elapsed Time: 6.919313) -lldb expr cmd benchmark: Avg: 0.218967 (Laps: 25, Total Elapsed Time: 5.474171) -lldb disassembly benchmark: Avg: 0.092677 (Laps: 10, Total Elapsed Time: 0.926766) - -# With patch to lldbbench.py to display min and max of samples. -[17:27:09] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103625 (Laps: 30, Total Elapsed Time: 3.108748, min=0.101225, max=0.136308) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102321 (Laps: 30, Total Elapsed Time: 3.069623, min=0.101270, max=0.102824) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.445943 (Laps: 30, Total Elapsed Time: 13.378290, min=0.438535, max=0.475691) -lldb frame variable benchmark: Avg: 1.612034 (Laps: 20, Total Elapsed Time: 32.240689, min=1.591328, max=1.649720) -lldb stepping benchmark: Avg: 0.155064 (Laps: 50, Total Elapsed Time: 7.753182, min=0.101287, max=2.028978) -lldb expr cmd benchmark: Avg: 0.206160 (Laps: 25, Total Elapsed Time: 5.154005, min=0.203282, max=0.224982) -lldb disassembly benchmark: Avg: 0.032946 (Laps: 10, Total Elapsed Time: 0.329464, min=0.031380, max=0.039198) - -r143118 (Oct 27, 2011): -# No performance regression. -[11:30:10] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.109056 (Laps: 30, Total Elapsed Time: 3.271690, min=0.101212, max=0.296496) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102844 (Laps: 30, Total Elapsed Time: 3.085306, min=0.101028, max=0.112504) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.467196 (Laps: 30, Total Elapsed Time: 14.015870, min=0.430639, max=1.059366) -lldb frame variable benchmark: Avg: 1.615098 (Laps: 20, Total Elapsed Time: 32.301958, min=1.599064, max=1.665124) -lldb stepping benchmark: Avg: 0.158506 (Laps: 50, Total Elapsed Time: 7.925285, min=0.101469, max=1.724667) -lldb expr cmd benchmark: Avg: 0.232584 (Laps: 25, Total Elapsed Time: 5.814609, min=0.202931, max=0.782470) -lldb disassembly benchmark: Avg: 0.090124 (Laps: 10, Total Elapsed Time: 0.901241, min=0.087497, max=0.099313) -[11:37:23] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103782 (Laps: 30, Total Elapsed Time: 3.113456, min=0.101887, max=0.136767) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102348 (Laps: 30, Total Elapsed Time: 3.070431, min=0.101648, max=0.102756) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.445628 (Laps: 30, Total Elapsed Time: 13.368829, min=0.438276, max=0.455466) -lldb frame variable benchmark: Avg: 1.583635 (Laps: 20, Total Elapsed Time: 31.672710, min=0.133858, max=2.073698) -lldb stepping benchmark: Avg: 0.157824 (Laps: 50, Total Elapsed Time: 7.891186, min=0.101352, max=2.172388) -lldb expr cmd benchmark: Avg: 0.207600 (Laps: 25, Total Elapsed Time: 5.189992, min=0.203037, max=0.241189) -lldb disassembly benchmark: Avg: 0.006725 (Laps: 10, Total Elapsed Time: 0.067249, min=0.002470, max=0.042690) - -r143199 (Oct 28, 2011): -# No performance regression. -[11:11:54] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.104717 (Laps: 30, Total Elapsed Time: 3.141521, min=0.101881, max=0.162480) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.116985 (Laps: 30, Total Elapsed Time: 3.509554, min=0.101890, max=0.537634) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.462864 (Laps: 30, Total Elapsed Time: 13.885922, min=0.434867, max=0.877184) -lldb frame variable benchmark: Avg: 1.749605 (Laps: 20, Total Elapsed Time: 34.992090, min=1.604043, max=2.365440) -lldb stepping benchmark: Avg: 0.147439 (Laps: 50, Total Elapsed Time: 7.371955, min=0.101088, max=2.360912) -lldb expr cmd benchmark: Avg: 0.210252 (Laps: 25, Total Elapsed Time: 5.256302, min=0.202591, max=0.258185) -lldb disassembly benchmark: Avg: 0.028243 (Laps: 10, Total Elapsed Time: 0.282434, min=0.027451, max=0.031222) -[11:16:16] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103913 (Laps: 30, Total Elapsed Time: 3.117384, min=0.101510, max=0.136605) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102452 (Laps: 30, Total Elapsed Time: 3.073559, min=0.101508, max=0.105250) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.461532 (Laps: 30, Total Elapsed Time: 13.845950, min=0.436977, max=0.676502) -lldb frame variable benchmark: Avg: 1.640990 (Laps: 20, Total Elapsed Time: 32.819801, min=1.583961, max=2.031209) -lldb stepping benchmark: Avg: 0.104966 (Laps: 50, Total Elapsed Time: 5.248294, min=0.101296, max=0.240781) -lldb expr cmd benchmark: Avg: 0.211872 (Laps: 25, Total Elapsed Time: 5.296811, min=0.203827, max=0.259524) -lldb disassembly benchmark: Avg: 0.104108 (Laps: 10, Total Elapsed Time: 1.041076, min=0.089751, max=0.227173) - -r143260 -# No performance regression. -[16:51:27] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103818 (Laps: 30, Total Elapsed Time: 3.114534, min=0.101654, max=0.135579) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102786 (Laps: 30, Total Elapsed Time: 3.083594, min=0.101567, max=0.115159) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.444478 (Laps: 30, Total Elapsed Time: 13.334348, min=0.429840, max=0.514523) -lldb frame variable benchmark: Avg: 1.627282 (Laps: 20, Total Elapsed Time: 32.545639, min=1.596098, max=1.768229) -lldb stepping benchmark: Avg: 0.134925 (Laps: 50, Total Elapsed Time: 6.746272, min=0.101132, max=1.743882) -lldb expr cmd benchmark: Avg: 0.209595 (Laps: 25, Total Elapsed Time: 5.239863, min=0.203182, max=0.255394) -lldb disassembly benchmark: Avg: 0.091296 (Laps: 10, Total Elapsed Time: 0.912963, min=0.089690, max=0.103690) -[17:31:27] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.104030 (Laps: 30, Total Elapsed Time: 3.120891, min=0.101980, max=0.136737) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102375 (Laps: 30, Total Elapsed Time: 3.071264, min=0.101454, max=0.103283) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.443155 (Laps: 30, Total Elapsed Time: 13.294637, min=0.434646, max=0.459273) -lldb frame variable benchmark: Avg: 1.608266 (Laps: 20, Total Elapsed Time: 32.165314, min=1.596172, max=1.620366) -lldb stepping benchmark: Avg: 0.104140 (Laps: 50, Total Elapsed Time: 5.207003, min=0.101436, max=0.196166) -lldb expr cmd benchmark: Avg: 0.208264 (Laps: 25, Total Elapsed Time: 5.206604, min=0.204082, max=0.258287) -lldb disassembly benchmark: Avg: 0.091677 (Laps: 10, Total Elapsed Time: 0.916773, min=0.090101, max=0.099648) - -r143359 -# No performance regression. -[13:20:01] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.106920 (Laps: 30, Total Elapsed Time: 3.207593, min=0.101197, max=0.197640) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.147324 (Laps: 30, Total Elapsed Time: 4.419733, min=0.101534, max=0.900991) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.463680 (Laps: 30, Total Elapsed Time: 13.910386, min=0.429071, max=0.872424) -lldb frame variable benchmark: Avg: 1.655778 (Laps: 20, Total Elapsed Time: 33.115570, min=1.597218, max=1.779512) -lldb stepping benchmark: Avg: 0.145967 (Laps: 50, Total Elapsed Time: 7.298373, min=0.101121, max=2.288423) -lldb expr cmd benchmark: Avg: 0.207389 (Laps: 25, Total Elapsed Time: 5.184725, min=0.203226, max=0.240773) -lldb disassembly benchmark: Avg: 0.091902 (Laps: 10, Total Elapsed Time: 0.919019, min=0.088413, max=0.115076) -[13:24:24] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.150258 (Laps: 30, Total Elapsed Time: 4.507753, min=0.101110, max=1.296165) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.192823 (Laps: 30, Total Elapsed Time: 5.784686, min=0.101897, max=0.697168) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.451879 (Laps: 30, Total Elapsed Time: 13.556380, min=0.428884, max=0.536964) -lldb frame variable benchmark: Avg: 1.725232 (Laps: 20, Total Elapsed Time: 34.504649, min=1.596926, max=2.303283) -lldb stepping benchmark: Avg: 0.111959 (Laps: 50, Total Elapsed Time: 5.597941, min=0.101375, max=0.586357) -lldb expr cmd benchmark: Avg: 0.207557 (Laps: 25, Total Elapsed Time: 5.188913, min=0.203918, max=0.241022) -lldb disassembly benchmark: Avg: 0.092959 (Laps: 10, Total Elapsed Time: 0.929594, min=0.089094, max=0.109135) - -r143469 -# No performance regression. -[11:45:27] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.112890 (Laps: 30, Total Elapsed Time: 3.386693, min=0.101696, max=0.414717) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.133955 (Laps: 30, Total Elapsed Time: 4.018643, min=0.101611, max=1.050222) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.470838 (Laps: 30, Total Elapsed Time: 14.125148, min=0.425866, max=1.437070) -lldb frame variable benchmark: Avg: 1.608339 (Laps: 20, Total Elapsed Time: 32.166771, min=1.579538, max=1.721902) -lldb stepping benchmark: Avg: 0.136881 (Laps: 50, Total Elapsed Time: 6.844043, min=0.101149, max=1.835094) -lldb expr cmd benchmark: Avg: 0.207529 (Laps: 25, Total Elapsed Time: 5.188236, min=0.203476, max=0.241281) -lldb disassembly benchmark: Avg: 0.036412 (Laps: 10, Total Elapsed Time: 0.364124, min=0.031895, max=0.069457) -[12:14:54] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103313 (Laps: 30, Total Elapsed Time: 3.099402, min=0.101813, max=0.126989) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102558 (Laps: 30, Total Elapsed Time: 3.076735, min=0.101576, max=0.107419) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.438302 (Laps: 30, Total Elapsed Time: 13.149063, min=0.431972, max=0.449742) -lldb frame variable benchmark: Avg: 1.610409 (Laps: 20, Total Elapsed Time: 32.208184, min=1.575063, max=1.724046) -lldb stepping benchmark: Avg: 0.103874 (Laps: 50, Total Elapsed Time: 5.193698, min=0.101364, max=0.186751) -lldb expr cmd benchmark: Avg: 0.207476 (Laps: 25, Total Elapsed Time: 5.186895, min=0.203365, max=0.240869) -lldb disassembly benchmark: Avg: 0.090917 (Laps: 10, Total Elapsed Time: 0.909167, min=0.089431, max=0.099787) - -r144546 -# Observed possible performance regression in lldb startup delay (run to breakpoint)? -# Need more investigation. -[11:27:23] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.112386 (Laps: 30, Total Elapsed Time: 3.371577, min=0.101772, max=0.393109) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.108774 (Laps: 30, Total Elapsed Time: 3.263209, min=0.101605, max=0.292425) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.529530 (Laps: 30, Total Elapsed Time: 15.885899, min=0.468891, max=1.747227) -lldb frame variable benchmark: Avg: 1.631610 (Laps: 20, Total Elapsed Time: 32.632193, min=1.575342, max=1.775941) -lldb stepping benchmark: Avg: 0.146749 (Laps: 50, Total Elapsed Time: 7.337451, min=0.100780, max=2.165057) -lldb expr cmd benchmark: Avg: 0.217782 (Laps: 25, Total Elapsed Time: 5.444553, min=0.203476, max=0.467801) -lldb disassembly benchmark: Avg: 0.091264 (Laps: 10, Total Elapsed Time: 0.912644, min=0.088928, max=0.101681) -[14:58:21] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.105535 (Laps: 30, Total Elapsed Time: 3.166062, min=0.101935, max=0.147107) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102372 (Laps: 30, Total Elapsed Time: 3.071164, min=0.100945, max=0.102721) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.483826 (Laps: 30, Total Elapsed Time: 14.514786, min=0.471770, max=0.532260) -lldb frame variable benchmark: Avg: 1.576992 (Laps: 20, Total Elapsed Time: 31.539838, min=0.102487, max=2.098732) -lldb stepping benchmark: Avg: 0.102836 (Laps: 50, Total Elapsed Time: 5.141815, min=0.101461, max=0.122378) -lldb expr cmd benchmark: Avg: 0.206334 (Laps: 25, Total Elapsed Time: 5.158355, min=0.203804, max=0.241043) -lldb disassembly benchmark: Avg: 0.033536 (Laps: 10, Total Elapsed Time: 0.335359, min=0.031975, max=0.041612) -[15:01:59] johnny:/Volumes/data/lldb/svn/trunk/test $ - -# Redid the r143469 measurements (svn/regress dir) right before the r145371 measurements (svn/trunk dir) on 10.7.2 (build 11C74). -# The lldb startup delay (run to breakpoint) in avg is not as significant. The min still shows some possible regression. -# The frame variable benchmark shows some possible regression. -[10:51:56] johnny:/Volumes/data/lldb/svn/regress/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.109821 (Laps: 30, Total Elapsed Time: 3.294643, min=0.101836, max=0.297468) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.121465 (Laps: 30, Total Elapsed Time: 3.643950, min=0.100776, max=0.665900) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.501870 (Laps: 30, Total Elapsed Time: 15.056112, min=0.469871, max=0.718775) -lldb frame variable benchmark: Avg: 1.663890 (Laps: 20, Total Elapsed Time: 33.277791, min=1.584265, max=1.999998) -lldb stepping benchmark: Avg: 0.105434 (Laps: 50, Total Elapsed Time: 5.271683, min=0.101120, max=0.256289) -lldb expr cmd benchmark: Avg: 0.240440 (Laps: 25, Total Elapsed Time: 6.011000, min=0.203547, max=0.956405) -lldb disassembly benchmark: Avg: 0.096988 (Laps: 10, Total Elapsed Time: 0.969877, min=0.089511, max=0.147797) -[10:55:38] johnny:/Volumes/data/lldb/svn/regress/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.107368 (Laps: 30, Total Elapsed Time: 3.221026, min=0.101374, max=0.163785) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.153588 (Laps: 30, Total Elapsed Time: 4.607645, min=0.101554, max=0.776372) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.510726 (Laps: 30, Total Elapsed Time: 15.321779, min=0.468395, max=0.643357) -lldb frame variable benchmark: Avg: 1.715136 (Laps: 20, Total Elapsed Time: 34.302718, min=1.527872, max=3.125777) -lldb stepping benchmark: Avg: 0.116140 (Laps: 50, Total Elapsed Time: 5.807012, min=0.100857, max=0.796673) -lldb expr cmd benchmark: Avg: 0.206397 (Laps: 25, Total Elapsed Time: 5.159914, min=0.203491, max=0.241283) -lldb disassembly benchmark: Avg: 0.036542 (Laps: 10, Total Elapsed Time: 0.365422, min=0.031872, max=0.060183) -[10:59:43] johnny:/Volumes/data/lldb/svn/regress/test $ pushd +1 -/Volumes/data/lldb/svn/trunk/test /Volumes/data/lldb/llvm /Volumes/data/lldb/svn/regress/test -[10:59:48] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103919 (Laps: 30, Total Elapsed Time: 3.117560, min=0.101766, max=0.137548) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.102705 (Laps: 30, Total Elapsed Time: 3.081165, min=0.101311, max=0.114192) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.504830 (Laps: 30, Total Elapsed Time: 15.144906, min=0.483528, max=0.627122) -lldb frame variable benchmark: Avg: 1.924774 (Laps: 20, Total Elapsed Time: 38.495475, min=1.798745, max=2.248269) -lldb stepping benchmark: Avg: 0.102595 (Laps: 50, Total Elapsed Time: 5.129757, min=0.100690, max=0.125930) -lldb expr cmd benchmark: Avg: 0.205395 (Laps: 25, Total Elapsed Time: 5.134883, min=0.202864, max=0.210484) -lldb disassembly benchmark: Avg: 0.033576 (Laps: 10, Total Elapsed Time: 0.335765, min=0.032021, max=0.039222) -[11:03:46] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' -lldb startup delay (create fresh target) benchmark: Avg: 0.103371 (Laps: 30, Total Elapsed Time: 3.101121, min=0.101556, max=0.127819) -lldb startup delay (set first breakpoint) benchmark: Avg: 0.103174 (Laps: 30, Total Elapsed Time: 3.095230, min=0.101763, max=0.114733) -lldb startup delay (run to breakpoint) benchmark: Avg: 0.513848 (Laps: 30, Total Elapsed Time: 15.415439, min=0.490004, max=0.748310) -lldb frame variable benchmark: Avg: 1.906068 (Laps: 20, Total Elapsed Time: 38.121364, min=1.872328, max=2.044472) -lldb stepping benchmark: Avg: 0.254817 (Laps: 50, Total Elapsed Time: 12.740872, min=0.100743, max=7.628899) -lldb expr cmd benchmark: Avg: 0.207850 (Laps: 25, Total Elapsed Time: 5.196255, min=0.203986, max=0.257482) -lldb disassembly benchmark: Avg: 0.092003 (Laps: 10, Total Elapsed Time: 0.920026, min=0.089568, max=0.100374) -[11:07:53] johnny:/Volumes/data/lldb/svn/trunk/test $ diff --git a/packages/Python/lldbsuite/test/bench.py b/packages/Python/lldbsuite/test/bench.py index 5a0fec7534a84..41d44bad987ef 100644 --- a/packages/Python/lldbsuite/test/bench.py +++ b/packages/Python/lldbsuite/test/bench.py @@ -10,8 +10,6 @@ test driver. Use the following to get only the benchmark results in your terminal output: ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' - -See also bench-history. """ from __future__ import print_function diff --git a/packages/Python/lldbsuite/test/benchmarks/continue/TestBenchmarkContinue.py b/packages/Python/lldbsuite/test/benchmarks/continue/TestBenchmarkContinue.py index 74336693bcb29..acc09224050d0 100644 --- a/packages/Python/lldbsuite/test/benchmarks/continue/TestBenchmarkContinue.py +++ b/packages/Python/lldbsuite/test/benchmarks/continue/TestBenchmarkContinue.py @@ -30,7 +30,8 @@ class TestBenchmarkContinue(BenchBase): def data_formatter_commands(self): """Benchmark different ways to continue a process""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file "+self.getBuildArtifact("a.out"), + CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/benchmarks/expression/TestExpressionCmd.py b/packages/Python/lldbsuite/test/benchmarks/expression/TestExpressionCmd.py index a9899d93bf030..064e7b3f52091 100644 --- a/packages/Python/lldbsuite/test/benchmarks/expression/TestExpressionCmd.py +++ b/packages/Python/lldbsuite/test/benchmarks/expression/TestExpressionCmd.py @@ -39,7 +39,7 @@ class ExpressionEvaluationCase(BenchBase): def run_lldb_repeated_exprs(self, exe_name, count): import pexpect - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Set self.child_prompt, which is "(lldb) ". self.child_prompt = '(lldb) ' diff --git a/packages/Python/lldbsuite/test/benchmarks/expression/TestRepeatedExprs.py b/packages/Python/lldbsuite/test/benchmarks/expression/TestRepeatedExprs.py index a223d2cf1fa7d..dcbd36cc13878 100644 --- a/packages/Python/lldbsuite/test/benchmarks/expression/TestRepeatedExprs.py +++ b/packages/Python/lldbsuite/test/benchmarks/expression/TestRepeatedExprs.py @@ -44,7 +44,7 @@ class RepeatedExprsCase(BenchBase): def run_lldb_repeated_exprs(self, exe_name, count): import pexpect - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Set self.child_prompt, which is "(lldb) ". self.child_prompt = '(lldb) ' @@ -94,7 +94,7 @@ class RepeatedExprsCase(BenchBase): def run_gdb_repeated_exprs(self, exe_name, count): import pexpect - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Set self.child_prompt, which is "(gdb) ". self.child_prompt = '(gdb) ' diff --git a/packages/Python/lldbsuite/test/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py b/packages/Python/lldbsuite/test/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py index 659382e7311bb..4ebb111c80261 100644 --- a/packages/Python/lldbsuite/test/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py +++ b/packages/Python/lldbsuite/test/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py @@ -30,7 +30,8 @@ class TestBenchmarkLibcxxList(BenchBase): def data_formatter_commands(self): """Benchmark the std::list data formatter (libc++)""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), + CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py b/packages/Python/lldbsuite/test/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py index 343f93d95c4e2..0c50661c5c709 100644 --- a/packages/Python/lldbsuite/test/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py +++ b/packages/Python/lldbsuite/test/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py @@ -30,7 +30,8 @@ class TestBenchmarkLibcxxMap(BenchBase): def data_formatter_commands(self): """Benchmark the std::map data formatter (libc++)""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " +self.getBuildArtifact("a.out"), + CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/concurrent_base.py b/packages/Python/lldbsuite/test/concurrent_base.py index 4a7ae0b9c2791..574b305afcbe3 100644 --- a/packages/Python/lldbsuite/test/concurrent_base.py +++ b/packages/Python/lldbsuite/test/concurrent_base.py @@ -32,13 +32,12 @@ class ConcurrentEventsBase(TestBase): super(ConcurrentEventsBase, self).setUp() # Find the line number for our breakpoint. self.filename = 'main.cpp' - source_relpath = os.path.join(os.path.pardir, self.filename) self.thread_breakpoint_line = line_number( - source_relpath, '// Set breakpoint here') + self.filename, '// Set breakpoint here') self.setup_breakpoint_line = line_number( - source_relpath, '// Break here and adjust num') + self.filename, '// Break here and adjust num') self.finish_breakpoint_line = line_number( - source_relpath, '// Break here and verify one thread is active') + self.filename, '// Break here and verify one thread is active') def describe_threads(self): ret = [] @@ -114,7 +113,7 @@ class ConcurrentEventsBase(TestBase): watchpoint_func. The inferior is continued until exit or a crash takes place, and the number of events seen by LLDB is verified to match the expected number of events. """ - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Get the target diff --git a/packages/Python/lldbsuite/test/configuration.py b/packages/Python/lldbsuite/test/configuration.py index a49948c020507..94781050dc4b8 100644 --- a/packages/Python/lldbsuite/test/configuration.py +++ b/packages/Python/lldbsuite/test/configuration.py @@ -24,40 +24,6 @@ import unittest2 import lldbsuite -def __setCrashInfoHook_Mac(text): - from . import crashinfo - crashinfo.setCrashReporterDescription(text) - - -def setupCrashInfoHook(): - if platform.system() == "Darwin": - from . import lock - test_dir = os.environ['LLDB_TEST'] - if not test_dir or not os.path.exists(test_dir): - return - dylib_lock = os.path.join(test_dir, "crashinfo.lock") - dylib_src = os.path.join(test_dir, "crashinfo.c") - dylib_dst = os.path.join(test_dir, "crashinfo.so") - try: - compile_lock = lock.Lock(dylib_lock) - compile_lock.acquire() - if not os.path.isfile(dylib_dst) or os.path.getmtime( - dylib_dst) < os.path.getmtime(dylib_src): - # we need to compile - cmd = "SDKROOT= xcrun clang %s -o %s -framework Python -Xlinker -dylib" % ( - dylib_src, dylib_dst) - if subprocess.call( - cmd, shell=True) != 0 or not os.path.isfile(dylib_dst): - raise Exception('command failed: "{}"'.format(cmd)) - finally: - compile_lock.release() - del compile_lock - - setCrashInfoHook = __setCrashInfoHook_Mac - - else: - pass - # The test suite. suite = unittest2.TestSuite() @@ -141,6 +107,9 @@ lldb_platform_name = None lldb_platform_url = None lldb_platform_working_dir = None +# The base directory in which the tests are being built. +test_build_dir = None + # Parallel execution settings is_inferior_test_runner = False multiprocess_test_subdir = None @@ -164,10 +133,6 @@ rerun_max_file_threhold = 0 # same base name. all_tests = set() -# safe default -setCrashInfoHook = lambda x: None - - def shouldSkipBecauseOfCategories(test_categories): if useCategories: if len(test_categories) == 0 or len( diff --git a/packages/Python/lldbsuite/test/crashinfo.c b/packages/Python/lldbsuite/test/crashinfo.c deleted file mode 100644 index 19013468bb260..0000000000000 --- a/packages/Python/lldbsuite/test/crashinfo.c +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************** - The LLVM Compiler Infrastructure - - This file is distributed under the University of Illinois Open Source - License. See LICENSE.TXT for details. - ****************************************************************************** - -* This C file vends a simple interface to set the Application Specific Info -* on Mac OS X through Python. To use, compile as a dylib, import crashinfo -* and call crashinfo.setCrashReporterDescription("hello world") -* The testCrashReporterDescription() API is simply there to let you test that this -* is doing what it is intended to do without having to actually cons up a crash -******************************************************************************/ - -#include <Python/Python.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -void *__crashreporter_info__ = NULL; - -asm(".desc ___crashreporter_info__, 0x10"); - -static PyObject* setCrashReporterDescription(PyObject* self, PyObject* string) -{ - if (__crashreporter_info__) - { - free(__crashreporter_info__); - __crashreporter_info__ = NULL; - } - - if (string && PyString_Check(string)) - { - Py_ssize_t size = PyString_Size(string); - char* data = PyString_AsString(string); - if (size > 0 && data) - { - ++size; // Include the NULL terminateor in allocation and memcpy() - __crashreporter_info__ = malloc(size); - memcpy(__crashreporter_info__, data, size); - return Py_True; - } - } - return Py_False; -} - -static PyObject* testCrashReporterDescription(PyObject*self, PyObject* arg) -{ - int* ptr = 0; - *ptr = 1; - return Py_None; -} - -static PyMethodDef crashinfo_methods[] = { - {"setCrashReporterDescription", setCrashReporterDescription, METH_O}, - {"testCrashReporterDescription", testCrashReporterDescription, METH_O}, - {NULL, NULL} -}; - -void initcrashinfo() -{ - (void) Py_InitModule("crashinfo", crashinfo_methods); -} - diff --git a/packages/Python/lldbsuite/test/darwin_log.py b/packages/Python/lldbsuite/test/darwin_log.py index 3207ef0bccd8c..8756eca3016a7 100644 --- a/packages/Python/lldbsuite/test/darwin_log.py +++ b/packages/Python/lldbsuite/test/darwin_log.py @@ -162,7 +162,7 @@ class DarwinLogTestBase(lldbtest.TestBase): if enable_options is not None and len(enable_options) > 0: enable_cmd += ' ' + ' '.join(enable_options) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.run_lldb_to_breakpoint(exe, self.source, self.line, enable_command=enable_cmd, settings_commands=settings_commands) @@ -346,7 +346,7 @@ class DarwinLogEventBasedTestBase(lldbtest.TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -382,7 +382,7 @@ class DarwinLogEventBasedTestBase(lldbtest.TestBase): # self.runCmd("log enable lldb process") # Launch the process - doesn't stop at entry. - process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, self.getBuildDir()) self.assertIsNotNone(process, lldbtest.PROCESS_IS_VALID) # Keep track of whether we're tracing output. diff --git a/packages/Python/lldbsuite/test/decorators.py b/packages/Python/lldbsuite/test/decorators.py index 95455f715cdc1..1fdfd2caac002 100644 --- a/packages/Python/lldbsuite/test/decorators.py +++ b/packages/Python/lldbsuite/test/decorators.py @@ -4,11 +4,13 @@ from __future__ import print_function # System modules from distutils.version import LooseVersion, StrictVersion from functools import wraps +import inspect import os import platform import re import sys import tempfile +import subprocess # Third-party modules import six @@ -20,6 +22,7 @@ import use_lldb_suite import lldb from . import configuration from . import test_categories +from . import lldbtest_config from lldbsuite.test_event.event_builder import EventBuilder from lldbsuite.support import funcutils from lldbsuite.test import lldbplatform @@ -170,7 +173,7 @@ def _decorateTest(mode, skip_for_arch = _match_decorator_property( archs, self.getArchitecture()) skip_for_debug_info = _match_decorator_property( - debug_info, self.debug_info) + debug_info, self.getDebugInfo()) skip_for_triple = _match_decorator_property( triple, lldb.DBG.GetSelectedPlatform().GetTriple()) skip_for_remote = _match_decorator_property( @@ -303,9 +306,13 @@ def add_test_categories(cat): if isinstance(func, type) and issubclass(func, unittest2.TestCase): raise Exception( "@add_test_categories can only be used to decorate a test method") - if hasattr(func, "categories"): - cat.extend(func.categories) - func.categories = cat + try: + if hasattr(func, "categories"): + cat.extend(func.categories) + setattr(func, "categories", cat) + except AttributeError: + raise Exception('Cannot assign categories to inline tests.') + return func return impl @@ -337,6 +344,28 @@ def no_debug_info_test(func): wrapper.__no_debug_info_test__ = True return wrapper +def apple_simulator_test(platform): + """ + Decorate the test as a test requiring a simulator for a specific platform. + + Consider that a simulator is available if you have the corresponding SDK installed. + The SDK identifiers for simulators are iphonesimulator, appletvsimulator, watchsimulator + """ + def should_skip_simulator_test(): + if lldbplatformutil.getHostPlatform() != 'darwin': + return "simulator tests are run only on darwin hosts" + try: + DEVNULL = open(os.devnull, 'w') + output = subprocess.check_output(["xcodebuild", "-showsdks"], stderr=DEVNULL) + if re.search('%ssimulator' % platform, output): + return None + else: + return "%s simulator is not supported on this system." % platform + except subprocess.CalledProcessError: + return "%s is not supported on this system (xcodebuild failed)." % feature + + return skipTestIfFn(should_skip_simulator_test) + def debugserver_test(func): """Decorate the item as a debugserver test.""" @@ -428,15 +457,9 @@ def expectedFlakey(expected_fn, bugnumber=None): return expectedFailure_impl -def expectedFlakeyDwarf(bugnumber=None): - def fn(self): - return self.debug_info == "dwarf" - return expectedFlakey(fn, bugnumber) - - def expectedFlakeyDsym(bugnumber=None): def fn(self): - return self.debug_info == "dwarf" + return self.getDebugInfo() == "dwarf" return expectedFlakey(fn, bugnumber) @@ -468,27 +491,6 @@ def expectedFlakeyNetBSD(bugnumber=None, compilers=None): return expectedFlakeyOS(['netbsd'], bugnumber, compilers) -def expectedFlakeyCompiler(compiler, compiler_version=None, bugnumber=None): - if compiler_version is None: - compiler_version = ['=', None] - - def fn(self): - return compiler in self.getCompiler() and self.expectedCompilerVersion(compiler_version) - return expectedFlakey(fn, bugnumber) - -# @expectedFlakeyClang('bugnumber', ['<=', '3.4']) - - -def expectedFlakeyClang(bugnumber=None, compiler_version=None): - return expectedFlakeyCompiler('clang', compiler_version, bugnumber) - -# @expectedFlakeyGcc('bugnumber', ['<=', '3.4']) - - -def expectedFlakeyGcc(bugnumber=None, compiler_version=None): - return expectedFlakeyCompiler('gcc', compiler_version, bugnumber) - - def expectedFlakeyAndroid(bugnumber=None, api_levels=None, archs=None): return expectedFlakey( _skip_for_android( @@ -497,6 +499,11 @@ def expectedFlakeyAndroid(bugnumber=None, api_levels=None, archs=None): archs), bugnumber) +def skipIfOutOfTreeDebugserver(func): + """Decorate the item to skip tests if using an out-of-tree debugserver.""" + def is_out_of_tree_debugserver(): + return "out-of-tree debugserver" if lldbtest_config.out_of_tree_debugserver else None + return skipTestIfFn(is_out_of_tree_debugserver)(func) def skipIfRemote(func): """Decorate the item to skip tests if testing remotely.""" @@ -518,7 +525,7 @@ def skipIfNoSBHeaders(func): 'LLDB.h') if os.path.exists(header): return None - + header = os.path.join( os.environ["LLDB_SRC"], "include", @@ -667,6 +674,18 @@ def skipIfTargetAndroid(api_levels=None, archs=None): api_levels, archs)) +def skipUnlessSupportedTypeAttribute(attr): + """Decorate the item to skip test unless Clang supports type __attribute__(attr).""" + def compiler_doesnt_support_struct_attribute(self): + compiler_path = self.getCompiler() + f = tempfile.NamedTemporaryFile() + cmd = [self.getCompiler(), "-x", "c++", "-c", "-o", f.name, "-"] + p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + stdout, stderr = p.communicate('struct __attribute__((%s)) Test {};'%attr) + if attr in stderr: + return "Compiler does not support attribute %s"%(attr) + return None + return skipTestIfFn(compiler_doesnt_support_struct_attribute) def skipUnlessThreadSanitizer(func): """Decorate the item to skip test unless Clang -fsanitize=thread is supported.""" @@ -696,7 +715,7 @@ def skipUnlessUndefinedBehaviorSanitizer(func): def is_compiler_clang_with_ubsan(self): # Write out a temp file which exhibits UB. - inputf = tempfile.NamedTemporaryFile(suffix='.c') + inputf = tempfile.NamedTemporaryFile(suffix='.c', mode='w') inputf.write('int main() { int x = 0; return x / x; }\n') inputf.flush() @@ -755,3 +774,39 @@ def skipUnlessAddressSanitizer(func): return "Compiler cannot compile with -fsanitize=address" return None return skipTestIfFn(is_compiler_with_address_sanitizer)(func) + +def skipIfXmlSupportMissing(func): + config = lldb.SBDebugger.GetBuildConfiguration() + xml = config.GetValueForKey("xml") + + fail_value = True # More likely to notice if something goes wrong + have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value) + return unittest2.skipIf(not have_xml, "requires xml support")(func) + +def skipIfLLVMTargetMissing(target): + config = lldb.SBDebugger.GetBuildConfiguration() + targets = config.GetValueForKey("targets").GetValueForKey("value") + found = False + for i in range(targets.GetSize()): + if targets.GetItemAtIndex(i).GetStringValue(99) == target: + found = True + break + + return unittest2.skipIf(not found, "requires " + target) + +# Call sysctl on darwin to see if a specified hardware feature is available on this machine. +def skipUnlessFeature(feature): + def is_feature_enabled(self): + if platform.system() == 'Darwin': + try: + DEVNULL = open(os.devnull, 'w') + output = subprocess.check_output(["/usr/sbin/sysctl", feature], stderr=DEVNULL) + # If 'feature: 1' was output, then this feature is available and + # the test should not be skipped. + if re.match('%s: 1\s*' % feature, output): + return None + else: + return "%s is not supported on this system." % feature + except subprocess.CalledProcessError: + return "%s is not supported on this system." % feature + return skipTestIfFn(is_feature_enabled) diff --git a/packages/Python/lldbsuite/test/dosep.py b/packages/Python/lldbsuite/test/dosep.py index 763793af93ed4..616fbf381edfd 100644 --- a/packages/Python/lldbsuite/test/dosep.py +++ b/packages/Python/lldbsuite/test/dosep.py @@ -470,20 +470,19 @@ def call_with_timeout( return process_driver.results -def process_dir(root, files, dotest_argv, inferior_pid_events): - """Examine a directory for tests, and invoke any found within it.""" +def process_file(test_file, dotest_argv, inferior_pid_events): + """Run tests in the specified file in a subprocess and gather the results.""" results = [] - for (base_name, full_test_path) in files: - import __main__ as main - global dotest_options - if dotest_options.p and not re.search(dotest_options.p, base_name): - continue + base_name = os.path.basename(test_file) + import __main__ as main + global dotest_options + if not dotest_options.p or re.search(dotest_options.p, base_name): script_file = main.__file__ command = ([sys.executable, script_file] + dotest_argv + ["-S", dotest_options.session_file_format] + - ["--inferior", "-p", base_name, root]) + ["--inferior", "-p", base_name, os.path.dirname(test_file)]) timeout_name = os.path.basename(os.path.splitext(base_name)[0]).upper() @@ -491,7 +490,7 @@ def process_dir(root, files, dotest_argv, inferior_pid_events): getDefaultTimeout(dotest_options.lldb_platform_name)) results.append(call_with_timeout( - command, timeout, base_name, inferior_pid_events, full_test_path)) + command, timeout, base_name, inferior_pid_events, test_file)) # result = (name, status, passes, failures, unexpected_successes) timed_out = [name for name, status, _, _, _ in results @@ -535,7 +534,7 @@ def process_dir_worker_multiprocessing( while not job_queue.empty(): try: job = job_queue.get(block=False) - result = process_dir(job[0], job[1], job[2], + result = process_file(job[0], job[1], job[2], inferior_pid_events) result_queue.put(result) except queue.Empty: @@ -543,11 +542,11 @@ def process_dir_worker_multiprocessing( pass -def process_dir_worker_multiprocessing_pool(args): - return process_dir(*args) +def process_file_worker_multiprocessing_pool(args): + return process_file(*args) -def process_dir_worker_threading(job_queue, result_queue, inferior_pid_events): +def process_file_worker_threading(job_queue, result_queue, inferior_pid_events): """Worker thread main loop when in threading mode. This one supports the hand-rolled pooling support. @@ -558,25 +557,24 @@ def process_dir_worker_threading(job_queue, result_queue, inferior_pid_events): while not job_queue.empty(): try: job = job_queue.get(block=False) - result = process_dir(job[0], job[1], job[2], - inferior_pid_events) + result = process_file(job[0], job[1], inferior_pid_events) result_queue.put(result) except queue.Empty: # Fine, we're done. pass -def process_dir_worker_threading_pool(args): - return process_dir(*args) +def process_file_worker_threading_pool(args): + return process_file(*args) -def process_dir_mapper_inprocess(args): +def process_file_mapper_inprocess(args): """Map adapter for running the subprocess-based, non-threaded test runner. @param args the process work item tuple @return the test result tuple """ - return process_dir(*args) + return process_file(*args) def collect_active_pids_from_pid_events(event_queue): @@ -646,16 +644,12 @@ def kill_all_worker_threads(workers, inferior_pid_events): worker.join() -def find_test_files_in_dir_tree(dir_root, found_func): - """Calls found_func for all the test files in the given dir hierarchy. +def find_test_files_in_dir_tree(dir_root): + """Returns all the test files in the given dir hierarchy. @param dir_root the path to the directory to start scanning for test files. All files in this directory and all its children directory trees will be searched. - - @param found_func a callable object that will be passed - the parent directory (relative to dir_root) and the list of - test files from within that directory. """ for root, _, files in os.walk(dir_root, topdown=False): def is_test_filename(test_dir, base_filename): @@ -676,12 +670,9 @@ def find_test_files_in_dir_tree(dir_root, found_func): return (base_filename.startswith("Test") and base_filename.endswith(".py")) - tests = [ - (filename, os.path.join(root, filename)) - for filename in files - if is_test_filename(root, filename)] - if tests: - found_func(root, tests) + for f in files: + if is_test_filename(root, f): + yield os.path.join(root, f) def initialize_global_vars_common(num_threads, test_work_items, session_dir, @@ -689,7 +680,7 @@ def initialize_global_vars_common(num_threads, test_work_items, session_dir, global g_session_dir, g_runner_context, total_tests, test_counter global test_name_len - total_tests = sum([len(item[1]) for item in test_work_items]) + total_tests = len(test_work_items) test_counter = multiprocessing.Value('i', 0) test_name_len = multiprocessing.Value('i', 0) g_session_dir = session_dir @@ -949,7 +940,7 @@ def multiprocessing_test_runner(num_threads, test_work_items, session_dir, workers = [] for _ in range(num_threads): worker = multiprocessing.Process( - target=process_dir_worker_multiprocessing, + target=process_file_worker_multiprocessing, args=(output_lock, test_counter, total_tests, @@ -1045,7 +1036,7 @@ def multiprocessing_test_runner_pool(num_threads, test_work_items, session_dir, # Start the map operation (async mode). map_future = pool.map_async( - process_dir_worker_multiprocessing_pool, test_work_items) + process_file_worker_multiprocessing_pool, test_work_items) return map_async_run_loop( map_future, RUNNER_PROCESS_ASYNC_MAP, RESULTS_LISTENER_CHANNEL) @@ -1092,7 +1083,7 @@ def threading_test_runner(num_threads, test_work_items, session_dir, workers = [] for _ in range(num_threads): worker = threading.Thread( - target=process_dir_worker_threading, + target=process_file_worker_threading, args=(job_queue, result_queue, inferior_pid_events)) @@ -1129,7 +1120,7 @@ def threading_test_runner_pool(num_threads, test_work_items, session_dir, pool = multiprocessing.pool.ThreadPool(num_threads) map_future = pool.map_async( - process_dir_worker_threading_pool, test_work_items) + process_file_worker_threading_pool, test_work_items) return map_async_run_loop( map_future, RUNNER_PROCESS_ASYNC_MAP, RESULTS_LISTENER_CHANNEL) @@ -1166,7 +1157,7 @@ def inprocess_exec_test_runner(test_work_items, session_dir, runner_context): socket_thread.start() # Do the work. - test_results = list(map(process_dir_mapper_inprocess, test_work_items)) + test_results = list(map(process_file_mapper_inprocess, test_work_items)) # If we have a listener channel, shut it down here. if RESULTS_LISTENER_CHANNEL is not None: @@ -1183,7 +1174,7 @@ def inprocess_exec_test_runner(test_work_items, session_dir, runner_context): def walk_and_invoke(test_files, dotest_argv, num_workers, test_runner_func): """Invokes the test runner on each test file specified by test_files. - @param test_files a list of (test_subdir, list_of_test_files_in_dir) + @param test_files a list of (test_file, full_path_to_test_file) @param num_workers the number of worker queues working on these test files @param test_runner_func the test runner configured to run the tests @@ -1218,8 +1209,8 @@ def walk_and_invoke(test_files, dotest_argv, num_workers, test_runner_func): # Build the test work items out of the (dir, file_list) entries passed in. test_work_items = [] - for entry in test_files: - test_work_items.append((entry[0], entry[1], dotest_argv, None)) + for test_file in test_files: + test_work_items.append((test_file, dotest_argv, None)) # Convert test work items into test results using whatever # was provided as the test run function. @@ -1533,31 +1524,15 @@ def rerun_tests(test_subdir, tests_for_rerun, dotest_argv, session_dir, # Sort rerun files into subdirectories. print("\nRerunning the following files:") - rerun_files_by_subdir = {} + rerun_files = [] for test_filename in tests_for_rerun.keys(): # Print the file we'll be rerunning test_relative_path = os.path.relpath( test_filename, lldbsuite.lldb_test_root) print(" {}".format(test_relative_path)) - # Store test filenames by subdir. - test_dir = os.path.dirname(test_filename) - test_basename = os.path.basename(test_filename) - if test_dir in rerun_files_by_subdir: - rerun_files_by_subdir[test_dir].append( - (test_basename, test_filename)) - else: - rerun_files_by_subdir[test_dir] = [(test_basename, test_filename)] - - # Break rerun work up by subdirectory. We do this since - # we have an invariant that states only one test file can - # be run at a time in any given subdirectory (related to - # rules around built inferior test program lifecycle). - rerun_work = [] - for files_by_subdir in rerun_files_by_subdir.values(): - rerun_work.append((test_subdir, files_by_subdir)) + rerun_files.append(test_filename) - # Run the work with the serial runner. # Do not update legacy counts, I am getting rid of # them so no point adding complicated merge logic here. rerun_thread_count = 1 @@ -1576,7 +1551,7 @@ def rerun_tests(test_subdir, tests_for_rerun, dotest_argv, session_dir, "function named '{}'".format(rerun_runner_name)) walk_and_invoke( - rerun_work, + rerun_files, dotest_argv, rerun_thread_count, rerun_runner_func) @@ -1675,15 +1650,9 @@ def main(num_threads, test_subdir, test_runner_name, results_formatter): list(runner_strategies_by_name.keys()))) test_runner_func = runner_strategies_by_name[test_runner_name] - # Collect the files on which we'll run the first test run phase. - test_files = [] - find_test_files_in_dir_tree( - test_subdir, lambda tdir, tfiles: test_files.append( - (test_subdir, tfiles))) - # Do the first test run phase. summary_results = walk_and_invoke( - test_files, + find_test_files_in_dir_tree(test_subdir), dotest_argv, num_threads, test_runner_func) diff --git a/packages/Python/lldbsuite/test/dotest.py b/packages/Python/lldbsuite/test/dotest.py index 7d739acba9525..d28c5ef069b7b 100644 --- a/packages/Python/lldbsuite/test/dotest.py +++ b/packages/Python/lldbsuite/test/dotest.py @@ -51,6 +51,8 @@ from ..support import seven def is_exe(fpath): """Returns true if fpath is an executable.""" + if fpath == None: + return False return os.path.isfile(fpath) and os.access(fpath, os.X_OK) @@ -299,12 +301,21 @@ def parseOptionsAndInitTestdirs(): configuration.compiler = candidate break + if args.dsymutil: + os.environ['DSYMUTIL'] = args.dsymutil + elif platform_system == 'Darwin': + os.environ['DSYMUTIL'] = seven.get_command_output( + 'xcrun -find -toolchain default dsymutil') + if args.channels: lldbtest_config.channels = args.channels if args.log_success: lldbtest_config.log_success = args.log_success + if args.out_of_tree_debugserver: + lldbtest_config.out_of_tree_debugserver = args.out_of_tree_debugserver + # Set SDKROOT if we are using an Apple SDK if platform_system == 'Darwin' and args.apple_sdk: os.environ['SDKROOT'] = seven.get_command_output( @@ -332,7 +343,7 @@ def parseOptionsAndInitTestdirs(): configuration.categoriesList = [] if args.skipCategories: - configuration.skipCategories = test_categories.validate( + configuration.skipCategories += test_categories.validate( args.skipCategories, False) if args.E: @@ -472,6 +483,8 @@ def parseOptionsAndInitTestdirs(): configuration.lldb_platform_url = args.lldb_platform_url if args.lldb_platform_working_dir: configuration.lldb_platform_working_dir = args.lldb_platform_working_dir + if args.test_build_dir: + configuration.test_build_dir = args.test_build_dir if args.event_add_entries and len(args.event_add_entries) > 0: entries = {} @@ -621,6 +634,12 @@ def setupSysPath(): os.environ["LLDB_TEST"] = scriptPath + # Set up the root build directory. + builddir = configuration.test_build_dir + if not configuration.test_build_dir: + raise Exception("test_build_dir is not set") + os.environ["LLDB_BUILD"] = os.path.abspath(configuration.test_build_dir) + # Set up the LLDB_SRC environment variable, so that the tests can locate # the LLDB source code. os.environ["LLDB_SRC"] = lldbsuite.lldb_root @@ -1085,6 +1104,39 @@ def checkLibcxxSupport(): print("Libc++ tests will not be run because: " + reason) configuration.skipCategories.append("libc++") +def canRunLibstdcxxTests(): + from lldbsuite.test import lldbplatformutil + + platform = lldbplatformutil.getPlatform() + if platform == "linux": + return True, "libstdcxx always present" + return False, "Don't know how to build with libstdcxx on %s" % platform + +def checkLibstdcxxSupport(): + result, reason = canRunLibstdcxxTests() + if result: + return # libstdcxx supported + if "libstdcxx" in configuration.categoriesList: + return # libstdcxx category explicitly requested, let it run. + print("libstdcxx tests will not be run because: " + reason) + configuration.skipCategories.append("libstdcxx") + +def checkDebugInfoSupport(): + import lldb + + platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] + compiler = configuration.compiler + skipped = [] + for cat in test_categories.debug_info_categories: + if cat in configuration.categoriesList: + continue # Category explicitly requested, let it run. + if test_categories.is_supported_on_platform(cat, platform, compiler): + continue + configuration.skipCategories.append(cat) + skipped.append(cat) + if skipped: + print("Skipping following debug info categories:", skipped) + def run_suite(): # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults # does not exist before proceeding to running the test suite. @@ -1117,7 +1169,6 @@ def run_suite(): signal.signal(signal.SIGINT, signal.SIG_IGN) setupSysPath() - configuration.setupCrashInfoHook() # # If '-l' is specified, do not skip the long running tests. @@ -1174,22 +1225,30 @@ def run_suite(): configuration.lldb_platform_working_dir, 448) # 448 = 0o700 if error.Fail(): raise Exception("making remote directory '%s': %s" % ( - remote_test_dir, error)) + configuration.lldb_platform_working_dir, error)) if not lldb.remote_platform.SetWorkingDirectory( configuration.lldb_platform_working_dir): - raise Exception("failed to set working directory '%s'" % remote_test_dir) + raise Exception("failed to set working directory '%s'" % configuration.lldb_platform_working_dir) lldb.DBG.SetSelectedPlatform(lldb.remote_platform) else: lldb.remote_platform = None configuration.lldb_platform_working_dir = None configuration.lldb_platform_url = None + # Set up the working directory. + # Note that it's not dotest's job to clean this directory. + import lldbsuite.test.lldbutil as lldbutil + build_dir = configuration.test_build_dir + lldbutil.mkdir_p(build_dir) + target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] checkLibcxxSupport() + checkLibstdcxxSupport() + checkDebugInfoSupport() - # Don't do debugserver tests on everything except OS X. + # Don't do debugserver tests on anything except OS X. configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform # Don't do lldb-server (llgs) tests on anything except Linux. diff --git a/packages/Python/lldbsuite/test/dotest_args.py b/packages/Python/lldbsuite/test/dotest_args.py index bc43a6fc04a9f..58190d8c75eeb 100644 --- a/packages/Python/lldbsuite/test/dotest_args.py +++ b/packages/Python/lldbsuite/test/dotest_args.py @@ -83,6 +83,8 @@ def create_parser(): help=textwrap.dedent('''Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged suggestions: do not lump the "-A arch1 -A arch2" together such that the -E option applies to only one of the architectures''')) + group.add_argument('--dsymutil', metavar='dsymutil', dest='dsymutil', help=textwrap.dedent('Specify which dsymutil to use.')) + # Test filtering options group = parser.add_argument_group('Test filtering options') group.add_argument( @@ -127,6 +129,11 @@ def create_parser(): metavar='server-path', help='The path to the debug server executable to use') group.add_argument( + '--out-of-tree-debugserver', + dest='out_of_tree_debugserver', + action='store_true', + help='A flag to indicate an out-of-tree debug server is being used') + group.add_argument( '-s', metavar='name', help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name') @@ -159,6 +166,12 @@ def create_parser(): metavar='Codesigning identity', default='lldb_codesign', help='The codesigning identity to use') + group.add_argument( + '--build-dir', + dest='test_build_dir', + metavar='Test build directory', + default='lldb-test-build.noindex', + help='The root build directory for the tests. It will be removed before running.') # Configuration options group = parser.add_argument_group('Remote platform options') diff --git a/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py b/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py index 8699b31f99298..f2dc5281f1376 100644 --- a/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py +++ b/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py @@ -46,7 +46,7 @@ class DriverBatchModeTest (TestBase): self.setTearDownCleanup() import pexpect - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") prompt = "(lldb) " # Pass CRASH so the process will crash and stop in batch mode. @@ -86,7 +86,7 @@ class DriverBatchModeTest (TestBase): self.setTearDownCleanup() import pexpect - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") prompt = "(lldb) " # Now do it again, and make sure if we don't crash, we quit: @@ -129,7 +129,7 @@ class DriverBatchModeTest (TestBase): self.setTearDownCleanup() import pexpect - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") prompt = "(lldb) " # Finally, start up the process by hand, attach to it, and wait for its completion. diff --git a/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py b/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py deleted file mode 100644 index eb3b0bbf8851d..0000000000000 --- a/packages/Python/lldbsuite/test/example/TestSequenceFunctions.py +++ /dev/null @@ -1,34 +0,0 @@ -"""An example unittest copied from python tutorial.""" - -import random -import unittest -import traceback - - -class SequenceFunctionsTestCase(unittest.TestCase): - - def setUp(self): - # traceback.print_stack() - self.seq = list(range(10)) - - def tearDown(self): - # traceback.print_stack() - pass - - def test_shuffle(self): - # make sure the shuffled sequence does not lose any elements - random.shuffle(self.seq) - self.seq.sort() - self.assertEqual(self.seq, list(range(10))) - - def test_choice(self): - element = random.choice(self.seq) - self.assertTrue(element in self.seq) - - def test_sample(self): - self.assertRaises(ValueError, random.sample, self.seq, 20) - for element in random.sample(self.seq, 5): - self.assertTrue(element in self.seq) - -if __name__ == '__main__': - unittest.main() diff --git a/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py b/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py index 2d4504f7ba423..6a8fb5db5439c 100644 --- a/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py +++ b/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py @@ -32,7 +32,8 @@ class TestExprLookupAnonStructTypedef(TestBase): """Test typedeffed untagged struct arguments for function call expressions""" 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", diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py index 16736f798528a..079ab6d608884 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py @@ -30,7 +30,8 @@ class ExprCommandCallFunctionTestCase(TestBase): def test_with(self): """Test calling std::String member function.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), + CURRENT_EXECUTABLE_SET) # Some versions of GCC encode two locations for the 'return' statement # in main.cpp diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py index a48a38aaf92cb..63511779a9275 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py @@ -31,7 +31,7 @@ class ExprCommandCallStopContinueTestCase(TestBase): def test(self): """Test gathering result from interrupted function call.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) # Some versions of GCC encode two locations for the 'return' statement # in main.cpp diff --git a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py index fda81ae8c3659..ff3bd99ced99c 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py +++ b/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py @@ -37,7 +37,7 @@ class ExprCommandCallUserDefinedFunction(TestBase): self.build() # Set breakpoint in main and run exe - 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/expression_command/call-overridden-method/Makefile b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/Makefile new file mode 100644 index 0000000000000..9d4f3b7f14124 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules + +clean:: + rm -rf $(wildcard *.o *.d *.dSYM) diff --git a/packages/Python/lldbsuite/test/expression_command/call-overridden-method/TestCallOverriddenMethod.py b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/TestCallOverriddenMethod.py new file mode 100644 index 0000000000000..1e61aa9f46e01 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/TestCallOverriddenMethod.py @@ -0,0 +1,49 @@ +""" +Test calling an overriden method. + +Note: + This verifies that LLDB is correctly building the method overrides table. + If this table is not built correctly then calls to overridden methods in + derived classes may generate references to non-existant vtable entries, + as the compiler treats the overridden method as a totally new virtual + method definition. + <rdar://problem/14205774> + +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class ExprCommandCallOverriddenMethod(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.c. + self.line = line_number('main.cpp', '// Set breakpoint here') + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") + def test(self): + """Test calls to overridden methods in derived classes.""" + self.build() + + # Set breakpoint in main and run exe + 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) + + self.runCmd("run", RUN_SUCCEEDED) + + # Test call to method in base class (this should always work as the base + # class method is never an override). + self.expect("expr b->foo()") + + # Test call to overridden method in derived class (this will fail if the + # overrides table is not correctly set up, as Derived::foo will be assigned + # a vtable entry that does not exist in the compiled program). + self.expect("expr d.foo()") diff --git a/packages/Python/lldbsuite/test/expression_command/call-overridden-method/main.cpp b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/main.cpp new file mode 100644 index 0000000000000..54ae705d29785 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/call-overridden-method/main.cpp @@ -0,0 +1,16 @@ +class Base { +public: + virtual ~Base() {} + virtual void foo() {} +}; + +class Derived : public Base { +public: + virtual void foo() {} +}; + +int main() { + Derived d; + Base *b = &d; + return 0; // Set breakpoint here +} diff --git a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py index 445979f5c701d..2f14068747655 100644 --- a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py +++ b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py @@ -49,6 +49,7 @@ class ExprCharTestCase(TestBase): archs=[ "arm", "aarch64", + "powerpc64le", "s390x"], bugnumber="llvm.org/pr23069") @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") diff --git a/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py b/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py index dcfb648ada500..dd31424dbbdc4 100644 --- a/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py +++ b/packages/Python/lldbsuite/test/expression_command/expr-in-syscall/TestExpressionInSyscall.py @@ -22,7 +22,7 @@ class ExprSyscallTestCase(TestBase): self.expr_syscall() def expr_syscall(self): - 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/expression_command/formatters/TestFormatters.py b/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py index c4126a329686d..f14b02bbd7c41 100644 --- a/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py +++ b/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py @@ -43,7 +43,7 @@ class ExprFormattersTestCase(TestBase): self.addTearDownHook(cleanup) """Test expr + formatters for good interoperability.""" - 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, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py b/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py index 894d0bfaa86ea..a5607f1950525 100644 --- a/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py +++ b/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py @@ -17,7 +17,7 @@ class IRInterpreterPHINodesTestCase(TestBase): """Test support for PHI nodes in the IR interpreter.""" 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 first assignment to i diff --git a/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py b/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py index 5c5110b69945b..d8a8038c84541 100644 --- a/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py +++ b/packages/Python/lldbsuite/test/expression_command/ir-interpreter/TestIRInterpreter.py @@ -17,6 +17,7 @@ from lldbsuite.test import lldbutil class IRInterpreterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -34,7 +35,7 @@ class IRInterpreterTestCase(TestBase): """Test the IR interpreter""" 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.c", self.line, num_expected_locations=1, loc_exact=False) @@ -85,3 +86,10 @@ class IRInterpreterTestCase(TestBase): jit_result, "While evaluating " + expression) + + def test_type_conversions(self): + target = self.dbg.GetDummyTarget() + short_val = target.EvaluateExpression("(short)-1") + self.assertEqual(short_val.GetValueAsSigned(), -1) + long_val = target.EvaluateExpression("(long) "+ short_val.GetName()) + self.assertEqual(long_val.GetValueAsSigned(), -1) diff --git a/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py b/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py index aa369ebeff878..7f639a4622018 100644 --- a/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py +++ b/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py @@ -28,7 +28,7 @@ class MultilineExpressionsTestCase(TestBase): """Test that multiline expressions work correctly""" self.build() import pexpect - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") prompt = "(lldb) " # So that the child gets torn down after the test. diff --git a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py index b4e9a8bfeab8b..1dbafc36a82a5 100644 --- a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py +++ b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py @@ -28,7 +28,7 @@ class ExprOptionsTestCase(TestBase): self.main_source = "main.cpp" self.main_source_spec = lldb.SBFileSpec(self.main_source) self.line = line_number('main.cpp', '// breakpoint_in_main') - self.exe = os.path.join(os.getcwd(), "a.out") + self.exe = self.getBuildArtifact("a.out") def test_expr_options(self): """These expression command options should work as expected.""" diff --git a/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py b/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py index e6c9d43adf04c..b6471d0f89722 100644 --- a/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py +++ b/packages/Python/lldbsuite/test/expression_command/persist_objc_pointeetype/TestPersistObjCPointeeType.py @@ -34,7 +34,7 @@ class PersistObjCPointeeType(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - 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.m", self.line, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py b/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py index 118b9f32c4bd4..7b963b5bfcd27 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_ptr_update/TestPersistentPtrUpdate.py @@ -28,7 +28,7 @@ class PersistentPtrUpdateTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd('break set -p here') diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py index 12452a9637720..f4ee1b0fb625d 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestNestedPersistentTypes.py @@ -22,7 +22,7 @@ class NestedPersistentTypesTestCase(TestBase): """Test that nested persistent types work.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --name main") diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py index 3d4df307d1b0c..f56cb11a80d84 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_types/TestPersistentTypes.py @@ -22,7 +22,7 @@ class PersistenttypesTestCase(TestBase): """Test that lldb persistent types works correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --name main") diff --git a/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py b/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py index b6f027964bab0..441a60b5a4636 100644 --- a/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py +++ b/packages/Python/lldbsuite/test/expression_command/persistent_variables/TestPersistentVariables.py @@ -19,7 +19,7 @@ class PersistentVariablesTestCase(TestBase): """Test that lldb persistent variables works correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --source-pattern-regexp break") diff --git a/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py b/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py index 13f8f58564e8b..4530342ea52d6 100644 --- a/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py +++ b/packages/Python/lldbsuite/test/expression_command/po_verbosity/TestPoVerbosity.py @@ -37,7 +37,7 @@ class PoVerbosityTestCase(TestBase): self.addTearDownHook(cleanup) """Test expr + formatters for good interoperability.""" - 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.m", self.line, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/pr35310/Makefile b/packages/Python/lldbsuite/test/expression_command/pr35310/Makefile new file mode 100644 index 0000000000000..8a7102e347af2 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/pr35310/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py b/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py new file mode 100644 index 0000000000000..9cc9df2b22be6 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py @@ -0,0 +1,40 @@ +from __future__ import print_function + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class ExprBug35310(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + self.main_source = "main.cpp" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") + def test_issue35310(self): + """Test invoking functions with non-standard linkage names. + + The GNU abi_tag extension used by libstdc++ is a common source + of these, but they could originate from other reasons as well. + """ + self.build() + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) + frame = thread.GetFrameAtIndex(0) + + value = frame.EvaluateExpression("a.test_abi_tag()") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsSigned(0), 1) + + value = frame.EvaluateExpression("a.test_asm_name()") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsSigned(0), 2) diff --git a/packages/Python/lldbsuite/test/expression_command/pr35310/main.cpp b/packages/Python/lldbsuite/test/expression_command/pr35310/main.cpp new file mode 100644 index 0000000000000..a8e8a5c737a01 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/pr35310/main.cpp @@ -0,0 +1,19 @@ +#include <stdio.h> + +class A { +public: + int __attribute__((abi_tag("cxx11"))) test_abi_tag() { + return 1; + } + int test_asm_name() asm("A_test_asm") { + return 2; + } +}; + +int main(int argc, char **argv) { + A a; + // Break here + a.test_abi_tag(); + a.test_asm_name(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py b/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py index ca43585616e50..0027fc226e377 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_8638051/Test8638051.py @@ -19,7 +19,7 @@ class Radar8638051TestCase(TestBase): """The following expression commands should not crash.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set -n c") diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py b/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py index c4d899cfc1e03..c44cb6fc39dac 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_9531204/TestPrintfAfterUp.py @@ -23,7 +23,7 @@ class Radar9531204TestCase(TestBase): """The evaluating printf(...) after break stop and then up a stack frame.""" 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_symbol( self, 'foo', sym_exact=True, num_expected_locations=1) diff --git a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py index 4fc2463b25a8b..dfef8735071b9 100644 --- a/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py +++ b/packages/Python/lldbsuite/test/expression_command/radar_9673664/TestExprHelpExamples.py @@ -29,7 +29,7 @@ class Radar9673644TestCase(TestBase): """The following expression commands should just work.""" 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/expression_command/rdar42038760/Makefile b/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile new file mode 100644 index 0000000000000..f5a47fcc46ccf --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py b/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py new file mode 100644 index 0000000000000..03424658f3ed3 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), None) diff --git a/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c b/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c new file mode 100644 index 0000000000000..98a957faf8bda --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c @@ -0,0 +1,19 @@ +// Make sure we IR-interpret the expression correctly. + +typedef unsigned int uint32_t; +struct S0 { + signed f2; +}; +static g_463 = 0x1561983AL; +void func_1(void) +{ + struct S0 l_19; + l_19.f2 = 419; + uint32_t l_4037 = 4294967295UL; + l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883']) +} +int main() +{ + func_1(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py index f6938b1ea98b0..c1a1b375e155a 100644 --- a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py +++ b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py @@ -11,23 +11,24 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -def enumerateJITFiles(): - return [f for f in os.listdir(os.getcwd()) if f.startswith("jit")] - -def countJITFiles(): - return len(enumerateJITFiles()) - -def cleanJITFiles(): - for j in enumerateJITFiles(): - os.remove(j) - return - class SaveJITObjectsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + def enumerateJITFiles(self): + return [f for f in os.listdir(self.getBuildDir()) if f.startswith("jit")] + + def countJITFiles(self): + return len(self.enumerateJITFiles()) + + def cleanJITFiles(self): + for j in self.enumerateJITFiles(): + os.remove(j) + return + @expectedFailureAll(oslist=["windows"]) def test_save_jit_objects(self): self.build() + os.chdir(self.getBuildDir()) src_file = "main.c" src_file_spec = lldb.SBFileSpec(src_file) @@ -36,16 +37,17 @@ class SaveJITObjectsTestCase(TestBase): frame = thread.frames[0] - cleanJITFiles() + self.cleanJITFiles() frame.EvaluateExpression("(void*)malloc(0x1)") - self.assertTrue(countJITFiles() == 0, + self.assertTrue(self.countJITFiles() == 0, "No files emitted with save-jit-objects=false") self.runCmd("settings set target.save-jit-objects true") frame.EvaluateExpression("(void*)malloc(0x1)") - jit_files_count = countJITFiles() - cleanJITFiles() + jit_files_count = self.countJITFiles() + self.cleanJITFiles() self.assertTrue(jit_files_count != 0, "At least one file emitted with save-jit-objects=true") process.Kill() + os.chdir(self.getSourceDir()) diff --git a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py index 1cd11a8c2759f..3af7d808e1286 100644 --- a/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py +++ b/packages/Python/lldbsuite/test/expression_command/test/TestExprs.py @@ -45,7 +45,7 @@ class BasicExprCommandsTestCase(TestBase): """These basic expression commands should work as expected.""" 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=False) @@ -107,7 +107,7 @@ class BasicExprCommandsTestCase(TestBase): """Test SBFrame.EvaluateExpression() API for evaluating an expression.""" 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) @@ -208,7 +208,7 @@ class BasicExprCommandsTestCase(TestBase): """Throw some expression commands with quotes at 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, "main.cpp", self.line, num_expected_locations=1, loc_exact=False) diff --git a/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py b/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py index 35ac151a3908c..f5ec4f027866a 100644 --- a/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py +++ b/packages/Python/lldbsuite/test/expression_command/test/TestExprs2.py @@ -31,7 +31,7 @@ class ExprCommands2TestCase(TestBase): """Test some more expression commands.""" 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=False) @@ -43,23 +43,38 @@ class ExprCommands2TestCase(TestBase): startstr="(int *) $0 = 0x") # (int *) $0 = 0x00007fff5fbff258 - # Do anonymous symbols work? - self.expect("expression ((char**)environ)[0]", - startstr="(char *) $1 = 0x") - # (char *) $1 = 0x00007fff5fbff298 "Apple_PubSub_Socket_Render=/tmp/launch-7AEsUD/Render" - # Do return values containing the contents of expression locals work? self.expect("expression int i = 5; i", - startstr="(int) $2 = 5") + startstr="(int) $1 = 5") # (int) $2 = 5 - self.expect("expression $2 + 1", - startstr="(int) $3 = 6") + self.expect("expression $1 + 1", + startstr="(int) $2 = 6") # (int) $3 = 6 # Do return values containing the results of static expressions work? self.expect("expression 20 + 3", - startstr="(int) $4 = 23") + startstr="(int) $3 = 23") # (int) $4 = 5 - self.expect("expression $4 + 1", - startstr="(int) $5 = 24") + self.expect("expression $3 + 1", + startstr="(int) $4 = 24") # (int) $5 = 6 + + @skipIfLinux + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows") + def test_expr_symbols(self): + """Test symbols.""" + self.build() + + 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=False) + + self.runCmd("run", RUN_SUCCEEDED) + + # Do anonymous symbols work? + self.expect("expression ((char**)environ)[0]", + startstr="(char *) $0 = 0x") + # (char *) $1 = 0x00007fff5fbff298 "Apple_PubSub_Socket_Render=/tmp/launch-7AEsUD/Render" diff --git a/packages/Python/lldbsuite/test/expression_command/top-level/Makefile b/packages/Python/lldbsuite/test/expression_command/top-level/Makefile index 48eec5c5d2683..9e35242c72fad 100644 --- a/packages/Python/lldbsuite/test/expression_command/top-level/Makefile +++ b/packages/Python/lldbsuite/test/expression_command/top-level/Makefile @@ -7,7 +7,7 @@ include $(LEVEL)/Makefile.rules a.out: dummy dummy: - $(MAKE) -f dummy.mk + $(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk clean:: - $(MAKE) -f dummy.mk clean + $(MAKE) VPATH=$(VPATH) -I $(SRCDIR) -f $(SRCDIR)/dummy.mk clean diff --git a/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py b/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py index dfe95a1a9fa7a..1a8a619b0ed22 100644 --- a/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py +++ b/packages/Python/lldbsuite/test/expression_command/top-level/TestTopLevelExprs.py @@ -37,7 +37,7 @@ class TopLevelExpressionsTestCase(TestBase): """Test top-level expressions.""" 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=False) @@ -45,7 +45,8 @@ class TopLevelExpressionsTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) def run_dummy(self): - self.runCmd("file dummy", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("dummy"), + CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( self, diff --git a/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py b/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py index 1ce75144017e5..bac8e5453e4a8 100644 --- a/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py +++ b/packages/Python/lldbsuite/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py @@ -28,7 +28,7 @@ class ObjCTypeQueryTestCase(TestBase): def test(self): """The expression parser's type search should be wider than the current compilation unit.""" 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile b/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile new file mode 100644 index 0000000000000..8a7102e347af2 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py b/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py new file mode 100644 index 0000000000000..4ad4225a5fe41 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py @@ -0,0 +1,37 @@ +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ExprXValuePrintingTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + self.main_source = "main.cpp" + self.main_source_spec = lldb.SBFileSpec(self.main_source) + + def do_test(self, dictionary=None): + """Printing an xvalue should work.""" + self.build(dictionary=dictionary) + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) + frame = thread.GetFrameAtIndex(0) + + value = frame.EvaluateExpression("foo().data") + self.assertTrue(value.IsValid()) + self.assertTrue(value.GetError().Success()) + self.assertEqual(value.GetValueAsSigned(), 1234) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") + def test(self): + self.do_test() + diff --git a/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp b/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp new file mode 100644 index 0000000000000..556c63f2b4499 --- /dev/null +++ b/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp @@ -0,0 +1,12 @@ +struct Tmp +{ + int data = 1234; +}; + +Tmp foo() { return Tmp(); } + +int main(int argc, char const *argv[]) +{ + int something = foo().data; + return 0; // Break here +} diff --git a/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py index aecbab1b363f3..aa80c9976eb86 100644 --- a/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py +++ b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py @@ -1,5 +1,5 @@ """ -Test that apropos env doesn't crash trying to touch the process plugin commmand +Test that apropos env doesn't crash trying to touch the process plugin command """ from __future__ import print_function @@ -24,12 +24,12 @@ class AproposWithProcessTestCase(TestBase): self.line = line_number('main.cpp', '// break here') def test_apropos_with_process(self): - """Test that apropos env doesn't crash trying to touch the process plugin commmand.""" + """Test that apropos env doesn't crash trying to touch the process plugin command.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # Break in main() aftre the variables are assigned values. + # Break in main() after the variables are assigned values. 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/functionalities/archives/TestBSDArchives.py b/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py index f825eaa86e85f..a0c0968655589 100644 --- a/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py +++ b/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py @@ -35,7 +35,7 @@ class BSDArchivesTestCase(TestBase): """Break inside a() and b() defined within libfoo.a.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break inside a() by file and line first. diff --git a/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py b/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py index 7bddc0cadccf2..5827dc3b4653a 100644 --- a/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py +++ b/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py @@ -37,7 +37,7 @@ class AsanTestCase(TestBase): self.line_breakpoint = line_number('main.c', '// break line') def asan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py b/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py index 0943d99ee8343..d7c5110218632 100644 --- a/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py +++ b/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py @@ -24,7 +24,7 @@ class AsanTestReportDataCase(TestBase): @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessAddressSanitizer - @expectedFailureAll(archs=['i386'], bugnumber="rdar://28658860") + @skipIf(archs=['i386'], bugnumber="llvm.org/PR36710") def test(self): self.build() self.asan_tests() @@ -39,7 +39,7 @@ class AsanTestReportDataCase(TestBase): self.line_crash = line_number('main.c', '// BOOM line') def asan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py b/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py index b348e72606ade..ad87796766c37 100644 --- a/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py +++ b/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py @@ -30,7 +30,7 @@ class AttachResumeTestCase(TestBase): def process_attach_continue_interrupt_detach(self): """Test attach/continue/interrupt/detach""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) popen = self.spawnSubprocess(exe) self.addTearDownHook(self.cleanupSubprocesses) diff --git a/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py b/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py index a4e3948e81ca7..38848e87cc4a0 100644 --- a/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py +++ b/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py @@ -52,7 +52,7 @@ class AvoidsFdLeakTestCase(TestBase): def do_test(self, commands): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") for c in commands: self.runCmd(c) @@ -81,7 +81,7 @@ class AvoidsFdLeakTestCase(TestBase): @skipIfDarwinEmbedded # <rdar://problem/33888742> # debugserver on ios has an extra fd open on launch def test_fd_leak_multitarget(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateBySourceRegex( diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py index 9b116a0a0a24a..46191d85296ab 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py @@ -30,7 +30,7 @@ class AddressBreakpointTestCase(TestBase): def address_breakpoints(self): """Test address breakpoints set with shared library of SBAddress work correctly.""" - 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/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py index 6f06ca7770c84..5014c1cd4a249 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py @@ -30,12 +30,13 @@ class BadAddressBreakpointTestCase(TestBase): def address_breakpoints(self): """Test that breakpoints set on a bad address say they are bad.""" + target, process, thread, bkpt = \ + lldbutil.run_to_source_breakpoint(self, + "Set a breakpoint here", + lldb.SBFileSpec("main.c")) - (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, - "Set a breakpoint here", lldb.SBFileSpec("main.c")) - - # Now see if we can read from 0. If I can't do that, I don't have a good way to know - # what an illegal address is... + # Now see if we can read from 0. If I can't do that, I don't + # have a good way to know what an illegal address is... error = lldb.SBError() ptr = process.ReadPointerFromMemory(0x0, error) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py index 9630e39e01429..0123e732e35d8 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py @@ -36,7 +36,7 @@ class BreakpointAutoContinue(TestBase): def make_target_and_bkpt(self, additional_options=None, num_expected_loc=1, pattern="Set a breakpoint here"): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target.IsValid(), "Target is not valid") diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py deleted file mode 100644 index 88ccc46441924..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py +++ /dev/null @@ -1,129 +0,0 @@ -""" -Test case sensitivity of paths on Windows / POSIX -llvm.org/pr22667 -""" - -import os -import lldb -from lldbsuite.test.lldbtest import * -from lldbsuite.test.decorators import * -from lldbsuite.test import lldbplatform, lldbplatformutil - - -class BreakpointCaseSensitivityTestCase(TestBase): - mydir = TestBase.compute_mydir(__file__) - BREAKPOINT_TEXT = 'Set a breakpoint here' - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - self.line = line_number('main.c', self.BREAKPOINT_TEXT) - - @skipIf(hostoslist=no_match(['windows'])) # Skip for non-windows platforms - def test_breakpoint_matches_file_with_different_case(self): - """Set breakpoint on file, should match files with different case on Windows""" - self.build() - self.case_sensitivity_breakpoint(True) - - @skipIf(hostoslist=['windows']) # Skip for windows platforms - def test_breakpoint_doesnt_match_file_with_different_case(self): - """Set breakpoint on file, shouldn't match files with different case on POSIX systems""" - self.build() - self.case_sensitivity_breakpoint(False) - - def case_sensitivity_breakpoint(self, case_insensitive): - """Set breakpoint on file, should match files with different case if case_insensitive is True""" - - # use different case to check CreateTarget - exe = 'a.out' - if case_insensitive: - exe = exe.upper() - - exe = os.path.join(os.getcwd(), exe) - - # Create a target by the debugger. - self.target = self.dbg.CreateTarget(exe) - self.assertTrue(self.target, VALID_TARGET) - cwd = os.getcwd() - - # try both BreakpointCreateByLocation and BreakpointCreateBySourceRegex - for regex in [False, True]: - # should always hit - self.check_breakpoint('main.c', regex, True) - # should always hit - self.check_breakpoint(os.path.join(cwd, 'main.c'), regex, True) - # different case for directory - self.check_breakpoint(os.path.join(cwd.upper(), 'main.c'), - regex, - case_insensitive) - # different case for file - self.check_breakpoint('Main.c', - regex, - case_insensitive) - # different case for both - self.check_breakpoint(os.path.join(cwd.upper(), 'Main.c'), - regex, - case_insensitive) - - def check_breakpoint(self, file, source_regex, should_hit): - """ - Check breakpoint hit at given file set by given method - - file: - File where insert the breakpoint - - source_regex: - True for testing using BreakpointCreateBySourceRegex, - False for BreakpointCreateByLocation - - should_hit: - True if the breakpoint should hit, False otherwise - """ - - desc = ' file %s set by %s' % ( - file, 'regex' if source_regex else 'location') - if source_regex: - breakpoint = self.target.BreakpointCreateBySourceRegex( - self.BREAKPOINT_TEXT, lldb.SBFileSpec(file)) - else: - breakpoint = self.target.BreakpointCreateByLocation( - file, self.line) - - self.assertEqual(breakpoint and breakpoint.GetNumLocations() == 1, - should_hit, - VALID_BREAKPOINT + desc) - - # Get the breakpoint location from breakpoint after we verified that, - # indeed, it has one location. - location = breakpoint.GetLocationAtIndex(0) - - self.assertEqual(location.IsValid(), - should_hit, - VALID_BREAKPOINT_LOCATION + desc) - - process = self.target.LaunchSimple( - None, None, self.get_process_working_directory()) - self.assertTrue(process, PROCESS_IS_VALID + desc) - - if should_hit: - # Did we hit our breakpoint? - from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint - threads = get_threads_stopped_at_breakpoint(process, breakpoint) - self.assertEqual( - len(threads), - 1, - "There should be a thread stopped at breakpoint" + - desc) - # The hit count for the breakpoint should be 1. - self.assertEqual(breakpoint.GetHitCount(), 1) - - else: - # check the breakpoint was not hit - self.assertEqual(lldb.eStateExited, process.GetState()) - self.assertEqual(breakpoint.GetHitCount(), 0) - - # let process finish - process.Continue() - - # cleanup - self.target.BreakpointDelete(breakpoint.GetID()) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c deleted file mode 100644 index 281ddfe7ef67c..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c +++ /dev/null @@ -1,8 +0,0 @@ -#include <stdio.h> - -int -main() -{ - printf("Set a breakpoint here.\n"); - return 0; -} diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py index 386eafbb0b60a..7a2dc61b1b690 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -11,18 +11,14 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import side_effect class BreakpointCommandTestCase(TestBase): + NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) - @classmethod - def classCleanup(cls): - """Cleanup the test byproduct of breakpoint_command_sequence(self).""" - cls.RemoveTempFile("output.txt") - cls.RemoveTempFile("output2.txt") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_breakpoint_command_sequence(self): """Test a sequence of breakpoint command add, list, and delete.""" @@ -49,9 +45,28 @@ class BreakpointCommandTestCase(TestBase): self.addTearDownHook( lambda: self.runCmd("settings clear auto-confirm")) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") + def test_delete_all_breakpoints(self): + """Test that deleting all breakpoints works.""" + self.build() + exe = self.getBuildArtifact("a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_symbol(self, "main") + lldbutil.run_break_set_by_file_and_line( + self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + self.runCmd("breakpoint delete") + self.runCmd("process continue") + self.expect("process status", PROCESS_STOPPED, + patterns=['Process .* exited with status = 0']) + + def breakpoint_command_sequence(self): """Test a sequence of breakpoint command add, list, and delete.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add three breakpoints on the same line. The first time we don't specify the file, @@ -66,12 +81,36 @@ class BreakpointCommandTestCase(TestBase): # setting breakpoint commands on two breakpoints at a time lldbutil.run_break_set_by_file_and_line( self, None, self.line, num_expected_locations=1, loc_exact=True) - + # Make sure relative path source breakpoints work as expected. We test + # with partial paths with and without "./" prefixes. + lldbutil.run_break_set_by_file_and_line( + self, "./main.c", self.line, + num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "breakpoint_command/main.c", self.line, + num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "./breakpoint_command/main.c", self.line, + num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "breakpoint/breakpoint_command/main.c", self.line, + num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "./breakpoint/breakpoint_command/main.c", self.line, + num_expected_locations=1, loc_exact=True) + # Test relative breakpoints with incorrect paths and make sure we get + # no breakpoint locations + lldbutil.run_break_set_by_file_and_line( + self, "invalid/main.c", self.line, + num_expected_locations=0, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "./invalid/main.c", self.line, + num_expected_locations=0, loc_exact=True) # Now add callbacks for the breakpoints just created. self.runCmd( "breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") self.runCmd( - "breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") + "breakpoint command add -s python -o 'import side_effect; side_effect.one_liner = \"one liner was here\"' 2") self.runCmd( "breakpoint command add --python-function bktptcmd.function 3") @@ -104,9 +143,8 @@ class BreakpointCommandTestCase(TestBase): "frame variable --show-types --scope"]) self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs=["Breakpoint commands (Python):", - "here = open", - "here.write", - "here.close()"]) + "import side_effect", + "side_effect.one_liner"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs=["Breakpoint commands (Python):", "bktptcmd.function(frame, bp_loc, internal_dict)"]) @@ -151,40 +189,14 @@ class BreakpointCommandTestCase(TestBase): extra_options="-f a.c", num_expected_locations=1) - # Run the program. Remove 'output.txt' if it exists. - self.RemoveTempFile("output.txt") - self.RemoveTempFile("output2.txt") + # Reset our canary variables and run the program. + side_effect.one_liner = None + side_effect.bktptcmd = None self.runCmd("run", RUN_SUCCEEDED) - # Check that the file 'output.txt' exists and contains the string - # "lldb". - - # The 'output.txt' file should now exist. - self.assertTrue( - os.path.isfile("output.txt"), - "'output.txt' exists due to breakpoint command for breakpoint 2.") - self.assertTrue( - os.path.isfile("output2.txt"), - "'output2.txt' exists due to breakpoint command for breakpoint 3.") - - # Read the output file produced by running the program. - with open('output.txt', 'r') as f: - output = f.read() - - self.expect( - output, - "File 'output.txt' and the content matches", - exe=False, - startstr="lldb") - - with open('output2.txt', 'r') as f: - output = f.read() - - self.expect( - output, - "File 'output2.txt' and the content matches", - exe=False, - startstr="lldb") + # Check the value of canary variables. + self.assertEquals("one liner was here", side_effect.one_liner) + self.assertEquals("function was here", side_effect.bktptcmd) # Finish the program. self.runCmd("process continue") @@ -237,7 +249,7 @@ class BreakpointCommandTestCase(TestBase): def breakpoint_command_script_parameters(self): """Test that the frame and breakpoint location are being properly passed to the script breakpoint command function.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint. @@ -245,42 +257,20 @@ class BreakpointCommandTestCase(TestBase): self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); here.write(str(frame) + \"\\n\"); here.write(str(bp_loc) + \"\\n\"); here.close()' 1") - - # Remove 'output-2.txt' if it already exists. + self.runCmd("breakpoint command add -s python -o 'import side_effect; side_effect.frame = str(frame); side_effect.bp_loc = str(bp_loc)' 1") - if (os.path.exists('output-2.txt')): - os.remove('output-2.txt') - - # Run program, hit breakpoint, and hopefully write out new version of - # 'output-2.txt' + # Reset canary variables and run. + side_effect.frame = None + side_effect.bp_loc = None self.runCmd("run", RUN_SUCCEEDED) - # Check that the file 'output.txt' exists and contains the string - # "lldb". - - # The 'output-2.txt' file should now exist. - self.assertTrue( - os.path.isfile("output-2.txt"), - "'output-2.txt' exists due to breakpoint command for breakpoint 1.") - - # Read the output file produced by running the program. - with open('output-2.txt', 'r') as f: - output = f.read() - - self.expect( - output, - "File 'output-2.txt' and the content matches", - exe=False, - startstr="frame #0:", - patterns=["1.* where = .*main .* resolved, hit count = 1"]) - - # Now remove 'output-2.txt' - os.remove('output-2.txt') + self.expect(side_effect.frame, exe=False, startstr="frame #0:") + self.expect(side_effect.bp_loc, exe=False, + patterns=["1.* where = .*main .* resolved, hit count = 1"]) def breakpoint_commands_on_creation(self): """Test that setting breakpoint commands when creating the breakpoint works""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target.IsValid(), "Created an invalid target.") diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py index 01af8369aaf15..7c7aad0bc81e4 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py @@ -12,12 +12,13 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import side_effect class PythonBreakpointCommandSettingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - my_var = 10 + NO_DEBUG_INFO_TESTCASE = True @add_test_categories(['pyapi']) def test_step_out_python(self): @@ -31,7 +32,7 @@ class PythonBreakpointCommandSettingTestCase(TestBase): self.main_source_spec = lldb.SBFileSpec(self.main_source) def do_set_python_command_from_python(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") error = lldb.SBError() self.target = self.dbg.CreateTarget(exe) @@ -69,12 +70,9 @@ class PythonBreakpointCommandSettingTestCase(TestBase): self.assertTrue(got_one_in_B, "Failed to match the pattern in B") self.target.BreakpointDelete(no_files_bkpt.GetID()) - PythonBreakpointCommandSettingTestCase.my_var = 10 error = lldb.SBError() - error = body_bkpt.SetScriptCallbackBody("\ -import TestBreakpointCommandsFromPython\n\ -TestBreakpointCommandsFromPython.PythonBreakpointCommandSettingTestCase.my_var = 20\n\ -print('Hit breakpoint')") + error = body_bkpt.SetScriptCallbackBody( + "import side_effect; side_effect.callback = 'callback was here'") self.assertTrue( error.Success(), "Failed to set the script callback body: %s." % @@ -84,9 +82,9 @@ print('Hit breakpoint')") "command script import --allow-reload ./bktptcmd.py") func_bkpt.SetScriptCallbackFunction("bktptcmd.function") - # We will use the function that touches a text file, so remove it - # first: - self.RemoveTempFile("output2.txt") + # Clear out canary variables + side_effect.bktptcmd = None + side_effect.callback = None # Now launch the process, and do not stop at entry point. self.process = self.target.LaunchSimple( @@ -100,11 +98,5 @@ print('Hit breakpoint')") self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.") self.thread = threads[0] - self.assertTrue(PythonBreakpointCommandSettingTestCase.my_var == 20) - - # Check for the function version as well, which produced this file: - # Remember to clean up after ourselves... - self.assertTrue( - os.path.isfile("output2.txt"), - "'output2.txt' exists due to breakpoint command for breakpoint function.") - self.RemoveTempFile("output2.txt") + self.assertEquals("callback was here", side_effect.callback) + self.assertEquals("function was here", side_effect.bktptcmd) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py index baf237bf07640..d064b75b91cfe 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestRegexpBreakCommand.py @@ -31,7 +31,7 @@ class RegexpBreakCommandTestCase(TestBase): def regexp_break_command(self): """Test the super consie "b" command, which is analias for _regexp-break.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) break_results = lldbutil.run_break_set_command( @@ -54,7 +54,7 @@ class RegexpBreakCommandTestCase(TestBase): num_locations=1) # Check breakpoint with full file path. - full_path = os.path.join(os.getcwd(), self.source) + full_path = os.path.join(self.getSourceDir(), self.source) break_results = lldbutil.run_break_set_command( self, "b %s:%d" % (full_path, self.line)) lldbutil.check_breakpoint_result( diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py index cf1fc2cf02c96..ac0f753ccd8d5 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py @@ -1,7 +1,5 @@ from __future__ import print_function - +import side_effect def function(frame, bp_loc, dict): - there = open("output2.txt", "w") - print("lldb", file=there) - there.close() + side_effect.bktptcmd = "function was here" diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c index 62ec97f43284b..702644b692d82 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/main.c @@ -9,5 +9,9 @@ int main (int argc, char const *argv[]) { + // Add a body to the function, so we can set more than one + // breakpoint in it. + static volatile int var = 0; + var++; return 0; // Set break point at this line. } diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py new file mode 100644 index 0000000000000..ef4ab2b159cc2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py @@ -0,0 +1,5 @@ +""" +A dummy module for testing the execution of various breakpoint commands. A +command will modify a global variable in this module and test will check its +value. +""" diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py index 3fd9b13c71197..959c7e8f95cce 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py @@ -59,7 +59,7 @@ class BreakpointConditionsTestCase(TestBase): def breakpoint_conditions(self, inline=False): """Exercise breakpoint condition with 'breakpoint modify -c <expr> id'.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) if inline: @@ -132,7 +132,7 @@ class BreakpointConditionsTestCase(TestBase): def breakpoint_conditions_python(self): """Use Python APIs to set breakpoint conditions.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -200,7 +200,7 @@ class BreakpointConditionsTestCase(TestBase): def breakpoint_invalid_conditions_python(self): """Use Python APIs to set breakpoint conditions.""" - 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/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py index 5d7b6f9169ad8..6f696be83249d 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_hit_count/TestBreakpointHitCount.py @@ -22,6 +22,31 @@ class BreakpointHitCountTestCase(TestBase): self.build() self.do_test_breakpoint_location_hit_count() + def test_breakpoint_one_shot(self): + """Check that one-shot breakpoints trigger only once.""" + self.build() + + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + self.runCmd("tb a") + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + from lldbsuite.test.lldbutil import get_stopped_thread + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue( + thread.IsValid(), + "There should be a thread stopped due to breakpoint") + + frame0 = thread.GetFrameAtIndex(0) + self.assertTrue(frame0.GetFunctionName() == "a(int)" or frame0.GetFunctionName() == "int a(int)"); + + process.Continue() + self.assertEqual(process.GetState(), lldb.eStateExited) + def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -32,7 +57,7 @@ class BreakpointHitCountTestCase(TestBase): def do_test_breakpoint_location_hit_count(self): """Use Python APIs to check breakpoint hit count.""" - 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/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py index 621bd4a55f06a..02fb1e0f49d4e 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ids/TestBreakpointIDs.py @@ -19,7 +19,7 @@ class BreakpointIDTestCase(TestBase): def test(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py index 09e20bc5ac353..eb4bac7e6e66e 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py @@ -46,7 +46,7 @@ class BreakpointIgnoreCountTestCase(TestBase): def breakpoint_ignore_count(self): """Exercise breakpoint ignore count with 'breakpoint set -i <count>'.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Create a breakpoint in main.c at line1. @@ -101,7 +101,7 @@ class BreakpointIgnoreCountTestCase(TestBase): def breakpoint_ignore_count_python(self): """Use Python APIs to set breakpoint ignore count.""" - 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/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py index 255b6f7fa2925..6eaab0c680f50 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py @@ -21,7 +21,7 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase): @skipIf(archs=no_match(re.compile('mips*'))) def test(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out.*"]) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py index 214c110afcd65..b69007014b10c 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_language/TestBreakpointLanguage.py @@ -36,7 +36,7 @@ class TestBreakpointLanguage(TestBase): self.build() # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") error = lldb.SBError() # Don't read in dependencies so we don't come across false matches that # add unwanted breakpoint hits. @@ -77,7 +77,7 @@ class TestBreakpointLanguage(TestBase): self.build() # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") error = lldb.SBError() # Don't read in dependencies so we don't come across false matches that # add unwanted breakpoint hits. diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py index de24d8b002d7c..7eb465f29599f 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py @@ -41,7 +41,7 @@ class BreakpointLocationsTestCase(TestBase): self.line = line_number('main.c', '// Set break point at this line.') def set_breakpoint (self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, "Target %s is not valid"%(exe)) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py index b95d2cea550ab..8b5352866c213 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py @@ -58,12 +58,12 @@ class BreakpointNames(TestBase): self.do_check_configuring_permissions_cli() def setup_target(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a targets we are making breakpoint in and copying to: self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - self.main_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "main.c")) + self.main_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "main.c")) def check_name_in_target(self, bkpt_name): name_list = lldb.SBStringList() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py index 871363b7aed3c..c9ef2a7300106 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py @@ -28,7 +28,7 @@ class BreakpointOptionsTestCase(TestBase): def breakpoint_options_test(self): """Test breakpoint command for different options.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 locations. @@ -78,7 +78,7 @@ class BreakpointOptionsTestCase(TestBase): def breakpoint_options_language_test(self): """Test breakpoint command for language option.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 locations. diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py index 2410f2ee82b38..7603bd90ffc57 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py @@ -15,8 +15,7 @@ class BreakpointSetRestart(TestBase): def test_breakpoint_set_restart(self): self.build() - cwd = os.getcwd() - exe = os.path.join(cwd, 'a.out') + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -33,9 +32,7 @@ class BreakpointSetRestart(TestBase): break bp = target.BreakpointCreateBySourceRegex( - self.BREAKPOINT_TEXT, lldb.SBFileSpec( - os.path.join( - cwd, 'main.cpp'))) + self.BREAKPOINT_TEXT, lldb.SBFileSpec('main.cpp')) self.assertTrue( bp.IsValid() and bp.GetNumLocations() == 1, VALID_BREAKPOINT) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/Makefile index 0ac34a186b259..2d7f20f43fed0 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/Makefile @@ -1,7 +1,14 @@ LEVEL = ../../../make -CXX_SOURCES := main.cpp +CXX_SOURCES := relative.cpp EXE := CompDirSymLink include $(LEVEL)/Makefile.rules + +# Force relative filenames by copying it into the build directory. +relative.cpp: main.cpp + cp -f $< $@ + +clean:: + rm -rf relative.cpp diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py index e4672fbbf1ba4..4385304c88b6f 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py @@ -13,7 +13,7 @@ from lldbsuite.test import lldbutil _EXE_NAME = 'CompDirSymLink' # Must match Makefile -_SRC_FILE = 'main.cpp' +_SRC_FILE = 'relative.cpp' _COMP_DIR_SYM_LINK_PROP = 'plugin.symbol-file.dwarf.comp-dir-symlink-paths' @@ -25,8 +25,9 @@ class CompDirSymLinkTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside main(). - self.line = line_number(_SRC_FILE, '// Set break point at this line.') - self.src_path = os.path.join(os.getcwd(), _SRC_FILE) + self.line = line_number( + os.path.join(self.getSourceDir(), "main.cpp"), + '// Set break point at this line.') @skipIf(hostoslist=["windows"]) def test_symlink_paths_set(self): @@ -35,39 +36,43 @@ class CompDirSymLinkTestCase(TestBase): self.runCmd( "settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink)) - lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line) + src_path = self.getBuildArtifact(_SRC_FILE) + lldbutil.run_break_set_by_file_and_line(self, src_path, self.line) @skipIf(hostoslist=no_match(["linux"])) def test_symlink_paths_set_procselfcwd(self): + os.chdir(self.getBuildDir()) pwd_symlink = '/proc/self/cwd' self.doBuild(pwd_symlink) self.runCmd( "settings set %s %s" % (_COMP_DIR_SYM_LINK_PROP, pwd_symlink)) - lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line) + src_path = self.getBuildArtifact(_SRC_FILE) + lldbutil.run_break_set_by_file_and_line(self, src_path, self.line) @skipIf(hostoslist=["windows"]) def test_symlink_paths_unset(self): pwd_symlink = self.create_src_symlink() self.doBuild(pwd_symlink) self.runCmd('settings clear ' + _COMP_DIR_SYM_LINK_PROP) + src_path = self.getBuildArtifact(_SRC_FILE) self.assertRaises( AssertionError, lldbutil.run_break_set_by_file_and_line, self, - self.src_path, + src_path, self.line) def create_src_symlink(self): - pwd_symlink = os.path.join(os.getcwd(), 'pwd_symlink') + pwd_symlink = self.getBuildArtifact('pwd_symlink') if os.path.exists(pwd_symlink): os.unlink(pwd_symlink) - os.symlink(os.getcwd(), pwd_symlink) + os.symlink(self.getBuildDir(), pwd_symlink) self.addTearDownHook(lambda: os.remove(pwd_symlink)) return pwd_symlink def doBuild(self, pwd_symlink): - self.build(None, None, {'PWD': pwd_symlink}, True) + self.build(None, None, {'PWD': pwd_symlink}) - exe = os.path.join(os.getcwd(), _EXE_NAME) + exe = self.getBuildArtifact(_EXE_NAME) self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py index adec9fa5dddb1..e4c19fd0d3da2 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py @@ -45,7 +45,7 @@ class TestCPPBreakpointLocations(TestBase): def breakpoint_id_tests(self): # 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) bp_dicts = [ @@ -69,7 +69,7 @@ class TestCPPBreakpointLocations(TestBase): @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test_destructors(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) # Don't skip prologue, so we can check the breakpoint address more diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py index 3019e1c1c5570..26fe02ba56ce7 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py @@ -32,7 +32,7 @@ class TestCPPExceptionBreakpoint (TestBase): self.main_source_spec = lldb.SBFileSpec(self.main_source) def do_cpp_exception_bkpt(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") error = lldb.SBError() self.target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py index d044827e00840..11ec67d910978 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py @@ -20,7 +20,7 @@ class DebugBreakTestCase(TestBase): def test_asm_int_3(self): """Test that intrinsics like `__debugbreak();` and `asm {"int3"}` are treated like breakpoints.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Run the program. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py index a934ad356ac6b..4b595ab7819e3 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py @@ -46,7 +46,7 @@ class BreakpointInDummyTarget (TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # The breakpoint list should show 3 locations. diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile index 801c1041bbe16..06ef85cf908dd 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile @@ -3,6 +3,5 @@ LEVEL = ../../../make DYLIB_NAME := foo DYLIB_CXX_SOURCES := foo.cpp CXX_SOURCES := main.cpp -CFLAGS_EXTRAS := -fPIC include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py index 4dfa03d5fab4e..9551ab278ebf3 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py @@ -17,23 +17,24 @@ class TestBreakpointInGlobalConstructors(TestBase): mydir = TestBase.compute_mydir(__file__) NO_DEBUG_INFO_TESTCASE = True - def setUp(self): - TestBase.setUp(self) + def test(self): + self.build() self.line_foo = line_number('foo.cpp', '// !BR_foo') self.line_main = line_number('main.cpp', '// !BR_main') - @expectedFailureAll(bugnumber="llvm.org/pr35480", oslist=["linux"]) - def test(self): - self.build() - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file %s" % exe) + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.assertTrue(target, VALID_TARGET) + + env= self.registerSharedLibrariesWithTarget(target, ["foo"]) bp_main = lldbutil.run_break_set_by_file_and_line( self, 'main.cpp', self.line_main) + bp_foo = lldbutil.run_break_set_by_file_and_line( - self, 'foo.cpp', self.line_foo) + self, 'foo.cpp', self.line_foo, num_expected_locations=-2) - self.runCmd("run") + process = target.LaunchSimple( + None, env, self.get_process_working_directory()) self.assertIsNotNone( lldbutil.get_one_thread_stopped_at_breakpoint_id( diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py index 21fe084d3dfb9..69dfac225258f 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py @@ -47,12 +47,8 @@ class HardwareBreakpointMultiThreadTestCase(TestBase): def break_multi_thread(self, removal_type): """Test that lldb hardware breakpoints work for multiple threads.""" - self.runCmd( - "file %s" % - os.path.join( - os.getcwd(), - 'a.out'), - CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), + CURRENT_EXECUTABLE_SET) # Stop in main before creating any threads. lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py index fe8f430096d99..ee67dda624204 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/TestInlinedBreakpoints.py @@ -33,7 +33,7 @@ class InlinedBreakpointsTestCase(TestBase): def inlined_breakpoints(self): """Test 'b basic_types.cpp:176' does break (where int.cpp includes basic_type.cpp).""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # With the inline-breakpoint-strategy, our file+line breakpoint should diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/basic_type.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/basic_type.cpp index 5881afe1f395a..75d2c3690c898 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/basic_type.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/inlined_breakpoints/basic_type.cpp @@ -20,6 +20,9 @@ #endif +#include <cstdint> +#include <cstdio> + class a_class { public: @@ -79,12 +82,9 @@ typedef struct a_union_nonzero_tag { } a_union_nonzero_t; -#include <stdint.h> -#include <stdio.h> - void Puts(char const *msg) { - puts(msg); + std::puts(msg); } int @@ -124,53 +124,53 @@ main (int argc, char const *argv[]) a_union_zero_t a_union_zero_array_unbounded[] = {{ T_VALUE_1 }, { T_VALUE_2 }}; #ifdef T_PRINTF_FORMAT - printf ("%s: a = '" T_PRINTF_FORMAT "'\n", T_CSTR, a); - printf ("%s*: %p => *a_ptr = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); - printf ("%s&: @%p => a_ref = '" T_PRINTF_FORMAT "'\n", T_CSTR, &a_ref, a_ref); - - printf ("%s[2]: a_array_bounded[0] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[0]); - printf ("%s[2]: a_array_bounded[1] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[1]); - - printf ("%s[]: a_array_unbounded[0] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_unbounded[0]); - printf ("%s[]: a_array_unbounded[1] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_unbounded[1]); - - printf ("(a_class) a_class_instance.m_a = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_a()); - printf ("(a_class) a_class_instance.m_b = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_b()); - printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_a()); - printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_b = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_b()); - printf ("(a_class&) a_class_ref = %p, a_class_ref.m_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_a()); - printf ("(a_class&) a_class_ref = %p, a_class_ref.m_b = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_b()); - - printf ("(a_struct_t) a_struct.a = '" T_PRINTF_FORMAT "'\n", a_struct.a); - printf ("(a_struct_t) a_struct.b = '" T_PRINTF_FORMAT "'\n", a_struct.b); - printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->a = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->a); - printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->b = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->b); - printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.a = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.a); - printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.b = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.b); + std::printf ("%s: a = '" T_PRINTF_FORMAT "'\n", T_CSTR, a); + std::printf ("%s*: %p => *a_ptr = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); + std::printf ("%s&: @%p => a_ref = '" T_PRINTF_FORMAT "'\n", T_CSTR, &a_ref, a_ref); + + std::printf ("%s[2]: a_array_bounded[0] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[0]); + std::printf ("%s[2]: a_array_bounded[1] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_bounded[1]); + + std::printf ("%s[]: a_array_unbounded[0] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_unbounded[0]); + std::printf ("%s[]: a_array_unbounded[1] = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_array_unbounded[1]); + + std::printf ("(a_class) a_class_instance.m_a = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_a()); + std::printf ("(a_class) a_class_instance.m_b = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_b()); + std::printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_a()); + std::printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_b = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_b()); + std::printf ("(a_class&) a_class_ref = %p, a_class_ref.m_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_a()); + std::printf ("(a_class&) a_class_ref = %p, a_class_ref.m_b = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_b()); + + std::printf ("(a_struct_t) a_struct.a = '" T_PRINTF_FORMAT "'\n", a_struct.a); + std::printf ("(a_struct_t) a_struct.b = '" T_PRINTF_FORMAT "'\n", a_struct.b); + std::printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->a = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->a); + std::printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->b = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->b); + std::printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.a = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.a); + std::printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.b = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.b); - printf ("(a_union_zero_t) a_union_zero.a = '" T_PRINTF_FORMAT "'\n", a_union_zero.a); - printf ("(a_union_zero_t*) a_union_zero_ptr = %p, a_union_zero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_zero_ptr, a_union_zero_ptr->a); - printf ("(a_union_zero_t&) a_union_zero_ref = %p, a_union_zero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_zero_ref, a_union_zero_ref.a); + std::printf ("(a_union_zero_t) a_union_zero.a = '" T_PRINTF_FORMAT "'\n", a_union_zero.a); + std::printf ("(a_union_zero_t*) a_union_zero_ptr = %p, a_union_zero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_zero_ptr, a_union_zero_ptr->a); + std::printf ("(a_union_zero_t&) a_union_zero_ref = %p, a_union_zero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_zero_ref, a_union_zero_ref.a); - printf ("(a_union_nonzero_t) a_union_nonzero.u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero.u.a); - printf ("(a_union_nonzero_t*) a_union_nonzero_ptr = %p, a_union_nonzero_ptr->u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero_ptr, a_union_nonzero_ptr->u.a); - printf ("(a_union_nonzero_t&) a_union_nonzero_ref = %p, a_union_nonzero_ref.u.a = '" T_PRINTF_FORMAT "'\n", &a_union_nonzero_ref, a_union_nonzero_ref.u.a); + std::printf ("(a_union_nonzero_t) a_union_nonzero.u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero.u.a); + std::printf ("(a_union_nonzero_t*) a_union_nonzero_ptr = %p, a_union_nonzero_ptr->u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero_ptr, a_union_nonzero_ptr->u.a); + std::printf ("(a_union_nonzero_t&) a_union_nonzero_ref = %p, a_union_nonzero_ref.u.a = '" T_PRINTF_FORMAT "'\n", &a_union_nonzero_ref, a_union_nonzero_ref.u.a); - printf ("(a_struct_t[2]) a_struct_array_bounded[0].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].a); - printf ("(a_struct_t[2]) a_struct_array_bounded[0].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].b); - printf ("(a_struct_t[2]) a_struct_array_bounded[1].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[1].a); - printf ("(a_struct_t[2]) a_struct_array_bounded[1].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[1].b); + std::printf ("(a_struct_t[2]) a_struct_array_bounded[0].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].a); + std::printf ("(a_struct_t[2]) a_struct_array_bounded[0].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[0].b); + std::printf ("(a_struct_t[2]) a_struct_array_bounded[1].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[1].a); + std::printf ("(a_struct_t[2]) a_struct_array_bounded[1].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_bounded[1].b); - printf ("(a_struct_t[]) a_struct_array_unbounded[0].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[0].a); - printf ("(a_struct_t[]) a_struct_array_unbounded[0].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[0].b); - printf ("(a_struct_t[]) a_struct_array_unbounded[1].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[1].a); - printf ("(a_struct_t[]) a_struct_array_unbounded[1].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[1].b); + std::printf ("(a_struct_t[]) a_struct_array_unbounded[0].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[0].a); + std::printf ("(a_struct_t[]) a_struct_array_unbounded[0].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[0].b); + std::printf ("(a_struct_t[]) a_struct_array_unbounded[1].a = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[1].a); + std::printf ("(a_struct_t[]) a_struct_array_unbounded[1].b = '" T_PRINTF_FORMAT "'\n", a_struct_array_unbounded[1].b); - printf ("(a_union_zero_t[2]) a_union_zero_array_bounded[0].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_bounded[0].a); - printf ("(a_union_zero_t[2]) a_union_zero_array_bounded[1].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_bounded[1].a); + std::printf ("(a_union_zero_t[2]) a_union_zero_array_bounded[0].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_bounded[0].a); + std::printf ("(a_union_zero_t[2]) a_union_zero_array_bounded[1].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_bounded[1].a); - printf ("(a_union_zero_t[]) a_union_zero_array_unbounded[0].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_unbounded[0].a); - printf ("(a_union_zero_t[]) a_union_zero_array_unbounded[1].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_unbounded[1].a); + std::printf ("(a_union_zero_t[]) a_union_zero_array_unbounded[0].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_unbounded[0].a); + std::printf ("(a_union_zero_t[]) a_union_zero_array_unbounded[1].a = '" T_PRINTF_FORMAT "'\n", a_union_zero_array_unbounded[1].a); #endif Puts("About to exit, break here to check values..."); // Set break point at this line. diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile index e7a1cab7e195f..06ef85cf908dd 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile @@ -3,6 +3,5 @@ LEVEL = ../../../make DYLIB_NAME := foo DYLIB_CXX_SOURCES := foo.cpp CXX_SOURCES := main.cpp -CFLAGS_EXTRAS += -fPIC include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py index 26041c313e57b..16d5bc75473ca 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py @@ -24,7 +24,7 @@ class TestMoveNearest(TestBase): """Test target.move-to-nearest logic""" self.build() - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) lldbutil.run_break_set_by_symbol(self, 'main', sym_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h index 060b91f5a5ea3..9f0e56dd22ee8 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h @@ -1,6 +1,5 @@ -LLDB_TEST_API inline int foo1() { return 1; } // !BR1 +inline int foo1() { return 1; } // !BR1 -LLDB_TEST_API inline int foo2() { return 2; } // !BR2 +inline int foo2() { return 2; } // !BR2 LLDB_TEST_API extern int call_foo1(); -LLDB_TEST_API extern int call_foo2(); diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py index f43bbb7515c18..e5e8473eedd65 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py @@ -22,7 +22,7 @@ class TestObjCBreakpoints(TestBase): mydir = TestBase.compute_mydir(__file__) def test_break(self): - """Test setting Objective C specific breakpoints (DWARF in .o files).""" + """Test setting Objective-C specific breakpoints (DWARF in .o files).""" self.build() self.setTearDownCleanup() self.check_objc_breakpoints(False) @@ -73,7 +73,7 @@ class TestObjCBreakpoints(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py index 6f93994a46647..5c3da17c254eb 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py @@ -60,7 +60,7 @@ class BreakpointSerialization(TestBase): self.addTearDownHook(cleanup) self.RemoveTempFile(self.bkpts_file_path) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create the targets we are making breakpoints in and copying them to: self.orig_target = self.dbg.CreateTarget(exe) @@ -73,7 +73,7 @@ class BreakpointSerialization(TestBase): # Call super's setUp(). TestBase.setUp(self) - self.bkpts_file_path = os.path.join(os.getcwd(), "breakpoints.json") + self.bkpts_file_path = self.getBuildArtifact("breakpoints.json") self.bkpts_file_spec = lldb.SBFileSpec(self.bkpts_file_path) def check_equivalence(self, source_bps, do_write = True): @@ -119,7 +119,7 @@ class BreakpointSerialization(TestBase): empty_module_list = lldb.SBFileSpecList() empty_cu_list = lldb.SBFileSpecList() - blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c")) + blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c")) # It isn't actually important for these purposes that these breakpoint # actually have locations. @@ -147,7 +147,7 @@ class BreakpointSerialization(TestBase): cu_list.Append(lldb.SBFileSpec("AnotherCU.c")) cu_list.Append(lldb.SBFileSpec("ThirdCU.c")) - blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c")) + blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c")) # It isn't actually important for these purposes that these breakpoint # actually have locations. @@ -174,7 +174,7 @@ class BreakpointSerialization(TestBase): empty_module_list = lldb.SBFileSpecList() empty_cu_list = lldb.SBFileSpecList() - blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c")) + blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c")) # It isn't actually important for these purposes that these breakpoint # actually have locations. @@ -218,7 +218,7 @@ class BreakpointSerialization(TestBase): empty_module_list = lldb.SBFileSpecList() empty_cu_list = lldb.SBFileSpecList() - blubby_file_spec = lldb.SBFileSpec(os.path.join(os.getcwd(), "blubby.c")) + blubby_file_spec = lldb.SBFileSpec(os.path.join(self.getSourceDir(), "blubby.c")) # It isn't actually important for these purposes that these breakpoint # actually have locations. diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py index 791cc70a7498e..4256c70a02650 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py @@ -28,7 +28,7 @@ class TestSourceRegexBreakpoints(TestBase): def source_regex_locations(self): """ Test that restricting source expressions to files & to functions. """ # 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) @@ -64,7 +64,7 @@ class TestSourceRegexBreakpoints(TestBase): def source_regex_restrictions(self): """ Test that restricting source expressions to files & to functions. """ # 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) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py index 4dfeae3f5e19c..c2084295ef79d 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py @@ -21,7 +21,7 @@ class StepOverBreakpointsTestCase(TestBase): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") src = lldb.SBFileSpec("main.cpp") # Create a target by the debugger. diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py index d562cb1511ac0..1698c0d0c35fa 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py @@ -8,13 +8,16 @@ from __future__ import print_function import os import time import lldb +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * class CmdPythonTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test(self): self.build() self.pycmd_tests() @@ -27,7 +30,7 @@ class CmdPythonTestCase(TestBase): self.expect('targetname', substrs=['a.out'], matching=False, error=True) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) @@ -46,6 +49,7 @@ class CmdPythonTestCase(TestBase): self.runCmd('command script delete tell_curr', check=False) self.runCmd('command script delete bug11569', check=False) self.runCmd('command script delete takes_exe_ctx', check=False) + self.runCmd('command script delete decorated', check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -64,13 +68,19 @@ class CmdPythonTestCase(TestBase): substrs=['Just a docstring for welcome_impl', 'A command that says hello to LLDB users']) + decorated_commands = ["decorated" + str(n) for n in range(1, 5)] + for name in decorated_commands: + self.expect(name, substrs=["hello from " + name]) + self.expect("help " + name, + substrs=["Python command defined by @lldb.command"]) + self.expect("help", substrs=['For more information run', - 'welcome']) + 'welcome'] + decorated_commands) self.expect("help -a", substrs=['For more information run', - 'welcome']) + 'welcome'] + decorated_commands) self.expect("help -u", matching=False, substrs=['For more information run']) diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py b/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py new file mode 100644 index 0000000000000..f9707a5706ac1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/command_script/decorated.py @@ -0,0 +1,35 @@ +from __future__ import print_function + +import lldb + + +@lldb.command() +def decorated1(debugger, args, exe_ctx, result, dict): + """ + Python command defined by @lldb.command + """ + print("hello from decorated1", file=result) + + +@lldb.command(doc="Python command defined by @lldb.command") +def decorated2(debugger, args, exe_ctx, result, dict): + """ + This docstring is overridden. + """ + print("hello from decorated2", file=result) + + +@lldb.command() +def decorated3(debugger, args, result, dict): + """ + Python command defined by @lldb.command + """ + print("hello from decorated3", file=result) + + +@lldb.command("decorated4") +def _decorated4(debugger, args, exe_ctx, result, dict): + """ + Python command defined by @lldb.command + """ + print("hello from decorated4", file=result) diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/py_import b/packages/Python/lldbsuite/test/functionalities/command_script/py_import index 169daacc1a833..6c1f7b8185f6d 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/py_import +++ b/packages/Python/lldbsuite/test/functionalities/command_script/py_import @@ -10,3 +10,4 @@ command script add tell_sync --function welcome.check_for_synchro --synchronicit command script add tell_async --function welcome.check_for_synchro --synchronicity async command script add tell_curr --function welcome.check_for_synchro --synchronicity curr command script add takes_exe_ctx --function welcome.takes_exe_ctx +command script import decorated.py diff --git a/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py b/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py index 975ad32689b2d..c6ad75f014ee7 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py @@ -32,7 +32,7 @@ class CommandScriptImmediateOutputTestCase (PExpectTest): """Test that LLDB correctly allows scripted commands to set immediate output to the console.""" self.launch(timeout=10) - script = os.path.join(os.getcwd(), 'custom_command.py') + script = os.path.join(self.getSourceDir(), 'custom_command.py') prompt = "\(lldb\) " self.sendline('command script import %s' % script, patterns=[prompt]) @@ -54,12 +54,12 @@ class CommandScriptImmediateOutputTestCase (PExpectTest): """Test that LLDB correctly allows scripted commands to set immediate output to a file.""" self.launch(timeout=10) - test_files = {os.path.join(os.getcwd(), 'read.txt'): 'r', - os.path.join(os.getcwd(), 'write.txt'): 'w', - os.path.join(os.getcwd(), 'append.txt'): 'a', - os.path.join(os.getcwd(), 'write_plus.txt'): 'w+', - os.path.join(os.getcwd(), 'read_plus.txt'): 'r+', - os.path.join(os.getcwd(), 'append_plus.txt'): 'a+'} + test_files = {self.getBuildArtifact('read.txt'): 'r', + self.getBuildArtifact('write.txt'): 'w', + self.getBuildArtifact('append.txt'): 'a', + self.getBuildArtifact('write_plus.txt'): 'w+', + self.getBuildArtifact('read_plus.txt'): 'r+', + self.getBuildArtifact('append_plus.txt'): 'a+'} starter_string = 'Starter Garbage\n' write_string = 'writing to file with mode: ' @@ -68,7 +68,7 @@ class CommandScriptImmediateOutputTestCase (PExpectTest): with open(path, 'w+') as init: init.write(starter_string) - script = os.path.join(os.getcwd(), 'custom_command.py') + script = os.path.join(self.getSourceDir(), 'custom_command.py') prompt = "\(lldb\) " self.sendline('command script import %s' % script, patterns=[prompt]) diff --git a/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py b/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py index 9f55f64b2be5d..a3b23834ee12a 100644 --- a/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py +++ b/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py @@ -17,6 +17,8 @@ class CommandLineCompletionTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + @classmethod def classCleanup(cls): """Cleanup the test byproducts.""" @@ -26,23 +28,17 @@ class CommandLineCompletionTestCase(TestBase): except: pass - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_at(self): """Test that 'at' completes to 'attach '.""" self.complete_from_to('at', 'attach ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_de(self): """Test that 'de' completes to 'detach '.""" self.complete_from_to('de', 'detach ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_process_attach_dash_dash_con(self): """Test that 'process attach --con' completes to 'process attach --continue '.""" self.complete_from_to( @@ -50,232 +46,157 @@ class CommandLineCompletionTestCase(TestBase): 'process attach --continue ') # <rdar://problem/11052829> - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_infinite_loop_while_completing(self): """Test that 'process print hello\' completes to itself and does not infinite loop.""" self.complete_from_to('process print hello\\', 'process print hello\\', turn_off_re_match=True) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_watchpoint_co(self): """Test that 'watchpoint co' completes to 'watchpoint command '.""" self.complete_from_to('watchpoint co', 'watchpoint command ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_watchpoint_command_space(self): - """Test that 'watchpoint command ' completes to ['Available completions:', 'add', 'delete', 'list'].""" + """Test that 'watchpoint command ' completes to ['add', 'delete', 'list'].""" self.complete_from_to( 'watchpoint command ', [ - 'Available completions:', 'add', 'delete', 'list']) + 'add', 'delete', 'list']) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_watchpoint_command_a(self): """Test that 'watchpoint command a' completes to 'watchpoint command add '.""" self.complete_from_to( 'watchpoint command a', 'watchpoint command add ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test - def test_watchpoint_set_variable_dash_w(self): - """Test that 'watchpoint set variable -w' completes to 'watchpoint set variable -w '.""" - self.complete_from_to( - 'watchpoint set variable -w', - 'watchpoint set variable -w ') - - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test - def test_watchpoint_set_variable_dash_w_space(self): - """Test that 'watchpoint set variable -w ' completes to ['Available completions:', 'read', 'write', 'read_write'].""" - self.complete_from_to('watchpoint set variable -w ', - ['Available completions:', 'read', 'write', 'read_write']) - - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_watchpoint_set_ex(self): """Test that 'watchpoint set ex' completes to 'watchpoint set expression '.""" self.complete_from_to( 'watchpoint set ex', 'watchpoint set expression ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_watchpoint_set_var(self): """Test that 'watchpoint set var' completes to 'watchpoint set variable '.""" self.complete_from_to('watchpoint set var', 'watchpoint set variable ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test - def test_watchpoint_set_variable_dash_w_read_underbar(self): - """Test that 'watchpoint set variable -w read_' completes to 'watchpoint set variable -w read_write'.""" - self.complete_from_to( - 'watchpoint set variable -w read_', - 'watchpoint set variable -w read_write') - - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_help_fi(self): - """Test that 'help fi' completes to ['Available completions:', 'file', 'finish'].""" + """Test that 'help fi' completes to ['file', 'finish'].""" self.complete_from_to( 'help fi', [ - 'Available completions:', 'file', 'finish']) + 'file', 'finish']) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_help_watchpoint_s(self): """Test that 'help watchpoint s' completes to 'help watchpoint set '.""" self.complete_from_to('help watchpoint s', 'help watchpoint set ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_append_target_er(self): """Test that 'settings append target.er' completes to 'settings append target.error-path'.""" self.complete_from_to( 'settings append target.er', 'settings append target.error-path') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_insert_after_target_en(self): """Test that 'settings insert-after target.env' completes to 'settings insert-after target.env-vars'.""" self.complete_from_to( 'settings insert-after target.env', 'settings insert-after target.env-vars') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_insert_before_target_en(self): """Test that 'settings insert-before target.env' completes to 'settings insert-before target.env-vars'.""" self.complete_from_to( 'settings insert-before target.env', 'settings insert-before target.env-vars') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_replace_target_ru(self): """Test that 'settings replace target.ru' completes to 'settings replace target.run-args'.""" self.complete_from_to( 'settings replace target.ru', 'settings replace target.run-args') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_s(self): - """Test that 'settings s' completes to ['Available completions:', 'set', 'show'].""" + """Test that 'settings s' completes to ['set', 'show'].""" self.complete_from_to( 'settings s', [ - 'Available completions:', 'set', 'show']) + 'set', 'show']) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_set_th(self): """Test that 'settings set thread-f' completes to 'settings set thread-format'.""" self.complete_from_to('settings set thread-f', 'settings set thread-format') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_s_dash(self): """Test that 'settings set -' completes to 'settings set -g'.""" self.complete_from_to('settings set -', 'settings set -g') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_clear_th(self): """Test that 'settings clear thread-f' completes to 'settings clear thread-format'.""" self.complete_from_to( 'settings clear thread-f', 'settings clear thread-format') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_set_ta(self): """Test that 'settings set ta' completes to 'settings set target.'.""" self.complete_from_to( 'settings set target.ma', 'settings set target.max-') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_set_target_exec(self): """Test that 'settings set target.exec' completes to 'settings set target.exec-search-paths '.""" self.complete_from_to( 'settings set target.exec', 'settings set target.exec-search-paths') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_set_target_pr(self): - """Test that 'settings set target.pr' completes to ['Available completions:', + """Test that 'settings set target.pr' completes to [ 'target.prefer-dynamic-value', 'target.process.'].""" self.complete_from_to('settings set target.pr', - ['Available completions:', - 'target.prefer-dynamic-value', + ['target.prefer-dynamic-value', 'target.process.']) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_set_target_process(self): """Test that 'settings set target.process' completes to 'settings set target.process.'.""" self.complete_from_to( 'settings set target.process', 'settings set target.process.') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_set_target_process_dot(self): """Test that 'settings set target.process.t' completes to 'settings set target.process.thread.'.""" self.complete_from_to( 'settings set target.process.t', 'settings set target.process.thread.') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_settings_set_target_process_thread_dot(self): - """Test that 'settings set target.process.thread.' completes to ['Available completions:', + """Test that 'settings set target.process.thread.' completes to [ 'target.process.thread.step-avoid-regexp', 'target.process.thread.trace-thread'].""" self.complete_from_to('settings set target.process.thread.', - ['Available completions:', - 'target.process.thread.step-avoid-regexp', + ['target.process.thread.step-avoid-regexp', 'target.process.thread.trace-thread']) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_target_space(self): - """Test that 'target ' completes to ['Available completions:', 'create', 'delete', 'list', + """Test that 'target ' completes to ['create', 'delete', 'list', 'modules', 'select', 'stop-hook', 'variable'].""" self.complete_from_to('target ', - ['Available completions:', - 'create', + ['create', 'delete', 'list', 'modules', @@ -283,35 +204,48 @@ class CommandLineCompletionTestCase(TestBase): 'stop-hook', 'variable']) - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_target_create_dash_co(self): """Test that 'target create --co' completes to 'target variable --core '.""" self.complete_from_to('target create --co', 'target create --core ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") @skipIfFreeBSD # timing out on the FreeBSD buildbot - @no_debug_info_test def test_target_va(self): """Test that 'target va' completes to 'target variable '.""" self.complete_from_to('target va', 'target variable ') - @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") - @expectedFailureAll( - oslist=lldbplatform.darwin_all, - bugnumber="llvm.org/pr25485,<rdar://problem/28573448>") + def test_command_argument_completion(self): + """Test completion of command arguments""" + self.complete_from_to("watchpoint set variable -", ["-w", "-s"]) + self.complete_from_to('watchpoint set variable -w', 'watchpoint set variable -w ') + self.complete_from_to("watchpoint set variable --", ["--watch", "--size"]) + self.complete_from_to("watchpoint set variable --w", "watchpoint set variable --watch") + self.complete_from_to('watchpoint set variable -w ', ['read', 'write', 'read_write']) + self.complete_from_to("watchpoint set variable --watch ", ["read", "write", "read_write"]) + self.complete_from_to("watchpoint set variable --watch w", "watchpoint set variable --watch write") + self.complete_from_to('watchpoint set variable -w read_', 'watchpoint set variable -w read_write') + # Now try the same thing with a variable name (non-option argument) to + # test that getopts arg reshuffling doesn't confuse us. + self.complete_from_to("watchpoint set variable foo -", ["-w", "-s"]) + self.complete_from_to('watchpoint set variable foo -w', 'watchpoint set variable foo -w ') + self.complete_from_to("watchpoint set variable foo --", ["--watch", "--size"]) + self.complete_from_to("watchpoint set variable foo --w", "watchpoint set variable foo --watch") + self.complete_from_to('watchpoint set variable foo -w ', ['read', 'write', 'read_write']) + self.complete_from_to("watchpoint set variable foo --watch ", ["read", "write", "read_write"]) + self.complete_from_to("watchpoint set variable foo --watch w", "watchpoint set variable foo --watch write") + self.complete_from_to('watchpoint set variable foo -w read_', 'watchpoint set variable foo -w read_write') + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489") def test_symbol_name(self): self.build() - self.complete_from_to('''file a.out - breakpoint set -n Fo''', + self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.complete_from_to('breakpoint set -n Fo', 'breakpoint set -n Foo::Bar(int,\\ int)', turn_off_re_match=True) def complete_from_to(self, str_input, patterns, turn_off_re_match=False): """Test that the completion mechanism completes str_input to patterns, where patterns could be a pattern-string or a list of pattern-strings""" - import pexpect # Patterns should not be None in order to proceed. self.assertFalse(patterns is None) # And should be either a string or list of strings. Check for list type @@ -321,53 +255,26 @@ class CommandLineCompletionTestCase(TestBase): if not isinstance(patterns, list): patterns = [patterns] - # The default lldb prompt. - prompt = "(lldb) " - - # So that the child gets torn down after the test. - self.child = pexpect.spawn(lldbtest_config.lldbExec, - [self.lldbOption] + ['--no-use-colors']) - child = self.child - # Turn on logging for input/output to/from the child. - with open('child_send.txt', 'w') as f_send: - with open('child_read.txt', 'w') as f_read: - child.logfile_send = f_send - child.logfile_read = f_read - - child.expect_exact(prompt) - child.setecho(True) - # Sends str_input and a Tab to invoke the completion machinery. - child.send("%s\t" % str_input) - child.sendline('') - child.expect_exact(prompt) - child.sendline('') - child.expect_exact(prompt) - - # Now that the necessary logging is done, restore logfile to None to - # stop further logging. - child.logfile_send = None - child.logfile_read = None - - with open('child_send.txt', 'r') as fs: - if self.TraceOn(): - print("\n\nContents of child_send.txt:") - print(fs.read()) - with open('child_read.txt', 'r') as fr: - from_child = fr.read() - if self.TraceOn(): - print("\n\nContents of child_read.txt:") - print(from_child) - - # The matching could be verbatim or using generic re pattern. - for p in patterns: - # Test that str_input completes to our patterns or substrings. - # If each pattern/substring matches from_child, the completion - # mechanism works! - if turn_off_re_match: - self.expect( - from_child, msg=COMPLETION_MSG( - str_input, p), exe=False, substrs=[p]) - else: - self.expect( - from_child, msg=COMPLETION_MSG( - str_input, p), exe=False, patterns=[p]) + interp = self.dbg.GetCommandInterpreter() + match_strings = lldb.SBStringList() + num_matches = interp.HandleCompletion(str_input, len(str_input), 0, -1, match_strings) + common_match = match_strings.GetStringAtIndex(0) + if num_matches == 0: + compare_string = str_input + else: + if common_match != None and len(common_match) > 0: + compare_string = str_input + common_match + else: + compare_string = "" + for idx in range(1, num_matches+1): + compare_string += match_strings.GetStringAtIndex(idx) + "\n" + + for p in patterns: + if turn_off_re_match: + self.expect( + compare_string, msg=COMPLETION_MSG( + str_input, p), exe=False, substrs=[p]) + else: + self.expect( + compare_string, msg=COMPLETION_MSG( + str_input, p), exe=False, patterns=[p]) diff --git a/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py b/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py index cec06e48f1cf6..904fb4c903722 100644 --- a/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py @@ -39,7 +39,7 @@ class ConditionalBreakTestCase(TestBase): bugnumber="llvm.org/pr26265: args in frames other than #0 are not evaluated correctly") def do_conditional_break(self): """Exercise some thread and frame APIs to break if c() is called by a().""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -112,9 +112,9 @@ class ConditionalBreakTestCase(TestBase): if not self.TraceOn(): self.HideStdout() - # Separate out the "file a.out" command from .lldb file, for the sake of + # Separate out the "file " + self.getBuildArtifact("a.out") command from .lldb file, for the sake of # remote testsuite. - self.runCmd("file a.out") + self.runCmd("file " + self.getBuildArtifact("a.out")) self.runCmd("command source .lldb") self.runCmd("break list") diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py index f8ce069478fd7..c8f93c1db3a8a 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/TestDarwinLogFilterMatchActivityChain.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterMatchActivityChain(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py index 12a430295a774..32b2623dfb981 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity/TestDarwinLogFilterMatchActivity.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterMatchActivity(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py index 8ce4d4135d18c..088d1036d1c4c 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/category/TestDarwinLogFilterMatchCategory.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterMatchCategory(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py index b7664ddd8071e..5a377f99128b1 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/message/TestDarwinLogFilterMatchMessage.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterMatchMessage(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py index 5afe649e16a24..f3d4d4de92f0e 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/subsystem/TestDarwinLogFilterMatchSubsystem.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterMatchSubsystem(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py index 74be57aeef854..16d678aa24175 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity-chain/TestDarwinLogFilterRegexActivityChain.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterRegexActivityChain(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py index 55f015403d1f9..e017d56af31c4 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/activity/TestDarwinLogFilterRegexActivity.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterRegexActivity(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py index 6786d6f009b00..5a618b11680c4 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/category/TestDarwinLogFilterRegexCategory.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterRegexCategory(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py index 28677b54c75d9..679db2ea37bba 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/filter/regex/subsystem/TestDarwinLogFilterRegexSubsystem.py @@ -29,7 +29,7 @@ class TestDarwinLogFilterRegexSubsystem(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py index 65822cab430a3..8c9e2875aec5c 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/format/TestDarwinLogMessageFormat.py @@ -28,7 +28,7 @@ class TestDarwinLogMessageFormat(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py index 85b8e30f60649..89791097a3f8d 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/debug/TestDarwinLogSourceDebug.py @@ -29,7 +29,7 @@ class TestDarwinLogSourceDebug(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py index 44348374636d6..865eea2419816 100644 --- a/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py +++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/source/info/TestDarwinLogSourceInfo.py @@ -29,7 +29,7 @@ class TestDarwinLogSourceInfo(darwin_log.DarwinLogTestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py index 410da702b93d8..18aac237672c0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py @@ -32,7 +32,7 @@ class DataFormatterBoolRefPtr(TestBase): def boolrefptr_data_formatter_commands(self): """Test the formatters we use for BOOL& and BOOL* in Objective-C.""" - 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.mm", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py index 9b430c726e122..891448f00d29b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py @@ -27,7 +27,7 @@ class CompactVectorsFormattingTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index 050f5236445bd..6d8a794070d77 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -25,7 +25,7 @@ class AdvDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py index 2d01eb79e188f..4e61b7419d5b0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py @@ -26,7 +26,7 @@ class CategoriesDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py index 0518a75051bbd..9749061f42d59 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py @@ -26,10 +26,12 @@ class CppDataFormatterTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24462: Data formatters have problems on Windows") + @skipIf(debug_info="gmodules", + bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py index e192943f381e9..c451d0f82792a 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-disabling/TestDataFormatterDisabling.py @@ -29,7 +29,7 @@ class DataFormatterDisablingTestCase(TestBase): def test_with_run_command(self): """Check that we can properly disable all data formatter categories.""" 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/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py index 710cfa8fe12c0..2d09be5441baa 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-enum-format/TestDataFormatterEnumFormat.py @@ -25,7 +25,7 @@ class EnumFormatTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py index d3d93dabc7fb9..81ddf597def63 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py @@ -9,6 +9,7 @@ import os import time import lldb from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * import lldbsuite.test.lldbutil as lldbutil @@ -22,10 +23,12 @@ class GlobalsDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') + @skipIf(debug_info="gmodules", + bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py index f4f0a4859896e..8b354d764e583 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-named-summaries/TestDataFormatterNamedSummaries.py @@ -25,7 +25,7 @@ class NamedSummariesDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py index bc39d8d7b152d..4643e4738229d 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py @@ -96,7 +96,7 @@ class ObjCDataFormatterTestCase(TestBase): def plain_data_formatter_commands(self): """Test basic ObjC formatting behavior.""" - 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.m", self.line, num_expected_locations=1, loc_exact=True) @@ -162,7 +162,7 @@ class ObjCDataFormatterTestCase(TestBase): def appkit_common_data_formatters_command(self): """Test formatters for AppKit classes.""" - 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.m", self.line, num_expected_locations=1, loc_exact=True) @@ -186,16 +186,18 @@ class ObjCDataFormatterTestCase(TestBase): def nsnumber_data_formatter_commands(self): # Now enable AppKit and check we are displaying Cocoa classes correctly - self.expect('frame variable num1 num2 num3 num5 num6 num7 num9', + self.expect('frame variable num1 num2 num3 num5 num6 num7 num8_Y num8_N num9', substrs=['(NSNumber *) num1 = ', ' (int)5', '(NSNumber *) num2 = ', ' (float)3.1', '(NSNumber *) num3 = ', ' (double)3.14', '(NSNumber *) num5 = ', ' (char)65', '(NSNumber *) num6 = ', ' (long)255', '(NSNumber *) num7 = ', '2000000', + '(NSNumber *) num8_Y = ', 'YES', + '(NSNumber *) num8_N = ', 'NO', '(NSNumber *) num9 = ', ' (short)-31616']) - + self.runCmd('frame variable num4', check=True) output = self.res.GetOutput() i128_handled_correctly = False @@ -213,9 +215,17 @@ class ObjCDataFormatterTestCase(TestBase): '(NSNumber *) num_at3 = ', ' (double)12.5', '(NSNumber *) num_at4 = ', ' (double)-12.5']) + def nsdecimalnumber_data_formatter_commands(self): + self.expect('frame variable decimal_number decimal_neg_number decimal_one decimal_zero decimal_nan', + substrs=['(NSDecimalNumber *) decimal_number = ', '123456 x 10^-10', + '(NSDecimalNumber *) decimal_neg_number = ', '-123456 x 10^10', + '(NSDecimalNumber *) decimal_one = ', '1 x 10^0', + '(NSDecimalNumber *) decimal_zero = ', '0', + '(NSDecimalNumber *) decimal_nan = ', 'NaN']) + def nscontainers_data_formatter_commands(self): self.expect( - 'frame variable newArray newDictionary newMutableDictionary cfarray_ref mutable_array_ref', + 'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref', substrs=[ '(NSArray *) newArray = ', '@"50 elements"', @@ -223,6 +233,10 @@ class ObjCDataFormatterTestCase(TestBase): ' 12 key/value pairs', '(NSDictionary *) newMutableDictionary = ', ' 21 key/value pairs', + '(NSDictionary *) nsDictionary = ', + ' 2 key/value pairs', + '(CFDictionaryRef) cfDictionaryRef = ', + ' 3 key/value pairs', '(CFArrayRef) cfarray_ref = ', '@"3 elements"', '(CFMutableArrayRef) mutable_array_ref = ', @@ -243,7 +257,7 @@ class ObjCDataFormatterTestCase(TestBase): def nsdata_data_formatter_commands(self): self.expect( - 'frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref', + 'frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref concreteData concreteMutableData', substrs=[ '(NSData *) immutableData = ', ' 4 bytes', @@ -254,7 +268,12 @@ class ObjCDataFormatterTestCase(TestBase): '(CFMutableDataRef) mutable_data_ref = ', '@"5 bytes"', '(CFMutableStringRef) mutable_string_ref = ', - ' @"Wish ya knew"']) + ' @"Wish ya knew"', + '(NSData *) concreteData = ', + ' 100000 bytes', + '(NSMutableData *) concreteMutableData = ', + ' 100000 bytes']) + def nsurl_data_formatter_commands(self): self.expect( @@ -360,7 +379,7 @@ class ObjCDataFormatterTestCase(TestBase): def expr_objc_data_formatter_commands(self): """Test common cases of expression parser <--> formatters interaction.""" - 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.m", self.line, num_expected_locations=1, loc_exact=True) @@ -408,7 +427,7 @@ class ObjCDataFormatterTestCase(TestBase): def cf_data_formatter_commands(self): """Test formatters for Core OSX frameworks.""" - 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.m", self.line, num_expected_locations=1, loc_exact=True) @@ -463,7 +482,7 @@ class ObjCDataFormatterTestCase(TestBase): def kvo_data_formatter_commands(self): """Test the behavior of formatters when KVO is in use.""" - 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m index 1543ce6edb91a..37b34f2ac8b9d 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/main.m @@ -169,7 +169,11 @@ int main (int argc, const char * argv[]) NSNumber* num_at3 = @12.5; NSNumber* num_at4 = @-12.5; - NSDecimalNumber* decimal_one = [NSDecimalNumber one]; + NSDecimalNumber* decimal_number = [NSDecimalNumber decimalNumberWithMantissa:123456 exponent:-10 isNegative:NO]; + NSDecimalNumber* decimal_number_neg = [NSDecimalNumber decimalNumberWithMantissa:123456 exponent:10 isNegative:YES]; + NSDecimalNumber* decimal_one = [NSDecimalNumber one]; + NSDecimalNumber* decimal_zero = [NSDecimalNumber zero]; + NSDecimalNumber* decimal_nan = [NSDecimalNumber notANumber]; NSString *str0 = [num6 stringValue]; @@ -381,6 +385,11 @@ int main (int argc, const char * argv[]) [newMutableDictionary setObject:@"foo" forKey:@"bar19"]; [newMutableDictionary setObject:@"foo" forKey:@"bar20"]; + id cfKeys[2] = { @"foo", @"bar", @"baz", @"quux" }; + id cfValues[2] = { @"foo", @"bar", @"baz", @"quux" }; + NSDictionary *nsDictionary = CFBridgingRelease(CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 2, nil, nil)); + CFDictionaryRef cfDictionaryRef = CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 3, nil, nil); + NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; [attrString isEqual:nil]; NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; @@ -396,6 +405,12 @@ int main (int argc, const char * argv[]) NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:4]; NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6]; + // No-copy versions of NSData initializers use NSConcreteData if over 2^16 elements are specified. + unsigned concreteLength = 100000; + void *zeroes = calloc(1, concreteLength); + NSData *concreteData = [[NSData alloc] initWithBytesNoCopy:zeroes length:concreteLength]; + NSMutableData *concreteMutableData = [[NSMutableData alloc] initWithBytesNoCopy:zeroes length:concreteLength]; + [mutableData appendBytes:"MOREDATA" length:8]; [immutableData length]; @@ -610,6 +625,7 @@ int main (int argc, const char * argv[]) [molecule setAtoms:nil]; [molecule setAtoms:[NSMutableArray new]]; + free(zeroes); [pool drain]; return 0; } diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py index 750e294607325..605b543a1b935 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py @@ -21,7 +21,7 @@ class NSIndexPathDataFormatterTestCase(TestBase): def appkit_tester_impl(self, commands): 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py index 12e62f62ee97c..41a6def00c493 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py @@ -21,7 +21,7 @@ class NSStringDataFormatterTestCase(TestBase): def appkit_tester_impl(self, commands): 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py index bf600219bced7..2c5041142fa9b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py @@ -32,7 +32,7 @@ class DataFormatterOneIsSingularTestCase(TestBase): def oneness_data_formatter_commands(self): """Test that 1 item is not as reported as 1 items.""" - 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py index ebabe30766117..397a461db683f 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py @@ -29,7 +29,7 @@ class PtrToArrayDataFormatterTestCase(TestBase): def data_formatter_commands(self): """Test that LLDB handles the clang typeclass Paren correctly.""" - 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/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py index 75d1853f6a714..cc4cfd2ceb727 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py @@ -40,7 +40,7 @@ class PythonSynthDataFormatterTestCase(TestBase): def data_formatter_commands(self): """Test using Python synthetic children provider.""" - 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) @@ -222,7 +222,7 @@ class PythonSynthDataFormatterTestCase(TestBase): def rdar10960550_formatter_commands(self): """Test that synthetic children persist stoppoints.""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) # The second breakpoint is on a multi-line expression, so the comment # can't be on the right line... diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py index 3355ca16305bd..1dd1912f4c73e 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py @@ -29,7 +29,7 @@ class ScriptDataFormatterTestCase(TestBase): def data_formatter_commands(self): """Test that that file and class static variables display correctly.""" - 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/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py index b0b45cb831b00..4ec7f13d11525 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py @@ -36,7 +36,7 @@ class SkipSummaryDataFormatterTestCase(TestBase): def data_formatter_commands(self): """Test that that file and class static variables display correctly.""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) #import lldbsuite.test.lldbutil as lldbutil lldbutil.run_break_set_by_file_and_line( diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py index 9e82f11ff36b4..13b38cbfa7023 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py @@ -33,7 +33,7 @@ class SmartArrayDataFormatterTestCase(TestBase): def data_formatter_commands(self): """Test that that file and class static variables display correctly.""" - 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/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py index 8d4132444fbd1..1f7a175974f95 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py @@ -28,7 +28,7 @@ class LibCxxAtomicTestCase(TestBase): def test(self): """Test that std::atomic as defined by libc++ is correctly printed by LLDB""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py index 73a1b4e16bf62..4fa115e516554 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py @@ -35,7 +35,7 @@ class TestDataFormatterLibcxxBitset(TestBase): "variable: %s, index: %d"%(name, size)) @add_test_categories(["libc++"]) - def test(self): + def test_value(self): """Test that std::bitset is displayed correctly""" self.build() lldbutil.run_to_source_breakpoint(self, '// break here', @@ -44,3 +44,19 @@ class TestDataFormatterLibcxxBitset(TestBase): self.check("empty", 0) self.check("small", 13) self.check("large", 200) + + @add_test_categories(["libc++"]) + def test_ptr_and_ref(self): + """Test that ref and ptr to std::bitset is displayed correctly""" + self.build() + (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, + 'Check ref and ptr', + lldb.SBFileSpec("main.cpp", False)) + + self.check("ref", 13) + self.check("ptr", 13) + + lldbutil.continue_to_breakpoint(process, bkpt) + + self.check("ref", 200) + self.check("ptr", 200) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp index a80f97b801571..2a1532adb4b29 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp @@ -1,4 +1,5 @@ #include <bitset> +#include <stdio.h> template<std::size_t N> void fill(std::bitset<N> &b) { @@ -10,11 +11,19 @@ void fill(std::bitset<N> &b) { } } +template<std::size_t N> +void by_ref_and_ptr(std::bitset<N> &ref, std::bitset<N> *ptr) { + // Check ref and ptr + return; +} + int main() { std::bitset<0> empty; std::bitset<13> small; fill(small); std::bitset<200> large; fill(large); - return 0; // break here + by_ref_and_ptr(small, &small); // break here + by_ref_and_ptr(large, &large); + return 0; } diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py index 63eb5e087e14f..81a76cc65d632 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py @@ -27,7 +27,7 @@ class LibCxxFunctionTestCase(TestBase): def test(self): """Test that std::function as defined by libc++ is correctly printed by LLDB""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py index f0857f420fc3d..9c9b2473aa746 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py @@ -25,7 +25,7 @@ class InitializerListTestCase(TestBase): def test(self): """Test that 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) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py index 9b4308f540955..b36fa6ee1dc82 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py @@ -29,7 +29,7 @@ class LibcxxIteratorDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that libc++ iterators format properly.""" 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp index 058a79317d19e..9d1cbfd912868 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp @@ -1,8 +1,4 @@ #include <string> -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY #include <map> #include <vector> @@ -39,4 +35,4 @@ int main() svter svI = sv.begin(); return 0; // Set break point at this line. -}
\ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index bb20b0e7d98ca..5f48b3541e5ab 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -31,10 +31,12 @@ class LibcxxListDataFormatterTestCase(TestBase): '// Set fourth break point at this line.') @add_test_categories(["libc++"]) + @skipIf(debug_info="gmodules", + bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") def test_with_run_command(self): """Test that 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) @@ -86,8 +88,9 @@ class LibcxxListDataFormatterTestCase(TestBase): substrs=['list has 0 items', '{}']) - self.runCmd("n") - + self.runCmd("n") # This gets up past the printf + self.runCmd("n") # Now advance over the first push_back. + self.expect("frame variable numbers_list", substrs=['list has 1 items', '[0] = ', @@ -185,6 +188,7 @@ class LibcxxListDataFormatterTestCase(TestBase): '\"is\"', '\"smart\"']) + self.runCmd("n") # This gets us past the printf self.runCmd("n") # check access-by-index diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py index e1ebbd5c226d0..f169b448680d1 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py @@ -18,13 +18,14 @@ from lldbsuite.test import lldbutil class LibcxxListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True @add_test_categories(["libc++"]) @expectedFailureAndroid(bugnumber="llvm.org/pr32592") @skipIfDarwin # rdar://25499635 def test_with_run_command(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp index 6a1266528d5e6..7c623e9a68b59 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp @@ -3,12 +3,8 @@ #define private public #define protected public -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY #include <list> - +#include <stdio.h> #include <assert.h> typedef std::list<int> int_list; @@ -18,7 +14,8 @@ int main() #ifdef LLDB_USING_LIBCPP int_list *numbers_list = new int_list{1,2,3,4,5,6,7,8,9,10}; - auto *third_elem = numbers_list->__end_.__next_->__next_->__next_; // Set break point at this line. + printf("// Set break point at this line."); + auto *third_elem = numbers_list->__end_.__next_->__next_->__next_; assert(third_elem->__value_ == 3); auto *fifth_elem = third_elem->__next_->__next_; assert(fifth_elem->__value_ == 5); diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp index 4f2bd74495a9b..56375874f37ed 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp @@ -1,10 +1,6 @@ #include <string> -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY #include <list> - +#include <stdio.h> typedef std::list<int> int_list; typedef std::list<std::string> string_list; @@ -13,7 +9,8 @@ int main() { int_list numbers_list; - (numbers_list.push_back(0x12345678)); // Set break point at this line. + printf("// Set break point at this line."); + (numbers_list.push_back(0x12345678)); (numbers_list.push_back(0x11223344)); (numbers_list.push_back(0xBEEFFEED)); (numbers_list.push_back(0x00ABBA00)); @@ -32,12 +29,15 @@ int main() (text_list.push_back(std::string("is"))); (text_list.push_back(std::string("smart"))); - (text_list.push_back(std::string("!!!"))); // Set second break point at this line. + printf("// Set second break point at this line."); + (text_list.push_back(std::string("!!!"))); std::list<int> countingList = {3141, 3142, 3142,3142,3142, 3142, 3142, 3141}; countingList.sort(); - countingList.unique(); // Set third break point at this line. - countingList.size(); // Set fourth break point at this line. + printf("// Set third break point at this line."); + countingList.unique(); + printf("// Set fourth break point at this line."); + countingList.size(); return 0; } diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index fc4714ea94e26..0f57f0abd9ce7 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -26,7 +26,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that 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) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py index b28a7e6bc31b6..cbcce47d364d1 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py @@ -27,7 +27,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that 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) bkpt = self.target().FindBreakpointByID( lldbutil.run_break_set_by_source_regexp( diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py index 2f448e8fd1153..72a886ff12852 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py @@ -27,22 +27,31 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): self.assertTrue(var.IsValid()) return var.GetType().GetCanonicalType().GetName() + def check_ii(self, var_name): + """ This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. + We use this to make sure we get the same values for ii when we look at the object + directly, and when we look at a reference to the object. """ + self.expect( + "frame variable " + var_name, + substrs=["size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"]) + self.expect( + "p " + var_name, + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + @add_test_categories(["libc++"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID( - lldbutil.run_break_set_by_source_regexp( - self, "Set break point at this line.")) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs=['stopped', - 'stop reason = breakpoint']) + (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -63,7 +72,7 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): "Type: " + ii_type) self.expect("frame variable ii", substrs=["size=0", "{}"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ii", substrs=[ @@ -74,38 +83,26 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): "[3] = 3", "[4] = 4", "[5] = 5"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect( - "frame variable ii", - substrs=[ - "size=7", - "[2] = 2", - "[3] = 3", - "[6] = 6"]) - self.expect( - "p ii", - substrs=[ - "size=7", - "[2] = 2", - "[3] = 3", - "[6] = 6"]) - self.expect("frame variable ii[2]", substrs=[" = 2"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) + + self.check_ii("ii") + + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable ii", substrs=["size=0", "{}"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable ii", substrs=["size=0", "{}"]) ss_type = self.getVariableType("ss") self.assertTrue(ss_type.startswith(self.namespace + "::multiset"), "Type: " + ss_type) self.expect("frame variable ss", substrs=["size=0", "{}"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ss", substrs=[ "size=2", '[0] = "a"', '[1] = "a very long string is right here"']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ss", substrs=[ @@ -123,7 +120,7 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): '[0] = "a"', '[1] = "a very long string is right here"']) self.expect("frame variable ss[2]", substrs=[' = "b"']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ss", substrs=[ @@ -131,3 +128,18 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): '[0] = "a"', '[1] = "a very long string is right here"', '[2] = "c"']) + + @add_test_categories(["libc++"]) + def test_ref_and_ptr(self): + """Test that the data formatters work on ref and ptr.""" + self.build() + (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Stop here to check by ref and ptr.", + lldb.SBFileSpec("main.cpp", False)) + # The reference should print just like the value: + self.check_ii("ref") + + self.expect("frame variable ptr", + substrs=["ptr =", "size=7"]) + self.expect("expr ptr", + substrs=["size=7"]) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp index 1e1dd3b160399..dd3d8be4ae915 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp @@ -1,8 +1,4 @@ #include <string> -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY #include <set> typedef std::multiset<int> intset; @@ -20,6 +16,12 @@ int thefoo_rw(int arg = 1) return g_the_foo; } +void by_ref_and_ptr(intset &ref, intset *ptr) +{ + // Stop here to check by ref and ptr + return; +} + int main() { intset ii; @@ -35,7 +37,9 @@ int main() ii.insert(6); thefoo_rw(1); // Set break point at this line. - + + by_ref_and_ptr(ii, &ii); + ii.clear(); thefoo_rw(1); // Set break point at this line. diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py index 2b157f7f6fccc..f9eb4d82025e3 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py @@ -32,6 +32,7 @@ class TestDataFormatterLibcxxQueue(TestBase): self.assertTrue(ch.IsValid()) self.assertEqual(ch.GetValueAsSigned(), i+1) + @expectedFailureAll(bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android") @add_test_categories(["libc++"]) def test(self): """Test that std::queue is displayed correctly""" diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py index ca89281292449..a6f1a3d2f4302 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py @@ -27,21 +27,31 @@ class LibcxxSetDataFormatterTestCase(TestBase): self.assertTrue(var.IsValid()) return var.GetType().GetCanonicalType().GetName() + def check_ii(self, var_name): + """ This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. + We use this to make sure we get the same values for ii when we look at the object + directly, and when we look at a reference to the object. """ + self.expect( + "frame variable " + var_name, + substrs=["size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"]) + self.expect( + "p " + var_name, + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + @add_test_categories(["libc++"]) def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID( - lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs=['stopped', - 'stop reason = breakpoint']) + (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -62,7 +72,7 @@ class LibcxxSetDataFormatterTestCase(TestBase): "Type: " + ii_type) self.expect("frame variable ii", substrs=["size=0", "{}"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ii", substrs=["size=6", @@ -72,24 +82,12 @@ class LibcxxSetDataFormatterTestCase(TestBase): "[3] = 3", "[4] = 4", "[5] = 5"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect( - "frame variable ii", - substrs=["size=7", - "[2] = 2", - "[3] = 3", - "[6] = 6"]) - self.expect("frame variable ii[2]", substrs=[" = 2"]) - self.expect( - "p ii", - substrs=[ - "size=7", - "[2] = 2", - "[3] = 3", - "[6] = 6"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) + self.check_ii("ii") + + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable ii", substrs=["size=0", "{}"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable ii", substrs=["size=0", "{}"]) ss_type = self.getVariableType("ss") @@ -97,13 +95,13 @@ class LibcxxSetDataFormatterTestCase(TestBase): "Type: " + ss_type) self.expect("frame variable ss", substrs=["size=0", "{}"]) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ss", substrs=["size=2", '[0] = "a"', '[1] = "a very long string is right here"']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ss", substrs=["size=4", @@ -119,10 +117,26 @@ class LibcxxSetDataFormatterTestCase(TestBase): '[0] = "a"', '[1] = "a very long string is right here"']) self.expect("frame variable ss[2]", substrs=[' = "b"']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect( "frame variable ss", substrs=["size=3", '[0] = "a"', '[1] = "a very long string is right here"', '[2] = "c"']) + + @add_test_categories(["libc++"]) + def test_ref_and_ptr(self): + """Test that the data formatters work on ref and ptr.""" + self.build() + (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Stop here to check by ref and ptr.", + lldb.SBFileSpec("main.cpp", False)) + # The reference should print just like the value: + self.check_ii("ref") + + self.expect("frame variable ptr", + substrs=["ptr =", "size=7"]) + self.expect("expr ptr", + substrs=["size=7"]) + diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp index cc3033ef26e43..df39e9746c03a 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp @@ -1,8 +1,4 @@ #include <string> -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY #include <set> typedef std::set<int> intset; @@ -20,6 +16,12 @@ int thefoo_rw(int arg = 1) return g_the_foo; } +void by_ref_and_ptr(intset &ref, intset *ptr) +{ + // Stop here to check by ref and ptr + return; +} + int main() { intset ii; @@ -35,7 +37,9 @@ int main() ii.insert(6); thefoo_rw(1); // Set break point at this line. - + + by_ref_and_ptr(ii, &ii); + ii.clear(); thefoo_rw(1); // Set break point at this line. diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py index 5b9b14d549e58..4574a044488ca 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py @@ -27,10 +27,11 @@ class LibcxxStringDataFormatterTestCase(TestBase): self.namespace = 'std::__' + ns + '1' @add_test_categories(["libc++"]) + @expectedFailureAll(bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android") def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile index 1f609a41d9086..24d7c220d075b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile @@ -2,6 +2,11 @@ LEVEL = ../../../../../make CXX_SOURCES := main.cpp +# Work around "exception specification in declaration does not match previous +# declaration" errors present in older libc++ releases. This error was fixed in +# the 3.8 release. +CFLAGS_EXTRAS += -fno-exceptions + USE_LIBCPP := 1 include $(LEVEL)/Makefile.rules CXXFLAGS += -O0 diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py index f61a715a4d3e1..4c60e403f6b0d 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py @@ -25,7 +25,7 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase): @add_test_categories(["libc++"]) def test_with_run_command(self): 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_source_regexp( self, "Set break point at this line.") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp index 4e8a1a779c0cf..81a5763559d31 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp @@ -1,8 +1,4 @@ #include <string> -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY #include <unordered_map> #include <unordered_set> @@ -81,4 +77,4 @@ int main() thefoo_rw(); // Set break point at this line. return 0; -}
\ No newline at end of file +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py index a7a00068383f3..1aa93d718fc96 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py @@ -27,7 +27,7 @@ class LibcxxVBoolDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp index 91fe509465e73..026cfc863f2c0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp @@ -1,9 +1,4 @@ #include <string> -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY - #include <vector> int main() diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py index 9e226a100a10e..aeb10984b3b87 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py @@ -17,22 +17,47 @@ class LibcxxVectorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + def check_numbers(self, var_name): + self.expect("frame variable " + var_name, + substrs=[var_name + ' = size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + + self.expect("p " + var_name, + substrs=['$', 'size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + + # check access-by-index + self.expect("frame variable " + var_name + "[0]", + substrs=['1']) + self.expect("frame variable " + var_name + "[1]", + substrs=['12']) + self.expect("frame variable " + var_name + "[2]", + substrs=['123']) + self.expect("frame variable " + var_name + "[3]", + substrs=['1234']) + @add_test_categories(["libc++"]) + @skipIf(debug_info="gmodules", + bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID( - lldbutil.run_break_set_by_source_regexp( - self, "break here")) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs=['stopped', - 'stop reason = breakpoint']) + (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, "break here", lldb.SBFileSpec("main.cpp", False)) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -52,7 +77,7 @@ class LibcxxVectorDataFormatterTestCase(TestBase): self.expect("frame variable numbers", substrs=['numbers = size=0']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) # first value added self.expect("frame variable numbers", @@ -61,7 +86,7 @@ class LibcxxVectorDataFormatterTestCase(TestBase): '}']) # add some more data - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable numbers", substrs=['numbers = size=4', @@ -94,47 +119,17 @@ class LibcxxVectorDataFormatterTestCase(TestBase): self.runCmd("type summary delete int_vect") # add some more data - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) - self.expect("frame variable numbers", - substrs=['numbers = size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - - self.expect("p numbers", - substrs=['$', 'size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - - # check access-by-index - self.expect("frame variable numbers[0]", - substrs=['1']) - self.expect("frame variable numbers[1]", - substrs=['12']) - self.expect("frame variable numbers[2]", - substrs=['123']) - self.expect("frame variable numbers[3]", - substrs=['1234']) + self.check_numbers("numbers") # clear out the vector and see that we do the right thing once again - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable numbers", substrs=['numbers = size=0']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) # first value added self.expect("frame variable numbers", @@ -168,7 +163,7 @@ class LibcxxVectorDataFormatterTestCase(TestBase): 'is', 'smart']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable strings", substrs=['vector has 4 items']) @@ -179,7 +174,25 @@ class LibcxxVectorDataFormatterTestCase(TestBase): self.expect("frame variable strings[1]", substrs=['is']) - lldbutil.continue_to_breakpoint(self.process(), bkpt) + lldbutil.continue_to_breakpoint(process, bkpt) self.expect("frame variable strings", substrs=['vector has 0 items']) + + @add_test_categories(["libc++"]) + @skipIf(debug_info="gmodules", + bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048") + def test_ref_and_ptr(self): + """Test that that file and class static variables display correctly.""" + self.build() + (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, "Stop here to check by ref", lldb.SBFileSpec("main.cpp", False)) + + # The reference should display the same was as the value did + self.check_numbers("ref") + + # The pointer should just show the right number of elements: + + self.expect("frame variable ptr", substrs=['ptr =', ' size=7']) + + self.expect("p ptr", substrs=['$', 'size=7']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp index a9aeacf90e43a..0e1dbe4f03e2b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/main.cpp @@ -1,12 +1,15 @@ +#include <stdio.h> #include <string> -#ifdef _LIBCPP_INLINE_VISIBILITY -#undef _LIBCPP_INLINE_VISIBILITY -#endif -#define _LIBCPP_INLINE_VISIBILITY #include <vector> typedef std::vector<int> int_vect; typedef std::vector<std::string> string_vect; +template <class T> +void by_ref_and_ptr(std::vector<T> &ref, std::vector<T> *ptr) { + // Stop here to check by ref + return; +} + int main() { int_vect numbers; @@ -17,8 +20,10 @@ int main() (numbers.push_back(12345)); // break here (numbers.push_back(123456)); (numbers.push_back(1234567)); + by_ref_and_ptr(numbers, &numbers); - numbers.clear(); // break here + printf("break here"); + numbers.clear(); (numbers.push_back(7)); // break here @@ -26,10 +31,11 @@ int main() (strings.push_back(std::string("goofy"))); (strings.push_back(std::string("is"))); (strings.push_back(std::string("smart"))); - - (strings.push_back(std::string("!!!"))); // break here - - strings.clear(); // break here + printf("break here"); + (strings.push_back(std::string("!!!"))); + + printf("break here"); + strings.clear(); return 0; // break here } diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py index 90a958d7cfe2c..463e2a9f190dc 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py @@ -23,12 +23,11 @@ class StdIteratorDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): """Test that libstdcpp iterators format properly.""" 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py index a8f99f41665f0..7f3755660543c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py @@ -27,12 +27,11 @@ class StdListDataFormatterTestCase(TestBase): self.final_line = line_number( 'main.cpp', '// Set final break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py index e25c410f91ce1..267e3beedb4cc 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py @@ -23,13 +23,11 @@ class StdMapDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows - @skipIfFreeBSD - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): """Test that 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_source_regexp( self, "Set break point at this line.") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py index 6809dd3c356d1..1ca4a15d85cc6 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py @@ -15,13 +15,10 @@ from lldbsuite.test import lldbutil class StdSmartPtrDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfFreeBSD - @skipIfWindows # libstdcpp not ported to Windows - @skipIfDarwin # doesn't compile on Darwin - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): 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_source_regexp( self, "Set break point at this line.") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py index d4e9e4d30f77f..042d9fbcd6a00 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py @@ -24,12 +24,11 @@ class StdStringDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py index b38747d0f9372..c2e02f5466910 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py @@ -15,13 +15,10 @@ from lldbsuite.test import lldbutil class StdTupleDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfFreeBSD - @skipIfWindows # libstdcpp not ported to Windows - @skipIfDarwin # doesn't compile on Darwin - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): 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_source_regexp( self, "Set break point at this line.") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py index 23da541120f6c..5d05418a8b492 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py @@ -15,13 +15,10 @@ from lldbsuite.test import lldbutil class StdUniquePtrDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfFreeBSD - @skipIfWindows # libstdcpp not ported to Windows - @skipIfDarwin # doesn't compile on Darwin - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): 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_source_regexp( self, "Set break point at this line.") @@ -74,7 +71,7 @@ class StdUniquePtrDataFormatterTestCase(TestBase): # reference chain and that it correctly handles the different options # for the frame variable command in this case. 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_source_regexp( self, "Set break point at this line.") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/TestDataFormatterInvalidStdUniquePtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/TestDataFormatterInvalidStdUniquePtr.py new file mode 100644 index 0000000000000..190cf78a3b43c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/TestDataFormatterInvalidStdUniquePtr.py @@ -0,0 +1,5 @@ +import lldbsuite.test.lldbinline as lldbinline +from lldbsuite.test.decorators import * + +lldbinline.MakeInlineTest(__file__, globals(), [no_debug_info_test]) + diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/main.cpp new file mode 100644 index 0000000000000..b12cab231695b --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/main.cpp @@ -0,0 +1,11 @@ +// Test that we don't crash when trying to pretty-print structures that don't +// have the layout our data formatters expect. +namespace std { +template<typename T, typename Deleter = void> +class unique_ptr {}; +} + +int main() { + std::unique_ptr<int> U; + return 0; //% self.expect("frame variable U", substrs=["unique_ptr", "{}"]) +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py index 57c9e2fe5dc79..fb37838bdaffb 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py @@ -23,16 +23,11 @@ class StdVBoolDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll( - oslist=['freebsd'], - bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') - @skipIfWindows # libstdcpp not ported to Windows. - @skipIfDarwin - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py index e3f21eb21ec0c..712de3d41f74a 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py @@ -23,13 +23,11 @@ class StdVectorDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfFreeBSD - @skipIfWindows # libstdcpp not ported to Windows - @skipIfwatchOS # libstdcpp not ported to watchos + @add_test_categories(["libstdcxx"]) def test_with_run_command(self): """Test that 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_source_regexp( self, "Set break point at this line.") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py index 8fff07d89dcae..0e3bcc0e73986 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py @@ -25,7 +25,7 @@ class SynthDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py index 75d3b4e5f5c2f..8bb60b8d679a5 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py @@ -27,7 +27,7 @@ class DataFormatterSynthTypeTestCase(TestBase): def test_with_run_command(self): """Test using Python synthetic children provider to provide a typename.""" 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/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py index 6e7ac2c13f319..08768a61bd9d4 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py @@ -30,7 +30,7 @@ class DataFormatterSynthValueTestCase(TestBase): def test_with_run_command(self): """Test using Python synthetic children provider to provide a value.""" 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/functionalities/data-formatter/format-propagation/TestFormatPropagation.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py index 0c15c793e1fe9..00eb3d00f783f 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/format-propagation/TestFormatPropagation.py @@ -26,7 +26,7 @@ class FormatPropagationTestCase(TestBase): def test_with_run_command(self): """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs.""" 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/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py index d6303fe8b73d0..d7507626e145b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py @@ -25,7 +25,7 @@ class FrameFormatSmallStructTestCase(TestBase): def test_with_run_command(self): """Test that the user can input a format but it will not prevail over summary format's choices.""" 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/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py index 32fbf48dcc683..cc22eca993e22 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py @@ -25,7 +25,7 @@ class DataFormatterHexCapsTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py index b7f60cfac41d6..55855dc8432b4 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py @@ -38,7 +38,7 @@ class LanguageCategoryUpdatesTestCase(TestBase): self.addTearDownHook(cleanup) 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/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py index 87fc2d1802b73..1ae5e40f97808 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py @@ -28,7 +28,7 @@ class NSArraySyntheticTestCase(TestBase): def test_rdar11086338_with_run_command(self): """Test that NSArray reports its synthetic children properly.""" 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py index 85675d211235c..65e32643dde36 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py @@ -28,7 +28,7 @@ class NSDictionarySyntheticTestCase(TestBase): def test_rdar11988289_with_run_command(self): """Test that NSDictionary reports its synthetic children properly.""" 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py index 6affc5a71faff..a3657026faefc 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py @@ -28,7 +28,7 @@ class NSSetSyntheticTestCase(TestBase): def test_rdar12529957_with_run_command(self): """Test that NSSet reports its synthetic children properly.""" 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py index 7ffddc5ec6732..87265087744cb 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py @@ -28,7 +28,7 @@ class DataFormatterOSTypeTestCase(TestBase): def test_ostype_with_run_command(self): """Test the formatters we use for OSType.""" 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.mm", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py index 49cda4ae6cc88..0bfd8df7b44ee 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py @@ -31,7 +31,7 @@ class PrintArrayTestCase(TestBase): def printarray_data_formatter_commands(self): """Test that expr -Z works""" - 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/functionalities/data-formatter/poarray/TestPrintObjectArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py index 83408e7b456e6..4326574c254c0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py @@ -32,7 +32,7 @@ class PrintObjectArrayTestCase(TestBase): def printarray_data_formatter_commands(self): """Test that expr -O -Z works""" - 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.mm", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py index 69b9dd0488713..862e2b57342d2 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py @@ -25,7 +25,7 @@ class PtrRef2TypedefTestCase(TestBase): def test_with_run_command(self): """Test that a pointer/reference to a typedef is formatted as we want.""" 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/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py index 01271b443d173..ba50ccd0ae5ee 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/pyobjsynthprovider/TestPyObjSynthProvider.py @@ -33,7 +33,7 @@ class PyObjectSynthProviderTestCase(TestBase): def provider_data_formatter_commands(self): """Test that the PythonObjectSyntheticChildProvider helper class works""" - 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/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py index 0a039107d842a..09888e1b469bb 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/refpointer-recursion/TestDataFormatterRefPtrRecursion.py @@ -25,7 +25,7 @@ class DataFormatterRefPtrRecursionTestCase(TestBase): def test_with_run_command(self): """Test that ValueObjectPrinter does not cause an infinite loop when a reference to a struct that contains a pointer to itself is printed.""" 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/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py index d7862d2327cf6..f766699bd8523 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/summary-string-onfail/Test-rdar-9974002.py @@ -30,7 +30,7 @@ class Radar9974002DataFormatterTestCase(TestBase): self.skipTest( "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") - 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/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py index 6d519761b7bbe..e94f6c4cc4072 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py @@ -26,7 +26,7 @@ class SyntheticCappingTestCase(TestBase): def test_with_run_command(self): """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs.""" 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/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py index 29c1214564d82..54e9a32157770 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py @@ -28,7 +28,7 @@ class SyntheticFilterRecomputingTestCase(TestBase): def test_rdar12437442_with_run_command(self): """Test that we update SBValues correctly as dynamic types change.""" 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.m", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py index 2e66b800b15eb..9435e80573e1c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py @@ -30,7 +30,7 @@ class TypeSummaryListScriptTestCase(TestBase): def data_formatter_commands(self): """Test printing out Python summary formatters.""" - 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/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py index d970d11a2babb..d3cc4d98aff71 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py @@ -25,7 +25,7 @@ class UserFormatVSSummaryTestCase(TestBase): def test_with_run_command(self): """Test that the user can input a format but it will not prevail over summary format's choices.""" 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/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py index 53073f6d910a0..f6dc47f358693 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/var-in-aggregate-misuse/TestVarInAggregateMisuse.py @@ -25,7 +25,7 @@ class VarInAggregateMisuseTestCase(TestBase): def test_with_run_command(self): """Test that 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) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py index cde0ef4096213..d3c04afe91eb8 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/varscript_formatting/TestDataFormatterVarScriptFormatting.py @@ -28,7 +28,7 @@ class PythonSynthDataFormatterTestCase(TestBase): def test_with_run_command(self): """Test using Python synthetic children provider.""" 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/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py index 2d4cd5782fdd9..c1dc15224b1ec 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py @@ -28,7 +28,7 @@ class VectorTypesFormattingTestCase(TestBase): def test_with_run_command(self): """Check that vector types format properly""" 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/functionalities/dead-strip/TestDeadStrip.py b/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py index 355d60ade90f8..9ba3d2d0ac75e 100644 --- a/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py +++ b/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py @@ -28,7 +28,7 @@ class DeadStripTestCase(TestBase): def test(self): """Test breakpoint works correctly with dead-code stripping.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break by function name f1 (live code). diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py index cee472ccb51fa..52f9daf6bd459 100644 --- a/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py @@ -16,57 +16,29 @@ from lldbsuite.test import lldbutil class DisassemblyTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True @expectedFailureAll( oslist=["windows"], bugnumber="function names print fully demangled instead of name-only") def test(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") - self.expect("file " + exe, - patterns=["Current executable set to .*a.out.*"]) - - match_object = lldbutil.run_break_set_command(self, "br s -n sum") - lldbutil.check_breakpoint_result( - self, - match_object, - symbol_name='sum', - symbol_match_exact=False, - num_locations=1) - - self.expect("run", - patterns=["Process .* launched: "]) - + target, _, _, bkpt = lldbutil.run_to_source_breakpoint(self, + "Set a breakpoint here", lldb.SBFileSpec("main.cpp")) self.runCmd("dis -f") - disassembly = self.res.GetOutput() + disassembly_with_break = self.res.GetOutput().splitlines() - # ARCH, if not specified, defaults to x86_64. - arch = self.getArchitecture() - if arch in ["", 'x86_64', 'i386', 'i686']: - breakpoint_opcodes = ["int3"] - instructions = [' mov', ' addl ', 'ret'] - elif arch in ["arm", "aarch64", "arm64", "armv7", "armv7k"]: - breakpoint_opcodes = ["brk", "udf"] - instructions = [' add ', ' ldr ', ' str '] - elif re.match("mips", arch): - breakpoint_opcodes = ["break"] - instructions = ['lw', 'sw'] - elif arch in ["s390x"]: - breakpoint_opcodes = [".long"] - instructions = [' l ', ' a ', ' st '] - else: - # TODO please add your arch here - self.fail( - 'unimplemented for arch = "{arch}"'.format( - arch=self.getArchitecture())) + self.assertTrue(target.BreakpointDelete(bkpt.GetID())) - # make sure that the software breakpoint has been removed - for op in breakpoint_opcodes: - self.assertFalse(op in disassembly) - - # make sure a few reasonable assembly instructions are here - self.expect( - disassembly, - exe=False, - startstr="a.out`sum", - substrs=instructions) + self.runCmd("dis -f") + disassembly_without_break = self.res.GetOutput().splitlines() + + # Make sure all assembly instructions are the same as instructions + # with the breakpoint removed. + self.assertEqual(len(disassembly_with_break), + len(disassembly_without_break)) + for dis_inst_with, dis_inst_without in \ + zip(disassembly_with_break, disassembly_without_break): + inst_with = dis_inst_with.split(':')[-1] + inst_without = dis_inst_without.split(':')[-1] + self.assertEqual(inst_with, inst_without) diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py b/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py index 47357cf4f71d6..c5fec5b02d6ba 100644 --- a/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py +++ b/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py @@ -30,7 +30,7 @@ class FrameDisassembleTestCase(TestBase): def frame_disassemble_test(self): """Sample test to ensure SBFrame::Disassemble produces SOME output""" - 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/functionalities/disassembly/main.cpp b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp index 93925829ec821..c68e3f1b3212c 100644 --- a/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp @@ -10,7 +10,7 @@ int sum (int a, int b) { - int result = a + b; + int result = a + b; // Set a breakpoint here return result; } @@ -20,7 +20,7 @@ main(int argc, char const *argv[]) int array[3]; - array[0] = sum (1238, 78392); // Set a breakpoint here + array[0] = sum (1238, 78392); array[1] = sum (379265, 23674); array[2] = sum (872934, 234); diff --git a/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py b/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py index 79e4e627592c0..aaba156537639 100644 --- a/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py +++ b/packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py @@ -39,7 +39,7 @@ class DynamicValueChildCountTestCase(TestBase): """Test fetching C++ dynamic values from pointers & references.""" """Get argument vals for the call stack when stopped on a breakpoint.""" 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/functionalities/embedded_interpreter/TestConvenienceVariables.py b/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py index 937ac92700193..0f130b3ecbabd 100644 --- a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py +++ b/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py @@ -29,7 +29,7 @@ class ConvenienceVariablesCase(TestBase): """Test convenience variables lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame.""" self.build() import pexpect - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") prompt = "(lldb) " python_prompt = ">>> " diff --git a/packages/Python/lldbsuite/test/functionalities/exec/Makefile b/packages/Python/lldbsuite/test/functionalities/exec/Makefile index 8a7102e347af2..784a53da4776e 100644 --- a/packages/Python/lldbsuite/test/functionalities/exec/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/exec/Makefile @@ -2,4 +2,12 @@ LEVEL = ../../make CXX_SOURCES := main.cpp +all: a.out secondprog + include $(LEVEL)/Makefile.rules + +secondprog: + $(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/secondprog.mk + +clean:: + $(MAKE) -f $(SRCDIR)/secondprog.mk clean diff --git a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py index 550eae85e1d6d..611869932b61d 100644 --- a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py +++ b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py @@ -29,44 +29,32 @@ class ExecTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipUnlessDarwin - @expectedFailureAll(oslist=['macosx'], bugnumber="rdar://36134350") # when building with cmake on green gragon or on ci.swift.org, this test fails. @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532") @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems def test_hitting_exec (self): self.do_test(False) @skipUnlessDarwin - @expectedFailureAll(oslist=['macosx'], bugnumber="rdar://36134350") # when building with cmake on green gragon or on ci.swift.org, this test fails. @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532") @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems def test_skipping_exec (self): - self.do_test(False) + self.do_test(True) def do_test(self, skip_exec): - if self.getArchitecture() == 'x86_64': - source = os.path.join(os.getcwd(), "main.cpp") - o_file = os.path.join(os.getcwd(), "main.o") - execute_command( - "'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" % - (os.environ["CC"], source, o_file)) - execute_command( - "'%s' -g -O0 -arch i386 -arch x86_64 '%s'" % - (os.environ["CC"], o_file)) - if self.debug_info != "dsym": - dsym_path = os.path.join(os.getcwd(), "a.out.dSYM") - execute_command("rm -rf '%s'" % (dsym_path)) - else: - self.build() - - exe = os.path.join(os.getcwd(), "a.out") + self.build() + exe = self.getBuildArtifact("a.out") + secondprog = self.getBuildArtifact("secondprog") # Create the target target = self.dbg.CreateTarget(exe) # Create any breakpoints we need - breakpoint = target.BreakpointCreateBySourceRegex( + breakpoint1 = target.BreakpointCreateBySourceRegex( 'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False)) - self.assertTrue(breakpoint, VALID_BREAKPOINT) + self.assertTrue(breakpoint1, VALID_BREAKPOINT) + breakpoint2 = target.BreakpointCreateBySourceRegex( + 'Set breakpoint 2 here', lldb.SBFileSpec("secondprog.cpp", False)) + self.assertTrue(breakpoint2, VALID_BREAKPOINT) # Launch the process process = target.LaunchSimple( @@ -74,7 +62,7 @@ class ExecTestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) if skip_exec: - self.debugger.HandleCommand("settings set target.process.stop-on-exec false") + self.dbg.HandleCommand("settings set target.process.stop-on-exec false") def cleanup(): self.runCmd("settings set target.process.stop-on-exec false", check=False) @@ -82,50 +70,48 @@ class ExecTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - - for i in range(6): - # The stop reason of the thread should be breakpoint. - self.assertTrue(process.GetState() == lldb.eStateStopped, - STOPPED_DUE_TO_BREAKPOINT) + # The stop reason of the thread should be breakpoint. + self.assertTrue(process.GetState() == lldb.eStateStopped, + STOPPED_DUE_TO_BREAKPOINT) + + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint1) + self.assertTrue(len(threads) == 1) - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - self.assertTrue(len(threads) == 1) + # We had a deadlock tearing down the TypeSystemMap on exec, but only if some + # expression had been evaluated. So make sure we do that here so the teardown + # is not trivial. - # We had a deadlock tearing down the TypeSystemMap on exec, but only if some - # expression had been evaluated. So make sure we do that here so the teardown - # is not trivial. + thread = threads[0] + value = thread.frames[0].EvaluateExpression("1 + 2") + self.assertTrue( + value.IsValid(), + "Expression evaluated successfully") + int_value = value.GetValueAsSigned() + self.assertTrue(int_value == 3, "Expression got the right result.") - thread = threads[0] - value = thread.frames[0].EvaluateExpression("1 + 2") + # Run and we should stop due to exec + process.Continue() + + if not skip_exec: + self.assertTrue(process.GetState() == lldb.eStateStopped, + "Process should be stopped at __dyld_start") + + threads = lldbutil.get_stopped_threads( + process, lldb.eStopReasonExec) self.assertTrue( - value.IsValid(), - "Expression evaluated successfully") - int_value = value.GetValueAsSigned() - self.assertTrue(int_value == 3, "Expression got the right result.") + len(threads) == 1, + "We got a thread stopped for exec.") - # Run and we should stop due to exec + # Run and we should stop at breakpoint in main after exec process.Continue() - if not skip_exec: - self.assertTrue(process.GetState() == lldb.eStateStopped, - "Process should be stopped at __dyld_start") - - threads = lldbutil.get_stopped_threads( - process, lldb.eStopReasonExec) - self.assertTrue( - len(threads) == 1, - "We got a thread stopped for exec.") - - # Run and we should stop at breakpoint in main after exec - process.Continue() - - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - if self.TraceOn(): - for t in process.threads: - print(t) - if t.GetStopReason() != lldb.eStopReasonBreakpoint: - self.runCmd("bt") - self.assertTrue(len(threads) == 1, - "Stopped at breakpoint in exec'ed process.") + threads = lldbutil.get_threads_stopped_at_breakpoint( + process, breakpoint2) + if self.TraceOn(): + for t in process.threads: + print(t) + if t.GetStopReason() != lldb.eStopReasonBreakpoint: + self.runCmd("bt") + self.assertTrue(len(threads) == 1, + "Stopped at breakpoint in exec'ed process.") diff --git a/packages/Python/lldbsuite/test/functionalities/exec/main.cpp b/packages/Python/lldbsuite/test/functionalities/exec/main.cpp index 700c5dd94b285..92206b2d88ef7 100644 --- a/packages/Python/lldbsuite/test/functionalities/exec/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/exec/main.cpp @@ -6,6 +6,8 @@ #include <stdlib.h> #include <spawn.h> #include <unistd.h> +#include <libgen.h> +#include <string> static void exit_with_errno (int err, const char *prefix) @@ -21,9 +23,9 @@ exit_with_errno (int err, const char *prefix) } static pid_t -spawn_process (const char **argv, +spawn_process (const char *progname, + const char **argv, const char **envp, - cpu_type_t cpu_type, int &err) { pid_t pid = 0; @@ -46,21 +48,12 @@ spawn_process (const char **argv, posix_spawnattr_setsigmask(&attr, &no_signals); posix_spawnattr_setsigdefault(&attr, &all_signals); - if (cpu_type != 0) - { - size_t ocount = 0; - err = posix_spawnattr_setbinpref_np (&attr, 1, &cpu_type, &ocount); - } - - if (err == 0) - { - err = posix_spawn (&pid, - argv[0], - file_actions, - &attr, - (char * const *)argv, - (char * const *)envp); - } + err = posix_spawn (&pid, + progname, + file_actions, + &attr, + (char * const *)argv, + (char * const *)envp); posix_spawnattr_destroy(&attr); } @@ -70,25 +63,14 @@ spawn_process (const char **argv, int main (int argc, char const **argv) { - printf ("pid %i: Pointer size is %zu.\n", getpid(), sizeof(void *)); + char *buf = (char*) malloc (strlen (argv[0]) + 12); + strlcpy (buf, argv[0], strlen (argv[0]) + 1); + std::string directory_name (::dirname (buf)); + + std::string other_program = directory_name + "/secondprog"; int err = 0; // Set breakpoint 1 here -#if defined (__x86_64__) - if (sizeof(void *) == 8) - { - spawn_process (argv, NULL, CPU_TYPE_I386, err); - if (err) - exit_with_errno (err, "posix_spawn i386 error"); - } - else - { - spawn_process (argv, NULL, CPU_TYPE_X86_64, err); - if (err) - exit_with_errno (err, "posix_spawn x86_64 error"); - } -#else - spawn_process (argv, NULL, 0, err); + spawn_process (other_program.c_str(), argv, NULL, err); if (err) exit_with_errno (err, "posix_spawn x86_64 error"); -#endif return 0; } diff --git a/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp b/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp new file mode 100644 index 0000000000000..5653471c15307 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp @@ -0,0 +1,5 @@ +#include <stdio.h> +int main () +{ + puts ("I am the second program."); // Set breakpoint 2 here +} diff --git a/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk b/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk new file mode 100644 index 0000000000000..88f76b5113b4f --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk @@ -0,0 +1,6 @@ +LEVEL = ../../make + +CXX_SOURCES := secondprog.cpp +EXE = secondprog + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py b/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py index 719f3f7199344..a498f0a360ee8 100644 --- a/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py +++ b/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py @@ -26,7 +26,7 @@ class ExprDoesntDeadlockTestCase(TestBase): def test_with_run_command(self): """Test that expr will time out and allow other threads to run if it blocks.""" 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/functionalities/fat_archives/Makefile b/packages/Python/lldbsuite/test/functionalities/fat_archives/Makefile index e1832fdefbee9..c7c5ef405459e 100644 --- a/packages/Python/lldbsuite/test/functionalities/fat_archives/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/fat_archives/Makefile @@ -1,12 +1,14 @@ -all: clean - $(CC) -arch i386 -g -c a.c +SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ + +all: a.c clean + $(CC) -arch i386 -g -c $(SRCDIR)/a.c ar -q liba-i386.a a.o ranlib liba-i386.a - $(CC) -arch x86_64 -g -c a.c + $(CC) -arch x86_64 -g -c $(SRCDIR)/a.c ar -q liba-x86_64.a a.o ranlib liba-x86_64.a lipo -create -output liba.a liba-i386.a liba-x86_64.a - $(CC) -g -c main.c + $(CC) -g -c $(SRCDIR)/main.c $(CC) -o a.out main.o -L. -la clean: diff --git a/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py b/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py index d62ccbff87fa5..80240534c368c 100644 --- a/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py +++ b/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py @@ -34,7 +34,7 @@ class FatArchiveTestCase(TestBase): DWARF in .o file debugging. The only thing this test needs to do is to compile and set a breakpoint in the target and verify any breakpoint locations have valid debug info for the function, and source file and line.''' - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create the target target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py b/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py index b7592c93704d1..f311fac4c0f7c 100644 --- a/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py +++ b/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py @@ -22,11 +22,12 @@ class TestFormats(TestBase): def test_formats(self): """Test format string functionality.""" self.build() + exe = self.getBuildArtifact("a.out") import pexpect prompt = "(lldb) " child = pexpect.spawn( - '%s %s -x -o "b main" -o r a.out' % - (lldbtest_config.lldbExec, self.lldbOption)) + '%s %s -x -o "b main" -o r %s' % + (lldbtest_config.lldbExec, self.lldbOption, exe)) # Turn on logging for what the child sends back. if self.TraceOn(): child.logfile_read = sys.stdout @@ -34,7 +35,7 @@ class TestFormats(TestBase): self.child = child # Substitute 'Help!' for 'help' using the 'commands regex' mechanism. - child.expect_exact(prompt + 'target create "a.out"') + child.expect_exact(prompt + 'target create "%s"' % exe) child.expect_exact(prompt + 'b main') child.expect_exact(prompt + 'r') child.expect_exact(prompt) diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py index 276760d305744..4abf1a8129633 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/array/TestArray.py @@ -14,12 +14,14 @@ from lldbsuite.test import lldbutil class TestArray(TestBase): mydir = TestBase.compute_mydir(__file__) + def setUp(self): + TestBase.setUp(self) + @skipUnlessDarwin @skipIfDarwinEmbedded # <rdar://problem/33842388> frame diagnose doesn't work for armv7 or arm64 def test_array(self): - TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py index 6529e11fafa89..e198720db57da 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/bad-reference/TestBadReference.py @@ -19,7 +19,7 @@ class TestBadReference(TestBase): def test_bad_reference(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py index 2e6fad5e1fdb2..7823c639572cf 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/complicated-expression/TestComplicatedExpression.py @@ -19,7 +19,7 @@ class TestDiagnoseDereferenceArgument(TestBase): def test_diagnose_dereference_argument(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py index 7839a47a8f411..335d61767cd8c 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py @@ -19,7 +19,7 @@ class TestDiagnoseDereferenceArgument(TestBase): def test_diagnose_dereference_argument(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py index 8e5cd430293d2..0398a161dcd88 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py @@ -20,7 +20,7 @@ class TestDiagnoseDereferenceFunctionReturn(TestBase): def test_diagnose_dereference_function_return(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py index 201923fb89d60..272a64e117b91 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/dereference-this/TestDiagnoseDereferenceThis.py @@ -19,7 +19,7 @@ class TestDiagnoseDereferenceThis(TestBase): def test_diagnose_dereference_this(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py index 08ef1c7fc5e6a..3d9c893bbd400 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/inheritance/TestDiagnoseInheritance.py @@ -19,7 +19,7 @@ class TestDiagnoseInheritance(TestBase): def test_diagnose_inheritance(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py index e962c2673faf8..da1fd187d1427 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/local-variable/TestLocalVariable.py @@ -19,7 +19,7 @@ class TestLocalVariable(TestBase): def test_local_variable(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py index bc11bd1afb78c..437cdbbc93b7e 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py @@ -19,7 +19,7 @@ class TestDiagnoseVirtualMethodCall(TestBase): def test_diagnose_virtual_method_call(self): TestBase.setUp(self) self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) self.expect("thread list", "Thread should be stopped", diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile b/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile index 089fc237b0540..cb1af719ac355 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile @@ -6,7 +6,7 @@ C_SOURCES := somefunc.c include $(LEVEL)/Makefile.rules other-2.o: other-2.cpp - $(CXX) $(CFLAGS_NO_DEBUG) -c other-2.cpp + $(CXX) $(CFLAGS_NO_DEBUG) -c $(SRCDIR)/other-2.cpp somefunc.o: somefunc.c - $(CC) $(CFLAGS) -std=c99 -c somefunc.c
\ No newline at end of file + $(CC) $(CFLAGS) -std=c99 -c $(SRCDIR)/somefunc.c diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py b/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py index 178e165f3cbe5..59af2de836ffb 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py +++ b/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py @@ -10,6 +10,7 @@ import time import re import lldb import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -22,6 +23,7 @@ class TestFrameGuessLanguage(TestBase): # each debug info format. NO_DEBUG_INFO_TESTCASE = True + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37658") def test_guess_language(self): """Test GuessLanguage for C and C++.""" self.build() @@ -39,7 +41,7 @@ class TestFrameGuessLanguage(TestBase): def do_test(self): """Test GuessLanguage for C & C++.""" - 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/functionalities/frame_var/TestFrameVar.py b/packages/Python/lldbsuite/test/functionalities/frame_var/TestFrameVar.py index b29f94bdb059f..960891b9eefc5 100644 --- a/packages/Python/lldbsuite/test/functionalities/frame_var/TestFrameVar.py +++ b/packages/Python/lldbsuite/test/functionalities/frame_var/TestFrameVar.py @@ -31,7 +31,7 @@ class TestFrameVar(TestBase): TestBase.setUp(self) def do_test(self): - 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/functionalities/gdb_remote_client/TestGDBRemoteClient.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py new file mode 100644 index 0000000000000..3bf0c52edaedc --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py @@ -0,0 +1,39 @@ +import lldb +import binascii +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + + +class TestGDBRemoteClient(GDBRemoteTestBase): + + def test_connect(self): + """Test connecting to a remote gdb server""" + target = self.createTarget("a.yaml") + process = self.connect(target) + self.assertPacketLogContains(["qProcessInfo", "qfThreadInfo"]) + + def test_attach_fail(self): + error_msg = "mock-error-msg" + + class MyResponder(MockGDBServerResponder): + # Pretend we don't have any process during the initial queries. + def qC(self): + return "E42" + + def qfThreadInfo(self): + return "OK" # No threads. + + # Then, when we are asked to attach, error out. + def vAttach(self, pid): + return "E42;" + binascii.hexlify(error_msg.encode()).decode() + + self.server.responder = MyResponder() + + target = self.dbg.CreateTarget("") + process = self.connect(target) + lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateConnected]) + + error = lldb.SBError() + target.AttachToProcessWithID(lldb.SBListener(), 47, error) + self.assertEquals(error_msg, error.GetCString()) diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py new file mode 100644 index 0000000000000..f70c854ed6d40 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py @@ -0,0 +1,80 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + + +class TestGDBRemoteLoad(GDBRemoteTestBase): + + def setUp(self): + super(TestGDBRemoteLoad, self).setUp() + self._initial_platform = lldb.DBG.GetSelectedPlatform() + + def tearDown(self): + lldb.DBG.SetSelectedPlatform(self._initial_platform) + super(TestGDBRemoteLoad, self).tearDown() + + def test_module_load_address(self): + """Test that setting the load address of a module uses virtual addresses""" + target = self.createTarget("a.yaml") + process = self.connect(target) + module = target.GetModuleAtIndex(0) + self.assertTrue(module.IsValid()) + self.assertTrue(target.SetModuleLoadAddress(module, 0).Success()) + address = target.ResolveLoadAddress(0x2001) + self.assertTrue(address.IsValid()) + self.assertEqual(".data", address.GetSection().GetName()) + + def test_ram_load(self): + """Test loading an object file to a target's ram""" + target = self.createTarget("a.yaml") + process = self.connect(target) + self.dbg.HandleCommand("target modules load -l -s0") + self.assertPacketLogContains([ + "M1000,4:c3c3c3c3", + "M1004,2:3232" + ]) + + @skipIfXmlSupportMissing + def test_flash_load(self): + """Test loading an object file to a target's flash memory""" + + class Responder(MockGDBServerResponder): + def qSupported(self, client_supported): + return "PacketSize=3fff;QStartNoAckMode+;qXfer:memory-map:read+" + + def qXferRead(self, obj, annex, offset, length): + if obj == "memory-map": + return (self.MEMORY_MAP[offset:offset + length], + offset + length < len(self.MEMORY_MAP)) + return None, False + + def other(self, packet): + if packet[0:11] == "vFlashErase": + return "OK" + if packet[0:11] == "vFlashWrite": + return "OK" + if packet == "vFlashDone": + return "OK" + return "" + + MEMORY_MAP = """<?xml version="1.0"?> +<memory-map> + <memory type="ram" start="0x0" length="0x1000"/> + <memory type="flash" start="0x1000" length="0x1000"> + <property name="blocksize">0x100</property> + </memory> + <memory type="ram" start="0x2000" length="0x1D400"/> +</memory-map> +""" + + self.server.responder = Responder() + target = self.createTarget("a.yaml") + process = self.connect(target) + self.dbg.HandleCommand("target modules load -l -s0") + self.assertPacketLogContains([ + "vFlashErase:1000,100", + "vFlashWrite:1000:\xc3\xc3\xc3\xc3", + "vFlashWrite:1004:\x32\x32", + "vFlashDone" + ]) diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRestartBug.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRestartBug.py new file mode 100644 index 0000000000000..142861a37dff2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestRestartBug.py @@ -0,0 +1,62 @@ +from __future__ import print_function +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + + +class TestRestartBug(GDBRemoteTestBase): + + @expectedFailureAll(bugnumber="llvm.org/pr24530") + def test(self): + """ + Test auto-continue behavior when a process is interrupted to deliver + an "asynchronous" packet. This simulates the situation when a process + stops on its own just as lldb client is about to interrupt it. The + client should not auto-continue in this case, unless the user has + explicitly requested that we ignore signals of this type. + """ + class MyResponder(MockGDBServerResponder): + continueCount = 0 + + def setBreakpoint(self, packet): + return "OK" + + def interrupt(self): + # Simulate process stopping due to a raise(SIGINT) just as lldb + # is about to interrupt it. + return "T02reason:signal" + + def cont(self): + self.continueCount += 1 + if self.continueCount == 1: + # No response, wait for the client to interrupt us. + return None + return "W00" # Exit + + self.server.responder = MyResponder() + target = self.createTarget("a.yaml") + process = self.connect(target) + self.dbg.SetAsync(True) + process.Continue() + + # resume the process and immediately try to set another breakpoint. When using the remote + # stub, this will trigger a request to stop the process. Make sure we + # do not lose this signal. + bkpt = target.BreakpointCreateByAddress(0x1234) + self.assertTrue(bkpt.IsValid()) + self.assertEqual(bkpt.GetNumLocations(), 1) + + event = lldb.SBEvent() + while self.dbg.GetListener().WaitForEvent(2, event): + if self.TraceOn(): + print("Process changing state to:", + self.dbg.StateAsCString(process.GetStateFromEvent(event))) + if process.GetStateFromEvent(event) == lldb.eStateExited: + break + + # We should get only one continue packet as the client should not + # auto-continue after setting the breakpoint. + self.assertEqual(self.server.responder.continueCount, 1) + # And the process should end up in the stopped state. + self.assertEqual(process.GetState(), lldb.eStateStopped) diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py new file mode 100644 index 0000000000000..ef9ce77009638 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py @@ -0,0 +1,124 @@ +from __future__ import print_function +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + +class TestTargetXMLArch(GDBRemoteTestBase): + + @skipIfXmlSupportMissing + @expectedFailureAll(archs=["i386"]) + @skipIfRemote + def test(self): + """ + Test lldb's parsing of the <architecture> tag in the target.xml register + description packet. + """ + class MyResponder(MockGDBServerResponder): + + def qXferRead(self, obj, annex, offset, length): + if annex == "target.xml": + return """<?xml version="1.0"?> + <target version="1.0"> + <architecture>i386:x86-64</architecture> + <feature name="org.gnu.gdb.i386.core"> + + <flags id="i386_eflags" size="4"> + <field name="CF" start="0" end="0"/> + <field name="" start="1" end="1"/> + <field name="PF" start="2" end="2"/> + <field name="AF" start="4" end="4"/> + <field name="ZF" start="6" end="6"/> + <field name="SF" start="7" end="7"/> + <field name="TF" start="8" end="8"/> + <field name="IF" start="9" end="9"/> + <field name="DF" start="10" end="10"/> + <field name="OF" start="11" end="11"/> + <field name="NT" start="14" end="14"/> + <field name="RF" start="16" end="16"/> + <field name="VM" start="17" end="17"/> + <field name="AC" start="18" end="18"/> + <field name="VIF" start="19" end="19"/> + <field name="VIP" start="20" end="20"/> + <field name="ID" start="21" end="21"/> + </flags> + + <reg name="rax" bitsize="64" regnum="0" type="int" group="general"/> + <reg name="rbx" bitsize="64" regnum="1" type="int" group="general"/> + <reg name="rcx" bitsize="64" regnum="2" type="int" group="general"/> + <reg name="rdx" bitsize="64" regnum="3" type="int" group="general"/> + <reg name="rsi" bitsize="64" regnum="4" type="int" group="general"/> + <reg name="rdi" bitsize="64" regnum="5" type="int" group="general"/> + <reg name="rbp" bitsize="64" regnum="6" type="data_ptr" group="general"/> + <reg name="rsp" bitsize="64" regnum="7" type="data_ptr" group="general"/> + <reg name="r8" bitsize="64" regnum="8" type="int" group="general"/> + <reg name="r9" bitsize="64" regnum="9" type="int" group="general"/> + <reg name="r10" bitsize="64" regnum="10" type="int" group="general"/> + <reg name="r11" bitsize="64" regnum="11" type="int" group="general"/> + <reg name="r12" bitsize="64" regnum="12" type="int" group="general"/> + <reg name="r13" bitsize="64" regnum="13" type="int" group="general"/> + <reg name="r14" bitsize="64" regnum="14" type="int" group="general"/> + <reg name="r15" bitsize="64" regnum="15" type="int" group="general"/> + <reg name="rip" bitsize="64" regnum="16" type="code_ptr" group="general"/> + <reg name="eflags" bitsize="32" regnum="17" type="i386_eflags" group="general"/> + + <reg name="cs" bitsize="32" regnum="18" type="int" group="general"/> + <reg name="ss" bitsize="32" regnum="19" type="int" group="general"/> + <reg name="ds" bitsize="32" regnum="20" type="int" group="general"/> + <reg name="es" bitsize="32" regnum="21" type="int" group="general"/> + <reg name="fs" bitsize="32" regnum="22" type="int" group="general"/> + <reg name="gs" bitsize="32" regnum="23" type="int" group="general"/> + + <reg name="st0" bitsize="80" regnum="24" type="i387_ext" group="float"/> + <reg name="st1" bitsize="80" regnum="25" type="i387_ext" group="float"/> + <reg name="st2" bitsize="80" regnum="26" type="i387_ext" group="float"/> + <reg name="st3" bitsize="80" regnum="27" type="i387_ext" group="float"/> + <reg name="st4" bitsize="80" regnum="28" type="i387_ext" group="float"/> + <reg name="st5" bitsize="80" regnum="29" type="i387_ext" group="float"/> + <reg name="st6" bitsize="80" regnum="30" type="i387_ext" group="float"/> + <reg name="st7" bitsize="80" regnum="31" type="i387_ext" group="float"/> + + <reg name="fctrl" bitsize="32" regnum="32" type="int" group="float"/> + <reg name="fstat" bitsize="32" regnum="33" type="int" group="float"/> + <reg name="ftag" bitsize="32" regnum="34" type="int" group="float"/> + <reg name="fiseg" bitsize="32" regnum="35" type="int" group="float"/> + <reg name="fioff" bitsize="32" regnum="36" type="int" group="float"/> + <reg name="foseg" bitsize="32" regnum="37" type="int" group="float"/> + <reg name="fooff" bitsize="32" regnum="38" type="int" group="float"/> + <reg name="fop" bitsize="32" regnum="39" type="int" group="float"/> + </feature> + </target>""", False + else: + return None, False + + def qC(self): + return "QC1" + + def haltReason(self): + return "T05thread:00000001;06:9038d60f00700000;07:98b4062680ffffff;10:c0d7bf1b80ffffff;" + + def readRegister(self, register): + regs = {0x0: "00b0060000610000", + 0xa: "68fe471c80ffffff", + 0xc: "60574a1c80ffffff", + 0xd: "18f3042680ffffff", + 0xe: "be8a4d7142000000", + 0xf: "50df471c80ffffff", + 0x10: "c0d7bf1b80ffffff" } + if register in regs: + return regs[register] + else: + return "0000000000000000" + + self.server.responder = MyResponder() + interp = self.dbg.GetCommandInterpreter() + result = lldb.SBCommandReturnObject() + if self.TraceOn(): + interp.HandleCommand("log enable gdb-remote packets", result) + target = self.dbg.CreateTarget('') + self.assertEqual('', target.GetTriple()) + process = self.connect(target) + if self.TraceOn(): + interp.HandleCommand("target list", result) + print(result.GetOutput()) + self.assertTrue(target.GetTriple().startswith('x86_64--')) diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py new file mode 100644 index 0000000000000..400a936610339 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py @@ -0,0 +1,50 @@ +from __future__ import print_function +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + + +class TestThreadSelectionBug(GDBRemoteTestBase): + def test(self): + class MyResponder(MockGDBServerResponder): + def cont(self): + # Simulate process stopping due to a raise(SIGINT) + return "T01reason:signal" + + self.server.responder = MyResponder() + target = self.createTarget("a.yaml") + process = self.connect(target) + python_os_plugin_path = os.path.join(self.getSourceDir(), + 'operating_system.py') + command = "settings set target.process.python-os-plugin-path '{}'".format( + python_os_plugin_path) + self.dbg.HandleCommand(command) + + self.assertTrue(process, PROCESS_IS_VALID) + self.assertEqual(process.GetNumThreads(), 3) + + # Verify our OS plug-in threads showed up + thread = process.GetThreadByID(0x1) + self.assertTrue( + thread.IsValid(), + "Make sure there is a thread 0x1 after we load the python OS plug-in") + thread = process.GetThreadByID(0x2) + self.assertTrue( + thread.IsValid(), + "Make sure there is a thread 0x2 after we load the python OS plug-in") + thread = process.GetThreadByID(0x3) + self.assertTrue( + thread.IsValid(), + "Make sure there is a thread 0x3 after we load the python OS plug-in") + + # Verify that a thread other than 3 is selected. + thread = process.GetSelectedThread() + self.assertNotEqual(thread.GetThreadID(), 0x3) + + # Verify that we select the thread backed by physical thread 1, rather + # than virtual thread 1. The mapping comes from the OS plugin, where we + # specified that thread 3 is backed by real thread 1. + process.Continue() + thread = process.GetSelectedThread() + self.assertEqual(thread.GetThreadID(), 0x3) diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/a.yaml b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/a.yaml new file mode 100644 index 0000000000000..f4e9ff5d87221 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/a.yaml @@ -0,0 +1,34 @@ +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_ARM +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x1000 + AddressAlign: 0x4 + Content: "c3c3c3c3" + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x2000 + AddressAlign: 0x4 + Content: "3232" +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0x1000 + PAddr: 0x1000 + Align: 0x4 + Sections: + - Section: .text + - Type: PT_LOAD + Flags: [ PF_R, PF_W ] + VAddr: 0x2000 + PAddr: 0x1004 + Align: 0x4 + Sections: + - Section: .data diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py new file mode 100644 index 0000000000000..ebafd405e23e8 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py @@ -0,0 +1,477 @@ +import os +import os.path +import subprocess +import threading +import socket +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbtest_config + + +def checksum(message): + """ + Calculate the GDB server protocol checksum of the message. + + The GDB server protocol uses a simple modulo 256 sum. + """ + check = 0 + for c in message: + check += ord(c) + return check % 256 + + +def frame_packet(message): + """ + Create a framed packet that's ready to send over the GDB connection + channel. + + Framing includes surrounding the message between $ and #, and appending + a two character hex checksum. + """ + return "$%s#%02x" % (message, checksum(message)) + + +def escape_binary(message): + """ + Escape the binary message using the process described in the GDB server + protocol documentation. + + Most bytes are sent through as-is, but $, #, and { are escaped by writing + a { followed by the original byte mod 0x20. + """ + out = "" + for c in message: + d = ord(c) + if d in (0x23, 0x24, 0x7d): + out += chr(0x7d) + out += chr(d ^ 0x20) + else: + out += c + return out + + +def hex_encode_bytes(message): + """ + Encode the binary message by converting each byte into a two-character + hex string. + """ + out = "" + for c in message: + out += "%02x" % ord(c) + return out + + +def hex_decode_bytes(hex_bytes): + """ + Decode the hex string into a binary message by converting each two-character + hex string into a single output byte. + """ + out = "" + hex_len = len(hex_bytes) + while i < hex_len - 1: + out += chr(int(hex_bytes[i:i + 2]), 16) + i += 2 + return out + + +class MockGDBServerResponder: + """ + A base class for handling client packets and issuing server responses for + GDB tests. + + This handles many typical situations, while still allowing subclasses to + completely customize their responses. + + Most subclasses will be interested in overriding the other() method, which + handles any packet not recognized in the common packet handling code. + """ + + registerCount = 40 + packetLog = None + + def __init__(self): + self.packetLog = [] + + def respond(self, packet): + """ + Return the unframed packet data that the server should issue in response + to the given packet received from the client. + """ + self.packetLog.append(packet) + if packet is MockGDBServer.PACKET_INTERRUPT: + return self.interrupt() + if packet == "c": + return self.cont() + if packet == "g": + return self.readRegisters() + if packet[0] == "G": + return self.writeRegisters(packet[1:]) + if packet[0] == "p": + return self.readRegister(int(packet[1:], 16)) + if packet[0] == "P": + register, value = packet[1:].split("=") + return self.readRegister(int(register, 16), value) + if packet[0] == "m": + addr, length = [int(x, 16) for x in packet[1:].split(',')] + return self.readMemory(addr, length) + if packet[0] == "M": + location, encoded_data = packet[1:].split(":") + addr, length = [int(x, 16) for x in location.split(',')] + return self.writeMemory(addr, encoded_data) + if packet[0:7] == "qSymbol": + return self.qSymbol(packet[8:]) + if packet[0:10] == "qSupported": + return self.qSupported(packet[11:].split(";")) + if packet == "qfThreadInfo": + return self.qfThreadInfo() + if packet == "qC": + return self.qC() + if packet == "QEnableErrorStrings": + return self.QEnableErrorStrings() + if packet == "?": + return self.haltReason() + if packet[0] == "H": + return self.selectThread(packet[1], int(packet[2:], 16)) + if packet[0:6] == "qXfer:": + obj, read, annex, location = packet[6:].split(":") + offset, length = [int(x, 16) for x in location.split(',')] + data, has_more = self.qXferRead(obj, annex, offset, length) + if data is not None: + return self._qXferResponse(data, has_more) + return "" + if packet.startswith("vAttach;"): + pid = packet.partition(';')[2] + return self.vAttach(int(pid, 16)) + if packet[0] == "Z": + return self.setBreakpoint(packet) + return self.other(packet) + + def interrupt(self): + raise self.UnexpectedPacketException() + + def cont(self): + raise self.UnexpectedPacketException() + + def readRegisters(self): + return "00000000" * self.registerCount + + def readRegister(self, register): + return "00000000" + + def writeRegisters(self, registers_hex): + return "OK" + + def writeRegister(self, register, value_hex): + return "OK" + + def readMemory(self, addr, length): + return "00" * length + + def writeMemory(self, addr, data_hex): + return "OK" + + def qSymbol(self, symbol_args): + return "OK" + + def qSupported(self, client_supported): + return "qXfer:features:read+;PacketSize=3fff;QStartNoAckMode+" + + def qfThreadInfo(self): + return "l" + + def qC(self): + return "QC0" + + def QEnableErrorStrings(self): + return "OK" + + def haltReason(self): + # SIGINT is 2, return type is 2 digit hex string + return "S02" + + def qXferRead(self, obj, annex, offset, length): + return None, False + + def _qXferResponse(self, data, has_more): + return "%s%s" % ("m" if has_more else "l", escape_binary(data)) + + def vAttach(self, pid): + raise self.UnexpectedPacketException() + + def selectThread(self, op, thread_id): + return "OK" + + def setBreakpoint(self, packet): + raise self.UnexpectedPacketException() + + def other(self, packet): + # empty string means unsupported + return "" + + """ + Raised when we receive a packet for which there is no default action. + Override the responder class to implement behavior suitable for the test at + hand. + """ + class UnexpectedPacketException(Exception): + pass + + +class MockGDBServer: + """ + A simple TCP-based GDB server that can test client behavior by receiving + commands and issuing custom-tailored responses. + + Responses are generated via the .responder property, which should be an + instance of a class based on MockGDBServerResponder. + """ + + responder = None + port = 0 + _socket = None + _client = None + _thread = None + _receivedData = None + _receivedDataOffset = None + _shouldSendAck = True + + def __init__(self, port = 0): + self.responder = MockGDBServerResponder() + self.port = port + self._socket = socket.socket() + + def start(self): + # Block until the socket is up, so self.port is available immediately. + # Then start a thread that waits for a client connection. + addr = ("127.0.0.1", self.port) + self._socket.bind(addr) + self.port = self._socket.getsockname()[1] + self._socket.listen(0) + self._thread = threading.Thread(target=self._run) + self._thread.start() + + def stop(self): + self._socket.close() + self._thread.join() + self._thread = None + + def _run(self): + # For testing purposes, we only need to worry about one client + # connecting just one time. + try: + # accept() is stubborn and won't fail even when the socket is + # shutdown, so we'll use a timeout + self._socket.settimeout(2.0) + client, client_addr = self._socket.accept() + self._client = client + # The connected client inherits its timeout from self._socket, + # but we'll use a blocking socket for the client + self._client.settimeout(None) + except: + return + self._shouldSendAck = True + self._receivedData = "" + self._receivedDataOffset = 0 + data = None + while True: + try: + data = self._client.recv(4096) + if data is None or len(data) == 0: + break + # In Python 2, sockets return byte strings. In Python 3, sockets return bytes. + # If we got bytes (and not a byte string), decode them to a string for later handling. + if isinstance(data, bytes) and not isinstance(data, str): + data = data.decode() + self._receive(data) + except Exception as e: + self._client.close() + break + + def _receive(self, data): + """ + Collects data, parses and responds to as many packets as exist. + Any leftover data is kept for parsing the next time around. + """ + self._receivedData += data + try: + packet = self._parsePacket() + while packet is not None: + self._handlePacket(packet) + packet = self._parsePacket() + except self.InvalidPacketException: + self._client.close() + + def _parsePacket(self): + """ + Reads bytes from self._receivedData, returning: + - a packet's contents if a valid packet is found + - the PACKET_ACK unique object if we got an ack + - None if we only have a partial packet + + Raises an InvalidPacketException if unexpected data is received + or if checksums fail. + + Once a complete packet is found at the front of self._receivedData, + its data is removed form self._receivedData. + """ + data = self._receivedData + i = self._receivedDataOffset + data_len = len(data) + if data_len == 0: + return None + if i == 0: + # If we're looking at the start of the received data, that means + # we're looking for the start of a new packet, denoted by a $. + # It's also possible we'll see an ACK here, denoted by a + + if data[0] == '+': + self._receivedData = data[1:] + return self.PACKET_ACK + if ord(data[0]) == 3: + self._receivedData = data[1:] + return self.PACKET_INTERRUPT + if data[0] == '$': + i += 1 + else: + raise self.InvalidPacketException( + "Unexpected leading byte: %s" % data[0]) + + # If we're looking beyond the start of the received data, then we're + # looking for the end of the packet content, denoted by a #. + # Note that we pick up searching from where we left off last time + while i < data_len and data[i] != '#': + i += 1 + + # If there isn't enough data left for a checksum, just remember where + # we left off so we can pick up there the next time around + if i > data_len - 3: + self._receivedDataOffset = i + return None + + # If we have enough data remaining for the checksum, extract it and + # compare to the packet contents + packet = data[1:i] + i += 1 + try: + check = int(data[i:i + 2], 16) + except ValueError: + raise self.InvalidPacketException("Checksum is not valid hex") + i += 2 + if check != checksum(packet): + raise self.InvalidPacketException( + "Checksum %02x does not match content %02x" % + (check, checksum(packet))) + # remove parsed bytes from _receivedData and reset offset so parsing + # can start on the next packet the next time around + self._receivedData = data[i:] + self._receivedDataOffset = 0 + return packet + + def _handlePacket(self, packet): + if packet is self.PACKET_ACK: + # Ignore ACKs from the client. For the future, we can consider + # adding validation code to make sure the client only sends ACKs + # when it's supposed to. + return + response = "" + # We'll handle the ack stuff here since it's not something any of the + # tests will be concerned about, and it'll get turned off quickly anyway. + if self._shouldSendAck: + self._client.sendall('+'.encode()) + if packet == "QStartNoAckMode": + self._shouldSendAck = False + response = "OK" + elif self.responder is not None: + # Delegate everything else to our responder + response = self.responder.respond(packet) + # Handle packet framing since we don't want to bother tests with it. + if response is not None: + framed = frame_packet(response) + # In Python 2, sockets send byte strings. In Python 3, sockets send bytes. + # If we got a string (and not a byte string), encode it before sending. + if isinstance(framed, str) and not isinstance(framed, bytes): + framed = framed.encode() + self._client.sendall(framed) + + PACKET_ACK = object() + PACKET_INTERRUPT = object() + + class InvalidPacketException(Exception): + pass + + +class GDBRemoteTestBase(TestBase): + """ + Base class for GDB client tests. + + This class will setup and start a mock GDB server for the test to use. + It also provides assertPacketLogContains, which simplifies the checking + of packets sent by the client. + """ + + NO_DEBUG_INFO_TESTCASE = True + mydir = TestBase.compute_mydir(__file__) + server = None + + def setUp(self): + TestBase.setUp(self) + self.server = MockGDBServer() + self.server.start() + + def tearDown(self): + # TestBase.tearDown will kill the process, but we need to kill it early + # so its client connection closes and we can stop the server before + # finally calling the base tearDown. + if self.process() is not None: + self.process().Kill() + self.server.stop() + TestBase.tearDown(self) + + def createTarget(self, yaml_path): + """ + Create a target by auto-generating the object based on the given yaml + instructions. + + This will track the generated object so it can be automatically removed + during tearDown. + """ + yaml_base, ext = os.path.splitext(yaml_path) + obj_path = self.getBuildArtifact(yaml_base) + self.yaml2obj(yaml_path, obj_path) + return self.dbg.CreateTarget(obj_path) + + def connect(self, target): + """ + Create a process by connecting to the mock GDB server. + + Includes assertions that the process was successfully created. + """ + listener = self.dbg.GetListener() + error = lldb.SBError() + url = "connect://localhost:%d" % self.server.port + process = target.ConnectRemote(listener, url, "gdb-remote", error) + self.assertTrue(error.Success(), error.description) + self.assertTrue(process, PROCESS_IS_VALID) + return process + + def assertPacketLogContains(self, packets): + """ + Assert that the mock server's packet log contains the given packets. + + The packet log includes all packets sent by the client and received + by the server. This fuction makes it easy to verify that the client + sent the expected packets to the server. + + The check does not require that the packets be consecutive, but does + require that they are ordered in the log as they ordered in the arg. + """ + i = 0 + j = 0 + log = self.server.responder.packetLog + + while i < len(packets) and j < len(log): + if log[j] == packets[i]: + i += 1 + j += 1 + if i < len(packets): + self.fail(u"Did not receive: %s\nLast 10 packets:\n\t%s" % + (packets[i], u'\n\t'.join(log[-10:]))) diff --git a/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py new file mode 100644 index 0000000000000..ad9b6fd4e55ae --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py @@ -0,0 +1,45 @@ +import lldb +import struct + + +class OperatingSystemPlugIn(object): + """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class""" + + def __init__(self, process): + '''Initialization needs a valid.SBProcess object. + + This plug-in will get created after a live process is valid and has stopped for the first time. + ''' + self.process = None + self.registers = None + self.threads = None + if isinstance(process, lldb.SBProcess) and process.IsValid(): + self.process = process + self.threads = None # Will be an dictionary containing info for each thread + + def get_target(self): + return self.process.target + + def get_thread_info(self): + if not self.threads: + self.threads = [{ + 'tid': 0x1, + 'name': 'one', + 'queue': 'queue1', + 'state': 'stopped', + 'stop_reason': 'none' + }, { + 'tid': 0x2, + 'name': 'two', + 'queue': 'queue2', + 'state': 'stopped', + 'stop_reason': 'none' + }, { + 'tid': 0x3, + 'name': 'three', + 'queue': 'queue3', + 'state': 'stopped', + 'stop_reason': 'sigstop', + 'core': 0 + }] + return self.threads diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py index 7b048fedebba5..75215f89ef0b2 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py @@ -125,7 +125,7 @@ class AssertingInferiorTestCase(TestBase): def inferior_asserting(self): """Inferior asserts upon launching; lldb should catch the event and stop.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -142,7 +142,7 @@ class AssertingInferiorTestCase(TestBase): def inferior_asserting_python(self): """Inferior asserts upon launching; lldb should catch the event and stop.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -166,7 +166,7 @@ class AssertingInferiorTestCase(TestBase): def inferior_asserting_registers(self): """Test that lldb can read registers after asserting.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -178,7 +178,7 @@ class AssertingInferiorTestCase(TestBase): def inferior_asserting_disassemble(self): """Test that lldb can disassemble frames after asserting.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -248,7 +248,7 @@ class AssertingInferiorTestCase(TestBase): def inferior_asserting_expr(self): """Test that the lldb expression interpreter can read symbols after asserting.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -272,7 +272,7 @@ class AssertingInferiorTestCase(TestBase): def inferior_asserting_step(self): """Test that lldb functions correctly after stepping through a call to assert().""" - 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/functionalities/inferior-changed/TestInferiorChanged.py b/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py index 3620de61a2e30..b1b9f4bc04c7b 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py @@ -41,7 +41,7 @@ class ChangedInferiorTestCase(TestBase): def inferior_crashing(self): """Inferior crashes upon launching; lldb should catch the event and stop.""" - self.exe = os.path.join(os.getcwd(), "a.out") + self.exe = self.getBuildArtifact("a.out") self.runCmd("file " + self.exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py index b233d2f768e0f..4f54f5d4103ba 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py @@ -100,7 +100,7 @@ class CrashingInferiorTestCase(TestBase): def inferior_crashing(self): """Inferior crashes upon launching; lldb should catch the event and stop.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -122,7 +122,7 @@ class CrashingInferiorTestCase(TestBase): def inferior_crashing_python(self): """Inferior crashes upon launching; lldb should catch the event and stop.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -148,7 +148,7 @@ class CrashingInferiorTestCase(TestBase): def inferior_crashing_registers(self): """Test that lldb can read registers after crashing.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -160,7 +160,7 @@ class CrashingInferiorTestCase(TestBase): def inferior_crashing_expr(self): """Test that the lldb expression interpreter can read symbols after crashing.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -176,7 +176,7 @@ class CrashingInferiorTestCase(TestBase): def inferior_crashing_step(self): """Test that lldb functions correctly after stepping through a crash.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.set_breakpoint(self.line) @@ -206,7 +206,7 @@ class CrashingInferiorTestCase(TestBase): def inferior_crashing_step_after_break(self): """Test that lldb behaves correctly when stepping after a crash.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -231,7 +231,7 @@ class CrashingInferiorTestCase(TestBase): def inferior_crashing_expr_step_expr(self): """Test that lldb expressions work before and after stepping after a crash.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py index 9987377a83ec7..d8efe65dc7f6d 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py @@ -83,7 +83,7 @@ class CrashingRecursiveInferiorTestCase(TestBase): def recursive_inferior_crashing(self): """Inferior crashes upon launching; lldb should catch the event and stop.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -117,7 +117,7 @@ class CrashingRecursiveInferiorTestCase(TestBase): def recursive_inferior_crashing_python(self): """Inferior crashes upon launching; lldb should catch the event and stop.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -143,7 +143,7 @@ class CrashingRecursiveInferiorTestCase(TestBase): def recursive_inferior_crashing_registers(self): """Test that lldb can read registers after crashing.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -155,7 +155,7 @@ class CrashingRecursiveInferiorTestCase(TestBase): def recursive_inferior_crashing_expr(self): """Test that the lldb expression interpreter can read symbols after crashing.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -168,7 +168,7 @@ class CrashingRecursiveInferiorTestCase(TestBase): def recursive_inferior_crashing_step(self): """Test that lldb functions correctly after stepping through a crash.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.set_breakpoint(self.line) @@ -196,7 +196,7 @@ class CrashingRecursiveInferiorTestCase(TestBase): def recursive_inferior_crashing_step_after_break(self): """Test that lldb behaves correctly when stepping after a crash.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) @@ -221,7 +221,7 @@ class CrashingRecursiveInferiorTestCase(TestBase): def recursive_inferior_crashing_expr_step_expr(self): """Test that lldb expressions work before and after stepping after a crash.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) diff --git a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py index cb801242aa582..4513db2ccdfcf 100644 --- a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py +++ b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py @@ -20,6 +20,7 @@ class TestInlineStepping(TestBase): @expectedFailureAll( compiler="icc", bugnumber="# Not really a bug. ICC combines two inlined functions.") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_with_python_api(self): """Test stepping over and into inlined functions.""" self.build() @@ -32,6 +33,7 @@ class TestInlineStepping(TestBase): self.inline_stepping_step_over() @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_step_in_template_with_python_api(self): """Test stepping in to templated functions.""" self.build() @@ -145,7 +147,7 @@ class TestInlineStepping(TestBase): def inline_stepping(self): """Use Python APIs to test stepping over and hitting breakpoints.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -257,7 +259,7 @@ class TestInlineStepping(TestBase): def inline_stepping_step_over(self): """Use Python APIs to test stepping over and hitting breakpoints.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -288,7 +290,7 @@ class TestInlineStepping(TestBase): def step_in_template(self): """Use Python APIs to test stepping in to templated functions.""" - 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/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py index 7ccfaa688b886..07f04b18bb976 100644 --- a/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py +++ b/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py @@ -22,7 +22,7 @@ class JITLoaderGDBTestCase(TestBase): def test_bogus_values(self): """Test that we handle inferior misusing the GDB JIT interface""" 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/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py b/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py index 43fa5f9d33f24..9b485b2235dd5 100644 --- a/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py +++ b/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py @@ -25,7 +25,7 @@ class LaunchWithShellExpandTestCase(TestBase): @skipIfDarwinEmbedded # iOS etc don't launch the binary via a shell, so arg expansion won't happen def test(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("target create %s" % exe) @@ -39,7 +39,7 @@ class LaunchWithShellExpandTestCase(TestBase): self.runCmd( "process launch -X true -w %s -- fi*.tx? () > <" % - (os.getcwd())) + (self.getSourceDir())) process = self.process() @@ -77,7 +77,7 @@ class LaunchWithShellExpandTestCase(TestBase): self.runCmd( 'process launch -X true -w %s -- "foo bar"' % - (os.getcwd())) + (self.getSourceDir())) process = self.process() @@ -99,7 +99,8 @@ class LaunchWithShellExpandTestCase(TestBase): self.runCmd("process kill") - self.runCmd('process launch -X true -w %s -- foo\ bar' % (os.getcwd())) + self.runCmd('process launch -X true -w %s -- foo\ bar' + % (self.getBuildDir())) process = self.process() diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile b/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile index 9a954a201cf2b..0dd9eb41a4089 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile @@ -7,11 +7,10 @@ CXX_SOURCES := main.cpp include $(LEVEL)/Makefile.rules -.PHONY: a.out: lib_a lib_b lib_c lib_d hidden_lib_d install_name_tool lib_%: - $(MAKE) -f $*.mk + $(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/$*.mk install_name_tool: ifeq ($(OS),Darwin) @@ -20,11 +19,11 @@ endif hidden_lib_d: - $(MAKE) -C hidden + $(MAKE) VPATH=$(SRCDIR)/hidden -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile clean:: - $(MAKE) -f a.mk clean - $(MAKE) -f b.mk clean - $(MAKE) -f c.mk clean - $(MAKE) -f d.mk clean - $(MAKE) -C hidden clean + $(MAKE) -f $(SRCDIR)/a.mk clean + $(MAKE) -f $(SRCDIR)/b.mk clean + $(MAKE) -f $(SRCDIR)/c.mk clean + $(MAKE) -f $(SRCDIR)/d.mk clean + $(MAKE) -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile clean diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py index 98b0c9ca19715..6302112d2fe9e 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -19,15 +19,23 @@ class LoadUnloadTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + def setUp(self): # Call super's setUp(). TestBase.setUp(self) + self.setup_test() + # Invoke the default build rule. + self.build() # Find the line number to break for main.cpp. self.line = line_number( 'main.cpp', '// Set break point at this line for test_lldb_process_load_and_unload_commands().') self.line_d_function = line_number( 'd.cpp', '// Find this line number within d_dunction().') + + def setup_test(self): + lldbutil.mkdir_p(self.getBuildArtifact("hidden")) if not self.platformIsDarwin(): if not lldb.remote_platform and "LD_LIBRARY_PATH" in os.environ: self.runCmd( @@ -36,12 +44,12 @@ class LoadUnloadTestCase(TestBase): "=" + os.environ["LD_LIBRARY_PATH"] + ":" + - os.getcwd()) + self.getBuildDir()) else: if lldb.remote_platform: wd = lldb.remote_platform.GetWorkingDirectory() else: - wd = os.getcwd() + wd = self.getBuildDir() self.runCmd( "settings set target.env-vars " + self.dylibPath + @@ -63,7 +71,7 @@ class LoadUnloadTestCase(TestBase): cwd = os.getcwd() for f in shlibs: err = lldb.remote_platform.Put( - lldb.SBFileSpec(os.path.join(cwd, f)), + lldb.SBFileSpec(self.getBuildArtifact(f)), lldb.SBFileSpec(os.path.join(wd, f))) if err.Fail(): raise RuntimeError( @@ -78,34 +86,32 @@ class LoadUnloadTestCase(TestBase): raise RuntimeError( "Unable to create a directory '%s'." % hidden_dir) err = lldb.remote_platform.Put( - lldb.SBFileSpec(os.path.join(cwd, 'hidden', shlib)), + lldb.SBFileSpec(os.path.join('hidden', shlib)), lldb.SBFileSpec(hidden_file)) if err.Fail(): raise RuntimeError( "Unable copy 'libloadunload_d.so' to '%s'.\n>>> %s" % (wd, err.GetCString())) + # libloadunload_d.so does not appear in the image list because executable + # dependencies are resolved relative to the debuggers PWD. Bug? + @expectedFailureAll(oslist=["linux"]) @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @not_remote_testsuite_ready @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_modules_search_paths(self): """Test target modules list after loading a different copy of the library libd.dylib, and verifies that it works with 'target modules search-paths add'.""" - - # Invoke the default build rule. - self.build() - if self.platformIsDarwin(): dylibName = 'libloadunload_d.dylib' else: dylibName = 'libloadunload_d.so' # The directory with the dynamic library we did not link to. - new_dir = os.path.join(os.getcwd(), "hidden") + new_dir = os.path.join(self.getBuildDir(), "hidden") - old_dylib = os.path.join(os.getcwd(), dylibName) + old_dylib = os.path.join(self.getBuildDir(), dylibName) new_dylib = os.path.join(new_dir, dylibName) - - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.expect("target modules list", @@ -115,14 +121,14 @@ class LoadUnloadTestCase(TestBase): # Add an image search path substitution pair. self.runCmd( "target modules search-paths add %s %s" % - (os.getcwd(), new_dir)) + (self.getBuildDir(), new_dir)) self.expect("target modules search-paths list", - substrs=[os.getcwd(), new_dir]) + substrs=[self.getBuildDir(), new_dir]) self.expect( "target modules search-paths query %s" % - os.getcwd(), + self.getBuildDir(), "Image search path successfully transformed", substrs=[new_dir]) @@ -146,17 +152,17 @@ class LoadUnloadTestCase(TestBase): "LLDB successfully locates the relocated dynamic library", substrs=[new_dylib]) + # libloadunload_d.so does not appear in the image list because executable + # dependencies are resolved relative to the debuggers PWD. Bug? + @expectedFailureAll(oslist=["linux"]) @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @expectedFailureAndroid # wrong source file shows up for hidden library @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_dyld_library_path(self): """Test (DY)LD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else.""" - - # Invoke the default build rule. - self.build() self.copy_shlibs_to_remote(hidden_dir=True) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Shut off ANSI color usage so we don't get ANSI escape sequences @@ -174,18 +180,19 @@ class LoadUnloadTestCase(TestBase): if lldb.remote_platform: wd = lldb.remote_platform.GetWorkingDirectory() else: - wd = os.getcwd() + wd = self.getBuildDir() old_dir = wd new_dir = os.path.join(wd, special_dir) old_dylib = os.path.join(old_dir, dylibName) - remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath + remove_dyld_path_cmd = "settings remove target.env-vars " \ + + self.dylibPath self.addTearDownHook( lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) - # For now we don't track (DY)LD_LIBRARY_PATH, so the old library will be in - # the modules list. + # For now we don't track (DY)LD_LIBRARY_PATH, so the old + # library will be in the modules list. self.expect("target modules list", substrs=[os.path.basename(old_dylib)], matching=True) @@ -203,26 +210,21 @@ class LoadUnloadTestCase(TestBase): if not self.platformIsDarwin(): env_cmd_string += ":" + wd self.runCmd(env_cmd_string) - + # This time, the hidden library should be picked up. self.expect("run", substrs=["return", "12345"]) @expectedFailureAll( bugnumber="llvm.org/pr25805", hostoslist=["windows"], - compiler="gcc", - archs=["i386"], triple='.*-android') @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_lldb_process_load_and_unload_commands(self): """Test that lldb process load/unload command work correctly.""" - - # Invoke the default build rule. - self.build() self.copy_shlibs_to_remote() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break at main.cpp before the call to dlopen(). @@ -233,15 +235,14 @@ class LoadUnloadTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) + ctx = self.platformContext + dylibName = ctx.shlib_prefix + 'loadunload_a.' + ctx.shlib_extension + localDylibPath = self.getBuildArtifact(dylibName) if lldb.remote_platform: - shlib_dir = lldb.remote_platform.GetWorkingDirectory() - else: - shlib_dir = self.mydir - - if self.platformIsDarwin(): - dylibName = 'libloadunload_a.dylib' + wd = lldb.remote_platform.GetWorkingDirectory() + remoteDylibPath = lldbutil.join_remote_paths(wd, dylibName) else: - dylibName = 'libloadunload_a.so' + remoteDylibPath = localDylibPath # Make sure that a_function does not exist at this point. self.expect( @@ -253,13 +254,10 @@ class LoadUnloadTestCase(TestBase): # Use lldb 'process load' to load the dylib. self.expect( - "process load %s --install" % - dylibName, - "%s loaded correctly" % - dylibName, + "process load %s --install=%s" % (localDylibPath, remoteDylibPath), + "%s loaded correctly" % dylibName, patterns=[ - 'Loading "%s".*ok' % - dylibName, + 'Loading "%s".*ok' % localDylibPath, 'Image [0-9]+ loaded']) # Search for and match the "Image ([0-9]+) loaded" pattern. @@ -295,12 +293,9 @@ class LoadUnloadTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support def test_load_unload(self): """Test breakpoint by name works correctly with dlopen'ing.""" - - # Invoke the default build rule. - self.build() self.copy_shlibs_to_remote() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break by function name a_function (not yet loaded). @@ -338,12 +333,9 @@ class LoadUnloadTestCase(TestBase): @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently def test_step_over_load(self): """Test stepping over code that loads a shared library works correctly.""" - - # Invoke the default build rule. - self.build() self.copy_shlibs_to_remote() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break by function name a_function (not yet loaded). @@ -366,16 +358,16 @@ class LoadUnloadTestCase(TestBase): substrs=['stopped', 'stop reason = step over']) + # We can't find a breakpoint location for d_init before launching because + # executable dependencies are resolved relative to the debuggers PWD. Bug? + @expectedFailureAll(oslist=["linux"]) @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently - @unittest2.expectedFailure("llvm.org/pr25806") def test_static_init_during_load(self): """Test that we can set breakpoints correctly in static initializers""" - - self.build() self.copy_shlibs_to_remote() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) a_init_bp_num = lldbutil.run_break_set_by_symbol( @@ -395,19 +387,19 @@ class LoadUnloadTestCase(TestBase): self.runCmd("continue") self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs=['stopped', - 'a_init', - 'stop reason = breakpoint %d' % a_init_bp_num]) + 'b_init', + 'stop reason = breakpoint %d' % b_init_bp_num]) self.expect("thread backtrace", - substrs=['a_init', + substrs=['b_init', 'dlopen', 'main']) self.runCmd("continue") self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs=['stopped', - 'b_init', - 'stop reason = breakpoint %d' % b_init_bp_num]) + 'a_init', + 'stop reason = breakpoint %d' % a_init_bp_num]) self.expect("thread backtrace", - substrs=['b_init', + substrs=['a_init', 'dlopen', 'main']) diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk b/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk index 0eb810e217874..fddca925dea2e 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk @@ -2,22 +2,18 @@ LEVEL := ../../make LIB_PREFIX := loadunload_ -CFLAGS_EXTRAS := -fPIC LD_EXTRAS := -L. -l$(LIB_PREFIX)b DYLIB_NAME := $(LIB_PREFIX)a DYLIB_CXX_SOURCES := a.cpp DYLIB_ONLY := YES -CXXFLAGS += -fPIC - include $(LEVEL)/Makefile.rules -.PHONY: $(DYLIB_FILENAME): lib_b -lib_b: - "$(MAKE)" -f b.mk +.PHONY lib_b: + $(MAKE) VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/b.mk clean:: - "$(MAKE)" -f b.mk clean + $(MAKE) -I $(SRCDIR) -f $(SRCDIR)/b.mk clean diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk b/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk index c1b0877d72a47..2fcdbea3a1c48 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk @@ -6,6 +6,4 @@ DYLIB_NAME := $(LIB_PREFIX)b DYLIB_CXX_SOURCES := b.cpp DYLIB_ONLY := YES -CXXFLAGS += -fPIC - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk b/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk index 5b5691efeef4c..d40949b146307 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk @@ -6,6 +6,4 @@ DYLIB_NAME := $(LIB_PREFIX)c DYLIB_CXX_SOURCES := c.cpp DYLIB_ONLY := YES -CXXFLAGS += -fPIC - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk b/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk index b6b6eeacba261..a5db3c7c31f0a 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk @@ -8,6 +8,4 @@ DYLIB_NAME := $(LIB_PREFIX)d DYLIB_CXX_SOURCES := d.cpp DYLIB_ONLY := YES -CXXFLAGS += -fPIC - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile b/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile index f84d8300843f6..271117a0ad88a 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile @@ -6,6 +6,4 @@ DYLIB_NAME := $(LIB_PREFIX)d DYLIB_CXX_SOURCES := d.cpp DYLIB_ONLY := YES -CXXFLAGS += -fPIC - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/load_using_paths/.categories b/packages/Python/lldbsuite/test/functionalities/load_using_paths/.categories new file mode 100644 index 0000000000000..c00c25822e4c2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/.categories @@ -0,0 +1 @@ +basic_process diff --git a/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile b/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile new file mode 100644 index 0000000000000..c4c3cfe3c18e2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile @@ -0,0 +1,14 @@ +LEVEL := ../../make + +CXX_SOURCES := main.cpp +LD_EXTRAS := -ldl + +include $(LEVEL)/Makefile.rules + +all: hidden_lib a.out + +hidden_lib: + $(MAKE) VPATH=$(SRCDIR)/hidden -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile + +clean:: + $(MAKE) -I $(SRCDIR)/hidden -C hidden -f $(SRCDIR)/hidden/Makefile clean diff --git a/packages/Python/lldbsuite/test/functionalities/load_using_paths/TestLoadUsingPaths.py b/packages/Python/lldbsuite/test/functionalities/load_using_paths/TestLoadUsingPaths.py new file mode 100644 index 0000000000000..2050586adfa1b --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/TestLoadUsingPaths.py @@ -0,0 +1,143 @@ +""" +Test that SBProcess.LoadImageUsingPaths works correctly. +""" + +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 + + +@skipIfWindows # The Windows platform doesn't implement DoLoadImage. +class LoadUsingPathsTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Make the hidden directory in the build hierarchy: + lldbutil.mkdir_p(self.getBuildArtifact("hidden")) + + # Invoke the default build rule. + self.build() + + ext = 'so' + if self.platformIsDarwin(): + ext = 'dylib' + self.lib_name = 'libloadunload.' + ext + + self.wd = self.getBuildDir() + self.hidden_dir = os.path.join(self.wd, 'hidden') + self.hidden_lib = os.path.join(self.hidden_dir, self.lib_name) + + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @not_remote_testsuite_ready + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + def test_load_using_paths(self): + """Test that we can load a module by providing a set of search paths.""" + if self.platformIsDarwin(): + dylibName = 'libloadunload_d.dylib' + else: + dylibName = 'libloadunload_d.so' + + # The directory with the dynamic library we did not link to. + path_dir = os.path.join(self.getBuildDir(), "hidden") + + (target, process, thread, + _) = lldbutil.run_to_source_breakpoint(self, + "Break here to do the load using paths", + lldb.SBFileSpec("main.cpp")) + error = lldb.SBError() + lib_spec = lldb.SBFileSpec(self.lib_name) + paths = lldb.SBStringList() + paths.AppendString(self.wd) + paths.AppendString(os.path.join(self.wd, "no_such_dir")) + + out_spec = lldb.SBFileSpec() + + # First try with no correct directories on the path, and make sure that doesn't blow up: + token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error) + self.assertEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Only looked on the provided path.") + + # Now add the correct dir to the paths list and try again: + paths.AppendString(self.hidden_dir) + token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error) + + self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token") + self.assertEqual(out_spec, lldb.SBFileSpec(self.hidden_lib), "Found the expected library") + + # Make sure this really is in the image list: + loaded_module = target.FindModule(out_spec) + + self.assertTrue(loaded_module.IsValid(), "The loaded module is in the image list.") + + # Now see that we can call a function in the loaded module. + value = thread.frames[0].EvaluateExpression("d_function()", lldb.SBExpressionOptions()) + self.assertTrue(value.GetError().Success(), "Got a value from the expression") + ret_val = value.GetValueAsSigned() + self.assertEqual(ret_val, 12345, "Got the right value") + + # Make sure the token works to unload it: + process.UnloadImage(token) + + # Make sure this really is no longer in the image list: + loaded_module = target.FindModule(out_spec) + + self.assertFalse(loaded_module.IsValid(), "The unloaded module is no longer in the image list.") + + # Make sure a relative path also works: + paths.Clear() + paths.AppendString(os.path.join(self.wd, "no_such_dir")) + paths.AppendString(self.wd) + relative_spec = lldb.SBFileSpec(os.path.join("hidden", self.lib_name)) + + out_spec = lldb.SBFileSpec() + token = process.LoadImageUsingPaths(relative_spec, paths, out_spec, error) + + self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token with relative path") + self.assertEqual(out_spec, lldb.SBFileSpec(self.hidden_lib), "Found the expected library with relative path") + + process.UnloadImage(token) + + # Make sure the presence of an empty path doesn't mess anything up: + paths.Clear() + paths.AppendString("") + paths.AppendString(os.path.join(self.wd, "no_such_dir")) + paths.AppendString(self.wd) + relative_spec = lldb.SBFileSpec(os.path.join("hidden", self.lib_name)) + + out_spec = lldb.SBFileSpec() + token = process.LoadImageUsingPaths(relative_spec, paths, out_spec, error) + + self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token with included empty path") + self.assertEqual(out_spec, lldb.SBFileSpec(self.hidden_lib), "Found the expected library with included empty path") + + process.UnloadImage(token) + + + + # Finally, passing in an absolute path should work like the basename: + # This should NOT work because we've taken hidden_dir off the paths: + abs_spec = lldb.SBFileSpec(os.path.join(self.hidden_dir, self.lib_name)) + + token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error) + self.assertEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Only looked on the provided path.") + + # But it should work when we add the dir: + # Now add the correct dir to the paths list and try again: + paths.AppendString(self.hidden_dir) + token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error) + + self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token") + self.assertEqual(out_spec, lldb.SBFileSpec(self.hidden_lib), "Found the expected library") + + diff --git a/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/Makefile b/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/Makefile new file mode 100644 index 0000000000000..bebfa92ecfb25 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/Makefile @@ -0,0 +1,7 @@ +LEVEL := ../../../make + +DYLIB_NAME := loadunload +DYLIB_CXX_SOURCES := d.cpp +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/d.cpp b/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/d.cpp new file mode 100644 index 0000000000000..6a7642c08b935 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/hidden/d.cpp @@ -0,0 +1,21 @@ +//===-- c.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int d_init() +{ + return 456; +} + +int d_global = d_init(); + +int +d_function () +{ // Find this line number within d_dunction(). + return 12345; +} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp b/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp index 6d725a5759b54..4b3320479c25a 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp @@ -1,4 +1,4 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// +//===-- main.c --------------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,13 +6,11 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#include <stdio.h> -extern int j; -extern int gfunc(int i); -extern int gfunc2(int i); int -main() -{ // FUNC_main - int i = gfunc(j) + gfunc2(j); - return i == 0; +main (int argc, char const *argv[]) +{ + printf("Break here to do the load using paths."); + return 0; } diff --git a/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py b/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py index dd4ab4cab2a99..db855f6302dd3 100644 --- a/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py +++ b/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py @@ -47,7 +47,7 @@ class LongjmpTestCase(TestBase): self.step_back_out() def start_test(self, symbol): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) diff --git a/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py b/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py index f2126e9ffd5f6..f45479bee0bf0 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py +++ b/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py @@ -28,7 +28,7 @@ class MemoryCacheTestCase(TestBase): def test_memory_cache(self): """Test the MemoryCache class with a sequence of 'memory read' and 'memory write' operations.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break in main() after the variables are assigned values. diff --git a/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py b/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py index f8f10a8d4f565..8e0fbaa320186 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py +++ b/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py @@ -28,10 +28,10 @@ class MemoryFindTestCase(TestBase): def test_memory_find(self): """Test the 'memory find' command.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # Break in main() aftre the variables are assigned values. + # Break in main() after the variables are assigned values. 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/functionalities/memory/read/TestMemoryRead.py b/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py index 91342fdaf1c30..2e4bbbd53f0fe 100644 --- a/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py +++ b/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py @@ -26,10 +26,10 @@ class MemoryReadTestCase(TestBase): def test_memory_read(self): """Test the 'memory read' command with plain and vector formats.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # Break in main() aftre the variables are assigned values. + # Break in main() after the variables are assigned values. 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/functionalities/mtc/simple/TestMTCSimple.py b/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py index eb6981d04fad9..b871b90961c96 100644 --- a/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py +++ b/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py @@ -33,7 +33,7 @@ class MTCSimpleTestCase(TestBase): @skipIf(archs=['i386']) def mtc_tests(self): # Load the test - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) self.runCmd("env DYLD_INSERT_LIBRARIES=%s" % self.mtc_dylib_path) diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py b/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py index 86c5e41b09311..f805b53d3cd4b 100644 --- a/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py +++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py @@ -26,10 +26,10 @@ class NestedAliasTestCase(TestBase): def test_nested_alias(self): """Test that an alias can reference other aliases without crashing.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # Break in main() aftre the variables are assigned values. + # Break in main() after the variables are assigned values. 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/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py b/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py index bbaba956acfd9..59e889e8b0fd1 100644 --- a/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py +++ b/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py @@ -23,9 +23,8 @@ class NonOverlappingIndexVariableCase(TestBase): def test_eval_index_variable(self): """Test expressions of variable 'i' which appears in two for loops.""" self.build() - self.exe_name = 'a.out' - exe = os.path.join(os.getcwd(), self.exe_name) - self.runCmd("file %s" % exe, 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/functionalities/non-overlapping-index-variable-i/main.cpp b/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp index b4f519cd25a87..2171a2648bde1 100644 --- a/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/non-overlapping-index-variable-i/main.cpp @@ -6,7 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#include <stdio.h> class Point { public: @@ -37,15 +36,11 @@ int main(int argc, char const *argv[]) { ptr[i]->point.y = i+1; } - printf("Finished populating data.\n"); for (int i = 0; i < 1000; ++i) { bool dump = argc > 1; // Set breakpoint here. // Evaluate a couple of expressions (2*1000 = 2000 exprs): // expr ptr[i]->point.x // expr ptr[i]->point.y - if (dump) { - printf("data[%d] = %d (%d, %d)\n", i, ptr[i]->id, ptr[i]->point.x, ptr[i]->point.y); - } } return 0; } diff --git a/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py b/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py index be89e36b5ce09..fd9812320f2b8 100644 --- a/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py +++ b/packages/Python/lldbsuite/test/functionalities/nosucharch/TestNoSuchArch.py @@ -15,7 +15,7 @@ class NoSuchArchTestCase(TestBase): def test(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Check that passing an invalid arch via the command-line fails but # doesn't crash diff --git a/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py b/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py index 54ea33ad24a9e..b81446f5a58f0 100644 --- a/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py +++ b/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py @@ -51,6 +51,14 @@ class PlatformPythonTestCase(TestBase): @add_test_categories(['pyapi']) @no_debug_info_test + def test_host_is_connected(self): + # We've already tested that this one IS the host platform. + host_platform = self.dbg.GetPlatformAtIndex(0) + self.assertTrue(host_platform.IsConnected(), "The host platform is always connected") + + + @add_test_categories(['pyapi']) + @no_debug_info_test def test_available_platform_list(self): """Test SBDebugger::GetNumAvailablePlatforms() and GetAvailablePlatformInfoAtIndex() API""" num_platforms = self.dbg.GetNumAvailablePlatforms() diff --git a/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py b/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py index 18fcc41fa9f63..25b83ed5532fd 100644 --- a/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py +++ b/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py @@ -45,7 +45,7 @@ class PluginCommandTestCase(TestBase): retobj = lldb.SBCommandReturnObject() retval = debugger.GetCommandInterpreter().HandleCommand( - "plugin load %s" % plugin_lib_name, retobj) + "plugin load %s" % self.getBuildArtifact(plugin_lib_name), retobj) retobj.Clear() diff --git a/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py b/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py index 9a5d320dce55a..4a19a4e77607c 100644 --- a/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py +++ b/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py @@ -44,9 +44,9 @@ class PluginPythonOSPlugin(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - cwd = os.getcwd() - exe = os.path.join(cwd, "a.out") - python_os_plugin_path = os.path.join(cwd, "operating_system.py") + exe = self.getBuildArtifact("a.out") + python_os_plugin_path = os.path.join(self.getSourceDir(), + "operating_system.py") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -128,9 +128,9 @@ class PluginPythonOSPlugin(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - cwd = os.getcwd() - exe = os.path.join(cwd, "a.out") - python_os_plugin_path = os.path.join(cwd, "operating_system2.py") + exe = self.getBuildArtifact("a.out") + python_os_plugin_path = os.path.join(self.getSourceDir(), + "operating_system2.py") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py index 63b93340cef35..879f1adebc6ae 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -40,73 +40,90 @@ class LinuxCoreTestCase(TestBase): lldb.DBG.SetSelectedPlatform(self._initial_platform) super(LinuxCoreTestCase, self).tearDown() - @skipIf(oslist=['windows']) + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" - self.do_test("linux-i386", self._i386_pid, self._i386_regions) + self.do_test("linux-i386", self._i386_pid, self._i386_regions, "a.out") + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_o32(self): """Test that lldb can read the process information from an MIPS O32 linux core file.""" - self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, self._mips_regions) + self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, + self._mips_regions, "linux-mipsel-gn") + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_n32(self): """Test that lldb can read the process information from an MIPS N32 linux core file """ - self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, self._mips_regions) + self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, + self._mips_regions, "linux-mips64el-") + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_n64(self): """Test that lldb can read the process information from an MIPS N64 linux core file """ - self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, self._mips_regions) + self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, + self._mips_regions, "linux-mips64el-") - @skipIf(oslist=['windows']) + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("PowerPC") def test_ppc64le(self): """Test that lldb can read the process information from an ppc64le linux core file.""" - self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions) + self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions, + "linux-ppc64le.ou") - @skipIf(oslist=['windows']) + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" - self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions) + self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions, + "a.out") - @skipIf(oslist=['windows']) + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("SystemZ") def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" - self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions) + self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions, + "a.out") - @skipIf(oslist=['windows']) + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_same_pid_running(self): """Test that we read the information from the core correctly even if we have a running process with the same PID around""" - try: - shutil.copyfile("linux-x86_64.out", "linux-x86_64-pid.out") - shutil.copyfile("linux-x86_64.core", "linux-x86_64-pid.core") - with open("linux-x86_64-pid.core", "r+b") as f: - # These are offsets into the NT_PRSTATUS and NT_PRPSINFO structures in the note - # segment of the core file. If you update the file, these offsets may need updating - # as well. (Notes can be viewed with readelf --notes.) - for pid_offset in [0x1c4, 0x320]: - f.seek(pid_offset) - self.assertEqual( - struct.unpack( - "<I", - f.read(4))[0], - self._x86_64_pid) - - # We insert our own pid, and make sure the test still - # works. - f.seek(pid_offset) - f.write(struct.pack("<I", os.getpid())) - self.do_test("linux-x86_64-pid", os.getpid(), self._x86_64_regions) - finally: - self.RemoveTempFile("linux-x86_64-pid.out") - self.RemoveTempFile("linux-x86_64-pid.core") - - @skipIf(oslist=['windows']) + exe_file = self.getBuildArtifact("linux-x86_64-pid.out") + core_file = self.getBuildArtifact("linux-x86_64-pid.core") + shutil.copyfile("linux-x86_64.out", exe_file) + shutil.copyfile("linux-x86_64.core", core_file) + with open(core_file, "r+b") as f: + # These are offsets into the NT_PRSTATUS and NT_PRPSINFO structures in the note + # segment of the core file. If you update the file, these offsets may need updating + # as well. (Notes can be viewed with readelf --notes.) + for pid_offset in [0x1c4, 0x320]: + f.seek(pid_offset) + self.assertEqual( + struct.unpack( + "<I", + f.read(4))[0], + self._x86_64_pid) + + # We insert our own pid, and make sure the test still + # works. + f.seek(pid_offset) + f.write(struct.pack("<I", os.getpid())) + self.do_test(self.getBuildArtifact("linux-x86_64-pid"), os.getpid(), + self._x86_64_regions, "a.out") + + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_two_cores_same_pid(self): """Test that we handle the situation if we have two core files with the same PID around""" @@ -132,10 +149,12 @@ class LinuxCoreTestCase(TestBase): # without destroying this process, run the test which opens another core file with the # same pid - self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions) + self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions, + "a.out") - @skipIf(oslist=['windows']) + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_FPR_SSE(self): # check x86_64 core file target = self.dbg.CreateTarget(None) @@ -280,7 +299,7 @@ class LinuxCoreTestCase(TestBase): self.dbg.SetOutputFileHandle(None, False) self.dbg.SetErrorFileHandle(None, False) - def do_test(self, filename, pid, region_count): + def do_test(self, filename, pid, region_count, thread_name): target = self.dbg.CreateTarget(filename + ".out") process = target.LoadCore(filename + ".core") self.assertTrue(process, PROCESS_IS_VALID) @@ -292,6 +311,7 @@ class LinuxCoreTestCase(TestBase): thread = process.GetSelectedThread() self.assertTrue(thread) self.assertEqual(thread.GetThreadID(), pid) + self.assertEqual(thread.GetName(), thread_name) backtrace = ["bar", "foo", "_start"] self.assertEqual(thread.GetNumFrames(), len(backtrace)) for i in range(len(backtrace)): diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py new file mode 100644 index 0000000000000..a299a4308bc8d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/TestMachCore.py @@ -0,0 +1,69 @@ +""" +Test basics of mach core file debugging. +""" + +from __future__ import print_function + +import shutil +import struct + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class MachCoreTestCase(TestBase): + NO_DEBUG_INFO_TESTCASE = True + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + super(MachCoreTestCase, self).setUp() + self._initial_platform = lldb.DBG.GetSelectedPlatform() + + def tearDown(self): + lldb.DBG.SetSelectedPlatform(self._initial_platform) + super(MachCoreTestCase, self).tearDown() + + @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + def test_selected_thread(self): + """Test that the right thread is selected after a core is loaded.""" + # Create core form YAML. + self.yaml2obj("test.core.yaml", self.getBuildArtifact("test.core")) + + # Set debugger into synchronous mode + self.dbg.SetAsync(False) + + # Create a target by the debugger. + target = self.dbg.CreateTarget("") + + # Load OS plugin. + python_os_plugin_path = os.path.join(self.getSourceDir(), + 'operating_system.py') + command = "settings set target.process.python-os-plugin-path '{}'".format( + python_os_plugin_path) + self.dbg.HandleCommand(command) + + # Load core. + process = target.LoadCore(self.getBuildArtifact("test.core")) + self.assertTrue(process, PROCESS_IS_VALID) + self.assertEqual(process.GetNumThreads(), 3) + + # Verify our OS plug-in threads showed up + thread = process.GetThreadByID(0x111111111) + self.assertTrue(thread.IsValid( + ), "Make sure there is a thread 0x111111111 after we load the python OS plug-in" + ) + thread = process.GetThreadByID(0x222222222) + self.assertTrue(thread.IsValid( + ), "Make sure there is a thread 0x222222222 after we load the python OS plug-in" + ) + thread = process.GetThreadByID(0x333333333) + self.assertTrue(thread.IsValid( + ), "Make sure there is a thread 0x333333333 after we load the python OS plug-in" + ) + + # Verify that the correct thread is selected + thread = process.GetSelectedThread() + self.assertEqual(thread.GetThreadID(), 0x333333333) diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py b/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py new file mode 100644 index 0000000000000..de6c3b7dd56ff --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/operating_system.py @@ -0,0 +1,45 @@ +import lldb +import struct + + +class OperatingSystemPlugIn(object): + """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class""" + + def __init__(self, process): + '''Initialization needs a valid.SBProcess object. + + This plug-in will get created after a live process is valid and has stopped for the first time. + ''' + self.process = None + self.registers = None + self.threads = None + if isinstance(process, lldb.SBProcess) and process.IsValid(): + self.process = process + self.threads = None # Will be an dictionary containing info for each thread + + def get_target(self): + return self.process.target + + def get_thread_info(self): + if not self.threads: + self.threads = [{ + 'tid': 0x111111111, + 'name': 'one', + 'queue': 'queue1', + 'state': 'stopped', + 'stop_reason': 'none' + }, { + 'tid': 0x222222222, + 'name': 'two', + 'queue': 'queue2', + 'state': 'stopped', + 'stop_reason': 'none' + }, { + 'tid': 0x333333333, + 'name': 'three', + 'queue': 'queue3', + 'state': 'stopped', + 'stop_reason': 'sigstop', + 'core': 0 + }] + return self.threads diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml b/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml new file mode 100644 index 0000000000000..84ce54e45e1f1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/mach-core/test.core.yaml @@ -0,0 +1,853 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x00000004 + ncmds: 59 + sizeofcmds: 4384 + flags: 0x00000000 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_THREAD + cmdsize: 208 + PayloadBytes: + - 0x04 + - 0x00 + - 0x00 + - 0x00 + - 0x2A + - 0x00 + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x80 + - 0xF7 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x20 + - 0xF6 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x10 + - 0xF6 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0xF0 + - 0xF5 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0xF0 + - 0xF5 + - 0xBF + - 0xEF + - 0xFE + - 0x7F + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0xFF + - 0xFF + - 0xFF + - 0xFF + - 0xC8 + - 0xB0 + - 0x70 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - 0xD0 + - 0xB0 + - 0x70 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0xA0 + - 0x0F + - 0x00 + - 0x00 + - 0x01 + - 0x00 + - 0x00 + - 0x00 + - 0x46 + - 0x02 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x2B + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x06 + - 0x00 + - 0x00 + - 0x00 + - 0x04 + - 0x00 + - 0x00 + - 0x00 + - 0x03 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x00 + - 0x10 + - 0x00 + - 0x02 + - 0xA7 + - 0xFF + - 0x7F + - 0x00 + - 0x00 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4294967296 + vmsize: 4096 + fileoff: 8192 + filesize: 4096 + maxprot: 5 + initprot: 5 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4294971392 + vmsize: 4096 + fileoff: 12288 + filesize: 4096 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4294975488 + vmsize: 307200 + fileoff: 16384 + filesize: 307200 + maxprot: 5 + initprot: 5 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295282688 + vmsize: 12288 + fileoff: 323584 + filesize: 12288 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295294976 + vmsize: 217088 + fileoff: 335872 + filesize: 217088 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295512064 + vmsize: 110592 + fileoff: 552960 + filesize: 110592 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295622656 + vmsize: 8192 + fileoff: 663552 + filesize: 8192 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295630848 + vmsize: 8192 + fileoff: 671744 + filesize: 8192 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295639040 + vmsize: 4096 + fileoff: 679936 + filesize: 4096 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295643136 + vmsize: 4096 + fileoff: 684032 + filesize: 4096 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295651328 + vmsize: 24576 + fileoff: 688128 + filesize: 24576 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295684096 + vmsize: 24576 + fileoff: 712704 + filesize: 24576 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295712768 + vmsize: 4096 + fileoff: 737280 + filesize: 4096 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4295716864 + vmsize: 8192 + fileoff: 741376 + filesize: 8192 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4296015872 + vmsize: 1048576 + fileoff: 749568 + filesize: 1048576 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4297064448 + vmsize: 1048576 + fileoff: 1798144 + filesize: 1048576 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4298113024 + vmsize: 1048576 + fileoff: 2846720 + filesize: 1048576 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 4303355904 + vmsize: 8388608 + fileoff: 3895296 + filesize: 8388608 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140732912369664 + vmsize: 8388608 + fileoff: 12283904 + filesize: 8388608 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140734252867584 + vmsize: 811999232 + fileoff: 20672512 + filesize: 811999232 + maxprot: 5 + initprot: 5 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735863480320 + vmsize: 20553728 + fileoff: 832671744 + filesize: 20553728 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735884034048 + vmsize: 2097152 + fileoff: 853225472 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735886131200 + vmsize: 2097152 + fileoff: 855322624 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735888228352 + vmsize: 2097152 + fileoff: 857419776 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735890325504 + vmsize: 2097152 + fileoff: 859516928 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735892422656 + vmsize: 2097152 + fileoff: 861614080 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735894519808 + vmsize: 2097152 + fileoff: 863711232 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735896616960 + vmsize: 2097152 + fileoff: 865808384 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735898714112 + vmsize: 2097152 + fileoff: 867905536 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735900811264 + vmsize: 2097152 + fileoff: 870002688 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735902908416 + vmsize: 10485760 + fileoff: 872099840 + filesize: 10485760 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735913394176 + vmsize: 4194304 + fileoff: 882585600 + filesize: 4194304 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735917588480 + vmsize: 2097152 + fileoff: 886779904 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735919685632 + vmsize: 2097152 + fileoff: 888877056 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735921782784 + vmsize: 4194304 + fileoff: 890974208 + filesize: 4194304 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735925977088 + vmsize: 4194304 + fileoff: 895168512 + filesize: 4194304 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735930171392 + vmsize: 6291456 + fileoff: 899362816 + filesize: 6291456 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735936462848 + vmsize: 2097152 + fileoff: 905654272 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735938560000 + vmsize: 2097152 + fileoff: 907751424 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735940657152 + vmsize: 2097152 + fileoff: 909848576 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735942754304 + vmsize: 2097152 + fileoff: 911945728 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735944851456 + vmsize: 6291456 + fileoff: 914042880 + filesize: 6291456 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735951142912 + vmsize: 2097152 + fileoff: 920334336 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735953240064 + vmsize: 4194304 + fileoff: 922431488 + filesize: 4194304 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735957434368 + vmsize: 2097152 + fileoff: 926625792 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735959531520 + vmsize: 2097152 + fileoff: 928722944 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735961628672 + vmsize: 20971520 + fileoff: 930820096 + filesize: 20971520 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735982600192 + vmsize: 6291456 + fileoff: 951791616 + filesize: 6291456 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735988891648 + vmsize: 2097152 + fileoff: 958083072 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735990988800 + vmsize: 2097152 + fileoff: 960180224 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735993085952 + vmsize: 2097152 + fileoff: 962277376 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735995183104 + vmsize: 2097152 + fileoff: 964374528 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735997280256 + vmsize: 2097152 + fileoff: 966471680 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140735999377408 + vmsize: 2097152 + fileoff: 968568832 + filesize: 2097152 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140736001474560 + vmsize: 1302528 + fileoff: 970665984 + filesize: 1302528 + maxprot: 3 + initprot: 3 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140736937222144 + vmsize: 219267072 + fileoff: 971968512 + filesize: 219267072 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140737486258176 + vmsize: 4096 + fileoff: 1191235584 + filesize: 4096 + maxprot: 1 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: '' + vmaddr: 140737487028224 + vmsize: 4096 + fileoff: 1191239680 + filesize: 4096 + maxprot: 5 + initprot: 5 + nsects: 0 + flags: 0 +... diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py index 4e587b92c1d26..5960215f8047f 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py @@ -59,6 +59,24 @@ class MiniDumpNewTestCase(TestBase): self.dbg.SetOutputFileHandle(None, False) self.dbg.SetErrorFileHandle(None, False) + def test_loadcore_error_status(self): + """Test the SBTarget.LoadCore(core, error) overload.""" + self.dbg.CreateTarget(None) + self.target = self.dbg.GetSelectedTarget() + error = lldb.SBError() + self.process = self.target.LoadCore("linux-x86_64.dmp", error) + self.assertTrue(self.process, PROCESS_IS_VALID) + self.assertTrue(error.Success()) + + def test_loadcore_error_status_failure(self): + """Test the SBTarget.LoadCore(core, error) overload.""" + self.dbg.CreateTarget(None) + self.target = self.dbg.GetSelectedTarget() + error = lldb.SBError() + self.process = self.target.LoadCore("non-existent.dmp", error) + self.assertFalse(self.process, PROCESS_IS_VALID) + self.assertTrue(error.Fail()) + def test_process_info_in_minidump(self): """Test that lldb can read the process information from the Minidump.""" # target create -c linux-x86_64.dmp @@ -70,6 +88,57 @@ class MiniDumpNewTestCase(TestBase): self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid) self.check_state() + def test_modules_in_mini_dump(self): + """Test that lldb can read the list of modules from the minidump.""" + # target create -c linux-x86_64.dmp + self.dbg.CreateTarget(None) + self.target = self.dbg.GetSelectedTarget() + self.process = self.target.LoadCore("linux-x86_64.dmp") + self.assertTrue(self.process, PROCESS_IS_VALID) + expected_modules = [ + { + 'filename' : 'linux-gate.so', + 'uuid' : '4EAD28F8-88EF-3520-872B-73C6F2FE7306-C41AF22F', + }, + { + 'filename' : 'libm-2.19.so', + 'uuid' : 'D144258E-6149-00B2-55A3-1F3FD2283A87-8670D5BC', + }, + { + 'filename' : 'libstdc++.so.6.0.19', + 'uuid' : '76190E92-2AF7-457D-078F-75C9B15FA184-E83EB506', + }, + { + 'filename' : 'libc-2.19.so', + 'uuid' : 'CF699A15-CAAE-64F5-0311-FC4655B86DC3-9A479789', + }, + { + 'filename' : 'linux-x86_64', + 'uuid' : 'E35C283B-C327-C287-62DB-788BF5A4078B-E2351448', + }, + { + 'filename' : 'libgcc_s.so.1', + 'uuid' : '36311B44-5771-0AE5-578C-4BF00791DED7-359DBB92', + }, + { + 'filename' : 'libpthread-2.19.so', + 'uuid' : '31E9F21A-E8C1-0396-171F-1E13DA157809-86FA696C', + }, + { + 'filename' : 'ld-2.19.so', + 'uuid' : 'D0F53790-4076-D73F-29E4-A37341F8A449-E2EF6CD0', + }, + { + 'filename' : 'libbreakpad.so', + 'uuid' : '784FD549-332D-826E-D23F-18C17C6F320A', + }, + ] + self.assertEqual(self.target.GetNumModules(), len(expected_modules)) + for module, expected in zip(self.target.modules, expected_modules): + self.assertTrue(module.IsValid()) + self.assertEqual(module.file.basename, expected['filename']) + self.assertEqual(module.GetUUIDString(), expected['uuid']) + def test_thread_info_in_minidump(self): """Test that lldb can read the thread information from the Minidump.""" # target create -c linux-x86_64.dmp @@ -100,6 +169,7 @@ class MiniDumpNewTestCase(TestBase): self.assertEqual(thread.GetNumFrames(), 2) frame = thread.GetFrameAtIndex(0) self.assertTrue(frame.IsValid()) + self.assertTrue(frame.GetModule().IsValid()) pc = frame.GetPC() eip = frame.FindRegister("pc") self.assertTrue(eip.IsValid()) @@ -162,32 +232,25 @@ class MiniDumpNewTestCase(TestBase): def test_deeper_stack_in_minidump_with_same_pid_running(self): """Test that we read the information from the core correctly even if we have a running process with the same PID""" - try: - self.do_change_pid_in_minidump("linux-x86_64_not_crashed.dmp", - "linux-x86_64_not_crashed-pid.dmp", - self._linux_x86_64_not_crashed_pid_offset, - str(self._linux_x86_64_not_crashed_pid), - str(os.getpid())) - self.do_test_deeper_stack("linux-x86_64_not_crashed", - "linux-x86_64_not_crashed-pid.dmp", - os.getpid()) - finally: - self.RemoveTempFile("linux-x86_64_not_crashed-pid.dmp") + new_core = self.getBuildArtifact("linux-x86_64_not_crashed-pid.dmp") + self.do_change_pid_in_minidump("linux-x86_64_not_crashed.dmp", + new_core, + self._linux_x86_64_not_crashed_pid_offset, + str(self._linux_x86_64_not_crashed_pid), + str(os.getpid())) + self.do_test_deeper_stack("linux-x86_64_not_crashed", new_core, os.getpid()) def test_two_cores_same_pid(self): """Test that we handle the situation if we have two core files with the same PID """ - try: - self.do_change_pid_in_minidump("linux-x86_64_not_crashed.dmp", - "linux-x86_64_not_crashed-pid.dmp", - self._linux_x86_64_not_crashed_pid_offset, - str(self._linux_x86_64_not_crashed_pid), - str(self._linux_x86_64_pid)) - self.do_test_deeper_stack("linux-x86_64_not_crashed", - "linux-x86_64_not_crashed-pid.dmp", - self._linux_x86_64_pid) - self.test_stack_info_in_minidump() - finally: - self.RemoveTempFile("linux-x86_64_not_crashed-pid.dmp") + new_core = self.getBuildArtifact("linux-x86_64_not_crashed-pid.dmp") + self.do_change_pid_in_minidump("linux-x86_64_not_crashed.dmp", + new_core, + self._linux_x86_64_not_crashed_pid_offset, + str(self._linux_x86_64_not_crashed_pid), + str(self._linux_x86_64_pid)) + self.do_test_deeper_stack("linux-x86_64_not_crashed", + new_core, self._linux_x86_64_pid) + self.test_stack_info_in_minidump() def test_local_variables_in_minidump(self): """Test that we can examine local variables in a Minidump.""" diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py index c7b64d783c713..61e2adee41d5c 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py @@ -41,6 +41,45 @@ class MiniDumpTestCase(TestBase): stop_description = thread.GetStopDescription(256) self.assertTrue("0xc0000005" in stop_description) + def test_modules_in_mini_dump(self): + """Test that lldb can read the list of modules from the minidump.""" + # target create -c fizzbuzz_no_heap.dmp + self.dbg.CreateTarget("") + self.target = self.dbg.GetSelectedTarget() + self.process = self.target.LoadCore("fizzbuzz_no_heap.dmp") + self.assertTrue(self.process, PROCESS_IS_VALID) + expected_modules = [ + { + 'filename' : r"C:\Windows\System32/MSVCP120D.dll", + 'uuid' : '6E51053C-E757-EB40-8D3F-9722C5BD80DD-01000000', + }, + { + 'filename' : r"C:\Windows\SysWOW64/kernel32.dll", + 'uuid' : '1B7ECBE5-5E00-1341-AB98-98D6913B52D8-02000000', + }, + { + 'filename' : r"C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug/fizzbuzz.exe", + 'uuid' : '91B7450F-969A-F946-BF8F-2D6076EA421A-11000000', + }, + { + 'filename' : r"C:\Windows\System32/MSVCR120D.dll", + 'uuid' : '86FB8263-C446-4640-AE42-8D97B3F91FF2-01000000', + }, + { + 'filename' : r"C:\Windows\SysWOW64/KERNELBASE.dll", + 'uuid' : '4152F90B-0DCB-D44B-AC5D-186A6452E522-01000000', + }, + { + 'filename' : r"C:\Windows\SysWOW64/ntdll.dll", + 'uuid' : '6A84B0BB-2C40-5240-A16B-67650BBFE6B0-02000000', + }, + ] + self.assertEqual(self.target.GetNumModules(), len(expected_modules)) + for module, expected in zip(self.target.modules, expected_modules): + self.assertTrue(module.IsValid()) + self.assertEqual(module.file.fullpath, expected['filename']) + self.assertEqual(module.GetUUIDString(), expected['uuid']) + @expectedFailureAll(bugnumber="llvm.org/pr35193", hostoslist=["windows"]) def test_stack_info_in_mini_dump(self): """Test that we can see a trivial stack in a VS-generate mini dump.""" @@ -58,13 +97,15 @@ class MiniDumpTestCase(TestBase): frame = thread.GetFrameAtIndex(i) self.assertTrue(frame.IsValid()) self.assertEqual(frame.GetPC(), pc_list[i]) + self.assertTrue(frame.GetModule().IsValid()) @skipUnlessWindows # Minidump saving works only on windows + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_deeper_stack_in_mini_dump(self): """Test that we can examine a more interesting stack in a mini dump.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") - core = os.path.join(os.getcwd(), "core.dmp") + exe = self.getBuildArtifact("a.out") + core = self.getBuildArtifact("core.dmp") try: # Set a breakpoint and capture a mini dump. target = self.dbg.CreateTarget(exe) @@ -96,11 +137,12 @@ class MiniDumpTestCase(TestBase): os.unlink(core) @skipUnlessWindows # Minidump saving works only on windows + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_local_variables_in_mini_dump(self): """Test that we can examine local variables in a mini dump.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") - core = os.path.join(os.getcwd(), "core.dmp") + exe = self.getBuildArtifact("a.out") + core = self.getBuildArtifact("core.dmp") try: # Set a breakpoint and capture a mini dump. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile index c4855ca9b12d3..624a6e1584e42 100644 --- a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile @@ -3,6 +3,4 @@ LEVEL = ../../make DYLIB_NAME := unlikely_name DYLIB_CXX_SOURCES := foo.cpp CXX_SOURCES := main.cpp -CFLAGS_EXTRAS += -fPIC - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py index 258c3d3fbb9fa..befb42186112c 100644 --- a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py +++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py @@ -20,7 +20,7 @@ class TestPreRunLibraries(TestBase): """Test that we find directly linked dylib pre-run.""" self.build() - target = self.dbg.CreateTarget("a.out") + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) self.assertTrue(target, VALID_TARGET) # I don't know what the name of a shared library diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py b/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py index c4d372cd3d301..617b4bcfaec35 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py +++ b/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py @@ -27,7 +27,7 @@ class ProcessAttachTestCase(TestBase): def test_attach_to_process_by_id(self): """Test attach by process id""" self.build() - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Spawn a new process popen = self.spawnSubprocess(exe) @@ -43,13 +43,13 @@ class ProcessAttachTestCase(TestBase): @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_attach_to_process_from_different_dir_by_id(self): """Test attach by process id""" + newdir = self.getBuildArtifact("newdir") try: - os.mkdir(os.path.join(os.getcwd(),'newdir')) - except OSError, e: + os.mkdir(newdir) + except OSError as e: if e.errno != os.errno.EEXIST: raise - testdir = os.getcwd() - newdir = os.path.join(testdir,'newdir') + testdir = self.getBuildDir() exe = os.path.join(newdir, 'proc_attach') self.buildProgram('main.cpp', exe) self.addTearDownHook(lambda: shutil.rmtree(newdir)) @@ -58,7 +58,7 @@ class ProcessAttachTestCase(TestBase): popen = self.spawnSubprocess(exe) self.addTearDownHook(self.cleanupSubprocesses) - os.chdir('newdir') + os.chdir(newdir) self.addTearDownHook(lambda: os.chdir(testdir)) self.runCmd("process attach -p " + str(popen.pid)) @@ -71,7 +71,7 @@ class ProcessAttachTestCase(TestBase): def test_attach_to_process_by_name(self): """Test attach by process name""" self.build() - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Spawn a new process popen = self.spawnSubprocess(exe) diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/Makefile b/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/Makefile index 87600bbccf9d6..3c1f73515eb7c 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/Makefile @@ -4,4 +4,11 @@ CXX_SOURCES := main.cpp EXE := AttachDenied +all: AttachDenied sign + include $(LEVEL)/Makefile.rules + +sign: entitlements.plist AttachDenied +ifeq ($(OS),Darwin) + codesign -s - -f --entitlements $^ +endif diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py b/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py index 5465b7155f501..b915b541fb4be 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py +++ b/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py @@ -18,6 +18,7 @@ exe_name = 'AttachDenied' # Must match Makefile class AttachDeniedTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True @skipIfWindows @skipIfiOSSimulator @@ -25,10 +26,10 @@ class AttachDeniedTestCase(TestBase): def test_attach_to_process_by_id_denied(self): """Test attach by process id denied""" self.build() - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Use a file as a synchronization point between test and inferior. - pid_file_path = lldbutil.append_to_process_working_directory( + pid_file_path = lldbutil.append_to_process_working_directory(self, "pid_file_%d" % (int(time.time()))) self.addTearDownHook( lambda: self.run_platform_command( diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/entitlements.plist b/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/entitlements.plist new file mode 100644 index 0000000000000..3d60e8bd0b94d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/entitlements.plist @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>com.apple.security.cs.debugger</key> + <true/> +</dict> +</plist> diff --git a/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py b/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py index 91436446ad990..8496ce6c04d73 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py +++ b/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py @@ -13,6 +13,7 @@ from lldbsuite.test import lldbutil class ChangeProcessGroupTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -26,10 +27,10 @@ class ChangeProcessGroupTestCase(TestBase): @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_setpgid(self): self.build() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") # Use a file as a synchronization point between test and inferior. - pid_file_path = lldbutil.append_to_process_working_directory( + pid_file_path = lldbutil.append_to_process_working_directory(self, "pid_file_%d" % (int(time.time()))) self.addTearDownHook( lambda: self.run_platform_command( diff --git a/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py b/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py index 5929a352b6155..9d1cac90d8569 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py +++ b/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py @@ -19,6 +19,7 @@ import six class ProcessLaunchTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -33,13 +34,13 @@ class ProcessLaunchTestCase(TestBase): def test_io(self): """Test that process launch I/O redirection flags work properly.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) - in_file = "input-file.txt" - out_file = "output-test.out" - err_file = "output-test.err" + in_file = os.path.join(self.getSourceDir(), "input-file.txt") + out_file = lldbutil.append_to_process_working_directory(self, "output-test.out") + err_file = lldbutil.append_to_process_working_directory(self, "output-test.err") # Make sure the output files do not exist before launching the process try: @@ -52,8 +53,8 @@ class ProcessLaunchTestCase(TestBase): except OSError: pass - launch_command = "process launch -i " + \ - in_file + " -o " + out_file + " -e " + err_file + launch_command = "process launch -i '{0}' -o '{1}' -e '{2}' -w '{3}'".format( + in_file, out_file, err_file, self.get_process_working_directory()) if lldb.remote_platform: self.runCmd('platform put-file "{local}" "{remote}"'.format( @@ -62,55 +63,19 @@ class ProcessLaunchTestCase(TestBase): self.expect(launch_command, patterns=["Process .* launched: .*a.out"]) - if lldb.remote_platform: - self.runCmd('platform get-file "{remote}" "{local}"'.format( - remote=out_file, local=out_file)) - self.runCmd('platform get-file "{remote}" "{local}"'.format( - remote=err_file, local=err_file)) - success = True err_msg = "" - # Check to see if the 'stdout' file was created - try: - out_f = open(out_file) - except IOError: + out = lldbutil.read_file_on_target(self, out_file) + if out != "This should go to stdout.\n": success = False - err_msg = err_msg + " ERROR: stdout file was not created.\n" - else: - # Check to see if the 'stdout' file contains the right output - line = out_f.readline() - if line != "This should go to stdout.\n": - success = False - err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n" - out_f.close() + err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n" - # Try to delete the 'stdout' file - try: - os.remove(out_file) - except OSError: - pass - # Check to see if the 'stderr' file was created - try: - err_f = open(err_file) - except IOError: + err = lldbutil.read_file_on_target(self, err_file) + if err != "This should go to stderr.\n": success = False - err_msg = err_msg + " ERROR: stderr file was not created.\n" - else: - # Check to see if the 'stderr' file contains the right output - line = err_f.readline() - if line != "This should go to stderr.\n": - success = False - err_msg = err_msg + " ERROR: stderr file does not contain correct output.\n\ -" - err_f.close() - - # Try to delete the 'stderr' file - try: - os.remove(err_file) - except OSError: - pass + err_msg = err_msg + " ERROR: stderr file does not contain correct output.\n" if not success: self.fail(err_msg) @@ -120,19 +85,47 @@ class ProcessLaunchTestCase(TestBase): # not working? @not_remote_testsuite_ready @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20265") - def test_set_working_dir(self): + def test_set_working_dir_nonexisting(self): + """Test that '-w dir' fails to set the working dir when running the inferior with a dir which doesn't exist.""" + d = {'CXX_SOURCES': 'print_cwd.cpp'} + self.build(dictionary=d) + self.setTearDownCleanup(d) + exe = self.getBuildArtifact("a.out") + self.runCmd("file " + exe) + + mywd = 'my_working_dir' + out_file_name = "my_working_dir_test.out" + err_file_name = "my_working_dir_test.err" + + my_working_dir_path = self.getBuildArtifact(mywd) + out_file_path = os.path.join(my_working_dir_path, out_file_name) + err_file_path = os.path.join(my_working_dir_path, err_file_name) + + # Check that we get an error when we have a nonexisting path + invalid_dir_path = mywd + 'z' + launch_command = "process launch -w %s -o %s -e %s" % ( + invalid_dir_path, out_file_path, err_file_path) + + self.expect( + launch_command, error=True, patterns=[ + "error:.* No such file or directory: %s" % + invalid_dir_path]) + + @not_remote_testsuite_ready + def test_set_working_dir_existing(self): """Test that '-w dir' sets the working dir when running the inferior.""" d = {'CXX_SOURCES': 'print_cwd.cpp'} self.build(dictionary=d) self.setTearDownCleanup(d) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe) mywd = 'my_working_dir' out_file_name = "my_working_dir_test.out" err_file_name = "my_working_dir_test.err" - my_working_dir_path = os.path.join(os.getcwd(), mywd) + my_working_dir_path = self.getBuildArtifact(mywd) + lldbutil.mkdir_p(my_working_dir_path) out_file_path = os.path.join(my_working_dir_path, out_file_name) err_file_path = os.path.join(my_working_dir_path, err_file_name) @@ -143,16 +136,6 @@ class ProcessLaunchTestCase(TestBase): except OSError: pass - # Check that we get an error when we have a nonexisting path - launch_command = "process launch -w %s -o %s -e %s" % ( - my_working_dir_path + 'z', out_file_path, err_file_path) - - self.expect( - launch_command, error=True, patterns=[ - "error:.* No such file or directory: %sz" % - my_working_dir_path]) - - # Really launch the process launch_command = "process launch -w %s -o %s -e %s" % ( my_working_dir_path, out_file_path, err_file_path) @@ -195,7 +178,7 @@ class ProcessLaunchTestCase(TestBase): d = {'CXX_SOURCES': source} self.build(dictionary=d) self.setTearDownCleanup(d) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") evil_var = 'INIT*MIDDLE}TAIL' diff --git a/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py b/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py index ee1f82b14f7b6..55dbc4223711a 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py +++ b/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py @@ -21,8 +21,8 @@ class ProcessSaveCoreTestCase(TestBase): def test_cannot_save_core_unless_process_stopped(self): """Test that SaveCore fails if the process isn't stopped.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") - core = os.path.join(os.getcwd(), "core.dmp") + exe = self.getBuildArtifact("a.out") + core = self.getBuildArtifact("core.dmp") target = self.dbg.CreateTarget(exe) process = target.LaunchSimple( None, None, self.get_process_working_directory()) @@ -35,8 +35,8 @@ class ProcessSaveCoreTestCase(TestBase): def test_save_windows_mini_dump(self): """Test that we can save a Windows mini dump.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") - core = os.path.join(os.getcwd(), "core.dmp") + exe = self.getBuildArtifact("a.out") + core = self.getBuildArtifact("core.dmp") try: target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateByName("bar") diff --git a/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py b/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py index 5085b8cce99a3..80ace219aeb1b 100644 --- a/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py +++ b/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py @@ -19,8 +19,7 @@ class TestPtrRefs(TestBase): def test_ptr_refs(self): """Test format string functionality.""" 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/functionalities/recursion/TestValueObjectRecursion.py b/packages/Python/lldbsuite/test/functionalities/recursion/TestValueObjectRecursion.py index 5b72d383f141f..569ecd249b21e 100644 --- a/packages/Python/lldbsuite/test/functionalities/recursion/TestValueObjectRecursion.py +++ b/packages/Python/lldbsuite/test/functionalities/recursion/TestValueObjectRecursion.py @@ -25,7 +25,7 @@ class ValueObjectRecursionTestCase(TestBase): def test_with_run_command(self): """Test that deeply nested ValueObjects still work.""" 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/functionalities/register/intel_avx/TestYMMRegister.py b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py index 6dccaa55a1039..d362e6a8ae3da 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py @@ -21,11 +21,13 @@ class TestYMMRegister(TestBase): @skipIfiOSSimulator @skipIfTargetAndroid() @skipIf(archs=no_match(['i386', 'x86_64'])) + @expectedFailureAll(oslist=["linux"], bugnumber="rdar://30523153") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995") def test(self): - self.build() + self.build(dictionary={"CFLAGS_EXTRAS": "-march=haswell"}) self.setTearDownCleanup() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -56,9 +58,10 @@ class TestYMMRegister(TestBase): else: register_range = 8 for i in range(register_range): + j = i - ((i / 8) * 8) self.runCmd("thread step-inst") - register_byte = (byte_pattern1 | i) + register_byte = (byte_pattern1 | j) pattern = "ymm" + str(i) + " = " + str('{') + ( str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) + str('}') @@ -66,7 +69,7 @@ class TestYMMRegister(TestBase): "register read ymm" + str(i), substrs=[pattern]) - register_byte = (byte_pattern2 | i) + register_byte = (byte_pattern2 | j) pattern = "ymm" + str(i) + " = " + str('{') + ( str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) + str('}') diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestZMMRegister.py b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestZMMRegister.py new file mode 100644 index 0000000000000..823e40155ff5a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestZMMRegister.py @@ -0,0 +1,126 @@ +""" +Test that we correctly read the YMM registers. +""" + +from __future__ import print_function + + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestYMMRegister(TestBase): + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + @skipUnlessDarwin + @skipIfiOSSimulator + @skipIf(archs=no_match(['i386', 'x86_64'])) + @debugserver_test + @skipUnlessFeature('hw.optional.avx512f') + def test(self): + self.build(dictionary={"CFLAGS_EXTRAS": "-mavx512f"}) + self.setTearDownCleanup() + + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + + self.assertTrue(target, VALID_TARGET) + + byte_pattern1 = 0x80 + byte_pattern2 = 0xFF + + # This test is working with assembly instructions; it'll make + # it easier to debug the console output if the assembly is + # displayed. + self.runCmd("settings set stop-disassembly-display always") + + # Launch the process and stop. + self.expect("run", PROCESS_STOPPED, substrs=['stopped']) + + # Check stop reason; Should be either signal SIGTRAP or EXC_BREAKPOINT + output = self.res.GetOutput() + matched = False + substrs = [ + 'stop reason = EXC_BREAKPOINT', + 'stop reason = signal SIGTRAP'] + for str1 in substrs: + matched = output.find(str1) != -1 + with recording(self, False) as sbuf: + print("%s sub string: %s" % ('Expecting', str1), file=sbuf) + print("Matched" if matched else "Not Matched", file=sbuf) + if matched: + break + self.assertTrue(matched, STOPPED_DUE_TO_SIGNAL) + + if self.getArchitecture() == 'x86_64': + register_range = 16 + else: + register_range = 8 + for i in range(register_range): + j = i - ((i / 8) * 8) + self.runCmd("thread step-inst") + + register_byte = (byte_pattern1 | j) + pattern = "ymm" + str(i) + " = " + str('{') + ( + str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) + str('}') + + self.expect( + "register read ymm" + str(i), + substrs=[pattern]) + + register_byte = (byte_pattern2 | j) + pattern = "ymm" + str(i) + " = " + str('{') + ( + str(hex(register_byte)) + ' ') * 31 + str(hex(register_byte)) + str('}') + + self.runCmd("thread step-inst") + self.expect( + "register read ymm" + str(i), + substrs=[pattern]) + + self.expect("continue", PROCESS_STOPPED, substrs=['stopped']) + + # Check stop reason; Should be either signal SIGTRAP or EXC_BREAKPOINT + output = self.res.GetOutput() + matched = False + substrs = [ + 'stop reason = EXC_BREAKPOINT', + 'stop reason = signal SIGTRAP'] + for str1 in substrs: + matched = output.find(str1) != -1 + with recording(self, False) as sbuf: + print("%s sub string: %s" % ('Expecting', str1), file=sbuf) + print("Matched" if matched else "Not Matched", file=sbuf) + if matched: + break + self.assertTrue(matched, STOPPED_DUE_TO_SIGNAL) + + if self.getArchitecture() == 'x86_64': + register_range = 32 + else: + register_range = 8 + for i in range(register_range): + j = i - ((i / 8) * 8) + self.runCmd("thread step-inst") + self.runCmd("thread step-inst") + + register_byte = (byte_pattern2 | j) + pattern = "zmm" + str(i) + " = " + str('{') + ( + str(hex(register_byte)) + ' ') * 63 + str(hex(register_byte)) + str('}') + + self.expect( + "register read zmm" + str(i), + substrs=[pattern]) + + register_byte = (byte_pattern2 | j) + pattern = "zmm" + str(i) + " = " + str('{') + ( + str(hex(register_byte)) + ' ') * 63 + str(hex(register_byte)) + str('}') + + self.runCmd("thread step-inst") + self.expect( + "register read zmm" + str(i), + substrs=[pattern]) diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c index 4cfb2239c06fb..671331fe450f4 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/main.c @@ -9,15 +9,14 @@ void func() { unsigned int ymmvalues[16]; - unsigned char val; - unsigned char i; - for (i = 0 ; i < 16 ; i++) + for (int i = 0 ; i < 16 ; i++) { - val = (0x80 | i); + unsigned char val = (0x80 | i); ymmvalues[i] = (val << 24) | (val << 16) | (val << 8) | val; } unsigned int ymmallones = 0xFFFFFFFF; +#if defined(__AVX__) __asm__("int3;" "vbroadcastss %1, %%ymm0;" "vbroadcastss %0, %%ymm0;" @@ -36,32 +35,109 @@ void func() { "vbroadcastss %8, %%ymm7;" "vbroadcastss %0, %%ymm7;" #if defined(__x86_64__) - "vbroadcastss %9, %%ymm8;" + "vbroadcastss %1, %%ymm8;" "vbroadcastss %0, %%ymm8;" - "vbroadcastss %10, %%ymm9;" + "vbroadcastss %2, %%ymm9;" "vbroadcastss %0, %%ymm9;" - "vbroadcastss %11, %%ymm10;" + "vbroadcastss %3, %%ymm10;" "vbroadcastss %0, %%ymm10;" - "vbroadcastss %12, %%ymm11;" + "vbroadcastss %4, %%ymm11;" "vbroadcastss %0, %%ymm11;" - "vbroadcastss %13, %%ymm12;" + "vbroadcastss %5, %%ymm12;" "vbroadcastss %0, %%ymm12;" - "vbroadcastss %14, %%ymm13;" + "vbroadcastss %6, %%ymm13;" "vbroadcastss %0, %%ymm13;" - "vbroadcastss %15, %%ymm14;" + "vbroadcastss %7, %%ymm14;" "vbroadcastss %0, %%ymm14;" - "vbroadcastss %16, %%ymm15;" + "vbroadcastss %8, %%ymm15;" "vbroadcastss %0, %%ymm15;" #endif ::"m"(ymmallones), "m"(ymmvalues[0]), "m"(ymmvalues[1]), "m"(ymmvalues[2]), "m"(ymmvalues[3]), "m"(ymmvalues[4]), "m"(ymmvalues[5]), "m"(ymmvalues[6]), "m"(ymmvalues[7]) + ); +#endif + +#if defined(__AVX512F__) + unsigned int zmmvalues[32]; + for (int i = 0 ; i < 32 ; i++) + { + unsigned char val = (0x80 | i); + zmmvalues[i] = (val << 24) | (val << 16) | (val << 8) | val; + } + + __asm__("int3;" + "vbroadcastss %1, %%zmm0;" + "vbroadcastss %0, %%zmm0;" + "vbroadcastss %2, %%zmm1;" + "vbroadcastss %0, %%zmm1;" + "vbroadcastss %3, %%zmm2;" + "vbroadcastss %0, %%zmm2;" + "vbroadcastss %4, %%zmm3;" + "vbroadcastss %0, %%zmm3;" + "vbroadcastss %5, %%zmm4;" + "vbroadcastss %0, %%zmm4;" + "vbroadcastss %6, %%zmm5;" + "vbroadcastss %0, %%zmm5;" + "vbroadcastss %7, %%zmm6;" + "vbroadcastss %0, %%zmm6;" + "vbroadcastss %8, %%zmm7;" + "vbroadcastss %0, %%zmm7;" #if defined(__x86_64__) - , - "m"(ymmvalues[8]), "m"(ymmvalues[9]), "m"(ymmvalues[10]), "m"(ymmvalues[11]), - "m"(ymmvalues[12]), "m"(ymmvalues[13]), "m"(ymmvalues[14]), "m"(ymmvalues[15]) + "vbroadcastss %1, %%zmm8;" + "vbroadcastss %0, %%zmm8;" + "vbroadcastss %2, %%zmm9;" + "vbroadcastss %0, %%zmm9;" + "vbroadcastss %3, %%zmm10;" + "vbroadcastss %0, %%zmm10;" + "vbroadcastss %4, %%zmm11;" + "vbroadcastss %0, %%zmm11;" + "vbroadcastss %5, %%zmm12;" + "vbroadcastss %0, %%zmm12;" + "vbroadcastss %6, %%zmm13;" + "vbroadcastss %0, %%zmm13;" + "vbroadcastss %7, %%zmm14;" + "vbroadcastss %0, %%zmm14;" + "vbroadcastss %8, %%zmm15;" + "vbroadcastss %0, %%zmm15;" + "vbroadcastss %1, %%zmm16;" + "vbroadcastss %0, %%zmm16;" + "vbroadcastss %2, %%zmm17;" + "vbroadcastss %0, %%zmm17;" + "vbroadcastss %3, %%zmm18;" + "vbroadcastss %0, %%zmm18;" + "vbroadcastss %4, %%zmm19;" + "vbroadcastss %0, %%zmm19;" + "vbroadcastss %5, %%zmm20;" + "vbroadcastss %0, %%zmm20;" + "vbroadcastss %6, %%zmm21;" + "vbroadcastss %0, %%zmm21;" + "vbroadcastss %7, %%zmm22;" + "vbroadcastss %0, %%zmm22;" + "vbroadcastss %8, %%zmm23;" + "vbroadcastss %0, %%zmm23;" + "vbroadcastss %1, %%zmm24;" + "vbroadcastss %0, %%zmm24;" + "vbroadcastss %2, %%zmm25;" + "vbroadcastss %0, %%zmm25;" + "vbroadcastss %3, %%zmm26;" + "vbroadcastss %0, %%zmm26;" + "vbroadcastss %4, %%zmm27;" + "vbroadcastss %0, %%zmm27;" + "vbroadcastss %5, %%zmm28;" + "vbroadcastss %0, %%zmm28;" + "vbroadcastss %6, %%zmm29;" + "vbroadcastss %0, %%zmm29;" + "vbroadcastss %7, %%zmm30;" + "vbroadcastss %0, %%zmm30;" + "vbroadcastss %8, %%zmm31;" + "vbroadcastss %0, %%zmm31;" +#endif + ::"m"(ymmallones), + "m"(zmmvalues[0]), "m"(zmmvalues[1]), "m"(zmmvalues[2]), "m"(zmmvalues[3]), + "m"(zmmvalues[4]), "m"(zmmvalues[5]), "m"(zmmvalues[6]), "m"(zmmvalues[7]) + ); #endif - ); } int main(int argc, char const *argv[]) { func(); } diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py index 96f3655542c83..00802ff895056 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py @@ -35,7 +35,7 @@ class RegisterCommandsTestCase(TestBase): """Test Intel(R) MPX registers after running example code.""" self.line = line_number('main.cpp', '// Set a break point here.') - 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) diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py index 45721dd260d9e..2fd2dab0184c3 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py +++ b/packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py @@ -29,7 +29,7 @@ class RegisterCommandsTestCase(TestBase): self.mpx_boundary_violation() def mpx_boundary_violation(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("run", RUN_SUCCEEDED) diff --git a/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py b/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py index 83cc48847c994..41e566438724f 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py +++ b/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py @@ -59,6 +59,7 @@ class RegisterCommandsTestCase(TestBase): # problem @skipIfTargetAndroid(archs=["i386"]) @skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64'])) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995") def test_fp_register_write(self): """Test commands that write to registers, in particular floating-point registers.""" self.build() @@ -69,6 +70,8 @@ class RegisterCommandsTestCase(TestBase): @expectedFailureAndroid(archs=["i386"]) @skipIfFreeBSD # llvm.org/pr25057 @skipIf(archs=no_match(['amd64', 'i386', 'x86_64'])) + @skipIfOutOfTreeDebugserver + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995") def test_fp_special_purpose_register_read(self): """Test commands that read fpu special purpose registers.""" self.build() @@ -76,6 +79,7 @@ class RegisterCommandsTestCase(TestBase): @skipIfiOSSimulator @skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64'])) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683") def test_register_expressions(self): """Test expression evaluation with commands related to registers.""" self.build() @@ -104,6 +108,7 @@ class RegisterCommandsTestCase(TestBase): @skipIfiOSSimulator @skipIf(archs=no_match(['amd64', 'x86_64'])) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683") def test_convenience_registers(self): """Test convenience registers.""" self.build() @@ -111,6 +116,7 @@ class RegisterCommandsTestCase(TestBase): @skipIfiOSSimulator @skipIf(archs=no_match(['amd64', 'x86_64'])) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683") def test_convenience_registers_with_process_attach(self): """Test convenience registers after a 'process attach'.""" self.build() @@ -118,13 +124,14 @@ class RegisterCommandsTestCase(TestBase): @skipIfiOSSimulator @skipIf(archs=no_match(['amd64', 'x86_64'])) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683") def test_convenience_registers_16bit_with_process_attach(self): """Test convenience registers after a 'process attach'.""" self.build() self.convenience_registers_with_process_attach(test_16bit_regs=True) def common_setup(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -149,7 +156,7 @@ class RegisterCommandsTestCase(TestBase): self.platform = "posix" if self.platform != "": - self.log_file = os.path.join(os.getcwd(), 'TestRegisters.log') + self.log_file = self.getBuildArtifact('TestRegisters.log') self.runCmd( "log enable " + self.platform + @@ -185,7 +192,7 @@ class RegisterCommandsTestCase(TestBase): new_value]) def fp_special_purpose_register_read(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -266,7 +273,7 @@ class RegisterCommandsTestCase(TestBase): 1 << fstat_top_pointer_initial) def fp_register_write(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -371,6 +378,8 @@ class RegisterCommandsTestCase(TestBase): self.write_and_read(currentFrame, reg, val, must) if self.getArchitecture() in ['amd64', 'i386', 'x86_64']: + if st0regname is None: + self.fail("st0regname could not be determined") self.runCmd( "register write " + st0regname + @@ -441,7 +450,7 @@ class RegisterCommandsTestCase(TestBase): def convenience_registers_with_process_attach(self, test_16bit_regs): """Test convenience registers after a 'process attach'.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Spawn a new process pid = self.spawnSubprocess(exe, ['wait_for_attach']).pid diff --git a/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py b/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py index 20d64b38f0ca6..044d3d25b7246 100644 --- a/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py +++ b/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py @@ -18,7 +18,7 @@ class TestRerun(TestBase): def test(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("target create %s" % exe) diff --git a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py index 606a71ff50197..b7d0d8170b3bb 100644 --- a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -40,28 +40,10 @@ class ReturnValueTestCase(TestBase): def test_with_python(self): """Test getting return values from stepping out.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") - error = lldb.SBError() - - self.target = self.dbg.CreateTarget(exe) - self.assertTrue(self.target, VALID_TARGET) - - inner_sint_bkpt = self.target.BreakpointCreateByName("inner_sint", exe) - self.assertTrue(inner_sint_bkpt, VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - self.process = self.target.LaunchSimple( - None, None, self.get_process_working_directory()) - - self.assertTrue(self.process, PROCESS_IS_VALID) + exe = self.getBuildArtifact("a.out") + (self.target, self.process, thread, inner_sint_bkpt) = lldbutil.run_to_name_breakpoint(self, "inner_sint", exe_name = exe) - # The stop reason of the thread should be breakpoint. - self.assertTrue(self.process.GetState() == lldb.eStateStopped, - STOPPED_DUE_TO_BREAKPOINT) - - # Now finish, and make sure the return value is correct. - thread = lldbutil.get_stopped_thread( - self.process, lldb.eStopReasonBreakpoint) + error = lldb.SBError() # inner_sint returns the variable value, so capture that here: in_int = thread.GetFrameAtIndex(0).FindVariable( @@ -86,10 +68,8 @@ class ReturnValueTestCase(TestBase): # Run again and we will stop in inner_sint the second time outer_sint is called. # Then test stepping out two frames at once: - - self.process.Continue() - thread_list = lldbutil.get_threads_stopped_at_breakpoint( - self.process, inner_sint_bkpt) + + thread_list = lldbutil.continue_to_breakpoint(self.process, inner_sint_bkpt) self.assertTrue(len(thread_list) == 1) thread = thread_list[0] @@ -189,7 +169,7 @@ class ReturnValueTestCase(TestBase): @skipIfDarwinEmbedded # <rdar://problem/33976032> ABIMacOSX_arm64 doesn't get structs this big correctly def test_vector_values(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") error = lldb.SBError() self.target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py b/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py index 2fc31a4e78aef..6e4dbf40e4677 100644 --- a/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py +++ b/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py @@ -21,7 +21,7 @@ class SetDataTestCase(TestBase): def test_set_data(self): """Test setting the contents of variables and registers using raw data.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("br s -p First") diff --git a/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py b/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py index 0a2756d87fbe8..316233b909e72 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py @@ -29,7 +29,7 @@ class SendSignalTestCase(TestBase): def test_with_run_command(self): """Test that lldb command 'process signal SIGUSR1' sends a signal to the inferior process.""" 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/functionalities/signal/handle-segv/TestHandleSegv.py b/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py index 97de99640f501..1ebab8837b92c 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py +++ b/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py @@ -20,7 +20,7 @@ class HandleSegvTestCase(TestBase): @skipIfDarwin def test_inferior_handle_sigsegv(self): 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/functionalities/signal/raise/TestRaise.py b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py index 79175562fe7ab..dfc54a639ea0c 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py +++ b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py @@ -58,7 +58,7 @@ class RaiseTestCase(TestBase): def signal_test(self, signal, test_passing): """Test that we handle inferior raising signals""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -188,92 +188,3 @@ class RaiseTestCase(TestBase): # reset signal handling to default self.set_handle(signal, default_pass, default_stop, default_notify) - - @expectedFailureAll( - oslist=["linux"] + - getDarwinOSTriples(), - bugnumber="llvm.org/pr20231") - def test_restart_bug(self): - """Test that we catch a signal in the edge case where the process receives it while we are - about to interrupt it""" - self.build() - exe = os.path.join(os.getcwd(), "a.out") - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - bkpt = target.BreakpointCreateByName("main") - self.assertTrue(bkpt.IsValid(), VALID_BREAKPOINT) - - # launch the inferior and don't wait for it to stop - self.dbg.SetAsync(True) - error = lldb.SBError() - listener = lldb.SBListener("my listener") - process = target.Launch(listener, - ["SIGSTOP"], # argv - None, # envp - None, # stdin_path - None, # stdout_path - None, # stderr_path - None, # working directory - 0, # launch flags - False, # Stop at entry - error) # error - - self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) - - event = lldb.SBEvent() - - # Give the child enough time to reach the breakpoint, - # while clearing out all the pending events. - # The last WaitForEvent call will time out after 2 seconds. - while listener.WaitForEvent(2, event): - if self.TraceOn(): - print( - "Process changing state to:", - self.dbg.StateAsCString( - process.GetStateFromEvent(event))) - - # now the process should be stopped - self.assertEqual( - process.GetState(), - lldb.eStateStopped, - PROCESS_STOPPED) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint( - process, bkpt)), 1, "A thread should be stopped at breakpoint") - - # Remove all breakpoints. This makes sure we don't have to single-step over them when we - # resume the process below - target.DeleteAllBreakpoints() - - # resume the process and immediately try to set another breakpoint. When using the remote - # stub, this will trigger a request to stop the process just as it is about to stop - # naturally due to a SIGSTOP signal it raises. Make sure we do not lose - # this signal. - process.Continue() - self.assertTrue(target.BreakpointCreateByName( - "handler").IsValid(), VALID_BREAKPOINT) - - # Clear the events again - while listener.WaitForEvent(2, event): - if self.TraceOn(): - print( - "Process changing state to:", - self.dbg.StateAsCString( - process.GetStateFromEvent(event))) - - # The process should be stopped due to a signal - self.assertEqual(process.GetState(), lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) - self.assertTrue( - thread.IsValid(), - "Thread should be stopped due to a signal") - self.assertTrue( - thread.GetStopReasonDataCount() >= 1, - "There was data in the event.") - signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSTOP") - self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo, - "The stop signal was %s" % signal) - - # We are done - process.Kill() diff --git a/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py b/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py index ad08c6a9e9528..984e802fdaa08 100644 --- a/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py +++ b/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py @@ -10,7 +10,7 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil - +import six class SingleQuoteInCommandLineTestCase(TestBase): @@ -35,7 +35,10 @@ class SingleQuoteInCommandLineTestCase(TestBase): """Test that 'lldb my_file_name' works where my_file_name is a string with a single quote char in it.""" import pexpect self.buildDefault() - system([["cp", "a.out", "\"%s\"" % self.myexe]]) + lldbutil.mkdir_p(self.getBuildArtifact("path with '09")) + system([["cp", + self.getBuildArtifact("a.out"), + "\"%s\"" % self.getBuildArtifact(self.myexe)]]) # The default lldb prompt. prompt = "(lldb) " @@ -43,35 +46,28 @@ class SingleQuoteInCommandLineTestCase(TestBase): # So that the child gets torn down after the test. self.child = pexpect.spawn( '%s %s "%s"' % - (lldbtest_config.lldbExec, self.lldbOption, self.myexe)) + (lldbtest_config.lldbExec, self.lldbOption, + self.getBuildArtifact(self.myexe))) child = self.child child.setecho(True) - # Turn on logging for input/output to/from the child. - with open('child_send.txt', 'w') as f_send: - with open('child_read.txt', 'w') as f_read: - child.logfile_send = f_send - child.logfile_read = f_read - - child.expect_exact(prompt) + child.logfile_send = send = six.StringIO() + child.logfile_read = read = six.StringIO() + child.expect_exact(prompt) - child.send("help watchpoint") - child.sendline('') - child.expect_exact(prompt) + child.send("help watchpoint") + child.sendline('') + child.expect_exact(prompt) # Now that the necessary logging is done, restore logfile to None to # stop further logging. child.logfile_send = None child.logfile_read = None - with open('child_send.txt', 'r') as fs: - if self.TraceOn(): - print("\n\nContents of child_send.txt:") - print(fs.read()) - with open('child_read.txt', 'r') as fr: - from_child = fr.read() - if self.TraceOn(): - print("\n\nContents of child_read.txt:") - print(from_child) + if self.TraceOn(): + print("\n\nContents of send") + print(send.getvalue()) + print("\n\nContents of read") + print(read.getvalue()) - self.expect(from_child, exe=False, - substrs=["Current executable set to"]) + self.expect(read.getvalue(), exe=False, + substrs=["Current executable set to"]) diff --git a/packages/Python/lldbsuite/test/functionalities/source-map/TestTargetSourceMap.py b/packages/Python/lldbsuite/test/functionalities/source-map/TestTargetSourceMap.py new file mode 100644 index 0000000000000..6bcd9c92f8ce6 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/source-map/TestTargetSourceMap.py @@ -0,0 +1,41 @@ +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * + + +class TestTargetSourceMap(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @no_debug_info_test + def test_source_map(self): + """Test target.source-map' functionality.""" + # Set the target soure map to map "./" to the current test directory + src_dir = self.getSourceDir() + src_path = os.path.join(src_dir, "main.c") + yaml_path = os.path.join(src_dir, "a.yaml") + yaml_base, ext = os.path.splitext(yaml_path) + obj_path = self.getBuildArtifact(yaml_base) + self.yaml2obj(yaml_path, obj_path) + + def cleanup(): + if os.path.exists(obj_path): + os.unlink(obj_path) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + # Create a target with the object file we just created from YAML + target = self.dbg.CreateTarget(obj_path) + + # Set a breakpoint before we remap source and verify that it fails + bp = target.BreakpointCreateByLocation(src_path, 2) + self.assertTrue(bp.GetNumLocations() == 0, + "make sure no breakpoints were resolved without map") + src_map_cmd = 'settings set target.source-map ./ "%s"' % (src_dir) + self.dbg.HandleCommand(src_map_cmd) + + # Set a breakpoint after we remap source and verify that it succeeds + bp = target.BreakpointCreateByLocation(src_path, 2) + self.assertTrue(bp.GetNumLocations() == 1, + "make sure breakpoint was resolved with map") diff --git a/packages/Python/lldbsuite/test/functionalities/source-map/a.yaml b/packages/Python/lldbsuite/test/functionalities/source-map/a.yaml new file mode 100644 index 0000000000000..2ffb94cb77546 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/source-map/a.yaml @@ -0,0 +1,396 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x0000000A + ncmds: 6 + sizeofcmds: 1376 + flags: 0x00000000 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_UUID + cmdsize: 24 + uuid: D37CC773-C218-3F97-99C9-CE4E77DDF2CE + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 4096 + nsyms: 2 + stroff: 4128 + strsize: 28 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __PAGEZERO + vmaddr: 0 + vmsize: 4294967296 + fileoff: 0 + filesize: 0 + maxprot: 0 + initprot: 0 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 232 + segname: __TEXT + vmaddr: 4294967296 + vmsize: 4096 + fileoff: 0 + filesize: 0 + maxprot: 7 + initprot: 5 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000100000FA0 + size: 15 + offset: 0x00000000 + align: 4 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __unwind_info + segname: __TEXT + addr: 0x0000000100000FB0 + size: 72 + offset: 0x00000000 + align: 2 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_SEGMENT_64 + cmdsize: 72 + segname: __LINKEDIT + vmaddr: 4294971392 + vmsize: 4096 + fileoff: 4096 + filesize: 60 + maxprot: 7 + initprot: 1 + nsects: 0 + flags: 0 + - cmd: LC_SEGMENT_64 + cmdsize: 952 + segname: __DWARF + vmaddr: 4294975488 + vmsize: 4096 + fileoff: 8192 + filesize: 563 + maxprot: 7 + initprot: 3 + nsects: 11 + flags: 0 + Sections: + - sectname: __debug_line + segname: __DWARF + addr: 0x0000000100002000 + size: 60 + offset: 0x00002000 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_pubnames + segname: __DWARF + addr: 0x000000010000203C + size: 27 + offset: 0x0000203C + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_pubtypes + segname: __DWARF + addr: 0x0000000100002057 + size: 26 + offset: 0x00002057 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_aranges + segname: __DWARF + addr: 0x0000000100002071 + size: 48 + offset: 0x00002071 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_info + segname: __DWARF + addr: 0x00000001000020A1 + size: 75 + offset: 0x000020A1 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_abbrev + segname: __DWARF + addr: 0x00000001000020EC + size: 52 + offset: 0x000020EC + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_str + segname: __DWARF + addr: 0x0000000100002120 + size: 28 + offset: 0x00002120 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __apple_names + segname: __DWARF + addr: 0x0000000100002160 + size: 60 + offset: 0x00002160 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __apple_namespac + segname: __DWARF + addr: 0x000000010000219C + size: 36 + offset: 0x0000219C + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __apple_types + segname: __DWARF + addr: 0x00000001000021C0 + size: 79 + offset: 0x000021C0 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __apple_objc + segname: __DWARF + addr: 0x000000010000220F + size: 36 + offset: 0x0000220F + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 +LinkEditData: + NameList: + - n_strx: 2 + n_type: 0x0F + n_sect: 1 + n_desc: 16 + n_value: 4294967296 + - n_strx: 22 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 4294971296 + StringTable: + - '' + - '' + - __mh_execute_header + - _main +DWARF: + debug_str: + - '' + - obj2yaml + - main.c + - . + - main + - int + debug_abbrev: + - Code: 0x00000001 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_producer + Form: DW_FORM_strp + - Attribute: DW_AT_language + Form: DW_FORM_data2 + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_stmt_list + Form: DW_FORM_sec_offset + - Attribute: DW_AT_comp_dir + Form: DW_FORM_strp + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Code: 0x00000002 + Tag: DW_TAG_subprogram + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Attribute: DW_AT_frame_base + Form: DW_FORM_exprloc + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Attribute: DW_AT_external + Form: DW_FORM_flag_present + - Code: 0x00000003 + Tag: DW_TAG_base_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_encoding + Form: DW_FORM_data1 + - Attribute: DW_AT_byte_size + Form: DW_FORM_data1 + debug_aranges: + - Length: + TotalLength: 44 + Version: 2 + CuOffset: 0 + AddrSize: 8 + SegSize: 0 + Descriptors: + - Address: 0x0000000100000FA0 + Length: 15 + debug_pubnames: + Length: + TotalLength: 23 + Version: 2 + UnitOffset: 0 + UnitSize: 75 + Entries: + - DieOffset: 0x0000002A + Name: main + debug_pubtypes: + Length: + TotalLength: 22 + Version: 2 + UnitOffset: 0 + UnitSize: 75 + Entries: + - DieOffset: 0x00000043 + Name: int + debug_info: + - Length: + TotalLength: 71 + Version: 4 + AbbrOffset: 0 + AddrSize: 8 + Entries: + - AbbrCode: 0x00000001 + Values: + - Value: 0x0000000000000001 + - Value: 0x000000000000000C + - Value: 0x000000000000000A + - Value: 0x0000000000000000 + - Value: 0x0000000000000011 + - Value: 0x0000000100000FA0 + - Value: 0x000000000000000F + - AbbrCode: 0x00000002 + Values: + - Value: 0x0000000100000FA0 + - Value: 0x000000000000000F + - Value: 0x0000000000000001 + BlockData: + - 0x56 + - Value: 0x0000000000000013 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - Value: 0x0000000000000043 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000018 + - Value: 0x0000000000000005 + - Value: 0x0000000000000004 + - AbbrCode: 0x00000000 + Values: + debug_line: + - Length: + TotalLength: 56 + Version: 2 + PrologueLength: 29 + MinInstLength: 1 + DefaultIsStmt: 1 + LineBase: 251 + LineRange: 14 + OpcodeBase: 13 + StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ] + IncludeDirs: + Files: + - Name: main.c + DirIdx: 0 + ModTime: 0 + Length: 0 + Opcodes: + - Opcode: DW_LNS_extended_op + ExtLen: 9 + SubOpcode: DW_LNE_set_address + Data: 4294971296 + - Opcode: DW_LNS_copy + Data: 4294971296 + - Opcode: DW_LNS_set_column + Data: 2 + - Opcode: DW_LNS_set_prologue_end + Data: 2 + - Opcode: 0xC9 + Data: 2 + - Opcode: DW_LNS_advance_pc + Data: 2 + - Opcode: DW_LNS_extended_op + ExtLen: 1 + SubOpcode: DW_LNE_end_sequence + Data: 2 +... diff --git a/packages/Python/lldbsuite/test/functionalities/stats/Makefile b/packages/Python/lldbsuite/test/functionalities/stats/Makefile new file mode 100644 index 0000000000000..f5a47fcc46ccf --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/stats/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py b/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py new file mode 100644 index 0000000000000..48e49ed009bac --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/stats/TestStats.py @@ -0,0 +1,5 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest( + __file__, globals(), []) diff --git a/packages/Python/lldbsuite/test/functionalities/stats/main.c b/packages/Python/lldbsuite/test/functionalities/stats/main.c new file mode 100644 index 0000000000000..9adb3a09a0806 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/stats/main.c @@ -0,0 +1,18 @@ +// Test that the lldb command `statistics` works. + +int main(void) { + int patatino = 27; + //%self.expect("statistics disable", substrs=['need to enable statistics before disabling'], error=True) + //%self.expect("statistics enable") + //%self.expect("statistics enable", substrs=['already enabled'], error=True) + //%self.expect("expr patatino", substrs=['27']) + //%self.expect("statistics disable") + //%self.expect("statistics dump", substrs=['expr evaluation successes : 1', 'expr evaluation failures : 0']) + //%self.expect("frame var", substrs=['27']) + //%self.expect("statistics enable") + //%self.expect("frame var", substrs=['27']) + //%self.expect("statistics disable") + //%self.expect("statistics dump", substrs=['frame var successes : 1', 'frame var failures : 0']) + + return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/stats_api/Makefile b/packages/Python/lldbsuite/test/functionalities/stats_api/Makefile new file mode 100644 index 0000000000000..f5a47fcc46ccf --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/stats_api/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py b/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py new file mode 100644 index 0000000000000..a6c38ca1d091e --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/stats_api/TestStatisticsAPI.py @@ -0,0 +1,28 @@ +# Test the SBAPI for GetStatistics() + +import json +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestStatsAPI(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + + def test_stats_api(self): + self.build() + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + stats = target.GetStatistics() + stream = lldb.SBStream() + res = stats.GetAsJSON(stream) + stats_json = sorted(json.loads(stream.GetData())) + self.assertEqual(len(stats_json), 4) + self.assertTrue("Number of expr evaluation failures" in stats_json) + self.assertTrue("Number of expr evaluation successes" in stats_json) + self.assertTrue("Number of frame var failures" in stats_json) + self.assertTrue("Number of frame var successes" in stats_json) diff --git a/packages/Python/lldbsuite/test/functionalities/stats_api/main.c b/packages/Python/lldbsuite/test/functionalities/stats_api/main.c new file mode 100644 index 0000000000000..03b2213bb9a36 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/stats_api/main.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/Makefile b/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/Makefile index 45b69a5bb6ebf..4f71dc87646da 100644 --- a/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/Makefile @@ -5,4 +5,4 @@ C_SOURCES := with-debug.c without-debug.c include $(LEVEL)/Makefile.rules without-debug.o: without-debug.c - $(CC) $(CFLAGS_NO_DEBUG) -c without-debug.c + $(CC) $(CFLAGS_NO_DEBUG) -c $< diff --git a/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py b/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py index 7ec934f26e0bb..446c2675f8840 100644 --- a/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py +++ b/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py @@ -15,11 +15,12 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class ReturnValueTestCase(TestBase): +class StepAvoidsNoDebugTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_step_out_with_python(self): """Test stepping out using avoid-no-debug with dsyms.""" self.build() @@ -36,6 +37,7 @@ class ReturnValueTestCase(TestBase): "3.9"], archs=["i386"], bugnumber="llvm.org/pr28549") + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_step_over_with_python(self): """Test stepping over using avoid-no-debug with dwarf.""" self.build() @@ -53,6 +55,7 @@ class ReturnValueTestCase(TestBase): archs=["i386"], bugnumber="llvm.org/pr28549") @expectedFailureAll(oslist=["ios", "tvos", "bridgeos"], bugnumber="<rdar://problem/34026777>") # lldb doesn't step past last source line in function on arm64 + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test_step_in_with_python(self): """Test stepping in using avoid-no-debug with dwarf.""" self.build() @@ -92,7 +95,7 @@ class ReturnValueTestCase(TestBase): (name, pattern)) def get_to_starting_point(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") error = lldb.SBError() self.target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py index 3d23f644554b1..767b368cc7dc7 100644 --- a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py +++ b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py @@ -38,7 +38,7 @@ class StopHookCmdTestCase(TestBase): def test(self): """Test a sequence of target stop-hook commands.""" 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( diff --git a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py index 74088581bad48..b76d98a333c20 100644 --- a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py +++ b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py @@ -45,7 +45,7 @@ class StopHookMechanismTestCase(TestBase): self.build() import pexpect - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") prompt = "(lldb) " add_prompt = "Enter your stop hook command(s). Type 'DONE' to end." add_prompt1 = "> " diff --git a/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py b/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py index 3a18877ef2d00..88267b60b9781 100644 --- a/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py @@ -46,7 +46,7 @@ class StopHookForMultipleThreadsTestCase(TestBase): self.setTearDownCleanup(dictionary=self.d) import pexpect - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) prompt = "(lldb) " # So that the child gets torn down after the test. diff --git a/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py b/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py index 7d2900d61718e..71bfff1d05d44 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py +++ b/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py @@ -25,15 +25,15 @@ class targetCommandTestCase(TestBase): def test_target_command(self): """Test some target commands: create, list, select.""" - da = {'C_SOURCES': 'a.c', 'EXE': 'a.out'} + da = {'C_SOURCES': 'a.c', 'EXE': self.getBuildArtifact('a.out')} self.build(dictionary=da) self.addTearDownCleanup(dictionary=da) - db = {'C_SOURCES': 'b.c', 'EXE': 'b.out'} + db = {'C_SOURCES': 'b.c', 'EXE': self.getBuildArtifact('b.out')} self.build(dictionary=db) self.addTearDownCleanup(dictionary=db) - dc = {'C_SOURCES': 'c.c', 'EXE': 'c.out'} + dc = {'C_SOURCES': 'c.c', 'EXE': self.getBuildArtifact('c.out')} self.build(dictionary=dc) self.addTearDownCleanup(dictionary=dc) @@ -44,7 +44,7 @@ class targetCommandTestCase(TestBase): @expectedFailureAndroid(archs=['aarch64']) def test_target_variable_command(self): """Test 'target variable' command before and after starting the inferior.""" - d = {'C_SOURCES': 'globals.c', 'EXE': 'globals'} + d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')} self.build(dictionary=d) self.addTearDownCleanup(dictionary=d) @@ -53,7 +53,7 @@ class targetCommandTestCase(TestBase): @expectedFailureAndroid(archs=['aarch64']) def test_target_variable_command_no_fail(self): """Test 'target variable' command before and after starting the inferior.""" - d = {'C_SOURCES': 'globals.c', 'EXE': 'globals'} + d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')} self.build(dictionary=d) self.addTearDownCleanup(dictionary=d) @@ -61,9 +61,9 @@ class targetCommandTestCase(TestBase): def do_target_command(self): """Exercise 'target create', 'target list', 'target select' commands.""" - exe_a = os.path.join(os.getcwd(), "a.out") - exe_b = os.path.join(os.getcwd(), "b.out") - exe_c = os.path.join(os.getcwd(), "c.out") + exe_a = self.getBuildArtifact("a.out") + exe_b = self.getBuildArtifact("b.out") + exe_c = self.getBuildArtifact("c.out") self.runCmd("target list") output = self.res.GetOutput() @@ -114,7 +114,8 @@ class targetCommandTestCase(TestBase): def do_target_variable_command(self, exe_name): """Exercise 'target variable' command before and after starting the inferior.""" - self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact(exe_name), + CURRENT_EXECUTABLE_SET) self.expect( "target variable my_global_char", @@ -206,7 +207,8 @@ class targetCommandTestCase(TestBase): def do_target_variable_command_no_fail(self, exe_name): """Exercise 'target variable' command before and after starting the inferior.""" - self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact(exe_name), + CURRENT_EXECUTABLE_SET) self.expect( "target variable my_global_char", diff --git a/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp b/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp index 71fb8e3bb565a..8e0f76f691b98 100755 --- a/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp @@ -2,6 +2,7 @@ #include <thread> #include <vector> #include <queue> +#include <functional> #include <future> #include <iostream> #include <cassert> diff --git a/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py b/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py index ba5094f6de3ee..e2026267c60e8 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py @@ -30,7 +30,7 @@ class BreakpointAfterJoinTestCase(TestBase): """Test breakpoint handling after a thread join.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint diff --git a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py index d1d70c58c4c7d..cef24d688bf93 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/TestBreakAfterJoin.py @@ -36,7 +36,7 @@ class BreakpointAfterJoinTestCase(TestBase): """Test breakpoint handling after a thread join.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/Makefile index 4b5e0ee942223..469c0809aa24a 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/Makefile @@ -1,9 +1,7 @@ -LEVEL = ../../../../make +LEVEL = ../../../make CXX_SOURCES := main.cpp ENABLE_THREADS := YES -VPATH = .. - include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/TestConcurrentBreakpointDelayBreakpointOneSignal.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointDelayBreakpointOneSignal.py index 2506a8231883f..2506a8231883f 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/TestConcurrentBreakpointDelayBreakpointOneSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointDelayBreakpointOneSignal.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/TestConcurrentBreakpointOneDelayBreakpointThreads.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointOneDelayBreakpointThreads.py index 8712342e5811c..8712342e5811c 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/TestConcurrentBreakpointOneDelayBreakpointThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointOneDelayBreakpointThreads.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py index 275d54d2149c0..275d54d2149c0 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/TestConcurrentCrashWithBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithBreak.py index 33d1074211ee5..33d1074211ee5 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/TestConcurrentCrashWithBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/TestConcurrentCrashWithSignal.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithSignal.py index 560c79ed8a8f4..560c79ed8a8f4 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/TestConcurrentCrashWithSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithSignal.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/TestConcurrentCrashWithWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpoint.py index c9cc6db960041..c9cc6db960041 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/TestConcurrentCrashWithWatchpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpoint.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/TestConcurrentCrashWithWatchpointBreakpointSignal.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpointBreakpointSignal.py index d99107b6e9b63..d99107b6e9b63 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/TestConcurrentCrashWithWatchpointBreakpointSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpointBreakpointSignal.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/TestConcurrentDelaySignalBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelaySignalBreak.py index 442134f4a0c7d..442134f4a0c7d 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/TestConcurrentDelaySignalBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelaySignalBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/TestConcurrentDelaySignalWatch.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelaySignalWatch.py index 28c5c68d45069..28c5c68d45069 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/TestConcurrentDelaySignalWatch.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelaySignalWatch.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/TestConcurrentDelayWatchBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayWatchBreak.py index 2d7c984e0e1ca..2d7c984e0e1ca 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/TestConcurrentDelayWatchBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayWatchBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/TestConcurrentDelayedCrashWithBreakpointSignal.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointSignal.py index 2b7e1b4572680..2b7e1b4572680 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/TestConcurrentDelayedCrashWithBreakpointSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointSignal.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py index 0564c86dfcbdd..0564c86dfcbdd 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/TestConcurrentManyBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py index a9f3fbb799f17..a9f3fbb799f17 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/TestConcurrentManyBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/TestConcurrentManyCrash.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyCrash.py index 88ab1d5e204cc..88ab1d5e204cc 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/TestConcurrentManyCrash.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyCrash.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/TestConcurrentManySignals.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py index 232b694c80f40..232b694c80f40 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/TestConcurrentManySignals.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/TestConcurrentManyWatchpoints.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py index 96b610f2b90bb..96b610f2b90bb 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/TestConcurrentManyWatchpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py index b921ac04ccc5d..b921ac04ccc5d 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/TestConcurrentNWatchNBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/TestConcurrentSignalBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalBreak.py index b8819f2869840..b8819f2869840 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/TestConcurrentSignalBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/TestConcurrentSignalDelayBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalDelayBreak.py index b7d8cb174d24c..b7d8cb174d24c 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/TestConcurrentSignalDelayBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalDelayBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/TestConcurrentSignalDelayWatch.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalDelayWatch.py index 2f3b858854b8f..2f3b858854b8f 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/TestConcurrentSignalDelayWatch.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalDelayWatch.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/TestConcurrentSignalNWatchNBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalNWatchNBreak.py index ebb13d99fb3c0..ebb13d99fb3c0 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/TestConcurrentSignalNWatchNBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalNWatchNBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/TestConcurrentSignalWatch.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py index 0fbaf364045d6..0fbaf364045d6 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/TestConcurrentSignalWatch.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/TestConcurrentSignalWatchBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalWatchBreak.py index 53da6658550d2..53da6658550d2 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/TestConcurrentSignalWatchBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalWatchBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/TestConcurrentTwoBreakpointThreads.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointThreads.py index 4e6bed2d5cbce..4e6bed2d5cbce 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/TestConcurrentTwoBreakpointThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointThreads.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/TestConcurrentTwoBreakpointsOneDelaySignal.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneDelaySignal.py index d7630575cb341..d7630575cb341 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/TestConcurrentTwoBreakpointsOneDelaySignal.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneDelaySignal.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/TestConcurrentTwoBreakpointsOneSignal.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py index 4c4caa5337348..4c4caa5337348 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/TestConcurrentTwoBreakpointsOneSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/TestConcurrentTwoBreakpointsOneWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneWatchpoint.py index 687be17ddc5aa..687be17ddc5aa 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/TestConcurrentTwoBreakpointsOneWatchpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneWatchpoint.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/TestConcurrentTwoWatchpointThreads.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointThreads.py index 025d91169451c..025d91169451c 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/TestConcurrentTwoWatchpointThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointThreads.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneBreakpoint.py index 5e95531ae09aa..5e95531ae09aa 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/TestConcurrentTwoWatchpointsOneBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneBreakpoint.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py index aa57e816bb58a..aa57e816bb58a 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/TestConcurrentTwoWatchpointsOneSignal.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneSignal.py index 31b583c1a65a1..31b583c1a65a1 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/TestConcurrentTwoWatchpointsOneSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneSignal.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/TestConcurrentWatchBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchBreak.py index 241ea5b64a03f..241ea5b64a03f 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/TestConcurrentWatchBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchBreak.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/TestConcurrentWatchBreakDelay.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchBreakDelay.py index 79a54b620e537..79a54b620e537 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/TestConcurrentWatchBreakDelay.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchBreakDelay.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py index 6a37abdbcbb85..6a37abdbcbb85 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/TestConcurrentWatchpointWithDelayWatchpointThreads.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py index 67ac92b853cdc..67ac92b853cdc 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/TestConcurrentWatchpointWithDelayWatchpointThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_delay_breakpoint_one_signal/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoint_one_delay_breakpoint_threads/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_watchpoint_breakpoint_signal/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_signal_watch/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delay_watch_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_signal/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/delayed_crash_with_breakpoint_watchpoint/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_breakpoints/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_crash/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_signals/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/many_watchpoints/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/n_watch_n_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_delay_watch/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_n_watch_n_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/signal_watch_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoint_threads/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_delay_signal/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_signal/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_breakpoints_one_watchpoint/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoint_threads/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_breakpoint/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_delay_breakpoint/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/two_watchpoints_one_signal/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watch_break_delay/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_delay_watchpoint_one_breakpoint/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/Makefile deleted file mode 100644 index 4b5e0ee942223..0000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/watchpoint_with_delay_watchpoint_threads/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -LEVEL = ../../../../make - -CXX_SOURCES := main.cpp - -ENABLE_THREADS := YES - -VPATH = .. - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py index 5343e19ee2037..b20b738825a25 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py @@ -12,7 +12,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class CreateDuringStepTestCase(TestBase): +class CrashDuringStepTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +26,7 @@ class CreateDuringStepTestCase(TestBase): def test_step_inst_with(self): """Test thread creation during step-inst handling.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py index 442887ed4e134..3f26d8c765797 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/TestCreateAfterAttach.py @@ -51,7 +51,7 @@ class CreateAfterAttachTestCase(TestBase): def create_after_attach(self, use_fork): """Test thread creation after process attach.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Spawn a new process if use_fork: diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py index f6d6197e1f116..3998db6d32563 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py @@ -83,7 +83,7 @@ class CreateDuringStepTestCase(TestBase): def create_during_step_base(self, step_cmd, step_stop_reason): """Test thread creation while using step-in.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Get the target process diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py index 456c890673cc2..c62990ccc93af 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py @@ -29,7 +29,7 @@ class ExitDuringBreakpointTestCase(TestBase): def test(self): """Test thread exit during breakpoint handling.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp index e41fbebf380d0..8fc1e42e96d00 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp @@ -86,7 +86,7 @@ int main () // last in the internal list maintained by the debugger. pseudo_barrier_init(g_barrier1, 5); - // The second break synchronyizes thread exection with the breakpoint. + // The second break synchronizes thread execution with the breakpoint. pseudo_barrier_init(g_barrier2, 5); // The third barrier keeps the waiting threads around until the breakpoint diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py index 4ba04953d6f15..0343a888a0f15 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py @@ -53,7 +53,7 @@ class ExitDuringStepTestCase(TestBase): def exit_during_step_base(self, step_cmd, step_stop_reason, by_instruction): """Test thread exit during step handling.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py index 26ee5d4084ebd..3300078e8c604 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py @@ -17,10 +17,11 @@ class ThreadJumpTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343") def test(self): """Test thread jump handling.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Find the line numbers for our breakpoints. @@ -50,8 +51,10 @@ class ThreadJumpTestCase(TestBase): self.do_min_test(self.mark3, self.mark2, "i", "5") # Try the double path, force it to return 'a' self.do_min_test(self.mark4, self.mark1, "j", "7") - # Try the double path, force it to return 'b' - self.do_min_test(self.mark4, self.mark2, "j", "8") + # Expected to fail on powerpc64le architecture + if not self.isPPC64le(): + # Try the double path, force it to return 'b' + self.do_min_test(self.mark4, self.mark2, "j", "8") # Try jumping to another function in a different file. self.runCmd( diff --git a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py index 18d88cb521137..cff9b5a8d5e5c 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py @@ -38,7 +38,7 @@ class MultipleBreakpointTestCase(TestBase): def test(self): """Test simultaneous breakpoints in multiple threads.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. diff --git a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py index 75a9b8873ddaa..4c4e645635c16 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py @@ -16,18 +16,19 @@ import lldbsuite.test.lldbutil as lldbutil class NumberOfThreadsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line numbers for our break points. self.thread3_notify_all_line = line_number('main.cpp', '// Set thread3 break point on notify_all at this line.') - self.thread3_before_lock_line = line_number('main.cpp', '// Set thread3 break point on lock at this line.') + self.thread3_before_lock_line = line_number('main.cpp', '// thread3-before-lock') def test_number_of_threads(self): """Test number of threads.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 location. @@ -63,10 +64,11 @@ class NumberOfThreadsTestCase(TestBase): 'Number of expected threads and actual threads do not match.') @skipIfDarwin # rdar://33462362 + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37658") def test_unique_stacks(self): """Test backtrace unique with multiple threads executing the same stack.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set a break point on the thread3 notify all (should get hit on threads 4-13). diff --git a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp index 42a07f353030d..fdc060d135dcf 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp @@ -12,7 +12,10 @@ void * thread3(void *input) { pseudo_barrier_wait(thread3_barrier); - std::unique_lock<std::mutex> lock(mutex); // Set thread3 break point on lock at this line. + + int dummy = 47; // thread3-before-lock + + std::unique_lock<std::mutex> lock(mutex); cond.notify_all(); // Set thread3 break point on notify_all at this line. return NULL; } diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py index 1fb52155c2665..0cbd94e199dcc 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -21,9 +21,7 @@ class ThreadStateTestCase(TestBase): @expectedFailureAll( oslist=["linux"], bugnumber="llvm.org/pr15824 thread states not properly maintained") - @expectedFailureAll( - oslist=lldbplatformutil.getDarwinOSTriples(), - bugnumber="llvm.org/pr15824 thread states not properly maintained and <rdar://problem/28557237>") + @skipIfDarwin # llvm.org/pr15824 thread states not properly maintained and <rdar://problem/28557237> @expectedFailureAll( oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") @@ -58,6 +56,7 @@ class ThreadStateTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + @skipIfDarwin # llvm.org/pr15824 thread states not properly maintained and <rdar://problem/28557237> def test_process_interrupt(self): """Test process interrupt.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -68,6 +67,7 @@ class ThreadStateTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly") + @skipIfDarwin # llvm.org/pr15824 thread states not properly maintained and <rdar://problem/28557237> def test_process_state(self): """Test thread states (comprehensive).""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -82,7 +82,7 @@ class ThreadStateTestCase(TestBase): def thread_state_after_breakpoint_test(self): """Test thread state after breakpoint.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. @@ -122,7 +122,7 @@ class ThreadStateTestCase(TestBase): def thread_state_after_continue_test(self): """Test thread state after continue.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. @@ -164,7 +164,7 @@ class ThreadStateTestCase(TestBase): def thread_state_after_expression_test(self): """Test thread state after expression.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. @@ -200,7 +200,7 @@ class ThreadStateTestCase(TestBase): def process_interrupt_test(self): """Test process interrupt and continue.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. @@ -240,7 +240,7 @@ class ThreadStateTestCase(TestBase): def thread_states_test(self): """Test thread states (comprehensive).""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py b/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py index 9c8bbf1eb081f..238b188378844 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py @@ -125,7 +125,7 @@ class ThreadStepOutTestCase(TestBase): def step_out_test(self, step_out_func): """Test single thread step out of a function.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint in the main thread. diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py b/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py index d63d5c55bc825..3bace5780639d 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py @@ -11,7 +11,7 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class TestCStepping(TestBase): +class StepUntilTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -26,7 +26,7 @@ class TestCStepping(TestBase): def do_until (self, args, until_lines, expected_linenum): 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/functionalities/thread/thread_exit/TestThreadExit.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py index deedc4b7507ab..07ceb3f5f6b7b 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py @@ -28,7 +28,7 @@ class ThreadExitTestCase(TestBase): def test(self): """Test thread exit handling.""" self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # This should create a breakpoint with 1 location. diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp index f9508cf6ecca7..432adc0ea00e3 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp @@ -64,7 +64,8 @@ int main () thread_1.join(); // Synchronize with the remaining thread - pseudo_barrier_wait(g_barrier3); // Set third breakpoint here + int dummy = 47; // Set third breakpoint here + pseudo_barrier_wait(g_barrier3); // Wait for the second thread to finish thread_2.join(); diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py index 8f004e6d319be..9fdf42ac4e3c4 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py @@ -13,68 +13,57 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +def set_thread_id(thread, breakpoint): + id = thread.id + breakpoint.SetThreadID(id) + +def set_thread_name(thread, breakpoint): + breakpoint.SetThreadName("main-thread") class ThreadSpecificBreakTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"]) @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], archs=['armv7', 'armv7k'], bugnumber='rdar://problem/34563920') # armv7 ios problem - breakpoint with tid qualifier isn't working - def test_python(self): + def test_thread_id(self): + self.do_test(set_thread_id) + + @skipUnlessDarwin + @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], archs=['armv7', 'armv7k'], bugnumber='rdar://problem/34563920') # armv7 ios problem - breakpoint with tid qualifier isn't working + def test_thread_name(self): + self.do_test(set_thread_name) + + def do_test(self, setter_method): """Test that we obey thread conditioned breakpoints.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + main_source_spec = lldb.SBFileSpec("main.cpp") + (target, process, main_thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self, + "Set main breakpoint here", main_source_spec) - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) + main_thread_id = main_thread.GetThreadID() # This test works by setting a breakpoint in a function conditioned to stop only on # the main thread, and then calling this function on a secondary thread, joining, # and then calling again on the main thread. If the thread specific breakpoint works # then it should not be hit on the secondary thread, only on the main # thread. - - main_source_spec = lldb.SBFileSpec("main.cpp") - - main_breakpoint = target.BreakpointCreateBySourceRegex( - "Set main breakpoint here", main_source_spec) thread_breakpoint = target.BreakpointCreateBySourceRegex( "Set thread-specific breakpoint here", main_source_spec) - - self.assertTrue( - main_breakpoint.IsValid(), - "Failed to set main breakpoint.") - self.assertGreater( - main_breakpoint.GetNumLocations(), - 0, - "main breakpoint has no locations associated with it.") - self.assertTrue( - thread_breakpoint.IsValid(), - "Failed to set thread breakpoint.") self.assertGreater( thread_breakpoint.GetNumLocations(), 0, "thread breakpoint has no locations associated with it.") - process = target.LaunchSimple( - None, None, self.get_process_working_directory()) - - self.assertTrue(process, PROCESS_IS_VALID) - - stopped_threads = lldbutil.get_threads_stopped_at_breakpoint( - process, main_breakpoint) - self.assertEqual( - len(stopped_threads), - 1, - "main breakpoint stopped at unexpected number of threads") - main_thread = stopped_threads[0] - main_thread_id = main_thread.GetThreadID() - # Set the thread-specific breakpoint to only stop on the main thread. The run the function # on another thread and join on it. If the thread-specific breakpoint works, the next # stop should be on the main thread. - thread_breakpoint.SetThreadID(main_thread_id) + + main_thread_id = main_thread.GetThreadID() + setter_method(main_thread, thread_breakpoint) process.Continue() next_stop_state = process.GetState() diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/main.cpp index 7721b5d843224..0509b3d37a7ff 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/main.cpp @@ -12,6 +12,11 @@ int main () { // Set main breakpoint here. + + #ifdef __APPLE__ + pthread_setname_np("main-thread"); + #endif + std::thread t(thread_function); t.join(); diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py index 3eddaca3e30de..8bf897f0bba72 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py @@ -21,6 +21,7 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase): # test frequently times out or hangs @skipIf(oslist=['windows', 'freebsd']) + @skipIfDarwin # hits break in another thread in testrun @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522') @add_test_categories(['pyapi']) @@ -28,7 +29,7 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase): def test_python(self): """Test that we obey thread conditioned breakpoints.""" 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/functionalities/tsan/basic/TestTsanBasic.py b/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py index f1689a8fda00e..c91ed41a2478e 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py +++ b/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py @@ -33,7 +33,7 @@ class TsanBasicTestCase(TestBase): self.line_thread2 = line_number('main.c', '// thread2 line') def tsan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py index 8baba9beed36a..7451dde1fa597 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py +++ b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py @@ -30,7 +30,7 @@ class TsanCPPGlobalLocationTestCase(TestBase): TestBase.setUp(self) def tsan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py index 3f0cae6a54c91..c68c2efff4cd5 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py +++ b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py @@ -30,7 +30,7 @@ class TsanGlobalLocationTestCase(TestBase): TestBase.setUp(self) def tsan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py index 436fcf63d07d0..93b06f6502a1e 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py +++ b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py @@ -30,7 +30,7 @@ class TsanMultipleTestCase(TestBase): TestBase.setUp(self) def tsan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py index f4380cf7749af..6e6587387ea93 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py @@ -26,7 +26,7 @@ class TsanThreadLeakTestCase(TestBase): self.tsan_tests() def tsan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py index 684e6f71d9318..6565a23365637 100644 --- a/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py @@ -30,7 +30,7 @@ class TsanThreadNumbersTestCase(TestBase): TestBase.setUp(self) def tsan_tests(self): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py b/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py index f0ecd464de1d1..c4d31df0989bd 100644 --- a/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py +++ b/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py @@ -35,7 +35,7 @@ class LaunchInTerminalTestCase(TestBase): @no_debug_info_test def test_launch_in_terminal(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) launch_info = lldb.SBLaunchInfo(["-lAF", "/tmp/"]) diff --git a/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py b/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py index 8d6311e42b93e..2c7fb01f2f269 100644 --- a/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py +++ b/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py @@ -25,7 +25,7 @@ class TypeCompletionTestCase(TestBase): def test_with_run_command(self): """Check that types only get completed when necessary.""" 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_source_regexp( self, "// Set break point at this line.") diff --git a/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py b/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py index b0f52923cc1f9..272634fcab91d 100644 --- a/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py +++ b/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py @@ -29,7 +29,7 @@ class TypeLookupTestCase(TestBase): def test_type_lookup(self): """Test type lookup command.""" 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.mm", self.line, num_expected_locations=1, loc_exact=True) diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/basic/TestUbsanBasic.py b/packages/Python/lldbsuite/test/functionalities/ubsan/basic/TestUbsanBasic.py index 8dcee97e32f50..5dfa08e783084 100644 --- a/packages/Python/lldbsuite/test/functionalities/ubsan/basic/TestUbsanBasic.py +++ b/packages/Python/lldbsuite/test/functionalities/ubsan/basic/TestUbsanBasic.py @@ -27,7 +27,7 @@ class UbsanBasicTestCase(TestBase): def ubsan_tests(self): # Load the test - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) @@ -84,7 +84,7 @@ class UbsanBasicTestCase(TestBase): self.assertEqual(data["instrumentation_class"], "UndefinedBehaviorSanitizer") self.assertEqual(data["description"], "misaligned-pointer-use") - self.assertEqual(data["filename"], "main.c") + self.assertEqual(os.path.basename(data["filename"]), "main.c") self.assertEqual(data["line"], self.line_align) self.runCmd("continue") diff --git a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py index a5e5f572a9792..d0502cc052a56 100644 --- a/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py +++ b/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py @@ -27,7 +27,7 @@ class UbsanUserExpressionTestCase(TestBase): def ubsan_tests(self): # Load the test - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect( "file " + exe, patterns=["Current executable set to .*a.out"]) diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py index a855be7536caf..9c87d1759f8c3 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py @@ -23,7 +23,7 @@ class EHFrameBasedUnwind(TestBase): self.build() self.setTearDownCleanup() - 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/functionalities/unwind/ehframe/main.c b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c index ae8060124ab29..46de1efe62656 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c +++ b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c @@ -1,6 +1,18 @@ void func() { -#ifndef __mips__ +#ifdef __powerpc64__ + __asm__ ( + "mflr 0;" + "std 0,16(1);" + "addi 1,1,-24;" + "mr 31,1;" + ".cfi_def_cfa_offset 24;" + "addi 0,0,0;" + "addi 1,1,24;" + "ld 0,16(1);" + ".cfi_def_cfa_offset 0;" + ); +#elif !defined __mips__ __asm__ ( "pushq $0x10;" ".cfi_def_cfa_offset 16;" diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py index c416004625613..a2558c77789ba 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py @@ -25,7 +25,7 @@ class NoreturnUnwind(TestBase): self.build() self.setTearDownCleanup() - 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/functionalities/unwind/sigtramp/TestSigtrampUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py index 598efbc5e0300..f971942322b16 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py @@ -25,7 +25,7 @@ class SigtrampUnwind(TestBase): self.build() self.setTearDownCleanup() - 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/functionalities/unwind/standard/TestStandardUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py index 2416128d2efa1..4bacb0bd98848 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py @@ -84,7 +84,7 @@ class StandardUnwindTest(TestBase): else: self.skipTest("No expectations for the current architecture") - 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/functionalities/value_md5_crash/TestValueMD5Crash.py b/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py index 8e3ab853e27d8..1a8fbdf5e2ba3 100644 --- a/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py +++ b/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py @@ -27,7 +27,7 @@ class ValueMD5CrashTestCase(TestBase): def test_with_run_command(self): """Verify that the hash computing logic for ValueObject's values can't crash us.""" 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/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py index 9fac249936eab..d39d35f768831 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py @@ -39,14 +39,14 @@ class HelloWatchLocationTestCase(TestBase): # Most of the MIPS boards provide only one H/W watchpoints, and S/W # watchpoints are not supported yet @expectedFailureAll(triple=re.compile('^mips')) - # SystemZ also currently supports only one H/W watchpoint - @expectedFailureAll(archs=['s390x']) + # SystemZ and PowerPC also currently supports only one H/W watchpoint + @expectedFailureAll(archs=['powerpc64le', 's390x']) @skipIfDarwin def test_hello_watchlocation(self): """Test watching a location with '-s size' option.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py index 2cfba398bac94..8e19f9b3b5b8f 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py @@ -28,7 +28,7 @@ class HelloWatchpointTestCase(TestBase): # And the watchpoint variable declaration line number. self.decl = line_number(self.source, '// Watchpoint variable declaration.') - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact('a.out') self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} @expectedFailureAll( @@ -40,7 +40,7 @@ class HelloWatchpointTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/TestWatchpointMultipleSlots.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/TestWatchpointMultipleSlots.py index ac2c2fb8ec5a3..b51cab38aa862 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/TestWatchpointMultipleSlots.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multi_watchpoint_slots/TestWatchpointMultipleSlots.py @@ -27,7 +27,7 @@ class WatchpointSlotsTestCase(TestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} # This is a arm and aarch64 specific test case. No other architectures tested. @@ -37,7 +37,7 @@ class WatchpointSlotsTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Detect line number after which we are going to increment arrayName. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py index c21355a2e8f90..7302f76c1fbce 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_hits/TestMultipleHits.py @@ -21,10 +21,10 @@ class MultipleHitsTestCase(TestBase): @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - @skipIf(bugnumber="llvm.org/pr30758", oslist=["linux"], archs=["arm", "aarch64"]) + @skipIf(bugnumber="llvm.org/pr30758", oslist=["linux"], archs=["arm", "aarch64", "powerpc64le"]) def test(self): self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py index 0c5798fdddfec..85d6c84d68fff 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py @@ -17,55 +17,26 @@ from lldbsuite.test import lldbutil class WatchpointForMultipleThreadsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + main_spec = lldb.SBFileSpec("main.cpp", False) @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - def test_watchpoint_multiple_threads(self): - """Test that lldb watchpoint works for multiple threads.""" - self.build() - self.setTearDownCleanup() - self.hello_multiple_threads() + def test_watchpoint_before_thread_start(self): + """Test that we can hit a watchpoint we set before starting another thread""" + self.do_watchpoint_test("Before running the thread") @expectedFailureAll( oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") - def test_watchpoint_multiple_threads_wp_set_and_then_delete(self): - """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires.""" + def test_watchpoint_after_thread_start(self): + """Test that we can hit a watchpoint we set after starting another thread""" + self.do_watchpoint_test("After running the thread") + + def do_watchpoint_test(self, line): self.build() - self.setTearDownCleanup() - self.hello_multiple_threads_wp_set_and_then_delete() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Our simple source filename. - self.source = 'main.cpp' - # Find the line number to break inside main(). - self.first_stop = line_number( - self.source, '// Set break point at this line') - - def hello_multiple_threads(self): - """Test that lldb watchpoint works for multiple threads.""" - self.runCmd( - "file %s" % - os.path.join( - os.getcwd(), - 'a.out'), - CURRENT_EXECUTABLE_SET) - - # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line( - self, None, self.first_stop, num_expected_locations=1) - - # Run the program. - self.runCmd("run", RUN_SUCCEEDED) - - # We should be stopped again due to the breakpoint. - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs=['stopped', - 'stop reason = breakpoint']) + lldbutil.run_to_source_breakpoint(self, line, self.main_spec) # Now let's set a write-type watchpoint for variable 'g_val'. self.expect( @@ -81,43 +52,29 @@ class WatchpointForMultipleThreadsTestCase(TestBase): self.expect("watchpoint list -v", substrs=['hit_count = 0']) - while True: - self.runCmd("process continue") + self.runCmd("process continue") - self.runCmd("thread list") - if "stop reason = watchpoint" in self.res.GetOutput(): - # Good, we verified that the watchpoint works! - self.runCmd("thread backtrace all") - break - else: - self.fail("The stop reason should be either break or watchpoint") + self.runCmd("thread list") + if "stop reason = watchpoint" in self.res.GetOutput(): + # Good, we verified that the watchpoint works! + self.runCmd("thread backtrace all") + else: + self.fail("The stop reason should be either break or watchpoint") # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should now be 1. self.expect("watchpoint list -v", substrs=['hit_count = 1']) - def hello_multiple_threads_wp_set_and_then_delete(self): + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") + def test_watchpoint_multiple_threads_wp_set_and_then_delete(self): """Test that lldb watchpoint works for multiple threads, and after the watchpoint is deleted, the watchpoint event should no longer fires.""" - self.runCmd( - "file %s" % - os.path.join( - os.getcwd(), - 'a.out'), - CURRENT_EXECUTABLE_SET) - - # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - lldbutil.run_break_set_by_file_and_line( - self, None, self.first_stop, num_expected_locations=1) - - # Run the program. - self.runCmd("run", RUN_SUCCEEDED) - - # We should be stopped again due to the breakpoint. - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs=['stopped', - 'stop reason = breakpoint']) + self.build() + self.setTearDownCleanup() + + lldbutil.run_to_source_breakpoint(self, "After running the thread", self.main_spec) # Now let's set a write-type watchpoint for variable 'g_val'. self.expect( diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp index 7f2e5e6e6cb58..1bfc3b2538b2f 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp @@ -7,73 +7,29 @@ // //===----------------------------------------------------------------------===// -#include <chrono> +#include "pseudo_barrier.h" #include <cstdio> -#include <mutex> -#include <random> #include <thread> -std::default_random_engine g_random_engine{std::random_device{}()}; -std::uniform_int_distribution<> g_distribution{0, 3000000}; +volatile uint32_t g_val = 0; +pseudo_barrier_t g_barrier; -uint32_t g_val = 0; - - -uint32_t -access_pool (bool flag = false) -{ - static std::mutex g_access_mutex; - g_access_mutex.lock(); - - uint32_t old_val = g_val; - if (flag) - { - printf("changing g_val to %d...\n", old_val + 1); - g_val = old_val + 1; - } - - g_access_mutex.unlock(); - return g_val; -} - -void -thread_func (uint32_t thread_index) -{ - printf ("%s (thread index = %u) starting...\n", __FUNCTION__, thread_index); - - uint32_t count = 0; - uint32_t val; - while (count++ < 15) - { - // random micro second sleep from zero to 3 seconds - int usec = g_distribution(g_random_engine); - printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); - std::this_thread::sleep_for(std::chrono::microseconds{usec}); - - if (count < 7) - val = access_pool (); - else - val = access_pool (true); - - printf ("%s (thread = %u) after usleep access_pool returns %d (count=%d)...\n", __FUNCTION__, thread_index, val, count); - } - printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); +void thread_func() { + pseudo_barrier_wait(g_barrier); + printf("%s starting...\n", __FUNCTION__); + for (uint32_t i = 0; i < 10; ++i) + g_val = i; } +int main(int argc, char const *argv[]) { + printf("Before running the thread\n"); + pseudo_barrier_init(g_barrier, 2); + std::thread thread(thread_func); -int main (int argc, char const *argv[]) -{ - std::thread threads[3]; - - printf ("Before turning all three threads loose...\n"); // Set break point at this line, - // in order to set our watchpoint. - // Create 3 threads - for (auto &thread : threads) - thread = std::thread{thread_func, std::distance(threads, &thread)}; + printf("After running the thread\n"); + pseudo_barrier_wait(g_barrier); - // Join all of our threads - for (auto &thread : threads) - thread.join(); + thread.join(); - return 0; + return 0; } diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py index 71686a5f5c491..e0c77b4ea6be0 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py @@ -29,7 +29,7 @@ class TestStepOverWatchpoint(TestBase): def test(self): """Test stepping over watchpoints.""" self.build() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) @@ -81,7 +81,7 @@ class TestStepOverWatchpoint(TestBase): # Most of the MIPS boards provide only one H/W watchpoints, and S/W # watchpoints are not supported yet arch = self.getArchitecture() - if re.match("^mips", arch): + if re.match("^mips", arch) or re.match("powerpc64le", arch): self.runCmd("watchpoint delete 1") # resolve_location=True, read=False, write=True diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py index 47454498e70ed..b2f267364dd01 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/variable_out_of_scope/TestWatchedVarHitWhenInScope.py @@ -18,13 +18,11 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - # # This test depends on not tracking watchpoint expression hits if we have # left the watchpoint scope. We will provide such an ability at some point # but the way this was done was incorrect, and it is unclear that for the # most part that's not what folks mostly want, so we have to provide a # clearer API to express this. - # def setUp(self): # Call super's setUp(). @@ -36,13 +34,13 @@ class WatchedVariableHitWhenInScopeTestCase(TestBase): # Test hangs due to a kernel bug, see fdfeff0f in the linux kernel for details @skipIfTargetAndroid(api_levels=list(range(25+1)), archs=["aarch64", "arm"]) - @unittest2.expectedFailure("rdar://problem/18685649") + @skipIf def test_watched_var_should_only_hit_when_in_scope(self): """Test that a variable watchpoint should only hit when in scope.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped in main. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py index 82865e646be52..5bb683934c1be 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py @@ -46,7 +46,7 @@ class WatchpointCommandsTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. @@ -117,7 +117,7 @@ class WatchpointCommandsTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. @@ -174,7 +174,7 @@ class WatchpointCommandsTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. @@ -234,7 +234,7 @@ class WatchpointCommandsTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. @@ -304,7 +304,7 @@ class WatchpointCommandsTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py index a4ceca34c0866..cd819f27ec5f0 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py @@ -45,7 +45,7 @@ class WatchpointLLDBCommandTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. @@ -113,7 +113,7 @@ class WatchpointLLDBCommandTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py index 50cd88bd86259..d9edd05d3a762 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py @@ -46,7 +46,7 @@ class WatchpointPythonCommandTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. @@ -116,7 +116,7 @@ class WatchpointPythonCommandTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. @@ -144,7 +144,8 @@ class WatchpointPythonCommandTestCase(TestBase): (self.source, self.decl)]) - cmd_script_file = os.path.join(os.getcwd(), "watchpoint_command.py") + cmd_script_file = os.path.join(self.getSourceDir(), + "watchpoint_command.py") self.runCmd("command script import '%s'" % (cmd_script_file)) self.runCmd( diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py index 34502a6d1d36e..a77b1e70e3dd5 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py @@ -45,7 +45,7 @@ class WatchpointConditionCmdTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py index dad633f052c65..587dcabb2ba39 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_disable/TestWatchpointDisable.py @@ -35,16 +35,12 @@ class TestWatchpointSetEnable(TestBase): def do_test(self, test_enable): """Set a watchpoint, disable it and make sure it doesn't get hit.""" - exe = 'a.out' - - exe = os.path.join(os.getcwd(), exe) + exe = self.getBuildArtifact("a.out") main_file_spec = lldb.SBFileSpec("main.c") # Create a target by the debugger. self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) - cwd = os.getcwd() - bkpt_before = self.target.BreakpointCreateBySourceRegex("Set a breakpoint here", main_file_spec) self.assertEqual(bkpt_before.GetNumLocations(), 1, "Failed setting the before breakpoint.") diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py index ea25803825206..cedfad9b566f5 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py @@ -33,7 +33,7 @@ class TestWatchpointEvents (TestBase): """Test that adding, deleting and modifying watchpoints sends the appropriate events.""" 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/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py index ee4b05c12659e..5b72f5edda74e 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py @@ -22,8 +22,10 @@ class TestValueOfVectorVariableTestCase(TestBase): bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") def test_value_of_vector_variable_using_watchpoint_set(self): """Test verify displayed value of vector variable.""" - self.build(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) + exe = self.getBuildArtifact("a.out") + d = {'C_SOURCES': self.source, 'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) self.value_of_vector_variable_with_watchpoint_set() def setUp(self): @@ -31,12 +33,10 @@ class TestValueOfVectorVariableTestCase(TestBase): TestBase.setUp(self) # Our simple source filename. self.source = 'main.c' - self.exe_name = 'a.out' - self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} def value_of_vector_variable_with_watchpoint_set(self): """Test verify displayed value of vector variable""" - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set break to get a frame diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py index b53e323cf4bdd..c7f7d02392eb0 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py @@ -44,7 +44,7 @@ class WatchLocationUsingWatchpointSetTestCase(TestBase): self.build() self.setTearDownCleanup() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py index 7460a1c094762..e6718f0bc6f02 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py @@ -33,7 +33,7 @@ class WatchpointSetErrorTestCase(TestBase): self.build() self.setTearDownCleanup() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Add a breakpoint to set a watchpoint when stopped on the breakpoint. diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py index ee64024893304..d4f78a5f3ecc5 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py @@ -28,7 +28,7 @@ class WatchpointSizeTestCase(TestBase): self.source = 'main.c' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} @expectedFailureAll( @@ -62,7 +62,7 @@ class WatchpointSizeTestCase(TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Detect line number after which we are going to increment arrayName. diff --git a/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories b/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories new file mode 100644 index 0000000000000..3a3f4df6416b9 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories @@ -0,0 +1 @@ +cmdline diff --git a/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py b/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py new file mode 100644 index 0000000000000..c25f9afbfa4ed --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py @@ -0,0 +1,39 @@ +""" +Test how lldb reacts to wrong commands +""" + +from __future__ import print_function + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class UnknownCommandTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @no_debug_info_test + def test_ambiguous_command(self): + command_interpreter = self.dbg.GetCommandInterpreter() + self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER) + result = lldb.SBCommandReturnObject() + + command_interpreter.HandleCommand("g", result) + self.assertFalse(result.Succeeded()) + self.assertRegexpMatches(result.GetError(), "Ambiguous command 'g'. Possible matches:") + self.assertRegexpMatches(result.GetError(), "gui") + self.assertRegexpMatches(result.GetError(), "gdb-remote") + self.assertEquals(1, result.GetError().count("gdb-remote")) + + @no_debug_info_test + def test_unknown_command(self): + command_interpreter = self.dbg.GetCommandInterpreter() + self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER) + result = lldb.SBCommandReturnObject() + + command_interpreter.HandleCommand("qbert", result) + self.assertFalse(result.Succeeded()) + self.assertEquals(result.GetError(), "error: 'qbert' is not a valid command.\n") 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/macosx/debug-info/apple_types/Makefile b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile index aa3a0fcdcea48..314f1cb2f077b 100644 --- a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/Makefile +++ b/packages/Python/lldbsuite/test/lang/cpp/dynamic-value-same-basename/Makefile @@ -1,6 +1,5 @@ LEVEL = ../../../make -C_SOURCES := main.c -MAKE_DSYM := NO +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/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile index 6067ee45e9848..314f1cb2f077b 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile +++ b/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/Makefile @@ -1,6 +1,5 @@ LEVEL = ../../../make -C_SOURCES := main.c -CFLAGS_EXTRAS += -std=c99 +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 diff --git a/packages/Python/lldbsuite/test/linux/add-symbols/Makefile b/packages/Python/lldbsuite/test/linux/add-symbols/Makefile index c701797f0a7db..71a5c11a83d13 100644 --- a/packages/Python/lldbsuite/test/linux/add-symbols/Makefile +++ b/packages/Python/lldbsuite/test/linux/add-symbols/Makefile @@ -2,11 +2,12 @@ LEVEL = ../../make CXX_SOURCES := main.cpp LD_EXTRAS += -Wl,--build-id=none -localall : stripped.out all +all: stripped.out + stripped.out : a.out - $(OBJCOPY) --remove-section=.note.gnu.build-id --remove-section=.gnu_debuglink --strip-debug a.out stripped.out + $(OBJCOPY) --remove-section=.note.gnu.build-id --remove-section=.gnu_debuglink --strip-debug $< $@ clean:: - $(RM) stripped.out + $(RM) stripped.out -include $(LEVEL)/Makefile.rules
\ No newline at end of file +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py b/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py index 477ddf9c15b12..946c151bb8faf 100644 --- a/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py +++ b/packages/Python/lldbsuite/test/linux/add-symbols/TestTargetSymbolsAddCommand.py @@ -22,8 +22,8 @@ class TargetSymbolsAddCommand(TestBase): """Test that 'target symbols add' can load the symbols even if gnu.build-id and gnu_debuglink are not present in the module. Similar to test_add_dsym_mid_execution test for macos.""" - self.build(clean=True) - exe = os.path.join(os.getcwd(), "stripped.out") + self.build() + exe = self.getBuildArtifact("stripped.out") self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) @@ -46,7 +46,8 @@ class TargetSymbolsAddCommand(TestBase): self.expect("frame select", substrs=['main.c'], matching=False) # Tell LLDB that a.out has symbols for stripped.out - self.runCmd("target symbols add -s stripped.out a.out") + self.runCmd("target symbols add -s %s %s" % + (exe, self.getBuildArtifact("a.out"))) # Check that symbols are now loaded and main.c is in the output. self.expect("frame select", substrs=['main.c']) diff --git a/packages/Python/lldbsuite/test/linux/builtin_trap/TestBuiltinTrap.py b/packages/Python/lldbsuite/test/linux/builtin_trap/TestBuiltinTrap.py index f24cae9ee0d9f..7ffc29fd49816 100644 --- a/packages/Python/lldbsuite/test/linux/builtin_trap/TestBuiltinTrap.py +++ b/packages/Python/lldbsuite/test/linux/builtin_trap/TestBuiltinTrap.py @@ -30,7 +30,7 @@ class BuiltinTrapTestCase(TestBase): def test_with_run_command(self): """Test that LLDB handles a function with __builtin_trap 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, diff --git a/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/Makefile b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/Makefile new file mode 100644 index 0000000000000..7cfad32f8272c --- /dev/null +++ b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/Makefile @@ -0,0 +1,10 @@ +LEVEL := ../../make + +C_SOURCES := a.c b.c +a.o: CFLAGS_EXTRAS += -gsplit-dwarf + +include $(LEVEL)/Makefile.rules + +.PHONY: clean +clean:: + $(RM) -f a.dwo a.o b.o main diff --git a/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py new file mode 100644 index 0000000000000..db91c39c39838 --- /dev/null +++ b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/TestMixedDwarfBinary.py @@ -0,0 +1,46 @@ +""" Testing debugging of a binary with "mixed" dwarf (with/without fission). """ +import os +import lldb +import sys +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestMixedDwarfBinary(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + + @no_debug_info_test # Prevent the genaration of the dwarf version of this test + @add_test_categories(["dwo"]) + @skipUnlessPlatform(["linux"]) + def test_mixed_dwarf(self): + """Test that 'frame variable' works + for the executable built from two source files compiled + with/whithout -gsplit-dwarf correspondingly.""" + + self.build() + exe = self.getBuildArtifact("a.out") + + self.target = self.dbg.CreateTarget(exe) + self.assertTrue(self.target, VALID_TARGET) + + main_bp = self.target.BreakpointCreateByName("g", "a.out") + self.assertTrue(main_bp, VALID_BREAKPOINT) + + self.process = self.target.LaunchSimple( + None, None, self.get_process_working_directory()) + self.assertTrue(self.process, PROCESS_IS_VALID) + + # The stop reason of the thread should be breakpoint. + self.assertTrue(self.process.GetState() == lldb.eStateStopped, + STOPPED_DUE_TO_BREAKPOINT) + + frame = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0) + x = frame.FindVariable("x") + self.assertTrue(x.IsValid(), "x is not valid") + y = frame.FindVariable("y") + self.assertTrue(y.IsValid(), "y is not valid") + diff --git a/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/a.c b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/a.c new file mode 100644 index 0000000000000..047e78a9b295e --- /dev/null +++ b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/a.c @@ -0,0 +1,3 @@ +int f() { + return 1; +} diff --git a/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/b.c b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/b.c new file mode 100644 index 0000000000000..d79970e13d491 --- /dev/null +++ b/packages/Python/lldbsuite/test/linux/mix-dwo-and-regular-objects/b.c @@ -0,0 +1,11 @@ +extern int f(); + +void g() { + int y = 14; + int x = f(); +} + +int main() { + g(); + return 0; +} diff --git a/packages/Python/lldbsuite/test/linux/sepdebugsymlink/Makefile b/packages/Python/lldbsuite/test/linux/sepdebugsymlink/Makefile new file mode 100644 index 0000000000000..3fd14a74bf360 --- /dev/null +++ b/packages/Python/lldbsuite/test/linux/sepdebugsymlink/Makefile @@ -0,0 +1,20 @@ +LEVEL = ../../make +C_SOURCES := main.c + +all: dirsymlink + +dirreal: a.out + $(RM) -r $@ + mkdir $@ + $(OBJCOPY) --only-keep-debug $< $@/stripped.debug + $(OBJCOPY) --strip-all --add-gnu-debuglink=$@/stripped.debug $< $@/stripped.out + +dirsymlink: dirreal + $(RM) -r $@ + mkdir $@ + ln -s ../$</stripped.out $@/stripped.symlink + +clean:: + $(RM) -r dirreal dirsymlink + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py b/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py new file mode 100644 index 0000000000000..12506811c5e21 --- /dev/null +++ b/packages/Python/lldbsuite/test/linux/sepdebugsymlink/TestTargetSymbolsSepDebugSymlink.py @@ -0,0 +1,23 @@ +""" Testing separate debug info loading for base binary with a symlink. """ +import os +import time +import lldb +import sys +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTargetSymbolsSepDebugSymlink(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @no_debug_info_test # Prevent the genaration of the dwarf version of this test + @skipUnlessPlatform(['linux']) + @skipIf(hostoslist=["windows"]) + @skipIfRemote # llvm.org/pr36237 + def test_target_symbols_sepdebug_symlink_case(self): + self.build() + exe = self.getBuildArtifact("dirsymlink/stripped.symlink") + + lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe) diff --git a/packages/Python/lldbsuite/test/linux/sepdebugsymlink/main.c b/packages/Python/lldbsuite/test/linux/sepdebugsymlink/main.c new file mode 100644 index 0000000000000..4cce7f667ff72 --- /dev/null +++ b/packages/Python/lldbsuite/test/linux/sepdebugsymlink/main.c @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py index 068594701507f..702d124834b2e 100644 --- a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py +++ b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py @@ -26,7 +26,7 @@ class CreateDuringInstructionStepTestCase(TestBase): bugnumber="llvm.org/pr24737") def test_step_inst(self): self.build(dictionary=self.getBuildFlags()) - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") diff --git a/packages/Python/lldbsuite/test/lldbinline.py b/packages/Python/lldbsuite/test/lldbinline.py index 70a0dda5343bf..bb925ef908f5a 100644 --- a/packages/Python/lldbsuite/test/lldbinline.py +++ b/packages/Python/lldbsuite/test/lldbinline.py @@ -84,25 +84,14 @@ class CommandParser: class InlineTest(TestBase): # Internal implementation - def getRerunArgs(self): - # The -N option says to NOT run a if it matches the option argument, so - # if we are using dSYM we say to NOT run dwarf (-N dwarf) and vice - # versa. - if self.using_dsym is None: - # The test was skipped altogether. - return "" - elif self.using_dsym: - return "-N dwarf %s" % (self.mydir) - else: - return "-N dsym %s" % (self.mydir) - def BuildMakefile(self): - if os.path.exists("Makefile"): + makefilePath = self.getBuildArtifact("Makefile") + if os.path.exists(makefilePath): return categories = {} - for f in os.listdir(os.getcwd()): + for f in os.listdir(self.getSourceDir()): t = source_type(f) if t: if t in list(categories.keys()): @@ -110,7 +99,7 @@ class InlineTest(TestBase): else: categories[t] = [f] - makefile = open("Makefile", 'w+') + makefile = open(makefilePath, 'w+') level = os.sep.join( [".."] * len(self.mydir.split(os.sep))) + os.sep + "make" @@ -134,56 +123,42 @@ class InlineTest(TestBase): makefile.flush() makefile.close() - @add_test_categories(["dsym"]) - def __test_with_dsym(self): - self.using_dsym = True + def _test(self): self.BuildMakefile() - self.buildDsym() - self.do_test() - - @add_test_categories(["dwarf"]) - def __test_with_dwarf(self): - self.using_dsym = False - self.BuildMakefile() - self.buildDwarf() - self.do_test() - - @add_test_categories(["dwo"]) - def __test_with_dwo(self): - self.using_dsym = False - self.BuildMakefile() - self.buildDwo() - self.do_test() - - @add_test_categories(["gmodules"]) - def __test_with_gmodules(self): - self.using_dsym = False - self.BuildMakefile() - self.buildGModules() + self.build() self.do_test() def execute_user_command(self, __command): exec(__command, globals(), locals()) def do_test(self): - exe_name = "a.out" - exe = os.path.join(os.getcwd(), exe_name) - source_files = [f for f in os.listdir(os.getcwd()) if source_type(f)] + exe = self.getBuildArtifact("a.out") + source_files = [f for f in os.listdir(self.getSourceDir()) + if source_type(f)] target = self.dbg.CreateTarget(exe) parser = CommandParser() parser.parse_source_files(source_files) parser.set_breakpoints(target) - process = target.LaunchSimple(None, None, os.getcwd()) + process = target.LaunchSimple(None, None, self.get_process_working_directory()) + hit_breakpoints = 0 while lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint): + hit_breakpoints += 1 thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) breakpoint_id = thread.GetStopReasonDataAtIndex(0) parser.handle_breakpoint(self, breakpoint_id) process.Continue() + self.assertTrue(hit_breakpoints > 0, + "inline test did not hit a single breakpoint") + # Either the process exited or the stepping plan is complete. + self.assertTrue(process.GetState() in [lldb.eStateStopped, + lldb.eStateExited], + PROCESS_EXITED) + # Utilities for testcases def check_expression(self, expression, expected_result, use_summary=True): @@ -223,32 +198,15 @@ def MakeInlineTest(__file, __globals, decorators=None): InlineTest.mydir = TestBase.compute_mydir(__file) test_name, _ = os.path.splitext(file_basename) + + test_func = ApplyDecoratorsToFunction(InlineTest._test, decorators) # Build the test case - test = type(test_name, (InlineTest,), {'using_dsym': None}) - test.name = test_name - - target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2] - if test_categories.is_supported_on_platform( - "dsym", target_platform, configuration.compiler): - test.test_with_dsym = ApplyDecoratorsToFunction( - test._InlineTest__test_with_dsym, decorators) - if test_categories.is_supported_on_platform( - "dwarf", target_platform, configuration.compiler): - test.test_with_dwarf = ApplyDecoratorsToFunction( - test._InlineTest__test_with_dwarf, decorators) - if test_categories.is_supported_on_platform( - "dwo", target_platform, configuration.compiler): - test.test_with_dwo = ApplyDecoratorsToFunction( - test._InlineTest__test_with_dwo, decorators) - if test_categories.is_supported_on_platform( - "gmodules", target_platform, configuration.compiler): - test.test_with_gmodules = ApplyDecoratorsToFunction( - test._InlineTest__test_with_gmodules, decorators) + test_class = type(test_name, (InlineTest,), dict(test=test_func, name=test_name)) # Add the test case to the globals, and hide InlineTest - __globals.update({test_name: test}) + __globals.update({test_name: test_class}) # Keep track of the original test filename so we report it # correctly in test results. - test.test_filename = __file - return test + test_class.test_filename = __file + return test_class diff --git a/packages/Python/lldbsuite/test/lldbplatformutil.py b/packages/Python/lldbsuite/test/lldbplatformutil.py index f7da58bd5259c..940b01e2fccbb 100644 --- a/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -33,6 +33,8 @@ def check_first_register_readable(test_case): test_case.expect("register read zero", substrs=['zero = 0x']) elif arch in ['s390x']: test_case.expect("register read r0", substrs=['r0 = 0x']) + elif arch in ['powerpc64le']: + test_case.expect("register read r0", substrs=['r0 = 0x']) else: # TODO: Add check for other architectures test_case.fail( @@ -109,7 +111,7 @@ def getHostPlatform(): # Attempts to return a platform name matching a target Triple platform. if sys.platform.startswith('linux'): return 'linux' - elif sys.platform.startswith('win32'): + elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'): return 'windows' elif sys.platform.startswith('darwin'): return 'darwin' diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py index ecc38f3554366..d5dd90a865178 100644 --- a/packages/Python/lldbsuite/test/lldbtest.py +++ b/packages/Python/lldbsuite/test/lldbtest.py @@ -44,12 +44,14 @@ import inspect import io import os.path import re +import shutil import signal from subprocess import * import sys import time import traceback import types +import distutils.spawn # Third-party modules import unittest2 @@ -69,15 +71,6 @@ from . import test_categories from lldbsuite.support import encoded_file from lldbsuite.support import funcutils -# dosep.py starts lots and lots of dotest instances -# This option helps you find if two (or more) dotest instances are using the same -# directory at the same time -# Enable it to cause test failures and stderr messages if dotest instances try to run in -# the same directory simultaneously -# it is disabled by default because it litters the test directories with -# ".dirlock" files -debug_confirm_directory_exclusivity = False - # See also dotest.parseOptionsAndInitTestdirs(), where the environment variables # LLDB_COMMAND_TRACE and LLDB_DO_CLEANUP are set from '-t' and '-r dir' # options. @@ -368,8 +361,8 @@ class _RemoteProcess(_BaseProcess): def launch(self, executable, args): if self._install_remote: src_path = executable - dst_path = lldbutil.append_to_process_working_directory( - os.path.basename(executable)) + dst_path = lldbutil.join_remote_paths( + lldb.remote_platform.GetWorkingDirectory(), os.path.basename(executable)) dst_file_spec = lldb.SBFileSpec(dst_path, False) err = lldb.remote_platform.Install( @@ -497,6 +490,8 @@ def getsource_if_available(obj): def builder_module(): if sys.platform.startswith("freebsd"): return __import__("builder_freebsd") + if sys.platform.startswith("openbsd"): + return __import__("builder_openbsd") if sys.platform.startswith("netbsd"): return __import__("builder_netbsd") if sys.platform.startswith("linux"): @@ -522,11 +517,14 @@ class Base(unittest2.TestCase): @staticmethod def compute_mydir(test_file): - '''Subclasses should call this function to correctly calculate the required "mydir" attribute as follows: + '''Subclasses should call this function to correctly calculate the + required "mydir" attribute as follows: - mydir = TestBase.compute_mydir(__file__)''' - test_dir = os.path.dirname(test_file) - return test_dir[len(os.environ["LLDB_TEST"]) + 1:] + mydir = TestBase.compute_mydir(__file__) + ''' + # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir + rel_prefix = test_file[len(os.environ["LLDB_TEST"]) + 1:] + return os.path.dirname(rel_prefix) def TraceOn(self): """Returns True if we are in trace mode (tracing detailed test execution).""" @@ -548,31 +546,11 @@ class Base(unittest2.TestCase): # Change current working directory if ${LLDB_TEST} is defined. # See also dotest.py which sets up ${LLDB_TEST}. if ("LLDB_TEST" in os.environ): - full_dir = os.path.join(os.environ["LLDB_TEST"], cls.mydir) + full_dir = os.path.join(os.environ["LLDB_TEST"], + cls.mydir) if traceAlways: print("Change dir to:", full_dir, file=sys.stderr) - os.chdir(os.path.join(os.environ["LLDB_TEST"], cls.mydir)) - - if debug_confirm_directory_exclusivity: - import lock - cls.dir_lock = lock.Lock(os.path.join(full_dir, ".dirlock")) - try: - cls.dir_lock.try_acquire() - # write the class that owns the lock into the lock file - cls.dir_lock.handle.write(cls.__name__) - except IOError as ioerror: - # nothing else should have this directory lock - # wait here until we get a lock - cls.dir_lock.acquire() - # read the previous owner from the lock file - lock_id = cls.dir_lock.handle.read() - print( - "LOCK ERROR: {} wants to lock '{}' but it is already locked by '{}'".format( - cls.__name__, - full_dir, - lock_id), - file=sys.stderr) - raise ioerror + os.chdir(full_dir) # Set platform context. cls.platformContext = lldbplatformutil.createPlatformContext() @@ -602,10 +580,6 @@ class Base(unittest2.TestCase): exc_type, exc_value, exc_tb = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_tb) - if debug_confirm_directory_exclusivity: - cls.dir_lock.release() - del cls.dir_lock - # Restore old working directory. if traceAlways: print("Restore dir to:", cls.oldcwd, file=sys.stderr) @@ -692,7 +666,7 @@ class Base(unittest2.TestCase): if not lldb.remote_platform or not configuration.lldb_platform_working_dir: return - components = [str(self.test_number)] + self.mydir.split(os.path.sep) + components = self.mydir.split(os.path.sep) + [str(self.test_number), self.getBuildDirBasename()] remote_test_dir = configuration.lldb_platform_working_dir for c in components: remote_test_dir = lldbutil.join_remote_paths(remote_test_dir, c) @@ -717,6 +691,36 @@ class Base(unittest2.TestCase): lldb.remote_platform.Run(shell_cmd) self.addTearDownHook(clean_working_directory) + def getSourceDir(self): + """Return the full path to the current test.""" + return os.path.join(os.environ["LLDB_TEST"], self.mydir) + + def getBuildDirBasename(self): + return self.__class__.__module__ + "." + self.testMethodName + + def getBuildDir(self): + """Return the full path to the current test.""" + return os.path.join(os.environ["LLDB_BUILD"], self.mydir, + self.getBuildDirBasename()) + + + def makeBuildDir(self): + """Create the test-specific working directory, deleting any previous + contents.""" + # See also dotest.py which sets up ${LLDB_BUILD}. + bdir = self.getBuildDir() + if os.path.isdir(bdir): + shutil.rmtree(bdir) + lldbutil.mkdir_p(bdir) + + def getBuildArtifact(self, name="a.out"): + """Return absolute path to an artifact in the test's build directory.""" + return os.path.join(self.getBuildDir(), name) + + def getSourcePath(self, name): + """Return absolute path to a file in the test's source directory.""" + return os.path.join(self.getSourceDir(), name) + def setUp(self): """Fixture for unittest test case setup. @@ -825,9 +829,6 @@ class Base(unittest2.TestCase): self.setPlatformWorkingDir() self.enableLogChannelsForCurrentTest() - # Initialize debug_info - self.debug_info = None - lib_dir = os.environ["LLDB_LIB_DIR"] self.dsym = None self.framework_dir = None @@ -850,6 +851,7 @@ class Base(unittest2.TestCase): self.framework_dir = None self.dsym = None self.darwinWithFramework = False + self.makeBuildDir() def setAsync(self, value): """ Sets async mode to True/False and ensures it is reset after the testcase completes.""" @@ -1236,6 +1238,13 @@ class Base(unittest2.TestCase): return True return False + def isPPC64le(self): + """Returns true if the architecture is PPC64LE.""" + arch = self.getArchitecture() + if re.match("powerpc64le", arch): + return True + return False + def getArchitecture(self): """Returns the architecture in effect the test suite is running with.""" module = builder_module() @@ -1378,13 +1387,17 @@ class Base(unittest2.TestCase): option_str += " -C " + comp return option_str + def getDebugInfo(self): + method = getattr(self, self.testMethodName) + return getattr(method, "debug_info", None) + # ================================================== # Build methods supported through a plugin interface # ================================================== def getstdlibFlag(self): """ Returns the proper -stdlib flag, or empty if not required.""" - if self.platformIsDarwin() or self.getPlatform() == "freebsd": + if self.platformIsDarwin() or self.getPlatform() == "freebsd" or self.getPlatform() == "openbsd": stdlibflag = "-stdlib=libc++" else: # this includes NetBSD stdlibflag = "" @@ -1402,7 +1415,6 @@ class Base(unittest2.TestCase): """ Platform-specific way to build a program that links with LLDB (via the liblldb.so or LLDB.framework). """ - stdflag = self.getstdFlag() stdlibflag = self.getstdlibFlag() @@ -1414,7 +1426,7 @@ class Base(unittest2.TestCase): 'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir, 'LD_EXTRAS': "%s -Wl,-rpath,%s" % (self.dsym, self.framework_dir), } - elif sys.platform.rstrip('0123456789') in ('freebsd', 'linux', 'netbsd', 'darwin') or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile': + elif sys.platform.startswith('win'): d = { 'CXX_SOURCES': sources, 'EXE': exe_name, @@ -1423,8 +1435,8 @@ class Base(unittest2.TestCase): os.path.join( os.environ["LLDB_SRC"], "include")), - 'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)} - elif sys.platform.startswith('win'): + 'LD_EXTRAS': "-L%s -lliblldb" % os.environ["LLDB_IMPLIB_DIR"]} + else: d = { 'CXX_SOURCES': sources, 'EXE': exe_name, @@ -1433,7 +1445,7 @@ class Base(unittest2.TestCase): os.path.join( os.environ["LLDB_SRC"], "include")), - 'LD_EXTRAS': "-L%s -lliblldb" % os.environ["LLDB_IMPLIB_DIR"]} + 'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)} if self.TraceOn(): print( "Building LLDB Driver (%s) from sources %s" % @@ -1454,16 +1466,16 @@ class Base(unittest2.TestCase): 'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir, 'LD_EXTRAS': "%s -Wl,-rpath,%s -dynamiclib" % (self.dsym, self.framework_dir), } - elif sys.platform.rstrip('0123456789') in ('freebsd', 'linux', 'netbsd', 'darwin') or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile': + elif self.getPlatform() == 'windows': d = { 'DYLIB_CXX_SOURCES': sources, 'DYLIB_NAME': lib_name, - 'CFLAGS_EXTRAS': "%s -I%s -fPIC" % (stdflag, - os.path.join( - os.environ["LLDB_SRC"], - "include")), - 'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)} - elif self.getPlatform() == 'windows': + 'CFLAGS_EXTRAS': "%s -I%s " % (stdflag, + os.path.join( + os.environ["LLDB_SRC"], + "include")), + 'LD_EXTRAS': "-shared -l%s\liblldb.lib" % self.os.environ["LLDB_IMPLIB_DIR"]} + else: d = { 'DYLIB_CXX_SOURCES': sources, 'DYLIB_NAME': lib_name, @@ -1471,7 +1483,7 @@ class Base(unittest2.TestCase): os.path.join( os.environ["LLDB_SRC"], "include")), - 'LD_EXTRAS': "-shared -l%s\liblldb.lib" % self.os.environ["LLDB_IMPLIB_DIR"]} + 'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)} if self.TraceOn(): print( "Building LLDB Library (%s) from sources %s" % @@ -1489,91 +1501,91 @@ class Base(unittest2.TestCase): self, architecture=None, compiler=None, - dictionary=None, - clean=True): + dictionary=None): """Platform specific way to build the default binaries.""" + testdir = self.mydir + testname = self.getBuildDirBasename() + if self.getDebugInfo(): + raise Exception("buildDefault tests must set NO_DEBUG_INFO_TESTCASE") module = builder_module() dictionary = lldbplatformutil.finalize_build_dictionary(dictionary) - if not module.buildDefault( - self, - architecture, - compiler, - dictionary, - clean): + if not module.buildDefault(self, architecture, compiler, + dictionary, testdir, testname): raise Exception("Don't know how to build default binary") def buildDsym( self, architecture=None, compiler=None, - dictionary=None, - clean=True): + dictionary=None): """Platform specific way to build binaries with dsym info.""" + testdir = self.mydir + testname = self.getBuildDirBasename() + if self.getDebugInfo() != "dsym": + raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault") + module = builder_module() dictionary = lldbplatformutil.finalize_build_dictionary(dictionary) - if not module.buildDsym( - self, - architecture, - compiler, - dictionary, - clean): + if not module.buildDsym(self, architecture, compiler, + dictionary, testdir, testname): raise Exception("Don't know how to build binary with dsym") def buildDwarf( self, architecture=None, compiler=None, - dictionary=None, - clean=True): + dictionary=None): """Platform specific way to build binaries with dwarf maps.""" + testdir = self.mydir + testname = self.getBuildDirBasename() + if self.getDebugInfo() != "dwarf": + raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault") + module = builder_module() dictionary = lldbplatformutil.finalize_build_dictionary(dictionary) - if not module.buildDwarf( - self, - architecture, - compiler, - dictionary, - clean): + if not module.buildDwarf(self, architecture, compiler, + dictionary, testdir, testname): raise Exception("Don't know how to build binary with dwarf") def buildDwo( self, architecture=None, compiler=None, - dictionary=None, - clean=True): + dictionary=None): """Platform specific way to build binaries with dwarf maps.""" + testdir = self.mydir + testname = self.getBuildDirBasename() + if self.getDebugInfo() != "dwo": + raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault") + module = builder_module() dictionary = lldbplatformutil.finalize_build_dictionary(dictionary) - if not module.buildDwo( - self, - architecture, - compiler, - dictionary, - clean): + if not module.buildDwo(self, architecture, compiler, + dictionary, testdir, testname): raise Exception("Don't know how to build binary with dwo") def buildGModules( self, architecture=None, compiler=None, - dictionary=None, - clean=True): + dictionary=None): """Platform specific way to build binaries with gmodules info.""" + testdir = self.mydir + testname = self.getBuildDirBasename() + if self.getDebugInfo() != "gmodules": + raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault") + module = builder_module() dictionary = lldbplatformutil.finalize_build_dictionary(dictionary) - if not module.buildGModules( - self, - architecture, - compiler, - dictionary, - clean): + if not module.buildGModules(self, architecture, compiler, + dictionary, testdir, testname): raise Exception("Don't know how to build binary with gmodules") def buildGo(self): """Build the default go binary. """ - system([[which('go'), 'build -gcflags "-N -l" -o a.out main.go']]) + exe = self.getBuildArtifact("a.out") + system([[which('go'), 'build -gcflags "-N -l" -o %s main.go' % exe]]) def signBinary(self, binary_path): if sys.platform.startswith("darwin"): @@ -1584,10 +1596,10 @@ class Base(unittest2.TestCase): def findBuiltClang(self): """Tries to find and use Clang from the build directory as the compiler (instead of the system compiler).""" paths_to_try = [ - "llvm-build/Release+Asserts/x86_64/Release+Asserts/bin/clang", - "llvm-build/Debug+Asserts/x86_64/Debug+Asserts/bin/clang", - "llvm-build/Release/x86_64/Release/bin/clang", - "llvm-build/Debug/x86_64/Debug/bin/clang", + "llvm-build/Release+Asserts/x86_64/bin/clang", + "llvm-build/Debug+Asserts/x86_64/bin/clang", + "llvm-build/Release/x86_64/bin/clang", + "llvm-build/Debug/x86_64/bin/clang", ] lldb_root_path = os.path.join( os.path.dirname(__file__), "..", "..", "..", "..") @@ -1597,12 +1609,38 @@ class Base(unittest2.TestCase): return path # Tries to find clang at the same folder as the lldb - path = os.path.join(os.path.dirname(lldbtest_config.lldbExec), "clang") - if os.path.exists(path): + lldb_dir = os.path.dirname(lldbtest_config.lldbExec) + path = distutils.spawn.find_executable("clang", lldb_dir) + if path is not None: return path return os.environ["CC"] + def findYaml2obj(self): + """ + Get the path to the yaml2obj executable, which can be used to create + test object files from easy to write yaml instructions. + + Throws an Exception if the executable cannot be found. + """ + # Tries to find yaml2obj at the same folder as clang + clang_dir = os.path.dirname(self.findBuiltClang()) + path = distutils.spawn.find_executable("yaml2obj", clang_dir) + if path is not None: + return path + raise Exception("yaml2obj executable not found") + + + def yaml2obj(self, yaml_path, obj_path): + """ + Create an object file at the given path from a yaml file. + + Throws subprocess.CalledProcessError if the object could not be created. + """ + yaml2obj = self.findYaml2obj() + command = [yaml2obj, "-o=%s" % obj_path, yaml_path] + system([command]) + def getBuildFlags( self, use_cpp11=True, @@ -1636,6 +1674,8 @@ class Base(unittest2.TestCase): cflags += "c++11" if self.platformIsDarwin() or self.getPlatform() == "freebsd": cflags += " -stdlib=libc++" + elif self.getPlatform() == "openbsd": + cflags += " -stdlib=libc++" elif self.getPlatform() == "netbsd": cflags += " -stdlib=libstdc++" elif "clang" in self.getCompiler(): @@ -1670,7 +1710,7 @@ class Base(unittest2.TestCase): return lib_dir def getLibcPlusPlusLibs(self): - if self.getPlatform() in ('freebsd', 'linux', 'netbsd'): + if self.getPlatform() in ('freebsd', 'linux', 'netbsd', 'openbsd'): return ['libc++.so.1'] else: return ['libc++.1.dylib', 'libc++abi.dylib'] @@ -1696,14 +1736,11 @@ class LLDBTestCaseFactory(type): for attrname, attrvalue in attrs.items(): if attrname.startswith("test") and not getattr( attrvalue, "__no_debug_info_test__", False): - target_platform = lldb.DBG.GetSelectedPlatform( - ).GetTriple().split('-')[2] # If any debug info categories were explicitly tagged, assume that list to be # authoritative. If none were specified, try with all debug # info formats. - all_dbginfo_categories = set( - test_categories.debug_info_categories) + all_dbginfo_categories = set(test_categories.debug_info_categories) categories = set( getattr( attrvalue, @@ -1712,48 +1749,16 @@ class LLDBTestCaseFactory(type): if not categories: categories = all_dbginfo_categories - supported_categories = [ - x for x in categories if test_categories.is_supported_on_platform( - x, target_platform, configuration.compiler)] - if "dsym" in supported_categories: - @decorators.add_test_categories(["dsym"]) - @wraps(attrvalue) - def dsym_test_method(self, attrvalue=attrvalue): - self.debug_info = "dsym" - return attrvalue(self) - dsym_method_name = attrname + "_dsym" - dsym_test_method.__name__ = dsym_method_name - newattrs[dsym_method_name] = dsym_test_method - - if "dwarf" in supported_categories: - @decorators.add_test_categories(["dwarf"]) + for cat in categories: + @decorators.add_test_categories([cat]) @wraps(attrvalue) - def dwarf_test_method(self, attrvalue=attrvalue): - self.debug_info = "dwarf" + def test_method(self, attrvalue=attrvalue): return attrvalue(self) - dwarf_method_name = attrname + "_dwarf" - dwarf_test_method.__name__ = dwarf_method_name - newattrs[dwarf_method_name] = dwarf_test_method - if "dwo" in supported_categories: - @decorators.add_test_categories(["dwo"]) - @wraps(attrvalue) - def dwo_test_method(self, attrvalue=attrvalue): - self.debug_info = "dwo" - return attrvalue(self) - dwo_method_name = attrname + "_dwo" - dwo_test_method.__name__ = dwo_method_name - newattrs[dwo_method_name] = dwo_test_method - - if "gmodules" in supported_categories: - @decorators.add_test_categories(["gmodules"]) - @wraps(attrvalue) - def gmodules_test_method(self, attrvalue=attrvalue): - self.debug_info = "gmodules" - return attrvalue(self) - gmodules_method_name = attrname + "_gmodules" - gmodules_test_method.__name__ = gmodules_method_name - newattrs[gmodules_method_name] = gmodules_test_method + method_name = attrname + "_" + cat + test_method.__name__ = method_name + test_method.debug_info = cat + newattrs[method_name] = test_method else: newattrs[attrname] = attrvalue @@ -1828,7 +1833,7 @@ class TestBase(Base): # Maximum allowed attempts when launching the inferior process. # Can be overridden by the LLDB_MAX_LAUNCH_COUNT environment variable. - maxLaunchCount = 3 + maxLaunchCount = 1 # Time to wait before the next launching attempt in second(s). # Can be overridden by the LLDB_TIME_WAIT_NEXT_LAUNCH environment variable. @@ -1836,7 +1841,7 @@ class TestBase(Base): def generateSource(self, source): template = source + '.template' - temp = os.path.join(os.getcwd(), template) + temp = os.path.join(self.getSourceDir(), template) with open(temp, 'r') as f: content = f.read() @@ -1855,7 +1860,7 @@ class TestBase(Base): header.startswith("SB") and header.endswith(".h"))] includes = '\n'.join(list) new_content = content.replace('%include_SB_APIs%', includes) - src = os.path.join(os.getcwd(), source) + src = os.path.join(self.getBuildDir(), source) with open(src, 'w') as f: f.write(new_content) @@ -1869,6 +1874,19 @@ class TestBase(Base): # decorators. Base.setUp(self) + if self.child: + # Set the clang modules cache path. + assert(self.getDebugInfo() == 'default') + mod_cache = os.path.join(self.getBuildDir(), "module-cache") + self.runCmd('settings set symbols.clang-modules-cache-path "%s"' + % mod_cache) + + # Disable Spotlight lookup. The testsuite creates + # different binaries with the same UUID, because they only + # differ in the debug info, which is not being hashed. + self.runCmd('settings set symbols.enable-external-lookup false') + + if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) @@ -1916,12 +1934,12 @@ class TestBase(Base): else: # Check relative names local_shlib_path = os.path.join( - os.getcwd(), shlib_prefix + name + shlib_extension) + self.getBuildDir(), shlib_prefix + name + shlib_extension) if not os.path.exists(local_shlib_path): local_shlib_path = os.path.join( - os.getcwd(), name + shlib_extension) + self.getBuildDir(), name + shlib_extension) if not os.path.exists(local_shlib_path): - local_shlib_path = os.path.join(os.getcwd(), name) + local_shlib_path = os.path.join(self.getBuildDir(), name) # Make sure we found the local shared library in the above code self.assertTrue(os.path.exists(local_shlib_path)) @@ -1931,7 +1949,7 @@ class TestBase(Base): if lldb.remote_platform: # We must set the remote install location if we want the shared library # to get uploaded to the remote target - remote_shlib_path = lldbutil.append_to_process_working_directory( + remote_shlib_path = lldbutil.append_to_process_working_directory(self, os.path.basename(local_shlib_path)) shlib_module.SetRemoteInstallFileSpec( lldb.SBFileSpec(remote_shlib_path, False)) @@ -1968,7 +1986,7 @@ class TestBase(Base): return lldb.remote_platform.GetWorkingDirectory() else: # local tests change directory into each test subdirectory - return os.getcwd() + return self.getBuildDir() def tearDown(self): #import traceback @@ -2249,24 +2267,23 @@ class TestBase(Base): self, architecture=None, compiler=None, - dictionary=None, - clean=True): + dictionary=None): """Platform specific way to build the default binaries.""" module = builder_module() + dictionary = lldbplatformutil.finalize_build_dictionary(dictionary) - if self.debug_info is None: - return self.buildDefault(architecture, compiler, dictionary, clean) - elif self.debug_info == "dsym": - return self.buildDsym(architecture, compiler, dictionary, clean) - elif self.debug_info == "dwarf": - return self.buildDwarf(architecture, compiler, dictionary, clean) - elif self.debug_info == "dwo": - return self.buildDwo(architecture, compiler, dictionary, clean) - elif self.debug_info == "gmodules": - return self.buildGModules( - architecture, compiler, dictionary, clean) + if self.getDebugInfo() is None: + return self.buildDefault(architecture, compiler, dictionary) + elif self.getDebugInfo() == "dsym": + return self.buildDsym(architecture, compiler, dictionary) + elif self.getDebugInfo() == "dwarf": + return self.buildDwarf(architecture, compiler, dictionary) + elif self.getDebugInfo() == "dwo": + return self.buildDwo(architecture, compiler, dictionary) + elif self.getDebugInfo() == "gmodules": + return self.buildGModules(architecture, compiler, dictionary) else: - self.fail("Can't build for debug info: %s" % self.debug_info) + self.fail("Can't build for debug info: %s" % self.getDebugInfo()) def run_platform_command(self, cmd): platform = self.dbg.GetSelectedPlatform() diff --git a/packages/Python/lldbsuite/test/lldbtest_config.py b/packages/Python/lldbsuite/test/lldbtest_config.py index 2e8e302fc7aaf..30546afe17bda 100644 --- a/packages/Python/lldbsuite/test/lldbtest_config.py +++ b/packages/Python/lldbsuite/test/lldbtest_config.py @@ -16,5 +16,8 @@ channels = [] # leave logs/traces even for successful test runs log_success = False +# Indicate whether we're testing with an out-of-tree debugserver +out_of_tree_debugserver = False + # path to the lldb command line executable tool lldbExec = None diff --git a/packages/Python/lldbsuite/test/lldbutil.py b/packages/Python/lldbsuite/test/lldbutil.py index 58a1ead1ea0bd..90ac799f4897e 100644 --- a/packages/Python/lldbsuite/test/lldbutil.py +++ b/packages/Python/lldbsuite/test/lldbutil.py @@ -9,6 +9,7 @@ from __future__ import absolute_import # System modules import collections +import errno import os import re import sys @@ -44,6 +45,14 @@ def which(program): return exe_file return None +def mkdir_p(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno != errno.EEXIST: + raise + if not os.path.isdir(path): + raise OSError(errno.ENOTDIR, "%s is not a directory"%path) # =================================================== # Disassembly for an SBFunction or an SBSymbol object # =================================================== @@ -334,7 +343,8 @@ def run_break_set_by_file_and_line( If extra_options is not None, then we append it to the breakpoint set command. - If num_expected_locations is -1 we check that we got AT LEAST one location, otherwise we check that num_expected_locations equals the number of locations. + If num_expected_locations is -1, we check that we got AT LEAST one location. If num_expected_locations is -2, we don't + check the actual number at all. Otherwise, we check that num_expected_locations equals the number of locations. If loc_exact is true, we check that there is one location, and that location must be at the input file and line number.""" @@ -554,7 +564,7 @@ def check_breakpoint_result( if num_locations == -1: test.assertTrue(out_num_locations > 0, "Expecting one or more locations, got none.") - else: + elif num_locations != -2: test.assertTrue( num_locations == out_num_locations, "Expecting %d locations, got %d." % @@ -566,7 +576,7 @@ def check_breakpoint_result( if 'file' in break_results: out_file_name = break_results['file'] test.assertTrue( - file_name == out_file_name, + file_name.endswith(out_file_name), "Breakpoint file name '%s' doesn't match resultant name '%s'." % (file_name, out_file_name)) @@ -725,29 +735,18 @@ def get_crashed_threads(test, process): threads.append(thread) return threads -def run_to_source_breakpoint(test, bkpt_pattern, source_spec, launch_info = None, exe_name = "a.out", in_cwd = True): - """Start up a target, using exe_name as the executable, and run it to - a breakpoint set by source regex bkpt_pattern. - If you want to pass in launch arguments or environment variables, you can optionally pass in - an SBLaunchInfo. If you do that, remember to set the working directory as well. - If your executable isn't called a.out, you can pass that in. And if your executable isn't - in the CWD, pass in the absolute path to the executable in exe_name, and set in_cwd to False. - If the target isn't valid, the breakpoint isn't found, or hit, the - function will cause a testsuite failure. - If successful it returns a tuple with the target process and thread that hit the breakpoint.""" +# Helper functions for run_to_{source,name}_breakpoint: +def run_to_breakpoint_make_target(test, exe_name, in_cwd): if in_cwd: - exe = os.path.join(os.getcwd(), exe_name) + exe = test.getBuildArtifact(exe_name) # Create the target target = test.dbg.CreateTarget(exe) test.assertTrue(target, "Target: %s is not valid."%(exe_name)) + return target - # Set the breakpoints - breakpoint = target.BreakpointCreateBySourceRegex( - bkpt_pattern, source_spec) - test.assertTrue(breakpoint.GetNumLocations() > 0, - 'No locations found for source breakpoint: "%s"'%(bkpt_pattern)) +def run_to_breakpoint_do_run(test, target, bkpt, launch_info): # Launch the process, and do not stop at the entry point. if not launch_info: @@ -757,15 +756,71 @@ def run_to_source_breakpoint(test, bkpt_pattern, source_spec, launch_info = None error = lldb.SBError() process = target.Launch(launch_info, error) - test.assertTrue(process, "Could not create a valid process for %s: %s"%(exe_name, error.GetCString())) + test.assertTrue(process, + "Could not create a valid process for %s: %s"%(target.GetExecutable().GetFilename(), + error.GetCString())) # Frame #0 should be at our breakpoint. threads = get_threads_stopped_at_breakpoint( - process, breakpoint) + process, bkpt) test.assertTrue(len(threads) == 1, "Expected 1 thread to stop at breakpoint, %d did."%(len(threads))) thread = threads[0] - return (target, process, thread, breakpoint) + return (target, process, thread, bkpt) + +def run_to_name_breakpoint (test, bkpt_name, launch_info = None, + exe_name = "a.out", + bkpt_module = None, + in_cwd = True): + """Start up a target, using exe_name as the executable, and run it to + a breakpoint set by name on bkpt_name restricted to bkpt_module. + + If you want to pass in launch arguments or environment + variables, you can optionally pass in an SBLaunchInfo. If you + do that, remember to set the working directory as well. + + If your executable isn't called a.out, you can pass that in. + And if your executable isn't in the CWD, pass in the absolute + path to the executable in exe_name, and set in_cwd to False. + + If you need to restrict the breakpoint to a particular module, + pass the module name (a string not a FileSpec) in bkpt_module. If + nothing is passed in setting will be unrestricted. + + If the target isn't valid, the breakpoint isn't found, or hit, the + function will cause a testsuite failure. + + If successful it returns a tuple with the target process and + thread that hit the breakpoint, and the breakpoint that we set + for you. + """ + + target = run_to_breakpoint_make_target(test, exe_name, in_cwd) + + breakpoint = target.BreakpointCreateByName(bkpt_name, bkpt_module) + + + test.assertTrue(breakpoint.GetNumLocations() > 0, + "No locations found for name breakpoint: '%s'."%(bkpt_name)) + return run_to_breakpoint_do_run(test, target, breakpoint, launch_info) + +def run_to_source_breakpoint(test, bkpt_pattern, source_spec, + launch_info = None, exe_name = "a.out", + bkpt_module = None, + in_cwd = True): + """Start up a target, using exe_name as the executable, and run it to + a breakpoint set by source regex bkpt_pattern. + + The rest of the behavior is the same as run_to_name_breakpoint. + """ + + target = run_to_breakpoint_make_target(test, exe_name, in_cwd) + # Set the breakpoints + breakpoint = target.BreakpointCreateBySourceRegex( + bkpt_pattern, source_spec, bkpt_module) + test.assertTrue(breakpoint.GetNumLocations() > 0, + 'No locations found for source breakpoint: "%s", file: "%s", dir: "%s"'%(bkpt_pattern, source_spec.GetFilename(), source_spec.GetDirectory())) + return run_to_breakpoint_do_run(test, target, breakpoint, launch_info) def continue_to_breakpoint(process, bkpt): """ Continues the process, if it stops, returns the threads stopped at bkpt; otherwise, returns None""" @@ -1195,11 +1250,11 @@ def join_remote_paths(*paths): return os.path.join(*paths).replace(os.path.sep, '/') -def append_to_process_working_directory(*paths): +def append_to_process_working_directory(test, *paths): remote = lldb.remote_platform if remote: return join_remote_paths(remote.GetWorkingDirectory(), *paths) - return os.path.join(os.getcwd(), *paths) + return os.path.join(test.getBuildDir(), *paths) # ================================================== # Utility functions to get the correct signal number @@ -1266,6 +1321,21 @@ def skip_if_library_missing(test, target, library): target)) +def read_file_on_target(test, remote): + if lldb.remote_platform: + local = test.getBuildArtifact("file_from_target") + error = lldb.remote_platform.Get(lldb.SBFileSpec(remote, False), + lldb.SBFileSpec(local, True)) + test.assertTrue(error.Success(), "Reading file {0} failed: {1}".format(remote, error)) + else: + local = remote + with open(local, 'r') as f: + return f.read() + +def read_file_from_process_wd(test, name): + path = append_to_process_working_directory(test, name) + return read_file_on_target(test, path) + def wait_for_file_on_target(testcase, file_path, max_attempts=6): for i in range(max_attempts): err, retcode, msg = testcase.run_platform_command("ls %s" % file_path) @@ -1280,9 +1350,4 @@ def wait_for_file_on_target(testcase, file_path, max_attempts=6): "File %s not found even after %d attempts." % (file_path, max_attempts)) - err, retcode, data = testcase.run_platform_command("cat %s" % (file_path)) - - testcase.assertTrue( - err.Success() and retcode == 0, "Failed to read file %s: %s, retcode: %d" % - (file_path, err.GetCString(), retcode)) - return data + return read_file_on_target(testcase, file_path) diff --git a/packages/Python/lldbsuite/test/logging/TestLogging.py b/packages/Python/lldbsuite/test/logging/TestLogging.py index 690c4f6ea69e6..cafbe437d84d1 100644 --- a/packages/Python/lldbsuite/test/logging/TestLogging.py +++ b/packages/Python/lldbsuite/test/logging/TestLogging.py @@ -17,34 +17,19 @@ from lldbsuite.test import lldbutil class LogTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - append_log_file = "lldb-commands-log-append.txt" - truncate_log_file = "lldb-commands-log-truncate.txt" + NO_DEBUG_INFO_TESTCASE = True - @classmethod - def classCleanup(cls): - """Cleanup the test byproducts.""" - cls.RemoveTempFile(cls.truncate_log_file) - cls.RemoveTempFile(cls.append_log_file) + def setUp(self): + super(LogTestCase, self).setUp() + self.log_file = self.getBuildArtifact("log-file.txt") def test(self): self.build() - if self.debug_info == "dsym": - self.command_log_tests("dsym") - else: - self.command_log_tests("dwarf") - - def command_log_tests(self, type): - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) - log_file = os.path.join( - os.getcwd(), - "lldb-commands-log-%s-%s-%s.txt" % - (type, - os.path.basename( - self.getCompiler()), - self.getArchitecture())) + log_file = os.path.join(self.getBuildDir(), "lldb-commands-log.txt") if (os.path.exists(log_file)): os.remove(log_file) @@ -75,47 +60,35 @@ class LogTestCase(TestBase): "Something was written to the log file.") # Check that lldb truncates its log files - @no_debug_info_test def test_log_truncate(self): - if (os.path.exists(self.truncate_log_file)): - os.remove(self.truncate_log_file) - # put something in our log file - with open(self.truncate_log_file, "w") as f: + with open(self.log_file, "w") as f: for i in range(1, 1000): f.write("bacon\n") - self.runCmd( - "log enable -t -f '%s' lldb commands" % - (self.truncate_log_file)) + self.runCmd("log enable -t -f '%s' lldb commands" % self.log_file) self.runCmd("help log") self.runCmd("log disable lldb") - self.assertTrue(os.path.isfile(self.truncate_log_file)) - with open(self.truncate_log_file, "r") as f: + self.assertTrue(os.path.isfile(self.log_file)) + with open(self.log_file, "r") as f: contents = f.read() # check that it got removed self.assertEquals(contents.find("bacon"), -1) # Check that lldb can append to a log file - @no_debug_info_test def test_log_append(self): - if (os.path.exists(self.append_log_file)): - os.remove(self.append_log_file) - # put something in our log file - with open(self.append_log_file, "w") as f: + with open(self.log_file, "w") as f: f.write("bacon\n") - self.runCmd( - "log enable -t -a -f '%s' lldb commands" % - (self.append_log_file)) + self.runCmd( "log enable -t -a -f '%s' lldb commands" % self.log_file) self.runCmd("help log") self.runCmd("log disable lldb") - self.assertTrue(os.path.isfile(self.append_log_file)) - with open(self.append_log_file, "r") as f: + self.assertTrue(os.path.isfile(self.log_file)) + with open(self.log_file, "r") as f: contents = f.read() # check that it is still there diff --git a/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile b/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile index 3a363ab98c174..5abcf02738c49 100644 --- a/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile +++ b/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile @@ -13,10 +13,10 @@ ifeq "$(OS)" "Darwin" CFLAGS += -arch $(ARCH) endif -all: clean +all: main.c clean mkdir hide.app mkdir hide.app/Contents - $(CC) $(CFLAGS) -g main.c + $(CC) $(CFLAGS) -g $< mv a.out.dSYM hide.app/Contents strip -x a.out diff --git a/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py b/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py index ec20ee2a24c01..be122f4f500d9 100644 --- a/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py +++ b/packages/Python/lldbsuite/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py @@ -25,8 +25,8 @@ class AddDsymMidExecutionCommandCase(TestBase): @no_debug_info_test # Prevent the genaration of the dwarf version of this test def test_add_dsym_mid_execution(self): """Test that add-dsym mid-execution loads the symbols at the right place for a slid binary.""" - self.buildDsym(clean=True) - exe = os.path.join(os.getcwd(), "a.out") + self.buildDefault(dictionary={'MAKE_DSYM':'YES'}) + exe = self.getBuildArtifact("a.out") self.target = self.dbg.CreateTarget(exe) self.assertTrue(self.target, VALID_TARGET) @@ -43,7 +43,8 @@ class AddDsymMidExecutionCommandCase(TestBase): self.assertTrue(self.process.GetState() == lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT) - self.runCmd("add-dsym hide.app/Contents/a.out.dSYM") + self.runCmd("add-dsym " + + self.getBuildArtifact("hide.app/Contents/a.out.dSYM")) self.expect("frame select", substrs=['a.out`main at main.c']) diff --git a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py deleted file mode 100644 index ff1ca2a9381ed..0000000000000 --- a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -Test that clang produces the __apple accelerator tables, for example, __apple_types, correctly. -""" - -from __future__ import print_function - - -import os -import time -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil -from lldbsuite.test.lldbutil import symbol_type_to_str - - -class AppleTypesTestCase(TestBase): - - mydir = TestBase.compute_mydir(__file__) - - # rdar://problem/11166975 - @skipUnlessDarwin - def test_debug_info_for_apple_types(self): - """Test that __apple_types section does get produced by clang.""" - - if not self.getCompiler().endswith('clang'): - self.skipTest("clang compiler only test") - - self.build() - if self.debug_info == "dsym": - exe = os.path.join(os.getcwd(), - "a.out.dSYM/Contents/Resources/DWARF/a.out") - else: - exe = os.path.join(os.getcwd(), "main.o") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - self.assertTrue(target.GetNumModules() > 0) - - # Hide stdout if not running with '-t' option. - if not self.TraceOn(): - self.HideStdout() - - print("Number of modules for the target: %d" % target.GetNumModules()) - for module in target.module_iter(): - print(module) - - # Get the executable module at index 0. - exe_module = target.GetModuleAtIndex(0) - - dwarf_section = exe_module.FindSection("__DWARF") - self.assertTrue(dwarf_section) - print("__DWARF section:", dwarf_section) - print("Number of sub-sections: %d" % dwarf_section.GetNumSubSections()) - INDENT = ' ' * 4 - for subsec in dwarf_section: - print(INDENT + str(subsec)) - - debug_str_sub_section = dwarf_section.FindSubSection("__debug_str") - self.assertTrue(debug_str_sub_section) - print("__debug_str sub-section:", debug_str_sub_section) - - # Find our __apple_types section by name. - apple_types_sub_section = dwarf_section.FindSubSection("__apple_types") - self.assertTrue(apple_types_sub_section) - print("__apple_types sub-section:", apple_types_sub_section) - - # These other three all important subsections should also be present. - self.assertTrue(dwarf_section.FindSubSection("__apple_names") and - dwarf_section.FindSubSection("__apple_namespac") and - dwarf_section.FindSubSection("__apple_objc")) diff --git a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/main.c b/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/main.c deleted file mode 100644 index cb4bdb9c16b42..0000000000000 --- a/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/main.c +++ /dev/null @@ -1,27 +0,0 @@ -//===-- main.c --------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -int main (int argc, char const *argv[]) -{ - struct point_tag { - int x; - int y; - }; // Set break point at this line. - - struct rect_tag { - struct point_tag bottom_left; - struct point_tag top_right; - }; - struct point_tag pt = { 2, 3 }; // This is the first executable statement. - struct rect_tag rect = {{1,2}, {3,4}}; - pt.x = argc; - pt.y = argc * argc; - rect.top_right.x = rect.top_right.x + argc; - rect.top_right.y = rect.top_right.y + argc; - return 0; -} diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/Makefile b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/Makefile new file mode 100644 index 0000000000000..5bb3a3ce3f102 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/Makefile @@ -0,0 +1,22 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +# Make an archive that has two object files with the same name, but +# different timestamps. Do it all in one rule so that the timestamps +# can be controlled without confusing Make. +libfoo.a: a.c sub1/a.c + $(CC) $(CFLAGS) -c $(<D)/a.c -o a.o + mkdir -p sub1 + $(CC) $(CFLAGS) -c $(<D)/sub1/a.c -o sub1/a.o + touch -t '198001010000.00' a.o + touch -t '198001010000.01' sub1/a.o + $(AR) $(ARFLAGS) $@ a.o sub1/a.o + rm a.o sub1/a.o + +include $(LEVEL)/Makefile.rules + +# Needs to come after include +OBJECTS += libfoo.a +$(EXE) : libfoo.a +.DEFAULT_GOAL := $(EXE) diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/TestDuplicateMembers.py b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/TestDuplicateMembers.py new file mode 100644 index 0000000000000..1af2463fe7b84 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/TestDuplicateMembers.py @@ -0,0 +1,55 @@ +"""Test breaking inside functions defined within a BSD archive file libfoo.a.""" + +from __future__ import print_function + + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class BSDArchivesTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24527. Makefile.rules doesn't know how to build static libs on Windows") + def test(self): + """Break inside a() and b() defined within libfoo.a.""" + self.build() + + exe = self.getBuildArtifact("a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break on a() and b() symbols + lldbutil.run_break_set_by_symbol( + self, "a", sym_exact=True) + lldbutil.run_break_set_by_symbol( + self, "b", sym_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', + 'stop reason = breakpoint']) + + # Break at a(int) first. + self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['(int) arg = 1']) + self.expect("frame variable __a_global", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['(int) __a_global = 1']) + + # Continue the program, we should break at b(int) next. + self.runCmd("continue") + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', + 'stop reason = breakpoint']) + self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['(int) arg = 2']) + self.expect("frame variable __b_global", VARIABLES_DISPLAYED_CORRECTLY, + substrs=['(int) __b_global = 2']) diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/a.c b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/a.c new file mode 100644 index 0000000000000..402a6270c9c7f --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/a.c @@ -0,0 +1,14 @@ +//===-- a.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int __a_global = 1; + +int a(int arg) { + int result = arg + __a_global; + return result; +} diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/main.c b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/main.c new file mode 100644 index 0000000000000..c5b1cc2f0d1c4 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/main.c @@ -0,0 +1,17 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include <stdio.h> + +extern int a(int); +extern int b(int); +int main (int argc, char const *argv[]) +{ + printf ("a(1) returns %d\n", a(1)); + printf ("b(2) returns %d\n", b(2)); +} diff --git a/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/sub1/a.c b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/sub1/a.c new file mode 100644 index 0000000000000..814d4e8b44e81 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/duplicate-archive-members/sub1/a.c @@ -0,0 +1,14 @@ +//===-- a.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +static int __b_global = 2; + +int b(int arg) { + int result = arg + __b_global; + return result; +} diff --git a/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/Makefile b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/Makefile new file mode 100644 index 0000000000000..18a4934cca370 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/Makefile @@ -0,0 +1,21 @@ +SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ + +CC ?= clang + +ifeq "$(ARCH)" "" + ARCH = x86_64 +endif + +CFLAGS ?= -g -O0 -arch $(ARCH) + +all: TestApp.app/Contents/MacOS/TestApp + +TestApp.app/Contents/MacOS/TestApp: $(SRCDIR)/main.c + $(CC) $(CFLAGS) -o TestApp $< + rm -rf TestApp.app + cp -r $(SRCDIR)/TestApp.app . + mv TestApp TestApp.app/Contents/MacOS/TestApp + mv TestApp.dSYM TestApp.app.dSYM + +clean: + rm -rf TestApp.app/Contents/MacOS/TestApp TestApp.app.dSYM diff --git a/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Info.plist b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Info.plist new file mode 100644 index 0000000000000..a47f72bb14da8 --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Info.plist @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>TestApp</string> + <key>CFBundleIdentifier</key> + <string>com.lldb.TestApp</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>TestApp</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSupportedPlatforms</key> + <array> + <string>MacOSX</string> + </array> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSMinimumSystemVersion</key> + <string>10.8</string> + <key>NSHumanReadableCopyright</key> + <string>Copyright © 2018 Jim Ingham. All rights reserved.</string> +</dict> +</plist> diff --git a/packages/Python/lldbsuite/test/functionalities/process_launch/my_working_dir/.keep b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/MacOS/.empty index e69de29bb2d1d..e69de29bb2d1d 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_launch/my_working_dir/.keep +++ b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/MacOS/.empty diff --git a/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/path with '09/.keep b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Resources/.empty index e69de29bb2d1d..e69de29bb2d1d 100644 --- a/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/path with '09/.keep +++ b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Resources/.empty diff --git a/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestFindAppInBundle.py b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestFindAppInBundle.py new file mode 100644 index 0000000000000..af6beeefd391f --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestFindAppInBundle.py @@ -0,0 +1,66 @@ +""" +Make sure we can find the binary inside an app bundle. +""" + +from __future__ import print_function + + +import os +import time +import re +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import lldbsuite.test.lldbplatformutil as lldbplatformutil +from lldbsuite.test.lldbtest import * + +@decorators.skipUnlessDarwin +class FindAppInMacOSAppBundle(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def test_find_app_in_bundle(self): + """There can be many tests in a test case - describe this test here.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.c") + self.find_app_in_bundle_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def find_app_in_bundle_test(self): + """This reads in the .app, makes sure we get the right binary and can run it.""" + + # This function starts a process, "a.out" by default, sets a source + # breakpoint, runs to it, and returns the thread, process & target. + # It optionally takes an SBLaunchOption argument if you want to pass + # arguments or environment variables. + exe = self.getBuildArtifact("TestApp.app") + error = lldb.SBError() + target = self.dbg.CreateTarget(exe, None, None, False, error) + self.assertTrue(error.Success(), "Could not create target: %s"%(error.GetCString())) + self.assertTrue(target.IsValid(), "Target: TestApp.app is not valid.") + exe_module_spec = target.GetExecutable() + self.assertTrue(exe_module_spec.GetFilename(), "TestApp") + + bkpt = target.BreakpointCreateBySourceRegex("Set a breakpoint here", self.main_source_file) + self.assertTrue(bkpt.GetNumLocations() == 1, "Couldn't set a breakpoint in the main app") + + if lldbplatformutil.getPlatform() == "macosx": + launch_info = lldb.SBLaunchInfo(None) + launch_info.SetWorkingDirectory(self.get_process_working_directory()) + + error = lldb.SBError() + process = target.Launch(launch_info, error) + + self.assertTrue(process.IsValid(), "Could not create a valid process for TestApp: %s"%(error.GetCString())) + + # Frame #0 should be at our breakpoint. + threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt) + + self.assertTrue(len(threads) == 1, "Expected 1 thread to stop at breakpoint, %d did."%(len(threads))) + + diff --git a/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/main.c b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/main.c new file mode 100644 index 0000000000000..27a0cdc01a9ae --- /dev/null +++ b/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/main.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int +main() +{ + printf("Set a breakpoint here.\n"); + return 0; +} + diff --git a/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/Makefile b/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/Makefile index 7b321e3deae0a..313c83e990d56 100644 --- a/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/Makefile +++ b/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/Makefile @@ -1,3 +1,5 @@ +SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ + CC ?= clang ifeq "$(ARCH)" "" @@ -7,7 +9,7 @@ endif CFLAGS ?= -g -O0 -arch $(ARCH) all: clean - $(CC) $(CFLAGS) -dynamiclib -o com.apple.sbd bundle.c + $(CC) $(CFLAGS) -dynamiclib -o com.apple.sbd $(SRCDIR)/bundle.c mkdir com.apple.sbd.xpc mv com.apple.sbd com.apple.sbd.xpc/ mkdir -p com.apple.sbd.xpc.dSYM/Contents/Resources/DWARF @@ -15,7 +17,7 @@ all: clean rm -rf com.apple.sbd.dSYM mkdir hide.app tar cf - com.apple.sbd.xpc com.apple.sbd.xpc.dSYM | ( cd hide.app;tar xBpf -) - $(CC) $(CFLAGS) -o find-bundle-with-dots-in-fn main.c + $(CC) $(CFLAGS) -o find-bundle-with-dots-in-fn $(SRCDIR)/main.c clean: rm -rf a.out a.out.dSYM hide.app com.apple.sbd com.apple.sbd.dSYM com.apple.sbd.xpc com.apple.sbd.xpc.dSYM find-bundle-with-dots-in-fn find-bundle-with-dots-in-fn.dSYM diff --git a/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py b/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py index 104e88752ec22..9a046cf0b294d 100644 --- a/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py +++ b/packages/Python/lldbsuite/test/macosx/find-dsym/bundle-with-dot-in-filename/TestBundleWithDotInFilename.py @@ -37,8 +37,9 @@ class BundleWithDotInFilenameTestCase(TestBase): def test_attach_and_check_dsyms(self): """Test attach to binary, see if the bundle dSYM is found""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) self.build() + os.chdir(self.getBuildDir()); popen = self.spawnSubprocess(exe) self.addTearDownHook(self.cleanupSubprocesses) @@ -66,6 +67,7 @@ class BundleWithDotInFilenameTestCase(TestBase): dsym_name = mod.GetSymbolFileSpec().GetFilename() self.assertTrue (dsym_name == 'com.apple.sbd', "Check that we found the dSYM for the bundle that was loaded") i=i+1 + os.chdir(self.getSourceDir()); if __name__ == '__main__': unittest.main() diff --git a/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/Makefile b/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/Makefile index 33b09502378c3..d52d6f1f0d37d 100644 --- a/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/Makefile +++ b/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/Makefile @@ -1,3 +1,5 @@ +SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ + CC ?= clang ifeq "$(ARCH)" "" @@ -7,12 +9,12 @@ endif CFLAGS ?= -g -O0 -arch $(ARCH) all: clean - $(CC) $(CFLAGS) -install_name $(PWD)/MyFramework.framework/Versions/A/MyFramework -dynamiclib -o MyFramework myframework.c + $(CC) $(CFLAGS) -install_name $(shell pwd)/MyFramework.framework/Versions/A/MyFramework -dynamiclib -o MyFramework $(SRCDIR)/myframework.c mkdir -p MyFramework.framework/Versions/A/Headers mkdir -p MyFramework.framework/Versions/A/Resources cp MyFramework MyFramework.framework/Versions/A - cp MyFramework.h MyFramework.framework/Versions/A/Headers - cp Info.plist MyFramework.framework/Versions/A/Resources + cp $(SRCDIR)/MyFramework.h MyFramework.framework/Versions/A/Headers + cp $(SRCDIR)/Info.plist MyFramework.framework/Versions/A/Resources ( cd MyFramework.framework/Versions ; ln -s A Current ) ( cd MyFramework.framework/ ; ln -s Versions/Current/Headers . ) ( cd MyFramework.framework/ ; ln -s Versions/Current/MyFramework . ) @@ -21,8 +23,8 @@ all: clean mkdir hide.app rm -f MyFramework tar cf - MyFramework.framework MyFramework.framework.dSYM | ( cd hide.app;tar xBpf -) - $(CC) $(CFLAGS) -o deep-bundle main.c -F. -framework MyFramework - + $(CC) $(CFLAGS) -o deep-bundle $(SRCDIR)/main.c -F. -framework MyFramework + clean: rm -rf a.out a.out.dSYM deep-bundle deep-bundle.dSYM MyFramework.framework MyFramework.framework.dSYM MyFramework MyFramework.dSYM hide.app diff --git a/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/TestDeepBundle.py b/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/TestDeepBundle.py index 493c4b99d094b..d6123e39c3fef 100644 --- a/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/TestDeepBundle.py +++ b/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/TestDeepBundle.py @@ -37,9 +37,9 @@ class DeepBundleTestCase(TestBase): def test_attach_and_check_dsyms(self): """Test attach to binary, see if the framework dSYM is found""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) self.build() - popen = self.spawnSubprocess(exe) + popen = self.spawnSubprocess(exe, [self.getBuildDir()]) self.addTearDownHook(self.cleanupSubprocesses) # Give the inferior time to start up, dlopen a bundle, remove the bundle it linked in @@ -49,7 +49,6 @@ class DeepBundleTestCase(TestBase): # binary & dSYM via target.exec-search-paths settings_str = "settings set target.exec-search-paths " + self.get_process_working_directory() + "/hide.app" self.runCmd(settings_str) - self.runCmd("process attach -p " + str(popen.pid)) target = self.dbg.GetSelectedTarget() diff --git a/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/main.c b/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/main.c index 19715216d6cfc..b5ef5cff74a39 100644 --- a/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/main.c +++ b/packages/Python/lldbsuite/test/macosx/find-dsym/deep-bundle/main.c @@ -1,12 +1,17 @@ #include <MyFramework/MyFramework.h> #include <unistd.h> +#include <stdio.h> #include <stdlib.h> int setup_is_complete = 0; -int main() +int main(int argc, const char **argv) { - system ("/bin/rm -rf MyFramework MyFramework.framework MyFramework.framework.dSYM"); + char command[8192]; + sprintf (command, + "/bin/rm -rf %s/MyFramework %s/MyFramework.framework %s/MyFramework.framework.dSYM", + argv[1], argv[1], argv[1]); + system (command); setup_is_complete = 1; diff --git a/packages/Python/lldbsuite/test/macosx/indirect_symbol/Makefile b/packages/Python/lldbsuite/test/macosx/indirect_symbol/Makefile index 07aa39eac3beb..69fd86e575e6d 100644 --- a/packages/Python/lldbsuite/test/macosx/indirect_symbol/Makefile +++ b/packages/Python/lldbsuite/test/macosx/indirect_symbol/Makefile @@ -1,14 +1,6 @@ -CC ?= clang -ifeq "$(ARCH)" "" - ARCH = x86_64 -endif - -ifeq "$(OS)" "" - OS = $(shell uname -s) -endif +LEVEL = ../../make -CFLAGS ?= -g -O0 -CWD := $(shell pwd) +include $(LEVEL)/Makefile.rules LIB_PREFIX := lib @@ -28,21 +20,21 @@ all: a.out $(LIB_INDIRECT) $(LIB_REEXPORT) a.out: main.o $(LIB_INDIRECT) $(LIB_REEXPORT) $(CC) $(CFLAGS) -o a.out main.o -L. $(LIB_INDIRECT) $(LIB_REEXPORT) -main.o: main.c - $(CC) $(CFLAGS) -c main.c +main.o: $(SRCDIR)/main.c + $(CC) $(CFLAGS) -c $(SRCDIR)/main.c $(LIB_INDIRECT): indirect.o $(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_INDIRECT) -o $(LIB_INDIRECT) indirect.o if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_INDIRECT); fi -indirect.o: indirect.c - $(CC) $(CFLAGS) -c indirect.c +indirect.o: $(SRCDIR)/indirect.c + $(CC) $(CFLAGS) -c $(SRCDIR)/indirect.c $(LIB_REEXPORT): reexport.o $(LIB_INDIRECT) - $(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_REEXPORT) -o $(LIB_REEXPORT) reexport.o -L. -lindirect -Wl,-alias_list,$(CWD)/alias.list + $(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_REEXPORT) -o $(LIB_REEXPORT) reexport.o -L. -lindirect -Wl,-alias_list,$(SRCDIR)/alias.list if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_REEXPORT); fi -reexport.o: reexport.c - $(CC) $(CFLAGS) -c reexport.c -clean: +reexport.o: $(SRCDIR)/reexport.c + $(CC) $(CFLAGS) -c $(SRCDIR)/reexport.c +clean:: rm -rf $(wildcard *.o *~ *.dylib *.so a.out *.dSYM) diff --git a/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py b/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py index afca8bcc0ded7..a87a628931093 100644 --- a/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py +++ b/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py @@ -26,14 +26,14 @@ class TestIndirectFunctions(TestBase): def test_with_python_api(self): """Test stepping and setting breakpoints in indirect and re-exported symbols.""" 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) if self.platformIsDarwin(): - lib1 = os.path.join(os.getcwd(), 'libindirect.dylib') - lib2 = os.path.join(os.getcwd(), 'libreexport.dylib') + lib1 = self.getBuildArtifact('libindirect.dylib') + lib2 = self.getBuildArtifact('libreexport.dylib') self.registerSharedLibrariesWithTarget(target, [lib1, lib2]) self.main_source_spec = lldb.SBFileSpec(self.main_source) diff --git a/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py b/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py index c2a27c5708986..59b325f579842 100644 --- a/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py +++ b/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py @@ -15,21 +15,20 @@ import re import sys from lldbsuite.test.decorators import * -from lldbsuite.test import lldbtest +from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbtest_config -class DarwinNSLogOutputTestCase(lldbtest.TestBase): +class DarwinNSLogOutputTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True - - mydir = lldbtest.TestBase.compute_mydir(__file__) + mydir = TestBase.compute_mydir(__file__) @skipUnlessDarwin @skipIfRemote # this test is currently written using lldb commands & assumes running on local system def setUp(self): # Call super's setUp(). - super(DarwinNSLogOutputTestCase, self).setUp() + TestBase.setUp(self) self.child = None self.child_prompt = '(lldb) ' self.strict_sources = False @@ -38,11 +37,11 @@ class DarwinNSLogOutputTestCase(lldbtest.TestBase): self.source = 'main.m' # Output filename. - self.exe_name = 'a.out' + self.exe_name = self.getBuildArtifact("a.out") self.d = {'OBJC_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. - self.line = lldbtest.line_number(self.source, '// break here') + self.line = line_number(self.source, '// break here') def tearDown(self): # Shut down the process if it's still running. @@ -111,7 +110,7 @@ class DarwinNSLogOutputTestCase(lldbtest.TestBase): self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) self.run_lldb_to_breakpoint(exe, self.source, self.line, settings_commands=settings_commands) self.expect_prompt() diff --git a/packages/Python/lldbsuite/test/macosx/order/Makefile b/packages/Python/lldbsuite/test/macosx/order/Makefile index 52fae2d2ca34d..ff5f1886ef561 100644 --- a/packages/Python/lldbsuite/test/macosx/order/Makefile +++ b/packages/Python/lldbsuite/test/macosx/order/Makefile @@ -1,7 +1,7 @@ LEVEL = ../../make C_SOURCES := main.c -LDFLAGS = $(CFLAGS) -Xlinker -order_file -Xlinker ./order-file +LDFLAGS = $(CFLAGS) -Xlinker -order_file -Xlinker $(SRCDIR)/order-file MAKE_DSYM := NO include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py b/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py index a70878f73e2ce..e7a4b20cd6bc0 100644 --- a/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py +++ b/packages/Python/lldbsuite/test/macosx/order/TestOrderFile.py @@ -22,12 +22,12 @@ class OrderFileTestCase(TestBase): def test(self): """Test debug symbols follow the correct order by the order file.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Test that the debug symbols have Function f3 before Function f1. # Use "-s address" option to sort by address. - self.runCmd("image dump symtab -s address a.out") + self.runCmd("image dump symtab -s address %s" % exe) output = self.res.GetOutput() mo_f3 = re.search("Code +.+f3", output) mo_f1 = re.search("Code +.+f1", output) diff --git a/packages/Python/lldbsuite/test/macosx/queues/Makefile b/packages/Python/lldbsuite/test/macosx/queues/Makefile index 93f2f7b2f340d..0d70f25950192 100644 --- a/packages/Python/lldbsuite/test/macosx/queues/Makefile +++ b/packages/Python/lldbsuite/test/macosx/queues/Makefile @@ -1,28 +1,5 @@ -CC ?= clang -ifeq "$(ARCH)" "" - ARCH = x86_64 -endif +LEVEL = ../../make -ifeq "$(OS)" "" - OS = $(shell uname -s) -endif +C_SOURCES := main.c -CFLAGS ?= -g -O0 -CWD := $(shell pwd) - -LIB_PREFIX := lib - -ifeq "$(OS)" "Darwin" - CFLAGS += -arch $(ARCH) -endif - -all: a.out - -a.out: main.o - $(CC) $(CFLAGS) -o a.out main.o - -main.o: main.c - $(CC) $(CFLAGS) -c main.c - -clean: - rm -rf $(wildcard *.o *~ *.dylib *.so a.out *.dSYM) +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py index 8eabe9a76637e..ba58372ce5b78 100644 --- a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py +++ b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py @@ -105,7 +105,7 @@ class TestQueues(TestBase): def queues(self): """Test queues inspection SB APIs without libBacktraceRecording.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -246,7 +246,7 @@ class TestQueues(TestBase): def queues_with_libBacktraceRecording(self): """Test queues inspection SB APIs with libBacktraceRecording present.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") if not os.path.isfile( '/Applications/Xcode.app/Contents/Developer/usr/lib/libBacktraceRecording.dylib'): diff --git a/packages/Python/lldbsuite/test/macosx/safe-to-func-call/Makefile b/packages/Python/lldbsuite/test/macosx/safe-to-func-call/Makefile index 93f2f7b2f340d..0d70f25950192 100644 --- a/packages/Python/lldbsuite/test/macosx/safe-to-func-call/Makefile +++ b/packages/Python/lldbsuite/test/macosx/safe-to-func-call/Makefile @@ -1,28 +1,5 @@ -CC ?= clang -ifeq "$(ARCH)" "" - ARCH = x86_64 -endif +LEVEL = ../../make -ifeq "$(OS)" "" - OS = $(shell uname -s) -endif +C_SOURCES := main.c -CFLAGS ?= -g -O0 -CWD := $(shell pwd) - -LIB_PREFIX := lib - -ifeq "$(OS)" "Darwin" - CFLAGS += -arch $(ARCH) -endif - -all: a.out - -a.out: main.o - $(CC) $(CFLAGS) -o a.out main.o - -main.o: main.c - $(CC) $(CFLAGS) -c main.c - -clean: - rm -rf $(wildcard *.o *~ *.dylib *.so a.out *.dSYM) +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.py b/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.py index 096064896eaa4..314084d0b1584 100644 --- a/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.py +++ b/packages/Python/lldbsuite/test/macosx/safe-to-func-call/TestSafeFuncCalls.py @@ -26,7 +26,7 @@ class TestSafeFuncCalls(TestBase): def test_with_python_api(self): """Test function call thread safety.""" 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/macosx/thread-names/Makefile b/packages/Python/lldbsuite/test/macosx/thread-names/Makefile index 93f2f7b2f340d..0d70f25950192 100644 --- a/packages/Python/lldbsuite/test/macosx/thread-names/Makefile +++ b/packages/Python/lldbsuite/test/macosx/thread-names/Makefile @@ -1,28 +1,5 @@ -CC ?= clang -ifeq "$(ARCH)" "" - ARCH = x86_64 -endif +LEVEL = ../../make -ifeq "$(OS)" "" - OS = $(shell uname -s) -endif +C_SOURCES := main.c -CFLAGS ?= -g -O0 -CWD := $(shell pwd) - -LIB_PREFIX := lib - -ifeq "$(OS)" "Darwin" - CFLAGS += -arch $(ARCH) -endif - -all: a.out - -a.out: main.o - $(CC) $(CFLAGS) -o a.out main.o - -main.o: main.c - $(CC) $(CFLAGS) -c main.c - -clean: - rm -rf $(wildcard *.o *~ *.dylib *.so a.out *.dSYM) +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/macosx/thread-names/TestInterruptThreadNames.py b/packages/Python/lldbsuite/test/macosx/thread-names/TestInterruptThreadNames.py index ae2916c92de97..925dc92951ced 100644 --- a/packages/Python/lldbsuite/test/macosx/thread-names/TestInterruptThreadNames.py +++ b/packages/Python/lldbsuite/test/macosx/thread-names/TestInterruptThreadNames.py @@ -23,7 +23,7 @@ class TestInterruptThreadNames(TestBase): def test_with_python_api(self): """Test that we get thread names when interrupting a process.""" 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/macosx/universal/Makefile b/packages/Python/lldbsuite/test/macosx/universal/Makefile index 854c78ed8c298..d74ed26f50ab7 100644 --- a/packages/Python/lldbsuite/test/macosx/universal/Makefile +++ b/packages/Python/lldbsuite/test/macosx/universal/Makefile @@ -1,19 +1,21 @@ CC ?= clang +all: testit + testit: testit.i386 testit.x86_64 - lipo -create -o testit testit.i386 testit.x86_64 + lipo -create -o testit $^ testit.i386: testit.i386.o - $(CC) -arch i386 -o testit.i386 testit.i386.o + $(CC) -arch i386 -o testit.i386 $< testit.x86_64: testit.x86_64.o - $(CC) -arch x86_64 -o testit.x86_64 testit.x86_64.o + $(CC) -arch x86_64 -o testit.x86_64 $< testit.i386.o: main.c - $(CC) -g -O0 -arch i386 -c -o testit.i386.o main.c + $(CC) -g -O0 -arch i386 -c -o testit.i386.o $< testit.x86_64.o: main.c - $(CC) -g -O0 -arch x86_64 -c -o testit.x86_64.o main.c + $(CC) -g -O0 -arch x86_64 -c -o testit.x86_64.o $< clean: rm -rf $(wildcard testit* *~) diff --git a/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py b/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py index 9a690e3ebb0ba..ca4f3ce9b1373 100644 --- a/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py +++ b/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py @@ -33,7 +33,7 @@ class UniversalTestCase(TestBase): self.build() # Note that "testit" is a universal binary. - exe = os.path.join(os.getcwd(), "testit") + exe = self.getBuildArtifact("testit") # Create a target by the debugger. target = self.dbg.CreateTargetWithFileAndTargetTriple( @@ -57,7 +57,7 @@ class UniversalTestCase(TestBase): self.build() # Note that "testit" is a universal binary. - exe = os.path.join(os.getcwd(), "testit") + exe = self.getBuildArtifact("testit") # By default, x86_64 is assumed if no architecture is specified. self.expect("file " + exe, CURRENT_EXECUTABLE_SET, @@ -130,7 +130,7 @@ class UniversalTestCase(TestBase): self.build() # Note that "testit" is a universal binary. - exe = os.path.join(os.getcwd(), "testit") + exe = self.getBuildArtifact("testit") # Create a target by the debugger. target = self.dbg.CreateTargetWithFileAndTargetTriple( diff --git a/packages/Python/lldbsuite/test/make/Android.rules b/packages/Python/lldbsuite/test/make/Android.rules index f7b8e2459611f..fab956e23641a 100644 --- a/packages/Python/lldbsuite/test/make/Android.rules +++ b/packages/Python/lldbsuite/test/make/Android.rules @@ -75,8 +75,15 @@ ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \ -D__ANDROID_API__=$(API_LEVEL) ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm -ifeq (1,$(USE_LIBCPP)) +ifeq (1,$(USE_LIBSTDCPP)) ARCH_CFLAGS += \ + -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \ + -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \ + -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward + + ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a +else + ARCH_CXXFLAGS += \ -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \ -isystem $(NDK_ROOT)/sources/android/support/include \ -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include @@ -84,11 +91,4 @@ ifeq (1,$(USE_LIBCPP)) ARCH_LDFLAGS += \ -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a -else - ARCH_CFLAGS += \ - -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \ - -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \ - -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward - - ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a endif diff --git a/packages/Python/lldbsuite/test/make/Makefile.rules b/packages/Python/lldbsuite/test/make/Makefile.rules index 4870cd95f80af..32f41b24d5dce 100644 --- a/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/packages/Python/lldbsuite/test/make/Makefile.rules @@ -6,6 +6,7 @@ # OBJC_SOURCES := # OBJCXX_SOURCES := # DYLIB_C_SOURCES := +# DYLIB_OBJC_SOURCES := # DYLIB_CXX_SOURCES := # # Specifying DYLIB_ONLY has the effect of building dylib only, skipping @@ -27,20 +28,21 @@ # Uncomment line below for debugging shell commands # SHELL = /bin/sh -x -THIS_FILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ +SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))/ +THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/ LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../ #---------------------------------------------------------------------- # If OS is not defined, use 'uname -s' to determine the OS name. # -# uname on Windows gives "windows32", but most environments standardize -# on "Windows_NT", so we'll make it consistent here. When running -# tests from Visual Studio, the environment variable isn't inherited -# all the way down to the process spawned for make. +# uname on Windows gives "windows32" or "server version windows32", but most +# environments standardize on "Windows_NT", so we'll make it consistent here. +# When running tests from Visual Studio, the environment variable isn't +# inherited all the way down to the process spawned for make. #---------------------------------------------------------------------- HOST_OS = $(shell uname -s) -ifeq "$(HOST_OS)" "windows32" +ifneq (,$(findstring windows32,$(HOST_OS))) HOST_OS = Windows_NT endif ifeq "$(OS)" "" @@ -145,7 +147,7 @@ ARCHFLAG ?= -arch # Change any build/tool options needed #---------------------------------------------------------------------- ifeq "$(OS)" "Darwin" - DS := $(shell xcrun -find -toolchain default dsymutil) + DS := $(DSYMUTIL) DSFLAGS = DSYM = $(EXE).dSYM AR := $(CROSS_COMPILE)libtool @@ -223,7 +225,7 @@ else CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) -I$(LLDB_BASE_DIR)include endif -CFLAGS += -include $(THIS_FILE_DIR)test_common.h -I$(THIS_FILE_DIR) +CFLAGS += -I$(SRCDIR) -include $(THIS_FILE_DIR)test_common.h -I$(THIS_FILE_DIR) CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS) # Use this one if you want to build one part of the result without debug information: @@ -237,13 +239,15 @@ ifeq "$(MAKE_DWO)" "YES" CFLAGS += -gsplit-dwarf endif +CLANG_MODULE_CACHE_DIR := module-cache + +MANDATORY_MODULE_BUILD_CFLAGS := -fmodules -gmodules -fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR) + ifeq "$(MAKE_GMODULES)" "YES" - CFLAGS += -fmodules -gmodules + CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) endif -CXXFLAGS += -std=c++11 -# FIXME: C++ modules aren't supported on all platforms. -CXXFLAGS += $(subst -fmodules,, $(CFLAGS)) +CXXFLAGS += -std=c++11 $(CFLAGS) $(ARCH_CXXFLAGS) LD = $(CC) LDFLAGS ?= $(CFLAGS) LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS) @@ -492,23 +496,6 @@ endif #---------------------------------------------------------------------- #---------------------------------------------------------------------- -# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO" -#---------------------------------------------------------------------- -ifneq "$(DYLIB_ONLY)" "YES" -$(DSYM) : $(EXE) -ifeq "$(OS)" "Darwin" -ifneq "$(MAKE_DSYM)" "NO" - "$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)" -endif -else -ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" - $(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)" - $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)" -endif -endif -endif - -#---------------------------------------------------------------------- # Compile the executable from all the objects. #---------------------------------------------------------------------- ifneq "$(DYLIB_NAME)" "" @@ -524,6 +511,22 @@ $(EXE) : $(OBJECTS) $(ARCHIVE_NAME) endif #---------------------------------------------------------------------- +# Make the dSYM file from the executable if $(MAKE_DSYM) != "NO" +#---------------------------------------------------------------------- +$(DSYM) : $(EXE) +ifeq "$(OS)" "Darwin" +ifneq "$(MAKE_DSYM)" "NO" + "$(DS)" $(DSFLAGS) -o "$(DSYM)" "$(EXE)" +else +endif +else +ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" + $(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)" + $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)" +endif +endif + +#---------------------------------------------------------------------- # Make the archive #---------------------------------------------------------------------- ifneq "$(ARCHIVE_NAME)" "" @@ -541,6 +544,11 @@ endif #---------------------------------------------------------------------- $(DYLIB_OBJECTS) : CFLAGS += -DCOMPILING_LLDB_TEST_DLL +ifneq "$(OS)" "Windows_NT" +$(DYLIB_OBJECTS) : CFLAGS += -fPIC +$(DYLIB_OBJECTS) : CXXFLAGS += -fPIC +endif + $(DYLIB_FILENAME) : $(DYLIB_OBJECTS) ifeq "$(OS)" "Darwin" $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -install_name "$(DYLIB_EXECUTABLE_PATH)/$(DYLIB_FILENAME)" -dynamiclib -o "$(DYLIB_FILENAME)" @@ -563,7 +571,7 @@ endif #ifneq "$(PCH_OUTPUT)" "" $(PCH_OUTPUT) : $(PCH_CXX_SOURCE) - $(CXX) $(CXXFLAGS) -x c++-header -o $(PCH_OUTPUT) $(PCH_CXX_SOURCE) + $(CXX) $(CXXFLAGS) -x c++-header -o $@ $< %.o : %.cpp $(PCH_OUTPUT) $(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $< #endif @@ -636,7 +644,7 @@ endif dsym: $(DSYM) all: $(EXE) $(DSYM) clean:: - $(RM) $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(DWOS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) + $(RM) -rf $(OBJECTS) $(PREREQS) $(PREREQS:.d=.d.tmp) $(DWOS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) $(CLANG_MODULE_CACHE_DIR) ifneq "$(DYLIB_NAME)" "" $(RM) -r $(DYLIB_FILENAME).dSYM $(RM) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_PREREQS:.d=.d.tmp) $(DYLIB_DWOS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).debug @@ -660,7 +668,7 @@ endif #---------------------------------------------------------------------- # From http://blog.melski.net/tag/debugging-makefiles/ -# +# # Usage: make print-CC print-CXX print-LD #---------------------------------------------------------------------- print-%: diff --git a/packages/Python/lldbsuite/test/plugins/builder_base.py b/packages/Python/lldbsuite/test/plugins/builder_base.py index bd6656bd5e87b..be891da2d0867 100644 --- a/packages/Python/lldbsuite/test/plugins/builder_base.py +++ b/packages/Python/lldbsuite/test/plugins/builder_base.py @@ -50,13 +50,32 @@ def getArchFlag(): return ("ARCHFLAG=" + archflag) if archflag else "" - -def getMake(): - """Returns the name for GNU make""" +def getMake(test_subdir, test_name): + """Returns the invocation for GNU make. + The first argument is a tuple of the relative path to the testcase + and its filename stem.""" if platform.system() == "FreeBSD" or platform.system() == "NetBSD": - return "gmake" + make = "gmake" else: - return "make" + make = "make" + + # Construct the base make invocation. + lldb_test = os.environ["LLDB_TEST"] + lldb_build = os.environ["LLDB_BUILD"] + if not (lldb_test and lldb_build and test_subdir and test_name and + (not os.path.isabs(test_subdir))): + raise Exception("Could not derive test directories") + build_dir = os.path.join(lldb_build, test_subdir, test_name) + src_dir = os.path.join(lldb_test, test_subdir) + # This is a bit of a hack to make inline testcases work. + makefile = os.path.join(src_dir, "Makefile") + if not os.path.isfile(makefile): + makefile = os.path.join(build_dir, "Makefile") + return [make, + "VPATH="+src_dir, + "-C", build_dir, + "-I", src_dir, + "-f", makefile] def getArchSpec(architecture): @@ -121,12 +140,11 @@ def buildDefault( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None, + testname=None): """Build the binaries the default way.""" commands = [] - if clean: - commands.append([getMake(), "clean", getCmdLine(dictionary)]) - commands.append([getMake(), getArchSpec(architecture), + commands.append(getMake(testdir, testname) + ["all", getArchSpec(architecture), getCCSpec(compiler), getCmdLine(dictionary)]) runBuildCommands(commands, sender=sender) @@ -140,13 +158,13 @@ def buildDwarf( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None, + testname=None): """Build the binaries with dwarf debug info.""" commands = [] - if clean: - commands.append([getMake(), "clean", getCmdLine(dictionary)]) - commands.append([getMake(), "MAKE_DSYM=NO", getArchSpec( - architecture), getCCSpec(compiler), getCmdLine(dictionary)]) + commands.append(getMake(testdir, testname) + + ["MAKE_DSYM=NO", getArchSpec(architecture), + getCCSpec(compiler), getCmdLine(dictionary)]) runBuildCommands(commands, sender=sender) # True signifies that we can handle building dwarf. @@ -158,13 +176,15 @@ def buildDwo( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None, + testname=None): """Build the binaries with dwarf debug info.""" commands = [] - if clean: - commands.append([getMake(), "clean", getCmdLine(dictionary)]) - commands.append([getMake(), "MAKE_DSYM=NO", "MAKE_DWO=YES", getArchSpec( - architecture), getCCSpec(compiler), getCmdLine(dictionary)]) + commands.append(getMake(testdir, testname) + + ["MAKE_DSYM=NO", "MAKE_DWO=YES", + getArchSpec(architecture), + getCCSpec(compiler), + getCmdLine(dictionary)]) runBuildCommands(commands, sender=sender) # True signifies that we can handle building dwo. @@ -176,13 +196,12 @@ def buildGModules( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None, + testname=None): """Build the binaries with dwarf debug info.""" commands = [] - if clean: - commands.append([getMake(), "clean", getCmdLine(dictionary)]) - commands.append([getMake(), - "MAKE_DSYM=NO", + commands.append(getMake(testdir, testname) + + ["MAKE_DSYM=NO", "MAKE_GMODULES=YES", getArchSpec(architecture), getCCSpec(compiler), @@ -195,12 +214,4 @@ def buildGModules( def cleanup(sender=None, dictionary=None): """Perform a platform-specific cleanup after the test.""" - #import traceback - # traceback.print_stack() - commands = [] - if os.path.isfile("Makefile"): - commands.append([getMake(), "clean", getCmdLine(dictionary)]) - - runBuildCommands(commands, sender=sender) - # True signifies that we can handle cleanup. return True diff --git a/packages/Python/lldbsuite/test/plugins/builder_darwin.py b/packages/Python/lldbsuite/test/plugins/builder_darwin.py index 06a2a86d47a4f..1cee39bbb4cb3 100644 --- a/packages/Python/lldbsuite/test/plugins/builder_darwin.py +++ b/packages/Python/lldbsuite/test/plugins/builder_darwin.py @@ -5,20 +5,20 @@ import lldbsuite.test.lldbtest as lldbtest from builder_base import * - def buildDsym( sender=None, architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None, + testname=None): """Build the binaries with dsym debug info.""" commands = [] - - if clean: - commands.append(["make", "clean", getCmdLine(dictionary)]) - commands.append(["make", "MAKE_DSYM=YES", getArchSpec( - architecture), getCCSpec(compiler), getCmdLine(dictionary)]) + commands.append(getMake(testdir, testname) + + ["MAKE_DSYM=YES", + getArchSpec(architecture), + getCCSpec(compiler), + "all", getCmdLine(dictionary)]) runBuildCommands(commands, sender=sender) diff --git a/packages/Python/lldbsuite/test/plugins/builder_freebsd.py b/packages/Python/lldbsuite/test/plugins/builder_freebsd.py index d9e654dc32f28..c3df36b5a36d5 100644 --- a/packages/Python/lldbsuite/test/plugins/builder_freebsd.py +++ b/packages/Python/lldbsuite/test/plugins/builder_freebsd.py @@ -6,5 +6,5 @@ def buildDsym( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None): return False diff --git a/packages/Python/lldbsuite/test/plugins/builder_linux.py b/packages/Python/lldbsuite/test/plugins/builder_linux.py index d9e654dc32f28..c3df36b5a36d5 100644 --- a/packages/Python/lldbsuite/test/plugins/builder_linux.py +++ b/packages/Python/lldbsuite/test/plugins/builder_linux.py @@ -6,5 +6,5 @@ def buildDsym( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None): return False diff --git a/packages/Python/lldbsuite/test/plugins/builder_netbsd.py b/packages/Python/lldbsuite/test/plugins/builder_netbsd.py index d9e654dc32f28..c3df36b5a36d5 100644 --- a/packages/Python/lldbsuite/test/plugins/builder_netbsd.py +++ b/packages/Python/lldbsuite/test/plugins/builder_netbsd.py @@ -6,5 +6,5 @@ def buildDsym( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None): return False diff --git a/packages/Python/lldbsuite/test/plugins/builder_openbsd.py b/packages/Python/lldbsuite/test/plugins/builder_openbsd.py new file mode 100644 index 0000000000000..c3df36b5a36d5 --- /dev/null +++ b/packages/Python/lldbsuite/test/plugins/builder_openbsd.py @@ -0,0 +1,10 @@ +from builder_base import * + + +def buildDsym( + sender=None, + architecture=None, + compiler=None, + dictionary=None, + testdir=None): + return False diff --git a/packages/Python/lldbsuite/test/plugins/builder_win32.py b/packages/Python/lldbsuite/test/plugins/builder_win32.py index d9e654dc32f28..c3df36b5a36d5 100644 --- a/packages/Python/lldbsuite/test/plugins/builder_win32.py +++ b/packages/Python/lldbsuite/test/plugins/builder_win32.py @@ -6,5 +6,5 @@ def buildDsym( architecture=None, compiler=None, dictionary=None, - clean=True): + testdir=None): return False diff --git a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py index 4bd4781c7ef51..5e21471e7c15f 100644 --- a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py +++ b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py @@ -23,7 +23,7 @@ class BreakpointAPITestCase(TestBase): def test_breakpoint_is_valid(self): """Make sure that if an SBBreakpoint gets deleted its IsValid returns false.""" 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) @@ -57,7 +57,7 @@ class BreakpointAPITestCase(TestBase): Breakpoint's IsValid returns false.""" 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/python_api/class_members/TestSBTypeClassMembers.py b/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py index a9e896f2579f8..074bbc76fd19a 100644 --- a/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py +++ b/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py @@ -34,7 +34,7 @@ class SBTypeMemberFunctionsTest(TestBase): 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) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py index 97261c70ec969..deb0c7a9fcbb4 100644 --- a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -31,6 +31,9 @@ class DisassembleRawDataTestCase(TestBase): elif re.match("mips", arch): target = self.dbg.CreateTargetWithFileAndTargetTriple("", "mips") raw_bytes = bytearray([0x03, 0xa0, 0xf0, 0x21]) + elif re.match("powerpc64le", arch): + target = self.dbg.CreateTargetWithFileAndTargetTriple("", "powerpc64le") + raw_bytes = bytearray([0x00, 0x00, 0x80, 0x38]) else: target = self.dbg.CreateTargetWithFileAndTargetTriple("", "x86_64") raw_bytes = bytearray([0x48, 0x89, 0xe5]) @@ -48,6 +51,9 @@ class DisassembleRawDataTestCase(TestBase): self.assertTrue(inst.GetMnemonic(target) == "move") self.assertTrue(inst.GetOperands(target) == '$' + "fp, " + '$' + "sp") + elif re.match("powerpc64le", arch): + self.assertTrue(inst.GetMnemonic(target) == "li") + self.assertTrue(inst.GetOperands(target) == "4, 0") else: self.assertTrue(inst.GetMnemonic(target) == "movq") self.assertTrue(inst.GetOperands(target) == diff --git a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py index e9ea0bd008795..8a9e456f3458d 100644 --- a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py +++ b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py @@ -15,6 +15,7 @@ from lldbsuite.test import lldbutil @skipIfLinux # llvm.org/pr25924, sometimes generating SIGSEGV +@skipIfDarwin class EventAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,7 +34,7 @@ class EventAPITestCase(TestBase): def test_listen_for_and_print_event(self): """Exercise SBEvent API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.dbg.SetAsync(True) @@ -122,7 +123,7 @@ class EventAPITestCase(TestBase): def test_wait_for_event(self): """Exercise SBListener.WaitForEvent() API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.dbg.SetAsync(True) @@ -201,7 +202,7 @@ class EventAPITestCase(TestBase): def test_add_listener_to_broadcaster(self): """Exercise some SBBroadcaster APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.dbg.SetAsync(True) diff --git a/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py b/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py index 0a0ac2d057704..c066dc58003d9 100644 --- a/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py +++ b/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py @@ -22,8 +22,7 @@ class SBFrameFindValueTestCase(TestBase): self.build() self.setTearDownCleanup() - exe_name = "a.out" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact("a.out") # Create the target target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py b/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py index 667bd58adcee0..8548506fdc463 100644 --- a/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py +++ b/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py @@ -28,10 +28,12 @@ class SBFormattersAPITestCase(TestBase): self.setTearDownCleanup() """Test Python APIs for working with formatters""" - 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) + self, "main.cpp", self.line, num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -439,7 +441,8 @@ class SBFormattersAPITestCase(TestBase): self.build(dictionary={'EXE': 'no_synth'}) self.setTearDownCleanup() - self.runCmd("file no_synth", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("no_synth"), + 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/python_api/frame/TestFrames.py b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py index a2d2cf12cdca0..85e915ad3a48a 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py +++ b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py @@ -24,7 +24,7 @@ class FrameAPITestCase(TestBase): def test_get_arg_vals_for_call_stack(self): """Exercise SBFrame.GetVariables() API to get argument vals.""" 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) @@ -127,7 +127,7 @@ class FrameAPITestCase(TestBase): def test_frame_api_boundary_condition(self): """Exercise SBFrame APIs with boundary condition inputs.""" 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) @@ -169,7 +169,7 @@ class FrameAPITestCase(TestBase): def test_frame_api_IsEqual(self): """Exercise SBFrame API IsEqual.""" 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/python_api/frame/get-variables/TestGetVariables.py b/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py index 86585d8d02e22..1bd54c39fa0b1 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py +++ b/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py @@ -51,7 +51,7 @@ class TestGetVariables(TestBase): self.dbg.SetAsync(False) # 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) diff --git a/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py b/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py index caa2696be7cdb..8b8f81ff4c4b4 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py +++ b/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py @@ -32,7 +32,7 @@ class InlinedFrameAPITestCase(TestBase): def test_stop_at_outer_inline(self): """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" 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/python_api/function_symbol/TestDisasmAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py index 4511da94437bb..f657d19764ba8 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py @@ -28,10 +28,11 @@ class DisasmAPITestCase(TestBase): 'main.c', '// Find the line number for breakpoint 2 here.') @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test(self): """Exercise getting SBAddress objects, disassembly, and SBAddress APIs.""" 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/python_api/function_symbol/TestSymbolAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py index 9919375abb59a..6644b81ef2a9d 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py @@ -28,10 +28,11 @@ class SymbolAPITestCase(TestBase): 'main.c', '// Find the line number for breakpoint 2 here.') @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test(self): """Exercise some SBSymbol and SBAddress APIs.""" 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/python_api/hello_world/TestHelloWorld.py b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py index fb4e54aa0bc56..b0f09d2fa7b5a 100644 --- a/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py +++ b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py @@ -14,15 +14,12 @@ from lldbsuite.test import lldbutil class HelloWorldTestCase(TestBase): - + NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Get the full path to our executable to be attached/debugged. - self.exe = os.path.join(os.getcwd(), self.testMethodName) - self.d = {'EXE': self.testMethodName} # Find a couple of the line numbers within main.c. self.line1 = line_number('main.c', '// Set break point at this line.') self.line2 = line_number('main.c', '// Waiting to be attached...') @@ -37,9 +34,12 @@ class HelloWorldTestCase(TestBase): @skipIfiOSSimulator def test_with_process_launch_api(self): """Create target, breakpoint, launch a process, and then kill it.""" - self.build(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - target = self.dbg.CreateTarget(self.exe) + # Get the full path to our executable to be attached/debugged. + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateByLocation("main.c", self.line1) @@ -82,12 +82,14 @@ class HelloWorldTestCase(TestBase): @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_with_attach_to_process_with_id_api(self): """Create target, spawn a process, and attach to it with process id.""" - self.build(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - target = self.dbg.CreateTarget(self.exe) + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) # Spawn a new process - popen = self.spawnSubprocess(self.exe, ["abc", "xyz"]) + popen = self.spawnSubprocess(exe, ["abc", "xyz"]) self.addTearDownHook(self.cleanupSubprocesses) # Give the subprocess time to start and wait for user input @@ -112,12 +114,14 @@ class HelloWorldTestCase(TestBase): @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails def test_with_attach_to_process_with_name_api(self): """Create target, spawn a process, and attach to it with process name.""" - self.build(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - target = self.dbg.CreateTarget(self.exe) + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) # Spawn a new process - popen = self.spawnSubprocess(self.exe, ["abc", "xyz"]) + popen = self.spawnSubprocess(exe, ["abc", "xyz"]) self.addTearDownHook(self.cleanupSubprocesses) # Give the subprocess time to start and wait for user input @@ -127,7 +131,7 @@ class HelloWorldTestCase(TestBase): error = lldb.SBError() # Pass 'False' since we don't want to wait for new instance of # "hello_world" to be launched. - name = os.path.basename(self.exe) + name = os.path.basename(exe) # While we're at it, make sure that passing a None as the process name # does not hang LLDB. diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/main.c b/packages/Python/lldbsuite/test/python_api/hello_world/main.c index 001e9c01e6e5e..32b0446517c54 100644 --- a/packages/Python/lldbsuite/test/python_api/hello_world/main.c +++ b/packages/Python/lldbsuite/test/python_api/hello_world/main.c @@ -1,5 +1,11 @@ #include <stdio.h> +#ifdef _MSC_VER +#include <windows.h> +#define sleep(x) Sleep((x) * 1000) +#else #include <unistd.h> +#endif + int main(int argc, char const *argv[]) { lldb_enable_attach(); diff --git a/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py b/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py index 7f5781f5cd8e1..2f31b0aebaa26 100644 --- a/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py +++ b/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py @@ -24,7 +24,7 @@ class CommandInterpreterAPICase(TestBase): def test_with_process_launch_api(self): """Test the SBCommandInterpreter APIs.""" 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/python_api/lldbutil/frame/TestFrameUtils.py b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py index bcbaa68ed9280..4db6322e75134 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py @@ -27,7 +27,7 @@ class FrameUtilsTestCase(TestBase): def test_frame_utils(self): """Test utility functions for the frame object.""" 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/python_api/lldbutil/iter/TestLLDBIterator.py b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py index ae7ec3dfc3ccc..6816b0d1ee953 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py @@ -30,7 +30,7 @@ class LLDBIteratorTestCase(TestBase): def test_lldb_iter_module(self): """Test module_iter works correctly for SBTarget -> SBModule.""" 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) @@ -66,7 +66,7 @@ class LLDBIteratorTestCase(TestBase): def test_lldb_iter_breakpoint(self): """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" 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) @@ -98,7 +98,7 @@ class LLDBIteratorTestCase(TestBase): def test_lldb_iter_frame(self): """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" 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/python_api/lldbutil/iter/TestRegistersIterator.py b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py index a19cc5c375f5a..bd46749d6e648 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py @@ -30,7 +30,7 @@ class RegistersIteratorTestCase(TestBase): def test_iter_registers(self): """Test iterator works correctly for lldbutil.iter_registers().""" 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/python_api/lldbutil/process/TestPrintStackTraces.py b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py index b447bb797a0fc..dcdade25d46f7 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py @@ -37,7 +37,7 @@ class ThreadsStackTracesTestCase(TestBase): def test_stack_traces(self): """Test SBprocess and SBThread APIs with printing of the stack traces.""" 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/python_api/module_section/TestModuleAndSection.py b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py index 79b988465d7e3..65b159974c085 100644 --- a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py +++ b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py @@ -26,7 +26,7 @@ class ModuleAndSectionAPIsTestCase(TestBase): def test_module_and_section(self): """Test module and section APIs.""" 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) @@ -77,7 +77,7 @@ class ModuleAndSectionAPIsTestCase(TestBase): def test_module_and_section_boundary_condition(self): """Test module and section APIs by passing None when it expects a Python string.""" 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) @@ -118,7 +118,7 @@ class ModuleAndSectionAPIsTestCase(TestBase): def test_module_compile_unit_iter(self): """Test module's compile unit iterator APIs.""" 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) @@ -141,3 +141,29 @@ class ModuleAndSectionAPIsTestCase(TestBase): INDENT2 = INDENT * 2 for cu in exe_module.compile_unit_iter(): print(cu) + + @add_test_categories(['pyapi']) + def test_find_compile_units(self): + """Exercise SBModule.FindCompileUnits() API.""" + d = {'EXE': 'b.out'} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.find_compile_units(self.getBuildArtifact('b.out')) + + def find_compile_units(self, exe): + """Exercise SBModule.FindCompileUnits() API.""" + source_name_list = ["main.cpp", "b.cpp", "c.cpp"] + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + num_modules = target.GetNumModules() + for i in range(num_modules): + module = target.GetModuleAtIndex(i) + for source_name in source_name_list: + list = module.FindCompileUnits(lldb.SBFileSpec(source_name, False)) + for sc in list: + self.assertTrue( + sc.GetCompileUnit().GetFileSpec().GetFilename() == + source_name) diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py index b7a683f25f623..6511ff865bd93 100644 --- a/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py +++ b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py @@ -20,6 +20,7 @@ class TestNameLookup(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test_target(self): """Exercise SBTarget.FindFunctions() with various name masks. @@ -28,7 +29,7 @@ class TestNameLookup(TestBase): and that using a function basename with eFunctionNameTypeFull works for all C++ functions that are at the global namespace level.""" 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/python_api/objc_type/TestObjCType.py b/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py index 89dfebde1af70..fd3bfa858e125 100644 --- a/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py +++ b/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py @@ -28,7 +28,7 @@ class ObjCSBTypeTestCase(TestBase): def test(self): """Test SBType for ObjC classes.""" 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/python_api/process/TestProcessAPI.py b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py index 065c707448909..fc17e4a76c54e 100644 --- a/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py +++ b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py @@ -29,7 +29,7 @@ class ProcessAPITestCase(TestBase): def test_read_memory(self): """Test Python SBProcess.ReadMemory() API.""" 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) @@ -127,7 +127,7 @@ class ProcessAPITestCase(TestBase): def test_write_memory(self): """Test Python SBProcess.WriteMemory() API.""" 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) @@ -186,7 +186,7 @@ class ProcessAPITestCase(TestBase): def test_access_my_int(self): """Test access 'my_int' using Python SBProcess.GetByteOrder() and other APIs.""" 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) @@ -284,7 +284,7 @@ class ProcessAPITestCase(TestBase): def test_remote_launch(self): """Test SBProcess.RemoteLaunch() API with a process not in eStateConnected, and it should fail.""" 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) @@ -308,7 +308,7 @@ class ProcessAPITestCase(TestBase): def test_get_num_supported_hardware_watchpoints(self): """Test SBProcess.GetNumSupportedHardwareWatchpoints() API with a process.""" 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) @@ -331,7 +331,7 @@ class ProcessAPITestCase(TestBase): def test_get_process_info(self): """Test SBProcess::GetProcessInfo() API with a locally launched process.""" 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/python_api/process/io/TestProcessIO.py b/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py index 71f77b3688096..e25083d6efb29 100644 --- a/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py +++ b/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py @@ -19,11 +19,13 @@ class ProcessIOTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) + + def setup_test(self): # Get the full path to our executable to be debugged. - self.exe = os.path.join(os.getcwd(), "process_io") - self.local_input_file = os.path.join(os.getcwd(), "input.txt") - self.local_output_file = os.path.join(os.getcwd(), "output.txt") - self.local_error_file = os.path.join(os.getcwd(), "error.txt") + self.exe = self.getBuildArtifact("process_io") + self.local_input_file = self.getBuildArtifact("input.txt") + self.local_output_file = self.getBuildArtifact("output.txt") + self.local_error_file = self.getBuildArtifact("error.txt") self.input_file = os.path.join( self.get_process_working_directory(), "input.txt") @@ -38,6 +40,7 @@ class ProcessIOTestCase(TestBase): @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdin_by_api(self): """Exercise SBProcess.PutSTDIN().""" + self.setup_test() self.build() self.create_target() self.run_process(True) @@ -49,6 +52,7 @@ class ProcessIOTestCase(TestBase): @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdin_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN without specifying STDOUT or STDERR.""" + self.setup_test() self.build() self.create_target() self.redirect_stdin() @@ -62,6 +66,7 @@ class ProcessIOTestCase(TestBase): @skipIfDarwinEmbedded # debugserver can't create/write files on the device def test_stdout_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT without specifying STDIN or STDERR.""" + self.setup_test() self.build() self.create_target() self.redirect_stdout() @@ -76,6 +81,7 @@ class ProcessIOTestCase(TestBase): @skipIfDarwinEmbedded # debugserver can't create/write files on the device def test_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDERR without specifying STDIN or STDOUT.""" + self.setup_test() self.build() self.create_target() self.redirect_stderr() @@ -90,6 +96,7 @@ class ProcessIOTestCase(TestBase): @skipIfDarwinEmbedded # debugserver can't create/write files on the device def test_stdout_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN.""" + self.setup_test() self.build() self.create_target() self.redirect_stdout() diff --git a/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py index 6302711606c51..b03cebce48c1a 100644 --- a/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py +++ b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py @@ -17,17 +17,19 @@ class TestReadMemCString(TestBase): def test_read_memory_c_string(self): """Test corner case behavior of SBProcess::ReadCStringFromMemory""" self.build() - self.dbg.SetAsync(False) + self.dbg.SetAsync(False) self.main_source = "main.c" - self.main_source_spec = lldb.SBFileSpec(self.main_source) - self.exe = os.path.join(os.getcwd(), "read-mem-cstring") + self.main_source_path = os.path.join(self.getSourceDir(), + self.main_source) + self.main_source_spec = lldb.SBFileSpec(self.main_source_path) + self.exe = self.getBuildArtifact("read-mem-cstring") (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, 'breakpoint here', self.main_source_spec, None, self.exe) - frame = thread.GetFrameAtIndex(0) - + frame = thread.GetFrameAtIndex(0) + err = lldb.SBError() empty_str_addr = frame.FindVariable("empty_string").GetValueAsUnsigned(err) diff --git a/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py b/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py index a84d0004c18b8..1d042b69287f5 100644 --- a/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py +++ b/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py @@ -26,7 +26,7 @@ class Radar12481949DataFormatterTestCase(TestBase): def test_with_run_command(self): """Check that SBValue.GetValueAsSigned() does the right thing for a 32-bit -1.""" 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/python_api/sbdata/TestSBData.py b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py index 0560ac502dcf7..a1a400a076b51 100644 --- a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py +++ b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py @@ -25,7 +25,7 @@ class SBDataAPICase(TestBase): def test_byte_order_and_address_byte_size(self): """Test the SBData::SetData() to ensure the byte order and address byte size are obeyed""" - addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88' + addr_data = b'\x11\x22\x33\x44\x55\x66\x77\x88' error = lldb.SBError() data = lldb.SBData() data.SetData(error, addr_data, lldb.eByteOrderBig, 4) @@ -45,7 +45,7 @@ class SBDataAPICase(TestBase): def test_with_run_command(self): """Test the SBData APIs.""" 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/python_api/sblaunchinfo/TestSBLaunchInfo.py b/packages/Python/lldbsuite/test/python_api/sblaunchinfo/TestSBLaunchInfo.py new file mode 100644 index 0000000000000..ee4a102fc145e --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/sblaunchinfo/TestSBLaunchInfo.py @@ -0,0 +1,31 @@ +""" +Test SBLaunchInfo +""" + +from __future__ import print_function + + +from lldbsuite.test.lldbtest import * + + +def lookup(info, key): + for i in range(info.GetNumEnvironmentEntries()): + KeyEqValue = info.GetEnvironmentEntryAtIndex(i) + Key, Value = KeyEqValue.split("=") + if Key == key: + return Value + return "" + +class TestSBLaunchInfo(TestBase): + + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + def test_environment_getset(self): + info = lldb.SBLaunchInfo(None) + info.SetEnvironmentEntries(["FOO=BAR"], False) + self.assertEquals(1, info.GetNumEnvironmentEntries()) + info.SetEnvironmentEntries(["BAR=BAZ"], True) + self.assertEquals(2, info.GetNumEnvironmentEntries()) + self.assertEquals("BAR", lookup(info, "FOO")) + self.assertEquals("BAZ", lookup(info, "BAR")) diff --git a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py index eab3cbb30ddc9..3d0c72146d5cc 100644 --- a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py +++ b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py @@ -22,7 +22,7 @@ class SBValuePersistTestCase(TestBase): """Test SBValue::Persist""" self.build() self.setTearDownCleanup() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_source_regexp(self, "break here") diff --git a/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py b/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py index 5893dfb8f7f2f..088a66c71c5ca 100644 --- a/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py +++ b/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py @@ -19,7 +19,7 @@ class SectionAPITestCase(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/python_api/signals/TestSignalsAPI.py b/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py index 76b1d603f55ff..482f4a829b204 100644 --- a/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py +++ b/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py @@ -22,7 +22,7 @@ class SignalsAPITestCase(TestBase): def test_ignore_signal(self): """Test Python SBUnixSignals.Suppress/Stop/Notify() API.""" 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/python_api/symbol-context/TestSymbolContext.py b/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py index 85ecb69a91fca..2b783fb90e56a 100644 --- a/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py @@ -31,7 +31,7 @@ class SymbolContextAPITestCase(TestBase): def test(self): """Exercise SBSymbolContext API extensively.""" 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) @@ -66,17 +66,14 @@ class SymbolContextAPITestCase(TestBase): module = context.GetModule() desc = lldbutil.get_description(module) self.expect(desc, "The module should match", exe=False, - substrs=[os.path.join(self.mydir, 'a.out')]) + substrs=[self.getBuildArtifact("a.out")]) compileUnit = context.GetCompileUnit() self.expect( str(compileUnit), "The compile unit should match", exe=False, - substrs=[ - os.path.join( - self.mydir, - 'main.c')]) + substrs=[self.getSourcePath('main.c')]) function = context.GetFunction() self.assertTrue(function) @@ -92,8 +89,7 @@ class SymbolContextAPITestCase(TestBase): lineEntry.GetFileSpec().GetDirectory(), "The line entry should have the correct directory", exe=False, - substrs=[ - self.mydir]) + substrs=[self.mydir]) self.expect( lineEntry.GetFileSpec().GetFilename(), "The line entry should have the correct filename", diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py index 429e9c4da34ad..8640abe5625bc 100644 --- a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py @@ -21,8 +21,7 @@ class SymbolContextTwoFilesTestCase(TestBase): def test_lookup_by_address(self): """Test lookup by address in a module with multiple compilation units""" 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) @@ -44,8 +43,7 @@ class SymbolContextTwoFilesTestCase(TestBase): """This test verifies that we correctly handle the case when multiple compile unit contains DW_AT_ranges and DW_AT_ranges_base attributes.""" 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/python_api/target/TestTargetAPI.py b/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py index adbdc524949d9..224dca77daa3e 100644 --- a/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py +++ b/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py @@ -46,6 +46,14 @@ class TargetAPITestCase(TestBase): self.find_global_variables('b.out') @add_test_categories(['pyapi']) + def test_find_compile_units(self): + """Exercise SBTarget.FindCompileUnits() API.""" + d = {'EXE': 'b.out'} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.find_compile_units(self.getBuildArtifact('b.out')) + + @add_test_categories(['pyapi']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_find_functions(self): """Exercise SBTarget.FindFunctions() API.""" @@ -61,12 +69,7 @@ class TargetAPITestCase(TestBase): self.get_description() @add_test_categories(['pyapi']) - def test_launch_new_process_and_redirect_stdout(self): - """Exercise SBTarget.Launch() API.""" - self.build() - self.launch_new_process_and_redirect_stdout() - - @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test_resolve_symbol_context_with_address(self): """Exercise SBTarget.ResolveSymbolContextForAddress() API.""" self.build() @@ -149,7 +152,7 @@ class TargetAPITestCase(TestBase): self.assertEqual(len(content), 1) def create_simple_target(self, fn): - exe = os.path.join(os.getcwd(), fn) + exe = self.getBuildArtifact(fn) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) return target @@ -175,7 +178,7 @@ class TargetAPITestCase(TestBase): def find_global_variables(self, exe_name): """Exercise SBTaget.FindGlobalVariables() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -216,8 +219,7 @@ class TargetAPITestCase(TestBase): # While we are at it, let's also exercise the similar # SBModule.FindGlobalVariables() API. for m in target.module_iter(): - if os.path.normpath(m.GetFileSpec().GetDirectory()) == os.getcwd( - ) and m.GetFileSpec().GetFilename() == exe_name: + if os.path.normpath(m.GetFileSpec().GetDirectory()) == self.getBuildDir() and m.GetFileSpec().GetFilename() == exe_name: value_list = m.FindGlobalVariables( target, 'my_global_var_of_char_type', 3) self.assertTrue(value_list.GetSize() == 1) @@ -225,9 +227,23 @@ class TargetAPITestCase(TestBase): value_list.GetValueAtIndex(0).GetValue() == "'X'") break + def find_compile_units(self, exe): + """Exercise SBTarget.FindCompileUnits() API.""" + source_name = "main.c" + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + list = target.FindCompileUnits(lldb.SBFileSpec(source_name, False)) + # Executable has been built just from one source file 'main.c', + # so we may check only the first element of list. + self.assertTrue( + list[0].GetCompileUnit().GetFileSpec().GetFilename() == source_name) + def find_functions(self, exe_name): """Exercise SBTaget.FindFunctions() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -243,7 +259,7 @@ class TargetAPITestCase(TestBase): def get_description(self): """Exercise SBTaget.GetDescription() API.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -269,9 +285,12 @@ class TargetAPITestCase(TestBase): substrs=['a.out', 'Target', 'Module', 'Breakpoint']) @not_remote_testsuite_ready - def launch_new_process_and_redirect_stdout(self): + @add_test_categories(['pyapi']) + @no_debug_info_test + def test_launch_new_process_and_redirect_stdout(self): """Exercise SBTaget.Launch() API with redirected stdout.""" - exe = os.path.join(os.getcwd(), "a.out") + self.build() + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -286,9 +305,12 @@ class TargetAPITestCase(TestBase): # Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file. # The inferior should run to completion after "process.Continue()" # call. - local_path = "stdout.txt" + local_path = self.getBuildArtifact("stdout.txt") + if os.path.exists(local_path): + os.remove(local_path) + if lldb.remote_platform: - stdout_path = lldbutil.append_to_process_working_directory( + stdout_path = lldbutil.append_to_process_working_directory(self, "lldb-stdout-redirect.txt") else: stdout_path = local_path @@ -314,26 +336,19 @@ class TargetAPITestCase(TestBase): # The 'stdout.txt' file should now exist. self.assertTrue( - os.path.isfile("stdout.txt"), + os.path.isfile(local_path), "'stdout.txt' exists due to redirected stdout via SBTarget.Launch() API.") # Read the output file produced by running the program. - with open('stdout.txt', 'r') as f: + with open(local_path, 'r') as f: output = f.read() - # Let's delete the 'stdout.txt' file as a cleanup step. - try: - os.remove("stdout.txt") - pass - except OSError: - pass - self.expect(output, exe=False, substrs=["a(1)", "b(2)", "a(3)"]) def resolve_symbol_context_with_address(self): """Exercise SBTaget.ResolveSymbolContextForAddress() API.""" - 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/python_api/thread/TestThreadAPI.py b/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py index a1272cbcbce1f..11740b1cf4df5 100644 --- a/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py +++ b/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py @@ -51,6 +51,7 @@ class ThreadAPITestCase(TestBase): self.step_out_of_malloc_into_function_b(self.exe_name) @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr32343') def test_step_over_3_times(self): """Test Python SBThread.StepOver() API.""" # We build a different executable than the default build() does. @@ -78,7 +79,7 @@ class ThreadAPITestCase(TestBase): def get_process(self): """Test Python SBThread.GetProcess() API.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -105,7 +106,7 @@ class ThreadAPITestCase(TestBase): def get_stop_description(self): """Test Python SBThread.GetStopDescription() API.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -134,7 +135,7 @@ class ThreadAPITestCase(TestBase): def step_out_of_malloc_into_function_b(self, exe_name): """Test Python SBThread.StepOut() API to step out of a malloc call where the call site is at function b().""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -181,7 +182,7 @@ class ThreadAPITestCase(TestBase): def step_over_3_times(self, exe_name): """Test Python SBThread.StepOver() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -227,7 +228,7 @@ class ThreadAPITestCase(TestBase): def run_to_address(self, exe_name): """Test Python SBThread.RunToAddress() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py b/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py index 5ab742dac7c75..40128d3ce94e3 100644 --- a/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py +++ b/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py @@ -34,7 +34,7 @@ class TypeAndTypeListTestCase(TestBase): 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) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py index 632244e8b9e68..8a4af0cc2b946 100644 --- a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py +++ b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py @@ -33,7 +33,7 @@ class ValueAPITestCase(TestBase): 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) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -61,9 +61,23 @@ class ValueAPITestCase(TestBase): list = target.FindGlobalVariables('days_of_week', 1) days_of_week = list.GetValueAtIndex(0) self.assertTrue(days_of_week, VALID_VARIABLE) - self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE) + self.assertEqual(days_of_week.GetNumChildren(), 7, VALID_VARIABLE) self.DebugSBValue(days_of_week) + # Use this to test the "child" and "children" accessors: + children = days_of_week.children + self.assertEqual(len(children), 7, VALID_VARIABLE) + for i in range(0, len(children)): + day = days_of_week.child[i] + list_day = children[i] + self.assertNotEqual(day, None) + self.assertNotEqual(list_day, None) + self.assertEqual(day.GetSummary(), list_day.GetSummary(), VALID_VARIABLE) + + # Spot check the actual value: + first_day = days_of_week.child[1] + self.assertEqual(first_day.GetSummary(), '"Monday"', VALID_VARIABLE) + # Get global variable 'weekdays'. list = target.FindGlobalVariables('weekdays', 1) weekdays = list.GetValueAtIndex(0) diff --git a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py index 64c7fde226704..18d39d9675c86 100644 --- a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py +++ b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py @@ -38,7 +38,7 @@ class ChangeValueAPITestCase(TestBase): 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) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py b/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py index c4b1e282590c4..6fa72837484ee 100644 --- a/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py +++ b/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py @@ -15,7 +15,7 @@ class ValueAPIEmptyClassTestCase(TestBase): @add_test_categories(['pyapi']) def test(self): self.build() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") line = line_number('main.cpp', '// Break at this line') # Create a target by the debugger. diff --git a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py index d5f53d712e7da..1b009521d253a 100644 --- a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py +++ b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py @@ -36,7 +36,7 @@ class ValueAsLinkedListTestCase(TestBase): 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) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py b/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py index f4789877f34ea..a83fd6e123904 100644 --- a/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py +++ b/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py @@ -20,16 +20,16 @@ class HelloWorldTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Get the full path to our executable to be attached/debugged. - self.exe = os.path.join(os.getcwd(), self.testMethodName) - self.d = {'EXE': self.testMethodName} @add_test_categories(['pyapi']) def test_with_process_launch_api(self): """Test SBValue::GetValueDidChange""" - self.build(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - target = self.dbg.CreateTarget(self.exe) + # Get the full path to our executable to be attached/debugged. + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateBySourceRegex( "break here", lldb.SBFileSpec("main.c")) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py index cef8a0c4e81f9..0236d4b2c6d8e 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py @@ -36,7 +36,7 @@ class SetWatchpointAPITestCase(TestBase): def test_watch_val(self): """Exercise SBValue.Watch() API to set a watchpoint.""" 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/python_api/watchpoint/TestWatchpointIgnoreCount.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py index 0d1ef809d2919..603b7a805008c 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -36,7 +36,7 @@ class WatchpointIgnoreCountTestCase(TestBase): def test_set_watch_ignore_count(self): """Test SBWatchpoint.SetIgnoreCount() API.""" 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/python_api/watchpoint/TestWatchpointIter.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py index ca5fca3acf9a0..b9fc7ceb1af62 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py @@ -39,7 +39,7 @@ class WatchpointIteratorTestCase(TestBase): def test_watch_iter(self): """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" 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/python_api/watchpoint/condition/TestWatchpointConditionAPI.py b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py index 4b0216d7a6025..bb32869543c71 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py @@ -42,7 +42,7 @@ class WatchpointConditionAPITestCase(TestBase): """Test watchpoint condition API.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py index e6bc9c0a76544..fdc8ac053d763 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py @@ -37,7 +37,7 @@ class SetWatchlocationAPITestCase(TestBase): def test_watch_location(self): """Exercise SBValue.WatchPointee() API to set a watchpoint.""" 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/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py index 80595060b42d0..d5862d274cebb 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py @@ -36,7 +36,7 @@ class TargetWatchAddressAPITestCase(TestBase): def test_watch_address(self): """Exercise SBTarget.WatchAddress() API to set a watchpoint.""" 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) @@ -112,7 +112,7 @@ class TargetWatchAddressAPITestCase(TestBase): def test_watch_address_with_invalid_watch_size(self): """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" 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/quit/TestQuit.py b/packages/Python/lldbsuite/test/quit/TestQuit.py new file mode 100644 index 0000000000000..28c05b833d640 --- /dev/null +++ b/packages/Python/lldbsuite/test/quit/TestQuit.py @@ -0,0 +1,32 @@ +""" +Test lldb's quit command. +""" + +from __future__ import print_function + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class QuitCommandTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @no_debug_info_test + def test_quit_exit_code_disallow(self): + self.ci.AllowExitCodeOnQuit(False) + self.expect( + "quit 20", + substrs=[ + "error: The current driver doesn't allow custom exit codes for the quit command"], + error=True) + self.assertFalse(self.ci.HasCustomQuitExitCode()) + + @no_debug_info_test + def test_quit_exit_code_allow(self): + self.ci.AllowExitCodeOnQuit(True) + self.runCmd("quit 10", check=False) + self.assertTrue(self.ci.HasCustomQuitExitCode()) + self.assertEqual(self.ci.GetQuitStatus(), 10) diff --git a/packages/Python/lldbsuite/test/settings/TestSettings.py b/packages/Python/lldbsuite/test/settings/TestSettings.py index 5e1cd44c01b9c..6b8ac7c3d5d51 100644 --- a/packages/Python/lldbsuite/test/settings/TestSettings.py +++ b/packages/Python/lldbsuite/test/settings/TestSettings.py @@ -17,16 +17,8 @@ from lldbsuite.test import lldbutil class SettingsCommandTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True - @classmethod - def classCleanup(cls): - """Cleanup the test byproducts.""" - cls.RemoveTempFile("output1.txt") - cls.RemoveTempFile("output2.txt") - cls.RemoveTempFile("stderr.txt") - cls.RemoveTempFile("stdout.txt") - - @no_debug_info_test def test_apropos_should_also_search_settings_description(self): """Test that 'apropos' command should also search descriptions for the settings variables.""" @@ -35,7 +27,6 @@ class SettingsCommandTestCase(TestBase): "environment variables", "executable's environment"]) - @no_debug_info_test def test_append_target_env_vars(self): """Test that 'append target.run-args' works.""" # Append the env-vars. @@ -48,7 +39,6 @@ class SettingsCommandTestCase(TestBase): self.expect('settings show target.env-vars', substrs=['MY_ENV_VAR=YES']) - @no_debug_info_test def test_insert_before_and_after_target_run_args(self): """Test that 'insert-before/after target.run-args' works.""" # Set the run-args first. @@ -70,7 +60,6 @@ class SettingsCommandTestCase(TestBase): '[3]: "b"', '[4]: "c"']) - @no_debug_info_test def test_replace_target_run_args(self): """Test that 'replace target.run-args' works.""" # Set the run-args and then replace the index-0 element. @@ -88,7 +77,6 @@ class SettingsCommandTestCase(TestBase): '[1]: "b"', '[2]: "c"']) - @no_debug_info_test def test_set_prompt(self): """Test that 'set prompt' actually changes the prompt.""" @@ -106,7 +94,6 @@ class SettingsCommandTestCase(TestBase): # Use '-r' option to reset to the original default prompt. self.runCmd("settings clear prompt") - @no_debug_info_test def test_set_term_width(self): """Test that 'set term-width' actually changes the term-width.""" @@ -125,7 +112,7 @@ class SettingsCommandTestCase(TestBase): """Test that 'set frame-format' with a backtick char in the format string works as well as fullpath.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) def cleanup(): @@ -153,15 +140,16 @@ class SettingsCommandTestCase(TestBase): substrs=[format_string]) self.runCmd("breakpoint set -n main") - self.runCmd("run") + self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()), + RUN_SUCCEEDED) self.expect("thread backtrace", - substrs=["`main", os.getcwd()]) + substrs=["`main", self.getSourceDir()]) def test_set_auto_confirm(self): """Test that after 'set auto-confirm true', manual confirmation should not kick in.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) self.runCmd("settings set auto-confirm true") @@ -186,7 +174,7 @@ class SettingsCommandTestCase(TestBase): """Test that user options for the disassembler take effect.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # AT&T syntax @@ -219,7 +207,7 @@ class SettingsCommandTestCase(TestBase): def test_run_args_and_env_vars(self): """Test that run-args and env-vars are passed to the launched process.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set the run-args and the env-vars. @@ -231,13 +219,11 @@ class SettingsCommandTestCase(TestBase): self.addTearDownHook( lambda: self.runCmd("settings clear target.env-vars")) - self.runCmd("run", RUN_SUCCEEDED) + self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()), + RUN_SUCCEEDED) # Read the output file produced by running the program. - if lldb.remote_platform: - self.runCmd('platform get-file "output2.txt" "output2.txt"') - with open('output2.txt', 'r') as f: - output = f.read() + output = lldbutil.read_file_from_process_wd(self, "output2.txt") self.expect( output, @@ -253,7 +239,7 @@ class SettingsCommandTestCase(TestBase): """Test that the host env vars are passed to the launched process.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # By default, inherit-env is 'true'. @@ -272,13 +258,11 @@ class SettingsCommandTestCase(TestBase): os.environ.pop("MY_HOST_ENV_VAR2") self.addTearDownHook(unset_env_variables) - self.runCmd("run", RUN_SUCCEEDED) + self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()), + RUN_SUCCEEDED) # Read the output file produced by running the program. - if lldb.remote_platform: - self.runCmd('platform get-file "output1.txt" "output1.txt"') - with open('output1.txt', 'r') as f: - output = f.read() + output = lldbutil.read_file_from_process_wd(self, "output1.txt") self.expect( output, @@ -292,12 +276,14 @@ class SettingsCommandTestCase(TestBase): """Test that setting target.error/output-path for the launched process works.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set the error-path and output-path and verify both are set. - self.runCmd("settings set target.error-path stderr.txt") - self.runCmd("settings set target.output-path stdout.txt") + self.runCmd("settings set target.error-path '{0}'".format( + lldbutil.append_to_process_working_directory(self, "stderr.txt"))) + self.runCmd("settings set target.output-path '{0}".format( + lldbutil.append_to_process_working_directory(self, "stdout.txt"))) # And add hooks to restore the original settings during tearDown(). self.addTearDownHook( lambda: self.runCmd("settings clear target.output-path")) @@ -306,44 +292,26 @@ class SettingsCommandTestCase(TestBase): self.expect("settings show target.error-path", SETTING_MSG("target.error-path"), - substrs=['target.error-path (file) = "stderr.txt"']) + substrs=['target.error-path (file)', 'stderr.txt"']) self.expect("settings show target.output-path", SETTING_MSG("target.output-path"), - substrs=['target.output-path (file) = "stdout.txt"']) - - self.runCmd("run", RUN_SUCCEEDED) - - if lldb.remote_platform: - self.runCmd('platform get-file "stderr.txt" "stderr.txt"') - self.runCmd('platform get-file "stdout.txt" "stdout.txt"') + substrs=['target.output-path (file)', 'stdout.txt"']) - # The 'stderr.txt' file should now exist. - self.assertTrue(os.path.isfile("stderr.txt"), - "'stderr.txt' exists due to target.error-path.") - - # Read the output file produced by running the program. - with open('stderr.txt', 'r') as f: - output = f.read() + self.runCmd("process launch --working-dir '{0}'".format(self.get_process_working_directory()), + RUN_SUCCEEDED) + output = lldbutil.read_file_from_process_wd(self, "stderr.txt") message = "This message should go to standard error." if lldbplatformutil.hasChattyStderr(self): self.expect(output, exe=False, substrs=[message]) else: self.expect(output, exe=False, startstr=message) - # The 'stdout.txt' file should now exist. - self.assertTrue(os.path.isfile("stdout.txt"), - "'stdout.txt' exists due to target.output-path.") - - # Read the output file produced by running the program. - with open('stdout.txt', 'r') as f: - output = f.read() - + output = lldbutil.read_file_from_process_wd(self, "stdout.txt") self.expect(output, exe=False, startstr="This message should go to standard out.") - @no_debug_info_test def test_print_dictionary_setting(self): self.runCmd("settings clear target.env-vars") self.runCmd("settings set target.env-vars [\"MY_VAR\"]=some-value") @@ -351,7 +319,6 @@ class SettingsCommandTestCase(TestBase): substrs=["MY_VAR=some-value"]) self.runCmd("settings clear target.env-vars") - @no_debug_info_test def test_print_array_setting(self): self.runCmd("settings clear target.run-args") self.runCmd("settings set target.run-args gobbledy-gook") @@ -359,7 +326,6 @@ class SettingsCommandTestCase(TestBase): substrs=['[0]: "gobbledy-gook"']) self.runCmd("settings clear target.run-args") - @no_debug_info_test def test_settings_with_quotes(self): self.runCmd("settings clear target.run-args") self.runCmd("settings set target.run-args a b c") @@ -392,7 +358,6 @@ class SettingsCommandTestCase(TestBase): 'thread-format (format-string) = "abc def "') self.runCmd('settings clear thread-format') - @no_debug_info_test def test_settings_with_trailing_whitespace(self): # boolean @@ -421,8 +386,8 @@ class SettingsCommandTestCase(TestBase): startstr='target.arg0 (string) = "cde"') self.runCmd("settings clear target.arg0", check=False) # file - path1 = os.path.join(os.getcwd(), "path1.txt") - path2 = os.path.join(os.getcwd(), "path2.txt") + path1 = self.getBuildArtifact("path1.txt") + path2 = self.getBuildArtifact("path2.txt") self.runCmd( "settings set target.output-path %s" % path1) # Set to known value @@ -517,7 +482,6 @@ class SettingsCommandTestCase(TestBase): substrs=['disassembly-format (format-string) = "foo "']) self.runCmd("settings clear disassembly-format", check=False) - @no_debug_info_test def test_all_settings_exist(self): self.expect("settings show", substrs=["auto-confirm", @@ -560,3 +524,41 @@ class SettingsCommandTestCase(TestBase): "target.process.extra-startup-command", "target.process.thread.step-avoid-regexp", "target.process.thread.trace-thread"]) + + # settings under an ".experimental" domain should have two properties: + # 1. If the name does not exist with "experimental" in the name path, + # the name lookup should try to find it without "experimental". So + # a previously-experimental setting that has been promoted to a + # "real" setting will still be set by the original name. + # 2. Changing a setting with .experimental., name, where the setting + # does not exist either with ".experimental." or without, should + # not generate an error. So if an experimental setting is removed, + # people who may have that in their ~/.lldbinit files should not see + # any errors. + def test_experimental_settings(self): + cmdinterp = self.dbg.GetCommandInterpreter() + result = lldb.SBCommandReturnObject() + + # Set target.arg0 to a known value, check that we can retrieve it via + # the actual name and via .experimental. + self.expect('settings set target.arg0 first-value') + self.expect('settings show target.arg0', substrs=['first-value']) + self.expect('settings show target.experimental.arg0', substrs=['first-value'], error=False) + + # Set target.arg0 to a new value via a target.experimental.arg0 name, + # verify that we can read it back via both .experimental., and not. + self.expect('settings set target.experimental.arg0 second-value', error=False) + self.expect('settings show target.arg0', substrs=['second-value']) + self.expect('settings show target.experimental.arg0', substrs=['second-value'], error=False) + + # showing & setting an undefined .experimental. setting should generate no errors. + self.expect('settings show target.experimental.setting-which-does-not-exist', patterns=['^\s$'], error=False) + self.expect('settings set target.experimental.setting-which-does-not-exist true', error=False) + + # A domain component before .experimental. which does not exist should give an error + # But the code does not yet do that. + # self.expect('settings set target.setting-which-does-not-exist.experimental.arg0 true', error=True) + + # finally, confirm that trying to set a setting that does not exist still fails. + # (SHOWING a setting that does not exist does not currently yield an error.) + self.expect('settings set target.setting-which-does-not-exist true', error=True) diff --git a/packages/Python/lldbsuite/test/settings/quoting/TestQuoting.py b/packages/Python/lldbsuite/test/settings/quoting/TestQuoting.py index 02110d1684f8f..9265b47962b1b 100644 --- a/packages/Python/lldbsuite/test/settings/quoting/TestQuoting.py +++ b/packages/Python/lldbsuite/test/settings/quoting/TestQuoting.py @@ -79,19 +79,25 @@ class SettingsCommandTestCase(TestBase): to stdout. Compare the stdout with args_out.""" self.buildDefault() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - self.runCmd("process launch -- " + args_in) + local_outfile = self.getBuildArtifact("output.txt") + if lldb.remote_platform: + remote_outfile = "output.txt" # Relative to platform's PWD + else: + remote_outfile = local_outfile + + self.runCmd("process launch -- %s %s" %(remote_outfile, args_in)) if lldb.remote_platform: - src_file_spec = lldb.SBFileSpec('output.txt', False) - dst_file_spec = lldb.SBFileSpec('output.txt', True) + src_file_spec = lldb.SBFileSpec(remote_outfile, False) + dst_file_spec = lldb.SBFileSpec(local_outfile, True) lldb.remote_platform.Get(src_file_spec, dst_file_spec) - with open('output.txt', 'r') as f: + with open(local_outfile, 'r') as f: output = f.read() - self.RemoveTempFile("output.txt") + self.RemoveTempFile(local_outfile) self.assertEqual(output, args_out) diff --git a/packages/Python/lldbsuite/test/settings/quoting/main.c b/packages/Python/lldbsuite/test/settings/quoting/main.c index 5e3e34f84a672..2ebaa142bc5ca 100644 --- a/packages/Python/lldbsuite/test/settings/quoting/main.c +++ b/packages/Python/lldbsuite/test/settings/quoting/main.c @@ -8,11 +8,11 @@ main(int argc, char const *argv[]) { int i; - FILE *output = fopen ("output.txt", "w"); + FILE *output = fopen (argv[1], "w"); if (output == NULL) exit (1); - for (i = 1; i < argc; ++i) + for (i = 2; i < argc; ++i) fwrite(argv[i], strlen(argv[i])+1, 1, output); fclose (output); diff --git a/packages/Python/lldbsuite/test/source-manager/Makefile b/packages/Python/lldbsuite/test/source-manager/Makefile index d6cd0db0506f7..5d19a27a2df2e 100644 --- a/packages/Python/lldbsuite/test/source-manager/Makefile +++ b/packages/Python/lldbsuite/test/source-manager/Makefile @@ -1,5 +1,13 @@ LEVEL = ../make -C_SOURCES := main.c +C_SOURCES := main-copy.c include $(LEVEL)/Makefile.rules + +# Copy file into the build folder to enable the test to modify it. +main-copy.c: main.c + cp -f $< $@ + + +clean:: + $(RM) main-copy.c diff --git a/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py b/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py index 31fe5437d1d2e..0df4f8b2d2a81 100644 --- a/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py +++ b/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py @@ -27,20 +27,19 @@ class SourceManagerTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - SOURCE_FILE = 'main.c' - NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside main(). - self.line = line_number(self.SOURCE_FILE, '// Set break point at this line.') + self.file = self.getBuildArtifact("main-copy.c") + self.line = line_number("main.c", '// Set break point at this line.') def get_expected_stop_column_number(self): """Return the 1-based column number of the first non-whitespace character in the breakpoint source line.""" - stop_line = get_line(self.SOURCE_FILE, self.line) + stop_line = get_line(self.file, self.line) # The number of spaces that must be skipped to get to the first non- # whitespace character --- where we expect the debugger breakpoint # column to be --- is equal to the number of characters that get @@ -50,7 +49,7 @@ class SourceManagerTestCase(TestBase): def do_display_source_python_api(self, use_color, column_marker_regex): 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) @@ -71,8 +70,7 @@ class SourceManagerTestCase(TestBase): # and styles such as underline. self.dbg.SetUseColor(use_color) - # Create the filespec for 'main.c'. - filespec = lldb.SBFileSpec('main.c', False) + filespec = lldb.SBFileSpec(self.file, False) source_mgr = self.dbg.GetSourceManager() # Use a string stream as the destination. stream = lldb.SBStream() @@ -116,16 +114,14 @@ class SourceManagerTestCase(TestBase): def test_move_and_then_display_source(self): """Test that target.source-map settings work by moving main.c to hidden/main.c.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Move main.c to hidden/main.c. - main_c = "main.c" - main_c_hidden = os.path.join("hidden", main_c) - os.rename(main_c, main_c_hidden) - - # Restore main.c after the test. - self.addTearDownHook(lambda: os.rename(main_c_hidden, main_c)) + hidden = self.getBuildArtifact("hidden") + lldbutil.mkdir_p(hidden) + main_c_hidden = os.path.join(hidden, "main-copy.c") + os.rename(self.file, main_c_hidden) if self.TraceOn(): system([["ls"]]) @@ -140,10 +136,10 @@ class SourceManagerTestCase(TestBase): # Set target.source-map settings. self.runCmd("settings set target.source-map %s %s" % - (os.getcwd(), os.path.join(os.getcwd(), "hidden"))) + (self.getBuildDir(), hidden)) # And verify that the settings work. self.expect("settings show target.source-map", - substrs=[os.getcwd(), os.path.join(os.getcwd(), "hidden")]) + substrs=[self.getBuildDir(), hidden]) # Display main() and verify that the source mapping has been kicked in. self.expect("source list -n main", SOURCE_DISPLAYED_CORRECTLY, @@ -152,23 +148,23 @@ class SourceManagerTestCase(TestBase): def test_modify_source_file_while_debugging(self): """Modify a source file while debugging the executable.""" 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( - self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + self, "main-copy.c", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs=['stopped', - 'main.c:%d' % self.line, + 'main-copy.c:%d' % self.line, 'stop reason = breakpoint']) # Display some source code. self.expect( - "source list -f main.c -l %d" % + "source list -f main-copy.c -l %d" % self.line, SOURCE_DISPLAYED_CORRECTLY, substrs=['Hello world']) @@ -189,7 +185,7 @@ class SourceManagerTestCase(TestBase): self.assertTrue(int(m.group(1)) > 0) # Read the main.c file content. - with io.open('main.c', 'r', newline='\n') as f: + with io.open(self.file, 'r', newline='\n') as f: original_content = f.read() if self.TraceOn(): print("original content:", original_content) @@ -197,48 +193,32 @@ class SourceManagerTestCase(TestBase): # Modify the in-memory copy of the original source code. new_content = original_content.replace('Hello world', 'Hello lldb', 1) - # This is the function to restore the original content. - def restore_file(): - #print("os.path.getmtime() before restore:", os.path.getmtime('main.c')) - time.sleep(1) - with io.open('main.c', 'w', newline='\n') as f: - f.write(original_content) - if self.TraceOn(): - with open('main.c', 'r') as f: - print("content restored to:", f.read()) - # Touch the file just to be sure. - os.utime('main.c', None) - if self.TraceOn(): - print( - "os.path.getmtime() after restore:", - os.path.getmtime('main.c')) - # Modify the source code file. - with io.open('main.c', 'w', newline='\n') as f: + with io.open(self.file, 'w', newline='\n') as f: time.sleep(1) f.write(new_content) if self.TraceOn(): print("new content:", new_content) print( "os.path.getmtime() after writing new content:", - os.path.getmtime('main.c')) - # Add teardown hook to restore the file to the original content. - self.addTearDownHook(restore_file) + os.path.getmtime(self.file)) # Display the source code again. We should see the updated line. self.expect( - "source list -f main.c -l %d" % + "source list -f main-copy.c -l %d" % self.line, SOURCE_DISPLAYED_CORRECTLY, substrs=['Hello lldb']) def test_set_breakpoint_with_absolute_path(self): self.build() + hidden = self.getBuildArtifact("hidden") + lldbutil.mkdir_p(hidden) self.runCmd("settings set target.source-map %s %s" % - (os.getcwd(), os.path.join(os.getcwd(), "hidden"))) + (self.getBuildDir(), hidden)) - exe = os.path.join(os.getcwd(), "a.out") - main = os.path.join(os.getcwd(), "hidden", "main.c") + exe = self.getBuildArtifact("a.out") + main = os.path.join(self.getBuildDir(), "hidden", "main-copy.c") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -249,5 +229,5 @@ class SourceManagerTestCase(TestBase): # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs=['stopped', - 'main.c:%d' % self.line, + 'main-copy.c:%d' % self.line, 'stop reason = breakpoint']) diff --git a/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py b/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py index e442509c471ec..e34fc3416d7e7 100644 --- a/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py +++ b/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py @@ -7,6 +7,7 @@ from __future__ import print_function import os import lldb +import six from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil @@ -58,13 +59,10 @@ class TestSTTYBeforeAndAfter(TestBase): child.expect(expect_prompt) # Turn on loggings for input/output to/from the child. - with open('child_send1.txt', 'w') as f_send1: - with open('child_read1.txt', 'w') as f_read1: - child.logfile_send = f_send1 - child.logfile_read = f_read1 - - child.sendline('stty -a') - child.expect(expect_prompt) + child.logfile_send = child_send1 = six.StringIO() + child.logfile_read = child_read1 = six.StringIO() + child.sendline('stty -a') + child.expect(expect_prompt) # Now that the stage1 logging is done, restore logfile to None to # stop further logging. @@ -79,43 +77,30 @@ class TestSTTYBeforeAndAfter(TestBase): child.sendline('quit') child.expect(expect_prompt) - with open('child_send2.txt', 'w') as f_send2: - with open('child_read2.txt', 'w') as f_read2: - child.logfile_send = f_send2 - child.logfile_read = f_read2 - - child.sendline('stty -a') - child.expect(expect_prompt) + child.logfile_send = child_send2 = six.StringIO() + child.logfile_read = child_read2 = six.StringIO() + child.sendline('stty -a') + child.expect(expect_prompt) - child.sendline('exit') + child.sendline('exit') # Now that the stage2 logging is done, restore logfile to None to # stop further logging. child.logfile_send = None child.logfile_read = None - with open('child_send1.txt', 'r') as fs: - if self.TraceOn(): - print("\n\nContents of child_send1.txt:") - print(fs.read()) - with open('child_read1.txt', 'r') as fr: - from_child1 = fr.read() - if self.TraceOn(): - print("\n\nContents of child_read1.txt:") - print(from_child1) - - with open('child_send2.txt', 'r') as fs: - if self.TraceOn(): - print("\n\nContents of child_send2.txt:") - print(fs.read()) - with open('child_read2.txt', 'r') as fr: - from_child2 = fr.read() - if self.TraceOn(): - print("\n\nContents of child_read2.txt:") - print(from_child2) - - stty_output1_lines = from_child1.splitlines() - stty_output2_lines = from_child2.splitlines() + if self.TraceOn(): + print("\n\nContents of child_send1:") + print(child_send1.getvalue()) + print("\n\nContents of child_read1:") + print(child_read1.getvalue()) + print("\n\nContents of child_send2:") + print(child_send2.getvalue()) + print("\n\nContents of child_read2:") + print(child_read2.getvalue()) + + stty_output1_lines = child_read1.getvalue().splitlines() + stty_output2_lines = child_read2.getvalue().splitlines() zipped = list(zip(stty_output1_lines, stty_output2_lines)) for tuple in zipped: if self.TraceOn(): diff --git a/packages/Python/lldbsuite/test/test_categories.py b/packages/Python/lldbsuite/test/test_categories.py index 46e3f3409dfce..8a9fd74211187 100644 --- a/packages/Python/lldbsuite/test/test_categories.py +++ b/packages/Python/lldbsuite/test/test_categories.py @@ -26,6 +26,7 @@ all_categories = { 'gmodules': 'Tests that can be run with -gmodules debug information', 'expression': 'Tests related to the expression parser', 'libc++': 'Test for libc++ data formatters', + 'libstdcxx': 'Test for libstdcxx data formatters', 'objc': 'Tests related to the Objective-C programming language support', 'pyapi': 'Tests related to the Python API', 'basic_process': 'Basic process execution sniff tests.', @@ -58,7 +59,7 @@ def is_supported_on_platform(category, platform, compiler_path): return platform in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"] elif category == "gmodules": # First, check to see if the platform can even support gmodules. - if platform not in ["linux", "freebsd", "darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]: + if platform not in ["freebsd", "darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]: return False return gmodules.is_compiler_clang_with_gmodules(compiler_path) return True diff --git a/packages/Python/lldbsuite/test/test_result.py b/packages/Python/lldbsuite/test/test_result.py index 3f5e556040b20..e5bac0cc4aab8 100644 --- a/packages/Python/lldbsuite/test/test_result.py +++ b/packages/Python/lldbsuite/test/test_result.py @@ -166,14 +166,7 @@ class LLDBTestResult(unittest2.TextTestResult): configuration.skip_tests, test.id()): self.hardMarkAsSkipped(test) - configuration.setCrashInfoHook( - "%s at %s" % - (str(test), inspect.getfile( - test.__class__))) self.counter += 1 - # if self.counter == 4: - # import crashinfo - # crashinfo.testCrashReporterDescription(None) test.test_number = self.counter if self.showAll: self.stream.write(self.fmt % self.counter) diff --git a/packages/Python/lldbsuite/test/test_runner/process_control.py b/packages/Python/lldbsuite/test/test_runner/process_control.py index 720f5112a4cd8..0b25874c24cf2 100644 --- a/packages/Python/lldbsuite/test/test_runner/process_control.py +++ b/packages/Python/lldbsuite/test/test_runner/process_control.py @@ -9,7 +9,7 @@ within the LLDB test suite. This module provides process-management support for the LLDB test -running infrasructure. +running infrastructure. """ # System imports diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py deleted file mode 100644 index 4f3562d42de83..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py +++ /dev/null @@ -1,94 +0,0 @@ -""" -Test that the lldb-mi driver exits properly. -""" - -from __future__ import print_function - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiExitTestCase(lldbmi_testcase.MiTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_exit(self): - """Test that '-gdb-exit' terminates local debug session and exits.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test -gdb-exit: try to exit and check that program is finished - self.runCmd("-gdb-exit") - self.expect("\^exit") - import pexpect - self.expect(pexpect.EOF) - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_quit(self): - """Test that 'quit' exits immediately.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test quit: try to exit and check that program is finished - self.runCmd("quit") - import pexpect - self.expect(pexpect.EOF) - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_q(self): - """Test that 'q' exits immediately.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test q: try to exit and check that program is finished - self.runCmd("q") - import pexpect - self.expect(pexpect.EOF) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py index 1eea89f4fff4e..b650eb89d812a 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py @@ -41,9 +41,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase): self.spawnLldbMi(args=None) # Test that -file-exec-and-symbols works for absolute path - import os - path = os.path.join(os.getcwd(), self.myexe) - self.runCmd("-file-exec-and-symbols \"%s\"" % path) + self.runCmd("-file-exec-and-symbols \"%s\"" % self.myexe) self.expect("\^done") # Run @@ -60,7 +58,8 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase): self.spawnLldbMi(args=None) # Test that -file-exec-and-symbols works for relative path - path = "./%s" % self.myexe + import os + path = os.path.relpath(self.myexe, self.getBuildDir()) self.runCmd("-file-exec-and-symbols %s" % path) self.expect("\^done") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py deleted file mode 100644 index 6bb7619e60b8d..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py +++ /dev/null @@ -1,260 +0,0 @@ -""" -Test lldb-mi -gdb-set and -gdb-show commands. -""" - -from __future__ import print_function - - -import unittest2 -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_set_target_async_default(self): - """Test that 'lldb-mi --interpreter' switches to async mode by default.""" - - self.spawnLldbMi(args=None) - - # Switch to sync mode - self.runCmd("-gdb-set target-async off") - self.expect("\^done") - self.runCmd("-gdb-show target-async") - self.expect("\^done,value=\"off\"") - - # Test that -gdb-set switches to async by default - self.runCmd("-gdb-set target-async") - self.expect("\^done") - self.runCmd("-gdb-show target-async") - self.expect("\^done,value=\"on\"") - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @expectedFlakeyLinux("llvm.org/pr26028") # Fails in ~1% of cases - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_set_target_async_on(self): - """Test that 'lldb-mi --interpreter' can execute commands in async mode.""" - - self.spawnLldbMi(args=None) - - # Switch to sync mode - self.runCmd("-gdb-set target-async off") - self.expect("\^done") - self.runCmd("-gdb-show target-async") - self.expect("\^done,value=\"off\"") - - # Test that -gdb-set can switch to async mode - self.runCmd("-gdb-set target-async on") - self.expect("\^done") - self.runCmd("-gdb-show target-async") - self.expect("\^done,value=\"on\"") - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Test that program is executed in async mode - self.runCmd("-exec-run") - self.expect("\*running") - self.expect("@\"argc=1") - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @expectedFailureAll( - oslist=["linux"], - bugnumber="Failing in ~11/600 dosep runs (build 3120-3122)") - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_set_target_async_off(self): - """Test that 'lldb-mi --interpreter' can execute commands in sync mode.""" - - self.spawnLldbMi(args=None) - - # Test that -gdb-set can switch to sync mode - self.runCmd("-gdb-set target-async off") - self.expect("\^done") - self.runCmd("-gdb-show target-async") - self.expect("\^done,value=\"off\"") - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Test that program is executed in async mode - self.runCmd("-exec-run") - unexpected = ["\*running"] # "\*running" is async notification - it = self.expect(unexpected + ["@\"argc=1\\\\r\\\\n"]) - if it < len(unexpected): - self.fail("unexpected found: %s" % unexpected[it]) - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_show_target_async(self): - """Test that 'lldb-mi --interpreter' in async mode by default.""" - - self.spawnLldbMi(args=None) - - # Test that default target-async value is "on" - self.runCmd("-gdb-show target-async") - self.expect("\^done,value=\"on\"") - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_show_language(self): - """Test that 'lldb-mi --interpreter' can get current language.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test that -gdb-show language gets current language - self.runCmd("-gdb-show language") - self.expect("\^done,value=\"c\+\+\"") - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @unittest2.expectedFailure("-gdb-set ignores unknown properties") - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_set_unknown(self): - """Test that 'lldb-mi --interpreter' fails when setting an unknown property.""" - - self.spawnLldbMi(args=None) - - # Test that -gdb-set fails if property is unknown - self.runCmd("-gdb-set unknown some_value") - self.expect("\^error") - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @unittest2.expectedFailure("-gdb-show ignores unknown properties") - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_show_unknown(self): - """Test that 'lldb-mi --interpreter' fails when showing an unknown property.""" - - self.spawnLldbMi(args=None) - - # Test that -gdb-show fails if property is unknown - self.runCmd("-gdb-show unknown") - self.expect("\^error") - - @expectedFailureAll( - oslist=["windows"], - bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_set_ouptut_radix(self): - """Test that 'lldb-mi --interpreter' works for -gdb-set output-radix.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to BP_printf - line = line_number('main.cpp', '// BP_printf') - self.runCmd("-break-insert main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Setup variable - self.runCmd("-var-create var_a * a") - self.expect( - "\^done,name=\"var_a\",numchild=\"0\",value=\"10\",type=\"int\",thread-id=\"1\",has_more=\"0\"") - - # Test default output - self.runCmd("-var-evaluate-expression var_a") - self.expect("\^done,value=\"10\"") - - # Test hex output - self.runCmd("-gdb-set output-radix 16") - self.expect("\^done") - self.runCmd("-var-evaluate-expression var_a") - self.expect("\^done,value=\"0xa\"") - - # Test octal output - self.runCmd("-gdb-set output-radix 8") - self.expect("\^done") - self.runCmd("-var-evaluate-expression var_a") - self.expect("\^done,value=\"012\"") - - # Test decimal output - self.runCmd("-gdb-set output-radix 10") - self.expect("\^done") - self.runCmd("-var-evaluate-expression var_a") - self.expect("\^done,value=\"10\"") - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - @expectedFailureAll( - bugnumber="llvm.org/pr31485: data-disassemble doesn't follow flavor settings") - def test_lldbmi_gdb_set_disassembly_flavor(self): - """Test that 'lldb-mi --interpreter' works for -gdb-set disassembly-flavor.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to BP_printf - line = line_number('main.cpp', '// BP_printf') - self.runCmd("-break-insert main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\".+addr=\"(0x[0-9a-f]+)\"") - - # Get starting and ending address from $pc - pc = int(self.child.match.group(1), base=16) - s_addr, e_addr = pc, pc + 1 - - # Test default output (att) - self.runCmd("-data-disassemble -s %d -e %d -- 0" % (s_addr, e_addr)) - self.expect("movl ") - - # Test intel style - self.runCmd("-gdb-set disassembly-flavor intel") - self.expect("\^done") - self.runCmd("-data-disassemble -s %d -e %d -- 0" % (s_addr, e_addr)) - self.expect("mov ") - - # Test AT&T style - self.runCmd("-gdb-set disassembly-flavor intel") - self.expect("\^done") - self.runCmd("-data-disassemble -s %d -e %d -- 0" % (s_addr, e_addr)) - self.expect("movl ") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py index a597ae1397ad7..92b7fdaca6627 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py @@ -18,6 +18,7 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_library_loaded(self): """Test that 'lldb-mi --interpreter' shows the =library-loaded notifications.""" @@ -29,13 +30,13 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase): # Test =library-loaded import os - path = os.path.join(os.getcwd(), self.myexe) + path = self.getBuildArtifact(self.myexe) symbols_path = os.path.join( path + ".dSYM", "Contents", "Resources", "DWARF", - self.myexe) + "a.out") def add_slashes(x): return x.replace( "\\", diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py index 16f71fe8130c0..c8bb89e07f6ba 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py @@ -200,7 +200,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("\*stopped,reason=\"breakpoint-hit\"") import os - path = os.path.join(os.getcwd(), "main.cpp") + path = os.path.join(self.getSourceDir(), "main.cpp") line = line_number('main.cpp', '// BP_return') self.runCmd("-break-insert %s:%d" % (path, line)) self.expect("\^done,bkpt={number=\"2\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py index 80ceadb6f2686..00c52dbe97aa9 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py @@ -18,29 +18,6 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @expectedFailureAll( - oslist=["linux"], - bugnumber="llvm.org/pr25000: lldb-mi does not receive broadcasted notification from Core/Process about process stopped") - def test_lldbmi_exec_run(self): - """Test that 'lldb-mi --interpreter' can stop at entry.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Test that program is stopped at entry - self.runCmd("-exec-run --start") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.*?thread-id=\"1\",stopped-threads=\"all\"") - # Test that lldb-mi is ready to execute next commands - self.expect(self.child_prompt, exactly=True) - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_exec_abort(self): """Test that 'lldb-mi --interpreter' works for -exec-abort.""" @@ -162,351 +139,3 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase): # Check argc to see if arg passed self.runCmd("-data-evaluate-expression argc") self.expect("\^done,value=\"1\"") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - def test_lldbmi_exec_next(self): - """Test that 'lldb-mi --interpreter' works for stepping.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Warning: the following is sensitive to the lines in the source - - # Test -exec-next - self.runCmd("-exec-next --thread 1 --frame 0") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"") - - # Test that --thread is optional - self.runCmd("-exec-next --frame 0") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"") - - # Test that --frame is optional - self.runCmd("-exec-next --thread 1") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"31\"") - - # Test that both --thread and --frame are optional - self.runCmd("-exec-next") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"32\"") - - # Test that an invalid --thread is handled - self.runCmd("-exec-next --thread 0") - self.expect("\^error,message=\"error: Thread index 0 is out of range") - self.runCmd("-exec-next --thread 10") - self.expect("\^error,message=\"error: Thread index 10 is out of range") - - # Test that an invalid --frame is handled - # FIXME: no error is returned - self.runCmd("-exec-next --frame 10") - #self.expect("\^error: Frame index 10 is out of range") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - def test_lldbmi_exec_next_instruction(self): - """Test that 'lldb-mi --interpreter' works for instruction stepping.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Warning: the following is sensitive to the lines in the - # source and optimizations - - # Test -exec-next-instruction - self.runCmd("-exec-next-instruction --thread 1 --frame 0") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"28\"") - - # Test that --thread is optional - self.runCmd("-exec-next-instruction --frame 0") - self.expect("\^running") - # Depending on compiler, it can stop at different line - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29)\"") - - # Test that --frame is optional - self.runCmd("-exec-next-instruction --thread 1") - self.expect("\^running") - # Depending on compiler, it can stop at different line - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29|30)\"") - - # Test that both --thread and --frame are optional - self.runCmd("-exec-next-instruction") - self.expect("\^running") - # Depending on compiler, it can stop at different line - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29|30|31)\"") - - # Test that an invalid --thread is handled - self.runCmd("-exec-next-instruction --thread 0") - self.expect("\^error,message=\"error: Thread index 0 is out of range") - self.runCmd("-exec-next-instruction --thread 10") - self.expect("\^error,message=\"error: Thread index 10 is out of range") - - # Test that an invalid --frame is handled - # FIXME: no error is returned - self.runCmd("-exec-next-instruction --frame 10") - #self.expect("\^error: Frame index 10 is out of range") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - def test_lldbmi_exec_step(self): - """Test that 'lldb-mi --interpreter' works for stepping into.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Warning: the following is sensitive to the lines in the source - - # Test that -exec-step steps into (or not) printf depending on debug info - # Note that message is different in Darwin and Linux: - # Darwin: "*stopped,reason=\"end-stepping-range\",frame={addr=\"0x[0-9a-f]+\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value="0x[0-9a-f]+\"}],file=\"main.cpp\",fullname=\".+main.cpp\",line=\"\d\"},thread-id=\"1\",stopped-threads=\"all\" - # Linux: - # "*stopped,reason=\"end-stepping-range\",frame={addr="0x[0-9a-f]+\",func=\"__printf\",args=[{name=\"format\",value=\"0x[0-9a-f]+\"}],file=\"printf.c\",fullname=\".+printf.c\",line="\d+"},thread-id=\"1\",stopped-threads=\"all\" - self.runCmd("-exec-step --thread 1 --frame 0") - self.expect("\^running") - it = self.expect(["\*stopped,reason=\"end-stepping-range\".+?func=\"main\"", - "\*stopped,reason=\"end-stepping-range\".+?func=\"(?!main).+?\""]) - # Exit from printf if needed - if it == 1: - self.runCmd("-exec-finish") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\"main\"") - - # Test that -exec-step steps into g_MyFunction and back out - # (and that --thread is optional) - self.runCmd("-exec-step --frame 0") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"") - # Use -exec-finish here to make sure that control reaches the caller. - # -exec-step can keep us in the g_MyFunction for gcc - self.runCmd("-exec-finish --frame 0") - self.expect("\^running") - it = self.expect(["\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"", - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\""]) - - if it == 1: - # Call to s_MyFunction may not follow immediately after g_MyFunction. - # There might be some instructions in between to restore caller-saved registers. - # We need to get past these instructions with a next to reach call to s_MyFunction. - self.runCmd("-exec-next --thread 1") - self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"") - - # Test that -exec-step steps into s_MyFunction - # (and that --frame is optional) - self.runCmd("-exec-step --thread 1") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"") - - # Test that -exec-step steps into g_MyFunction from inside - # s_MyFunction (and that both --thread and --frame are optional) - self.runCmd("-exec-step") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"") - - # Test that an invalid --thread is handled - self.runCmd("-exec-step --thread 0") - self.expect("\^error,message=\"error: Thread index 0 is out of range") - self.runCmd("-exec-step --thread 10") - self.expect("\^error,message=\"error: Thread index 10 is out of range") - - # Test that an invalid --frame is handled - # FIXME: no error is returned - self.runCmd("-exec-step --frame 10") - #self.expect("\^error: Frame index 10 is out of range") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - def test_lldbmi_exec_step_instruction(self): - """Test that 'lldb-mi --interpreter' works for instruction stepping into.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Warning: the following is sensitive to the lines in the - # source and optimizations - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test that -exec-next steps over printf - self.runCmd("-exec-next --thread 1 --frame 0") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"29\"") - - # Test that -exec-step-instruction steps over non branching - # instruction - self.runCmd("-exec-step-instruction --thread 1 --frame 0") - self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".+?main\.cpp\"") - - # Test that -exec-step-instruction steps into g_MyFunction - # instruction (and that --thread is optional) - - # In case of MIPS, there might be more than one instruction - # before actual call instruction (like load, move and call instructions). - # The -exec-step-instruction would step one assembly instruction. - # Thus we may not enter into g_MyFunction function. The -exec-step would definitely - # step into the function. - - if self.isMIPS(): - self.runCmd("-exec-step --frame 0") - else: - self.runCmd("-exec-step-instruction --frame 0") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"") - - # Test that -exec-step-instruction steps over non branching - # (and that --frame is optional) - self.runCmd("-exec-step-instruction --thread 1") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"") - - # Test that -exec-step-instruction steps into g_MyFunction - # (and that both --thread and --frame are optional) - self.runCmd("-exec-step-instruction") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"") - - # Test that an invalid --thread is handled - self.runCmd("-exec-step-instruction --thread 0") - self.expect("\^error,message=\"error: Thread index 0 is out of range") - self.runCmd("-exec-step-instruction --thread 10") - self.expect("\^error,message=\"error: Thread index 10 is out of range") - - # Test that an invalid --frame is handled - # FIXME: no error is returned - self.runCmd("-exec-step-instruction --frame 10") - #self.expect("\^error: Frame index 10 is out of range") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - def test_lldbmi_exec_finish(self): - """Test that 'lldb-mi --interpreter' works for -exec-finish.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Set BP at g_MyFunction and run to BP - self.runCmd("-break-insert -f g_MyFunction") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test that -exec-finish returns from g_MyFunction - self.runCmd("-exec-finish --thread 1 --frame 0") - self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"") - - # Run to BP inside s_MyFunction call - self.runCmd("-break-insert s_MyFunction") - self.expect("\^done,bkpt={number=\"2\"") - self.runCmd("-exec-continue") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test that -exec-finish hits BP at g_MyFunction call inside - # s_MyFunction (and that --thread is optional) - self.runCmd("-exec-finish --frame 0") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test that -exec-finish returns from g_MyFunction call inside - # s_MyFunction (and that --frame is optional) - self.runCmd("-exec-finish --thread 1") - self.expect("\^running") - self.expect( - "\*stopped,reason=\"end-stepping-range\".+?func=\".*?s_MyFunction.*?\"") - - # Test that -exec-finish returns from s_MyFunction - # (and that both --thread and --frame are optional) - self.runCmd("-exec-finish") - self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"") - - # Test that an invalid --thread is handled - self.runCmd("-exec-finish --thread 0") - self.expect("\^error,message=\"error: Thread index 0 is out of range") - self.runCmd("-exec-finish --thread 10") - self.expect("\^error,message=\"error: Thread index 10 is out of range") - - # Test that an invalid --frame is handled - # FIXME: no error is returned - #self.runCmd("-exec-finish --frame 10") - #self.expect("\^error: Frame index 10 is out of range") - - # Set BP at printf and run to BP - self.runCmd("-break-insert -f printf") - self.expect("\^done,bkpt={number=\"3\"") - self.runCmd("-exec-continue") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test that -exec-finish returns from printf - self.runCmd("-exec-finish --thread 1 --frame 0") - self.expect("\^running") - self.expect("\*stopped,reason=\"end-stepping-range\".+?func=\"main\"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py index f3a2772468625..5e6b3f20dde76 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py @@ -18,6 +18,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfDarwin # pexpect is known to be unreliable on Darwin @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_data_disassemble(self): """Test that 'lldb-mi --interpreter' works for -data-disassemble.""" @@ -79,8 +80,8 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): # To match the escaped characters in the ouptut, we must use four backslashes per matches backslash # See https://docs.python.org/2/howto/regex.html#the-backslash-plague - # The MIPS disassembler never prints stub name - if self.isMIPS(): + # The MIPS and PPC64le disassemblers never print stub name + if self.isMIPS() or self.isPPC64le(): self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}", "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?\"}"]) else: @@ -89,6 +90,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfDarwin # pexpect is known to be unreliable on Darwin @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_data_read_memory_bytes_global(self): """Test that -data-read-memory-bytes can access global buffers.""" @@ -132,6 +134,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfDarwin # pexpect is known to be unreliable on Darwin @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_data_read_memory_bytes_local(self): """Test that -data-read-memory-bytes can access local buffers.""" @@ -272,6 +275,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfDarwin # pexpect is known to be unreliable on Darwin @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_data_list_register_names(self): """Test that 'lldb-mi --interpreter' works for -data-list-register-names.""" @@ -299,6 +303,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfDarwin # pexpect is known to be unreliable on Darwin @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_data_list_register_values(self): """Test that 'lldb-mi --interpreter' works for -data-list-register-values.""" @@ -328,61 +333,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - def test_lldbmi_data_info_line(self): - """Test that 'lldb-mi --interpreter' works for -data-info-line.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Get the address of main and its line - self.runCmd("-data-evaluate-expression main") - self.expect( - "\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"") - addr = int(self.child.after.split("\"")[1].split(" ")[0], 16) - line = line_number('main.cpp', '// FUNC_main') - - # Test that -data-info-line works for address - self.runCmd("-data-info-line *%#x" % addr) - self.expect( - "\^done,start=\"0x0*%x\",end=\"0x[0-9a-f]+\",file=\".+?main.cpp\",line=\"%d\"" % - (addr, line)) - - # Test that -data-info-line works for file:line - self.runCmd("-data-info-line main.cpp:%d" % line) - self.expect( - "\^done,start=\"0x0*%x\",end=\"0x[0-9a-f]+\",file=\".+?main.cpp\",line=\"%d\"" % - (addr, line)) - - # Test that -data-info-line fails when invalid address is specified - self.runCmd("-data-info-line *0x0") - self.expect( - "\^error,msg=\"Command 'data-info-line'\. Error: The LineEntry is absent or has an unknown format\.\"") - - # Test that -data-info-line fails when file is unknown - self.runCmd("-data-info-line unknown_file:1") - self.expect( - "\^error,msg=\"Command 'data-info-line'\. Error: The LineEntry is absent or has an unknown format\.\"") - - # Test that -data-info-line fails when line has invalid format - self.runCmd("-data-info-line main.cpp:bad_line") - self.expect( - "\^error,msg=\"error: invalid line number string 'bad_line'") - self.runCmd("-data-info-line main.cpp:0") - self.expect("\^error,msg=\"error: zero is an invalid line number") - - @skipIfRemote # We do not currently support remote debugging via the MI. - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows + @skipIfDarwin # pexpect is known to be unreliable on Darwin @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races def test_lldbmi_data_evaluate_expression(self): """Test that 'lldb-mi --interpreter' works for -data-evaluate-expression.""" diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py index 7a28f297a1c8a..21c08ab74f172 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py @@ -34,6 +34,26 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\"") + @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows. + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races. + def test_lldbmi_target_list(self): + """Test that 'lldb-mi --interpreter' can list targets by 'target list' command.""" + + self.spawnLldbMi(args=None) + + # Test that initially there are no targets. + self.runCmd("target list") + self.expect(r"~\"No targets.\\n\"") + self.expect("\^done") + + # Add target. + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + + # Test that "target list" lists added target. + self.runCmd("target list") + self.expect(r"~\"Current targets:\\n\* target #0: %s" % self.myexe) + @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py index 2f207928db7df..ccd7eba8bfe31 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py @@ -36,6 +36,25 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\"") + @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows. + @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races. + def test_lldbmi_target_list(self): + """Test that 'lldb-mi --interpreter' can list targets by 'target list' command.""" + + self.spawnLldbMi(args=None) + + # Test that initially there are no targets. + self.runCmd("-interpreter-exec console \"target list\"") + self.expect(r"~\"No targets.\\n\"") + + # Add target. + self.runCmd("-file-exec-and-symbols %s" % self.myexe) + + # Test that "target list" lists added target. + self.runCmd("-interpreter-exec console \"target list\"") + self.expect(r"~\"Current targets:\\n\* target #0: %s" % self.myexe) + @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. @@ -95,53 +114,6 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @expectedFailureAll( - oslist=["linux"], - bugnumber="Failing in ~9/600 dosep runs (build 3120-3122)") - @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_settings_set_target_run_args_after(self): - """Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Test that "settings set target.run-args" passes arguments to executable - # FIXME: --arg1 causes an error - self.runCmd( - "-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"") - self.expect("\^done") - - # Run to BP_printf - line = line_number('main.cpp', '// BP_printf') - self.runCmd("-break-insert main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Run to BP_return - line = line_number('main.cpp', '// BP_return') - self.runCmd("-break-insert main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"2\"") - self.runCmd("-exec-continue") - self.expect("\^running") - - # Test that arguments were passed properly - self.expect("@\"argc=5\\\\r\\\\n\"") - self.expect("@\"argv.0.=.*lldb-mi") - self.expect("@\"argv.1.=arg1\\\\r\\\\n\"") - self.expect("@\"argv.2.=2nd arg\\\\r\\\\n\"") - self.expect("@\"argv.3.=third_arg\\\\r\\\\n\"") - self.expect("@\"argv.4.=fourth=4th arg\\\\r\\\\n\"") - - # Hit BP_return - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. def test_lldbmi_process_launch(self): """Test that 'lldb-mi --interpreter' can launch process by "process launch" command.""" diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py index 2226395dcf2e9..7b6ee55b250e1 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py @@ -11,18 +11,25 @@ from lldbsuite.test.lldbtest import * class MiTestCaseBase(Base): mydir = None - myexe = "a.out" - mylog = "child.log" + myexe = None + mylog = None + NO_DEBUG_INFO_TESTCASE = True @classmethod def classCleanup(cls): - TestBase.RemoveTempFile(cls.myexe) - TestBase.RemoveTempFile(cls.mylog) + if cls.myexe: + TestBase.RemoveTempFile(cls.myexe) + if cls.mylog: + TestBase.RemoveTempFile(cls.mylog) def setUp(self): + if not self.mydir: + raise("mydir is empty") + Base.setUp(self) self.buildDefault() self.child_prompt = "(gdb)" + self.myexe = self.getBuildArtifact("a.out") def tearDown(self): if self.TraceOn(): @@ -36,8 +43,9 @@ class MiTestCaseBase(Base): def spawnLldbMi(self, args=None): import pexpect self.child = pexpect.spawn("%s --interpreter %s" % ( - self.lldbMiExec, args if args else "")) + self.lldbMiExec, args if args else ""), cwd=self.getBuildDir()) self.child.setecho(True) + self.mylog = self.getBuildArtifact("child.log") self.child.logfile_read = open(self.mylog, "w") # wait until lldb-mi has started up and is ready to go self.expect(self.child_prompt, exactly=True) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py index cea5e6f96e9cb..13800de634f1e 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py @@ -89,7 +89,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("\*stopped,reason=\"breakpoint-hit\"") @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipUnlessDarwin + @skipIfDarwin # pexpect is known to be unreliable on Darwin @skipIfRemote # We do not currently support remote debugging via the MI. def test_lldbmi_stopped_when_stopatentry_remote(self): """Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (remote).""" diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py index 80b925993d313..7c225ab87a3cd 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py @@ -9,6 +9,7 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import os class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): @@ -17,6 +18,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_executable_option_file(self): """Test that 'lldb-mi --interpreter %s' loads executable file.""" @@ -43,6 +45,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_executable_option_unknown_file(self): """Test that 'lldb-mi --interpreter %s' fails on unknown executable file.""" @@ -63,18 +66,16 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_executable_option_absolute_path(self): """Test that 'lldb-mi --interpreter %s' loads executable which is specified via absolute path.""" # Prepare path to executable - import os - path = os.path.join(os.getcwd(), self.myexe) - - self.spawnLldbMi(args="%s" % path) + self.spawnLldbMi(args="%s" % self.myexe) # Test that the executable is loaded when file was specified using # absolute path - self.expect("-file-exec-and-symbols \"%s\"" % path) + self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) self.expect("\^done") # Test that lldb-mi is ready when executable was loaded @@ -88,12 +89,12 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_executable_option_relative_path(self): """Test that 'lldb-mi --interpreter %s' loads executable which is specified via relative path.""" # Prepare path to executable - path = "./%s" % self.myexe - + path = os.path.relpath(self.myexe, self.getBuildDir()) self.spawnLldbMi(args="%s" % path) # Test that the executable is loaded when file was specified using @@ -111,11 +112,12 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_executable_option_unknown_path(self): """Test that 'lldb-mi --interpreter %s' fails on executable file which is specified via unknown path.""" # Prepare path to executable - path = "unknown_dir/%s" % self.myexe + path = "unknown_dir" + self.myexe self.spawnLldbMi(args="%s" % path) @@ -129,16 +131,25 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): # Test that lldb-mi is ready when executable was loaded self.expect(self.child_prompt, exactly=True) + def copyScript(self, sourceFile): + """copy the script to builddir and replace a.out with the full path""" + destFile = os.path.join(os.path.dirname(self.myexe), + sourceFile+'.script') + with open(sourceFile, 'r') as src: + with open(destFile, 'w+') as dest: + dest.write(src.read().replace("a.out", self.myexe)) + return destFile + @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + @skipIfDarwin def test_lldbmi_source_option_start_script(self): """Test that 'lldb-mi --interpreter' can execute user's commands after initial commands were executed.""" # Prepared source file - sourceFile = "start_script" - + sourceFile = self.copyScript("start_script") self.spawnLldbMi(args="--source %s" % sourceFile) # After '-file-exec-and-symbols a.out' @@ -171,17 +182,18 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): self.runCmd("-data-evaluate-expression a") self.expect("\^done,value=\"10\"") self.expect(self.child_prompt, exactly=True) + os.unlink(sourceFile) @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots + @skipIfDarwin def test_lldbmi_source_option_start_script_exit(self): """Test that 'lldb-mi --interpreter' can execute a prepared file which passed via --source option.""" # Prepared source file - sourceFile = "start_script_exit" - + sourceFile = self.copyScript("start_script_exit") self.spawnLldbMi(args="--source %s" % sourceFile) # After '-file-exec-and-symbols a.out' @@ -215,15 +227,16 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): self.expect("-gdb-exit") self.expect("\^exit") self.expect("\*stopped,reason=\"exited-normally\"") + os.unlink(sourceFile) @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_source_option_start_script_error(self): """Test that 'lldb-mi --interpreter' stops execution of initial commands in case of error.""" # Prepared source file - sourceFile = "start_script_error" - + sourceFile = self.copyScript("start_script_error") self.spawnLldbMi(args="--source %s" % sourceFile) # After '-file-exec-and-symbols a.out' @@ -236,14 +249,16 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): # Test that lldb-mi is ready after execution of --source start_script self.expect(self.child_prompt, exactly=True) + os.unlink(sourceFile) @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_log_option(self): """Test that 'lldb-mi --log' creates a log file in the current directory.""" - logDirectory = "." + logDirectory = self.getBuildDir() self.spawnLldbMi(args="%s --log" % self.myexe) # Test that the executable is loaded when file was specified @@ -273,6 +288,7 @@ class MiStartupOptionsTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfRemote # We do not currently support remote debugging via the MI. @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin def test_lldbmi_log_directory_option(self): """Test that 'lldb-mi --log --log-dir' creates a log file in the directory specified by --log-dir.""" diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile deleted file mode 100644 index dde38f4e486c4..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -LEVEL = ../../../make - -CXX_SOURCES := main.cpp symbol_list_lines_inline_test.cpp symbol_list_lines_inline_test2.cpp - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py deleted file mode 100644 index 6ac9bf8135639..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py +++ /dev/null @@ -1,104 +0,0 @@ -""" -Test lldb-mi -symbol-xxx commands. -""" - -from __future__ import print_function - - -import lldbmi_testcase -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase): - - mydir = TestBase.compute_mydir(__file__) - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - @expectedFailureAll( - oslist=["linux"], - bugnumber="new failure after r256863") - def test_lldbmi_symbol_list_lines_file(self): - """Test that 'lldb-mi --interpreter' works for -symbol-list-lines when file exists.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to main - self.runCmd("-break-insert -f main") - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Get address of main and its line - self.runCmd("-data-evaluate-expression main") - self.expect( - "\^done,value=\"0x[0-9a-f]+ \(a.out`main at main.cpp:[0-9]+\)\"") - addr = int(self.child.after.split("\"")[1].split(" ")[0], 16) - line = line_number('main.cpp', '// FUNC_main') - - # Test that -symbol-list-lines works on valid data - self.runCmd("-symbol-list-lines main.cpp") - self.expect( - "\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % - (addr, line)) - - # Test that -symbol-list-lines doesn't include lines from other sources - # by checking the first and last line, and making sure the other lines - # are between 30 and 39. - sline = line_number( - 'symbol_list_lines_inline_test2.cpp', - '// FUNC_gfunc2') - eline = line_number( - 'symbol_list_lines_inline_test2.cpp', - '// END_gfunc2') - self.runCmd("-symbol-list-lines symbol_list_lines_inline_test2.cpp") - self.expect( - "\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*\]" % - (sline, eline)) - # FIXME: This doesn't work for symbol_list_lines_inline_test.cpp due to clang bug llvm.org/pr24716 (fixed in newer versions of clang) - ##sline = line_number('symbol_list_lines_inline_test.cpp', '// FUNC_gfunc') - ##eline = line_number('symbol_list_lines_inline_test.cpp', '// STRUCT_s') - ##self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.cpp") - ##self.expect("\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"3\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}\]" % (sline, eline)) - - # Test that -symbol-list-lines works on header files by checking the first - # and last line, and making sure the other lines are under 29. - sline = line_number('symbol_list_lines_inline_test.h', '// FUNC_ifunc') - eline = line_number('symbol_list_lines_inline_test.h', '// FUNC_mfunc') - self.runCmd("-symbol-list-lines symbol_list_lines_inline_test.h") - self.expect( - "\^done,lines=\[\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d\"\})*(,\{pc=\"0x[0-9a-f]+\",line=\"1\d\"\})*,\{pc=\"0x[0-9a-f]+\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"2\d\"\})*\]" % - (sline, eline)) - - # Test that -symbol-list-lines fails when file doesn't exist - self.runCmd("-symbol-list-lines unknown_file") - self.expect( - "\^error,message=\"error: No source filenames matched 'unknown_file'\. \"") - - # Test that -symbol-list-lines fails when file is specified using - # relative path - self.runCmd("-symbol-list-lines ./main.cpp") - self.expect( - "\^error,message=\"error: No source filenames matched '\./main\.cpp'\. \"") - - # Test that -symbol-list-lines works when file is specified using - # absolute path - import os - path = os.path.join(os.getcwd(), "main.cpp") - self.runCmd("-symbol-list-lines \"%s\"" % path) - self.expect( - "\^done,lines=\[\{pc=\"0x0*%x\",line=\"%d\"\}(,\{pc=\"0x[0-9a-f]+\",line=\"\d+\"\})+\]" % - (addr, line)) - - # Test that -symbol-list-lines fails when file doesn't exist - self.runCmd("-symbol-list-lines unknown_dir/main.cpp") - self.expect( - "\^error,message=\"error: No source filenames matched 'unknown_dir/main\.cpp'\. \"") diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp deleted file mode 100644 index c432ba8c477cb..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Skip lines so we can make sure we're not seeing any lines from -// symbol_list_lines_inline_test.h included in -symbol-list-lines -// symbol_list_lines_inline_test.cpp, by checking that all the lines -// are between 30 and 39. -// line 5 -// line 6 -// line 7 -// line 8 -// line 9 -// line 10 -// line 11 -// line 12 -// line 13 -// line 14 -// line 15 -// line 16 -// line 17 -// line 18 -// line 19 -// line 20 -// line 21 -// line 22 -// line 23 -// line 24 -// line 25 -// line 26 -// line 27 -// line 28 -// line 29 -#include "symbol_list_lines_inline_test.h" -int -gfunc(int i) -{ // FUNC_gfunc - return ns::ifunc(i); -} -namespace ns -{ -S s; // STRUCT_s -} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h deleted file mode 100644 index 4b986dc69321a..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h +++ /dev/null @@ -1,24 +0,0 @@ -namespace ns -{ -inline int -ifunc(int i) -{ // FUNC_ifunc - return i; -} -struct S -{ - int a; - int b; - S() - : a(3) - , b(4) - { - } - int - mfunc() - { // FUNC_mfunc - return a + b; - } -}; -extern S s; -} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp deleted file mode 100644 index cfedf47ad6b18..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Skip lines so we can make sure we're not seeing any lines from -// symbol_list_lines_inline_test.h included in -symbol-list-lines -// symbol_list_lines_inline_test2.cpp, by checking that all the lines -// are between 30 and 39. -// line 5 -// line 6 -// line 7 -// line 8 -// line 9 -// line 10 -// line 11 -// line 12 -// line 13 -// line 14 -// line 15 -// line 16 -// line 17 -// line 18 -// line 19 -// line 20 -// line 21 -// line 22 -// line 23 -// line 24 -// line 25 -// line 26 -// line 27 -// line 28 -// line 29 -#include "symbol_list_lines_inline_test.h" -int j = 2; -int -gfunc2(int i) -{ // FUNC_gfunc2 - i += ns::s.mfunc(); - i += ns::ifunc(i); - return i == 0; // END_gfunc2 -} diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py index 93f599317c6cc..50a94b53a18b3 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py @@ -19,6 +19,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_tokens(self): """Test that 'lldb-mi --interpreter' prints command tokens.""" @@ -43,11 +44,12 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_specialchars(self): """Test that 'lldb-mi --interpreter' handles complicated strings.""" # Create an alias for myexe - complicated_myexe = "C--mpl-x file's`s @#$%^&*()_+-={}[]| name" + complicated_myexe = self.getBuildArtifact("C--mpl-x file's`s @#$%^&*()_+-={}[]| name") os.symlink(self.myexe, complicated_myexe) self.addTearDownHook(lambda: os.unlink(complicated_myexe)) @@ -68,31 +70,8 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races + @skipIfDarwin @skipIfRemote # We do not currently support remote debugging via the MI. - @expectedFailureAll( - oslist=["linux"], - bugnumber="Failing in ~6/600 dosep runs (build 3120-3122)") - def test_lldbmi_process_output(self): - """Test that 'lldb-mi --interpreter' wraps process output correctly.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run - self.runCmd("-exec-run") - self.expect("\^running") - - # Test that a process output is wrapped correctly - self.expect("\@\"'\\\\r\\\\n\"") - self.expect("\@\"` - it's \\\\\\\\n\\\\x12\\\\\"\\\\\\\\\\\\\"") - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. - @expectedFailureAll(oslist=["macosx"], bugnumber="rdar://28805064") def test_lldbmi_output_grammar(self): """Test that 'lldb-mi --interpreter' uses standard output syntax.""" diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py index 137408a2bd2b8..db6f9b2a820ae 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py @@ -18,6 +18,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # cannot attach to process on linux @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_target_attach_wait_for(self): """Test that 'lldb-mi --interpreter' works for -target-attach -n <name> --waitfor.""" @@ -32,7 +33,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): # Load executable # FIXME: -file-exec-and-sybmols is not required for target attach, but # the test will not pass without this - self.runCmd("-file-exec-and-symbols %s" % exeName) + self.runCmd("-file-exec-and-symbols %s" % self.getBuildArtifact(exeName)) self.expect("\^done") # Set up attach @@ -40,7 +41,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): time.sleep(4) # Give attach time to setup # Start target process - self.spawnSubprocess(os.path.join(os.path.dirname(__file__), exeName)) + self.spawnSubprocess(self.getBuildArtifact(exeName)) self.addTearDownHook(self.cleanupSubprocesses) self.expect("\^done") @@ -61,6 +62,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # cannot attach to process on linux @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_target_attach_name(self): """Test that 'lldb-mi --interpreter' works for -target-attach -n <name>.""" @@ -71,8 +73,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): self.addTearDownCleanup(dictionary=d) # Start target process - targetProcess = self.spawnSubprocess( - os.path.join(os.path.dirname(__file__), exeName)) + targetProcess = self.spawnSubprocess(self.getBuildArtifact(exeName)) self.addTearDownHook(self.cleanupSubprocesses) self.spawnLldbMi(args=None) @@ -98,6 +99,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # cannot attach to process on linux @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_target_attach_pid(self): """Test that 'lldb-mi --interpreter' works for -target-attach <pid>.""" @@ -109,7 +111,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase): # Start target process targetProcess = self.spawnSubprocess( - os.path.join(os.path.dirname(__file__), exeName)) + self.getBuildArtifact(exeName)) self.addTearDownHook(self.cleanupSubprocesses) self.spawnLldbMi(args=None) diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py index 4384c79fc8459..cf1da5bae9ce7 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py @@ -175,81 +175,6 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase): @expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr23357") @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. - def test_lldbmi_gdb_set_show_print_expand_aggregates(self): - """Test that 'lldb-mi --interpreter' can expand aggregates everywhere.""" - - self.spawnLldbMi(args=None) - - # Load executable - self.runCmd("-file-exec-and-symbols %s" % self.myexe) - self.expect("\^done") - - # Run to BP_gdb_set_show_print_expand_aggregates - line = line_number( - 'main.cpp', - '// BP_gdb_set_show_print_expand_aggregates') - self.runCmd("-break-insert main.cpp:%d" % line) - self.expect("\^done,bkpt={number=\"1\"") - self.runCmd("-exec-run") - self.expect("\^running") - self.expect("\*stopped,reason=\"breakpoint-hit\"") - - # Test that default print expand-aggregates value is "off" - self.runCmd("-gdb-show print expand-aggregates") - self.expect("\^done,value=\"off\"") - - # Test that composite type isn't expanded when print expand-aggregates - # is "off" - self.runCmd("-var-create var1 * complx") - self.expect( - "\^done,name=\"var1\",numchild=\"3\",value=\"{\.\.\.}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") - - # Test that composite type[] isn't expanded when print - # expand-aggregates is "off" - self.eval_and_check_array("complx_array", "complex_type", 2) - - # Test that a struct with a char first element is not formatted as a - # string - self.runCmd("-var-create - * &nstr") - self.expect( - "\^done,name=\"var\d+\",numchild=\"2\",value=\"0x[0-9a-f]+\",type=\"not_str \*\",thread-id=\"1\",has_more=\"0\"") - - # Test that -gdb-set can set print expand-aggregates flag - self.runCmd("-gdb-set print expand-aggregates on") - self.expect("\^done") - self.runCmd("-gdb-set print expand-aggregates 1") - self.expect("\^done") - self.runCmd("-gdb-show print expand-aggregates") - self.expect("\^done,value=\"on\"") - - # Test that composite type is expanded when print expand-aggregates is - # "on" - self.runCmd("-var-create var3 * complx") - self.expect( - "\^done,name=\"var3\",numchild=\"3\",value=\"{i = 3, inner = {l = 3}, complex_ptr = 0x[0-9a-f]+}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"") - - # Test that composite type[] is expanded when print expand-aggregates - # is "on" - self.runCmd("-var-create var4 * complx_array") - self.expect( - "\^done,name=\"var4\",numchild=\"2\",value=\"{\[0\] = {i = 4, inner = {l = 4}, complex_ptr = 0x[0-9a-f]+}, \[1\] = {i = 5, inner = {l = 5}, complex_ptr = 0x[0-9a-f]+}}\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"") - - # Test that -gdb-set print expand-aggregates fails if "on"/"off" isn't - # specified - self.runCmd("-gdb-set print expand-aggregates") - self.expect( - "\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") - - # Test that -gdb-set print expand-aggregates fails when option is - # unknown - self.runCmd("-gdb-set print expand-aggregates unknown") - self.expect( - "\^error,msg=\"The request ''print' expects option-name and \"on\" or \"off\"' failed.\"") - - @skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows - @expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr23357") - @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races - @skipIfRemote # We do not currently support remote debugging via the MI. def test_lldbmi_gdb_set_show_print_aggregate_field_names(self): """Test that 'lldb-mi --interpreter' can expand aggregates everywhere.""" diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py index 6155858cf112b..5ef7d11b8ac0a 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py +++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py @@ -18,6 +18,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_eval(self): """Test that 'lldb-mi --interpreter' works for evaluating.""" @@ -159,7 +160,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots - @skipIfDarwin # rdar://33462982 + @skipIfDarwin @skipIfRemote # We do not currently support remote debugging via the MI. def test_lldbmi_var_update(self): """Test that 'lldb-mi --interpreter' works for -var-update.""" @@ -231,6 +232,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_var_create_register(self): """Test that 'lldb-mi --interpreter' works for -var-create $regname.""" @@ -275,6 +277,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_var_list_children(self): """Test that 'lldb-mi --interpreter' works for -var-list-children.""" @@ -395,6 +398,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_var_create_for_stl_types(self): """Test that 'lldb-mi --interpreter' print summary for STL types.""" @@ -421,6 +425,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots @skipIfRemote # We do not currently support remote debugging via the MI. + @skipIfDarwin def test_lldbmi_var_create_for_unnamed_objects(self): """Test that 'lldb-mi --interpreter' can expand unnamed structures and unions.""" diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py new file mode 100644 index 0000000000000..8c8fed8e44e01 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py @@ -0,0 +1,112 @@ +from __future__ import print_function + + +import gdbremote_testcase +import lldbgdbserverutils +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +import json + +class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + def check_simulator_ostype(self, sdk, platform, arch='x86_64'): + sim_devices_str = subprocess.check_output(['xcrun', 'simctl', 'list', + '-j', 'devices']) + sim_devices = json.loads(sim_devices_str)['devices'] + # Find an available simulator for the requested platform + deviceUDID = None + for (runtime,devices) in sim_devices.items(): + if not platform in runtime.lower(): + continue + for device in devices: + if device['availability'] != '(available)': + continue + deviceUDID = device['udid'] + break + if deviceUDID != None: + break + + # Launch the process using simctl + self.assertIsNotNone(deviceUDID) + exe_name = 'test_simulator_platform_{}'.format(platform) + sdkroot = subprocess.check_output(['xcrun', '--show-sdk-path', '--sdk', + sdk]) + self.build(dictionary={ 'EXE': exe_name, 'SDKROOT': sdkroot.strip(), + 'ARCH': arch }) + exe_path = self.getBuildArtifact(exe_name) + sim_launcher = subprocess.Popen(['xcrun', 'simctl', 'spawn', + deviceUDID, exe_path, + 'print-pid', 'sleep:10'], + stderr=subprocess.PIPE) + # Get the PID from the process output + pid = None + while not pid: + stderr = sim_launcher.stderr.readline() + if stderr == '': + continue + m = re.match(r"PID: (.*)", stderr) + self.assertIsNotNone(m) + pid = int(m.group(1)) + + # Launch debug monitor attaching to the simulated process + self.init_debugserver_test() + server = self.connect_to_debug_monitor(attach_pid=pid) + + # Setup packet sequences + self.add_no_ack_remote_stream() + self.add_process_info_collection_packets() + self.test_sequence.add_log_lines( + ["read packet: " + + "$jGetLoadedDynamicLibrariesInfos:{\"fetch_all_solibs\" : true}]#ce", + {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", + "capture": {1: "dylib_info_raw"}}], + True) + + # Run the stream + context = self.expect_gdbremote_sequence() + self.assertIsNotNone(context) + + # Gather process info response + process_info = self.parse_process_info_response(context) + self.assertIsNotNone(process_info) + + # Check that ostype is correct + self.assertEquals(process_info['ostype'], platform) + + # Now for dylibs + dylib_info_raw = context.get("dylib_info_raw") + dylib_info = json.loads(self.decode_gdbremote_binary(dylib_info_raw)) + images = dylib_info['images'] + + image_info = None + for image in images: + if image['pathname'] != exe_path: + continue + image_info = image + break + + self.assertIsNotNone(image_info) + self.assertEquals(image['min_version_os_name'], platform) + + + @apple_simulator_test('iphone') + @debugserver_test + def test_simulator_ostype_ios(self): + self.check_simulator_ostype(sdk='iphonesimulator', + platform='ios') + + @apple_simulator_test('appletv') + @debugserver_test + def test_simulator_ostype_tvos(self): + self.check_simulator_ostype(sdk='appletvsimulator', + platform='tvos') + + @apple_simulator_test('watch') + @debugserver_test + def test_simulator_ostype_watchos(self): + self.check_simulator_ostype(sdk='watchsimulator', + platform='watchos', arch='i386') diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/TestGdbRemoteExitCode.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExitCode.py index 5ef4249bd2416..5ef4249bd2416 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/TestGdbRemoteExitCode.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExitCode.py diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py index 94e81963483a1..7d8e28c745c94 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py @@ -125,6 +125,8 @@ class TestGdbRemoteExpeditedRegisters( self.set_inferior_startup_launch() self.stop_notification_contains_pc_register() + # powerpc64 has no FP register + @skipIf(triple='^powerpc64') def stop_notification_contains_fp_register(self): self.stop_notification_contains_generic_register("fp") diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py new file mode 100644 index 0000000000000..76910758fa912 --- /dev/null +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteGPacket.py @@ -0,0 +1,40 @@ +from __future__ import print_function + + +import gdbremote_testcase +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestGdbRemoteGPacket(gdbremote_testcase.GdbRemoteTestCaseBase): + + mydir = TestBase.compute_mydir(__file__) + + def run_test_g_packet(self): + self.build() + self.prep_debug_monitor_and_inferior() + self.test_sequence.add_log_lines( + ["read packet: $g#67", + {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", + "capture": {1: "register_bank"}}], + True) + self.connect_to_debug_monitor() + context = self.expect_gdbremote_sequence() + register_bank = context.get("register_bank") + self.assertTrue(register_bank[0] != 'E') + + self.test_sequence.add_log_lines( + ["read packet: $G" + register_bank + "#00", + {"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$", + "capture": {1: "G_reply"}}], + True) + context = self.expect_gdbremote_sequence() + self.assertTrue(context.get("G_reply")[0] != 'E') + + + @skipIfOutOfTreeDebugserver + @debugserver_test + def test_g_packet_debugserver(self): + self.init_debugserver_test() + self.run_test_g_packet() diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py index cab8a9cedfa08..41205302f3bc9 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py @@ -20,7 +20,7 @@ class TestGdbRemoteModuleInfo(gdbremote_testcase.GdbRemoteTestCaseBase): self.test_sequence.add_log_lines([ 'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % ( - lldbutil.append_to_process_working_directory("a.out"), + lldbutil.append_to_process_working_directory(self, "a.out"), info["triple"].decode('hex')), {"direction": "send", "regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}', diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py index a4f306efdc985..82e76ca125bbe 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py @@ -261,7 +261,6 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod lldbgdbserverutils.parse_reg_info_response(reg_info_packet)) @debugserver_test - @expectedFailureDarwin("llvm.org/pr25486") @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet def test_qRegisterInfo_returns_one_valid_result_debugserver(self): self.init_debugserver_test() @@ -294,7 +293,6 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod self.assert_valid_reg_info(reg_info) @debugserver_test - @expectedFailureDarwin("llvm.org/pr25486") @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet def test_qRegisterInfo_returns_all_valid_results_debugserver(self): self.init_debugserver_test() @@ -332,8 +330,9 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod # Ensure we have a program counter register. self.assertTrue('pc' in generic_regs) - # Ensure we have a frame pointer register. - self.assertTrue('fp' in generic_regs) + # Ensure we have a frame pointer register. PPC64le's FP is the same as SP + if self.getArchitecture() != 'powerpc64le': + self.assertTrue('fp' in generic_regs) # Ensure we have a stack pointer register. self.assertTrue('sp' in generic_regs) @@ -558,7 +557,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod self.assertIsNotNone(reg_infos) self.assertTrue(len(reg_infos) > 0) - inferior_exe_path = os.path.abspath("a.out") + inferior_exe_path = self.getBuildArtifact("a.out") Target = self.dbg.CreateTarget(inferior_exe_path) byte_order = Target.GetByteOrder() diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile deleted file mode 100644 index 6ff66a3ab5d9a..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -LEVEL = ../../../make - -override CFLAGS_EXTRAS += -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -ENABLE_THREADS := YES -CXX_SOURCES := main.cpp -MAKE_DSYM :=NO - -include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp deleted file mode 100644 index a3691a8d42b90..0000000000000 --- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp +++ /dev/null @@ -1,355 +0,0 @@ -#include <cstdlib> -#include <cstring> -#include <errno.h> -#include <inttypes.h> -#include <memory> -#include <pthread.h> -#include <setjmp.h> -#include <signal.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> -#include <time.h> -#include <unistd.h> -#include <vector> - -#if defined(__APPLE__) -__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2) -int pthread_threadid_np(pthread_t, __uint64_t *); -#elif defined(__linux__) -#include <sys/syscall.h> -#elif defined(__NetBSD__) -#include <lwp.h> -#endif - -static const char *const RETVAL_PREFIX = "retval:"; -static const char *const SLEEP_PREFIX = "sleep:"; -static const char *const STDERR_PREFIX = "stderr:"; -static const char *const SET_MESSAGE_PREFIX = "set-message:"; -static const char *const PRINT_MESSAGE_COMMAND = "print-message:"; -static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:"; -static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:"; -static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:"; - -static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:"; -static const char *const CALL_FUNCTION_PREFIX = "call-function:"; - -static const char *const THREAD_PREFIX = "thread:"; -static const char *const THREAD_COMMAND_NEW = "new"; -static const char *const THREAD_COMMAND_PRINT_IDS = "print-ids"; -static const char *const THREAD_COMMAND_SEGFAULT = "segfault"; - -static bool g_print_thread_ids = false; -static pthread_mutex_t g_print_mutex = PTHREAD_MUTEX_INITIALIZER; -static bool g_threads_do_segfault = false; - -static pthread_mutex_t g_jump_buffer_mutex = PTHREAD_MUTEX_INITIALIZER; -static jmp_buf g_jump_buffer; -static bool g_is_segfaulting = false; - -static char g_message[256]; - -static volatile char g_c1 = '0'; -static volatile char g_c2 = '1'; - -static void print_thread_id() { -// Put in the right magic here for your platform to spit out the thread id (tid) -// that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else -// clause print out the unsupported text so that the unit test knows to skip -// verifying thread ids. -#if defined(__APPLE__) - __uint64_t tid = 0; - pthread_threadid_np(pthread_self(), &tid); - printf("%" PRIx64, tid); -#elif defined(__linux__) - // This is a call to gettid() via syscall. - printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid))); -#elif defined(__NetBSD__) - // Technically lwpid_t is 32-bit signed integer - printf("%" PRIx64, static_cast<uint64_t>(_lwp_self())); -#else - printf("{no-tid-support}"); -#endif -} - -static void signal_handler(int signo) { - const char *signal_name = nullptr; - switch (signo) { - case SIGUSR1: - signal_name = "SIGUSR1"; - break; - case SIGSEGV: - signal_name = "SIGSEGV"; - break; - default: - signal_name = nullptr; - } - - // Print notice that we received the signal on a given thread. - pthread_mutex_lock(&g_print_mutex); - if (signal_name) - printf("received %s on thread id: ", signal_name); - else - printf("received signo %d (%s) on thread id: ", signo, strsignal(signo)); - print_thread_id(); - printf("\n"); - pthread_mutex_unlock(&g_print_mutex); - - // Reset the signal handler if we're one of the expected signal handlers. - switch (signo) { - case SIGSEGV: - if (g_is_segfaulting) { - // Fix up the pointer we're writing to. This needs to happen if nothing - // intercepts the SIGSEGV (i.e. if somebody runs this from the command - // line). - longjmp(g_jump_buffer, 1); - } - break; - case SIGUSR1: - if (g_is_segfaulting) { - // Fix up the pointer we're writing to. This is used to test gdb remote - // signal delivery. A SIGSEGV will be raised when the thread is created, - // switched out for a SIGUSR1, and then this code still needs to fix the - // seg fault. (i.e. if somebody runs this from the command line). - longjmp(g_jump_buffer, 1); - } - break; - } - - // Reset the signal handler. - sig_t sig_result = signal(signo, signal_handler); - if (sig_result == SIG_ERR) { - fprintf(stderr, "failed to set signal handler: errno=%d\n", errno); - exit(1); - } -} - -static void swap_chars() { - g_c1 = '1'; - g_c2 = '0'; - - g_c1 = '0'; - g_c2 = '1'; -} - -static void hello() { - pthread_mutex_lock(&g_print_mutex); - printf("hello, world\n"); - pthread_mutex_unlock(&g_print_mutex); -} - -static void *thread_func(void *arg) { - static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER; - static int s_thread_index = 1; - - pthread_mutex_lock(&s_thread_index_mutex); - const int this_thread_index = s_thread_index++; - pthread_mutex_unlock(&s_thread_index_mutex); - - if (g_print_thread_ids) { - pthread_mutex_lock(&g_print_mutex); - printf("thread %d id: ", this_thread_index); - print_thread_id(); - printf("\n"); - pthread_mutex_unlock(&g_print_mutex); - } - - if (g_threads_do_segfault) { - // Sleep for a number of seconds based on the thread index. - // TODO add ability to send commands to test exe so we can - // handle timing more precisely. This is clunky. All we're - // trying to do is add predictability as to the timing of - // signal generation by created threads. - int sleep_seconds = 2 * (this_thread_index - 1); - while (sleep_seconds > 0) - sleep_seconds = sleep(sleep_seconds); - - // Test creating a SEGV. - pthread_mutex_lock(&g_jump_buffer_mutex); - g_is_segfaulting = true; - int *bad_p = nullptr; - if (setjmp(g_jump_buffer) == 0) { - // Force a seg fault signal on this thread. - *bad_p = 0; - } else { - // Tell the system we're no longer seg faulting. - // Used by the SIGUSR1 signal handler that we inject - // in place of the SIGSEGV so it only tries to - // recover from the SIGSEGV if this seg fault code - // was in play. - g_is_segfaulting = false; - } - pthread_mutex_unlock(&g_jump_buffer_mutex); - - pthread_mutex_lock(&g_print_mutex); - printf("thread "); - print_thread_id(); - printf(": past SIGSEGV\n"); - pthread_mutex_unlock(&g_print_mutex); - } - - int sleep_seconds_remaining = 60; - while (sleep_seconds_remaining > 0) { - sleep_seconds_remaining = sleep(sleep_seconds_remaining); - } - - return nullptr; -} - -int main(int argc, char **argv) { - lldb_enable_attach(); - - std::vector<pthread_t> threads; - std::unique_ptr<uint8_t[]> heap_array_up; - int return_value = 0; - - // Set the signal handler. - sig_t sig_result = signal(SIGALRM, signal_handler); - if (sig_result == SIG_ERR) { - fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno); - exit(1); - } - - sig_result = signal(SIGUSR1, signal_handler); - if (sig_result == SIG_ERR) { - fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno); - exit(1); - } - - sig_result = signal(SIGSEGV, signal_handler); - if (sig_result == SIG_ERR) { - fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno); - exit(1); - } - - // Process command line args. - for (int i = 1; i < argc; ++i) { - if (std::strstr(argv[i], STDERR_PREFIX)) { - // Treat remainder as text to go to stderr. - fprintf(stderr, "%s\n", (argv[i] + strlen(STDERR_PREFIX))); - } else if (std::strstr(argv[i], RETVAL_PREFIX)) { - // Treat as the return value for the program. - return_value = std::atoi(argv[i] + strlen(RETVAL_PREFIX)); - } else if (std::strstr(argv[i], SLEEP_PREFIX)) { - // Treat as the amount of time to have this process sleep (in seconds). - int sleep_seconds_remaining = std::atoi(argv[i] + strlen(SLEEP_PREFIX)); - - // Loop around, sleeping until all sleep time is used up. Note that - // signals will cause sleep to end early with the number of seconds - // remaining. - for (int i = 0; sleep_seconds_remaining > 0; ++i) { - sleep_seconds_remaining = sleep(sleep_seconds_remaining); - // std::cout << "sleep result (call " << i << "): " << - // sleep_seconds_remaining << std::endl; - } - } else if (std::strstr(argv[i], SET_MESSAGE_PREFIX)) { - // Copy the contents after "set-message:" to the g_message buffer. - // Used for reading inferior memory and verifying contents match - // expectations. - strncpy(g_message, argv[i] + strlen(SET_MESSAGE_PREFIX), - sizeof(g_message)); - - // Ensure we're null terminated. - g_message[sizeof(g_message) - 1] = '\0'; - - } else if (std::strstr(argv[i], PRINT_MESSAGE_COMMAND)) { - pthread_mutex_lock(&g_print_mutex); - printf("message: %s\n", g_message); - pthread_mutex_unlock(&g_print_mutex); - } else if (std::strstr(argv[i], GET_DATA_ADDRESS_PREFIX)) { - volatile void *data_p = nullptr; - - if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_message")) - data_p = &g_message[0]; - else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c1")) - data_p = &g_c1; - else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c2")) - data_p = &g_c2; - - pthread_mutex_lock(&g_print_mutex); - printf("data address: %p\n", data_p); - pthread_mutex_unlock(&g_print_mutex); - } else if (std::strstr(argv[i], GET_HEAP_ADDRESS_COMMAND)) { - // Create a byte array if not already present. - if (!heap_array_up) - heap_array_up.reset(new uint8_t[32]); - - pthread_mutex_lock(&g_print_mutex); - printf("heap address: %p\n", heap_array_up.get()); - pthread_mutex_unlock(&g_print_mutex); - } else if (std::strstr(argv[i], GET_STACK_ADDRESS_COMMAND)) { - pthread_mutex_lock(&g_print_mutex); - printf("stack address: %p\n", &return_value); - pthread_mutex_unlock(&g_print_mutex); - } else if (std::strstr(argv[i], GET_CODE_ADDRESS_PREFIX)) { - void (*func_p)() = nullptr; - - if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX), "hello")) - func_p = hello; - else if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX), - "swap_chars")) - func_p = swap_chars; - - pthread_mutex_lock(&g_print_mutex); - printf("code address: %p\n", func_p); - pthread_mutex_unlock(&g_print_mutex); - } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) { - // Defaut to providing the address of main. - if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0) - hello(); - else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), - "swap_chars") == 0) - swap_chars(); - else { - pthread_mutex_lock(&g_print_mutex); - printf("unknown function: %s\n", - argv[i] + strlen(CALL_FUNCTION_PREFIX)); - pthread_mutex_unlock(&g_print_mutex); - } - } else if (std::strstr(argv[i], THREAD_PREFIX)) { - // Check if we're creating a new thread. - if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) { - // Create a new thread. - pthread_t new_thread; - const int err = - ::pthread_create(&new_thread, nullptr, thread_func, nullptr); - if (err) { - fprintf(stderr, "pthread_create() failed with error code %d\n", err); - exit(err); - } - threads.push_back(new_thread); - } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX), - THREAD_COMMAND_PRINT_IDS)) { - // Turn on thread id announcing. - g_print_thread_ids = true; - - // And announce us. - pthread_mutex_lock(&g_print_mutex); - printf("thread 0 id: "); - print_thread_id(); - printf("\n"); - pthread_mutex_unlock(&g_print_mutex); - } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX), - THREAD_COMMAND_SEGFAULT)) { - g_threads_do_segfault = true; - } else { - // At this point we don't do anything else with threads. - // Later use thread index and send command to thread. - } - } else { - // Treat the argument as text for stdout. - printf("%s\n", argv[i]); - } - } - - // If we launched any threads, join them - for (std::vector<pthread_t>::iterator it = threads.begin(); - it != threads.end(); ++it) { - void *thread_retval = nullptr; - const int err = ::pthread_join(*it, &thread_retval); - if (err != 0) - fprintf(stderr, "pthread_join() failed with error code %d\n", err); - } - - return return_value; -} diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 67887256d97d0..c5d21a9c9b7a0 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -32,7 +32,7 @@ class GdbRemoteTestCaseBase(TestBase): NO_DEBUG_INFO_TESTCASE = True - _TIMEOUT_SECONDS = 7 + _TIMEOUT_SECONDS = 120 _GDBREMOTE_KILL_PACKET = "$k#6b" @@ -483,7 +483,7 @@ class GdbRemoteTestCaseBase(TestBase): # This process needs to be started so that it just hangs around for a while. We'll # have it sleep. if not exe_path: - exe_path = os.path.abspath("a.out") + exe_path = self.getBuildArtifact("a.out") args = [] if inferior_args: @@ -546,10 +546,10 @@ class GdbRemoteTestCaseBase(TestBase): if self._inferior_startup == self._STARTUP_LAUNCH: # Build launch args if not inferior_exe_path: - inferior_exe_path = os.path.abspath("a.out") + inferior_exe_path = self.getBuildArtifact("a.out") if lldb.remote_platform: - remote_path = lldbutil.append_to_process_working_directory( + remote_path = lldbutil.append_to_process_working_directory(self, os.path.basename(inferior_exe_path)) remote_file_spec = lldb.SBFileSpec(remote_path, False) err = lldb.remote_platform.Install(lldb.SBFileSpec( @@ -1008,9 +1008,10 @@ class GdbRemoteTestCaseBase(TestBase): reg_info["name"] in PREFERRED_REGISTER_NAMES): # We found a preferred register. Use it. return reg_info["lldb_register_index"] - if ("generic" in reg_info) and (reg_info["generic"] == "fp"): - # A frame pointer register will do as a register to modify - # temporarily. + if ("generic" in reg_info) and (reg_info["generic"] == "fp" or + reg_info["generic"] == "arg1"): + # A frame pointer or first arg register will do as a + # register to modify temporarily. alternative_register_index = reg_info["lldb_register_index"] # We didn't find a preferred register. Return whatever alternative register @@ -1076,6 +1077,18 @@ class GdbRemoteTestCaseBase(TestBase): auxv_dict = {} + # PowerPC64le's auxvec has a special key that must be ignored. + # This special key may be used multiple times, resulting in + # multiple key/value pairs with the same key, which would otherwise + # break this test check for repeated keys. + # + # AT_IGNOREPPC = 22 + ignored_keys_for_arch = { 'powerpc64le' : [22] } + arch = self.getArchitecture() + ignore_keys = None + if arch in ignored_keys_for_arch: + ignore_keys = ignored_keys_for_arch[arch] + while len(auxv_data) > 0: # Chop off key. raw_key = auxv_data[:word_size] @@ -1089,6 +1102,9 @@ class GdbRemoteTestCaseBase(TestBase): key = unpack_endian_binary_string(endian, raw_key) value = unpack_endian_binary_string(endian, raw_value) + if ignore_keys and key in ignore_keys: + continue + # Handle ending entry. if key == 0: self.assertEqual(value, 0) @@ -1607,10 +1623,10 @@ class GdbRemoteTestCaseBase(TestBase): '.*' if lldbplatformutil.hasChattyStderr(self) else '^' + regex + '$' def install_and_create_launch_args(self): - exe_path = os.path.abspath('a.out') + exe_path = self.getBuildArtifact("a.out") if not lldb.remote_platform: return [exe_path] - remote_path = lldbutil.append_to_process_working_directory( + remote_path = lldbutil.append_to_process_working_directory(self, os.path.basename(exe_path)) remote_file_spec = lldb.SBFileSpec(remote_path, False) err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True), diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp index a574b41abf670..ca032c120bebd 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp +++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp @@ -48,6 +48,8 @@ static const char *const THREAD_COMMAND_NEW = "new"; static const char *const THREAD_COMMAND_PRINT_IDS = "print-ids"; static const char *const THREAD_COMMAND_SEGFAULT = "segfault"; +static const char *const PRINT_PID_COMMAND = "print-pid"; + static bool g_print_thread_ids = false; static pthread_mutex_t g_print_mutex = PTHREAD_MUTEX_INITIALIZER; static bool g_threads_do_segfault = false; @@ -61,6 +63,10 @@ static char g_message[256]; static volatile char g_c1 = '0'; static volatile char g_c2 = '1'; +static void print_pid() { + fprintf(stderr, "PID: %d\n", getpid()); +} + static void print_thread_id() { // Put in the right magic here for your platform to spit out the thread id (tid) // that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else @@ -303,18 +309,22 @@ int main(int argc, char **argv) { printf("code address: %p\n", func_p); pthread_mutex_unlock(&g_print_mutex); } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) { + void (*func_p)() = nullptr; + // Defaut to providing the address of main. if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0) - hello(); + func_p = hello; else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "swap_chars") == 0) - swap_chars(); + func_p = swap_chars; else { pthread_mutex_lock(&g_print_mutex); printf("unknown function: %s\n", argv[i] + strlen(CALL_FUNCTION_PREFIX)); pthread_mutex_unlock(&g_print_mutex); } + if (func_p) + func_p(); } else if (std::strstr(argv[i], THREAD_PREFIX)) { // Check if we're creating a new thread. if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) { @@ -345,6 +355,8 @@ int main(int argc, char **argv) { // At this point we don't do anything else with threads. // Later use thread index and send command to thread. } + } else if (std::strstr(argv[i], PRINT_PID_COMMAND)) { + print_pid(); } else { // Treat the argument as text for stdout. printf("%s\n", argv[i]); diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py index 7e4190b7fe954..aa4b3dee79218 100644 --- a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py +++ b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py @@ -20,12 +20,9 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase): self.init_llgs_test(False) working_dir = lldb.remote_platform.GetWorkingDirectory() - err = lldb.remote_platform.Put( - lldb.SBFileSpec( - os.path.join( - os.getcwd(), "a.out")), lldb.SBFileSpec( - os.path.join( - working_dir, "a.out"))) + src = lldb.SBFileSpec(self.getBuildArtifact("a.out")) + dest = lldb.SBFileSpec(os.path.join(working_dir, "a.out")) + err = lldb.remote_platform.Put(src, dest) if err.Fail(): raise RuntimeError( "Unable copy '%s' to '%s'.\n>>> %s" % @@ -37,9 +34,9 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase): unix_protocol = protocol.startswith("unix-") if unix_protocol: p = re.search("^(.*)-connect", protocol) - listen_url = "%s://%s" % (p.group(1), - os.path.join(working_dir, - "platform-%d.sock" % int(time.time()))) + path = lldbutil.join_remote_paths(configuration.lldb_platform_working_dir, + self.getBuildDirBasename(), "platform-%d.sock" % int(time.time())) + listen_url = "%s://%s" % (p.group(1), path) else: listen_url = "*:0" diff --git a/packages/Python/lldbsuite/test/types/AbstractBase.py b/packages/Python/lldbsuite/test/types/AbstractBase.py index ee548954a7418..37ddfb756bb03 100644 --- a/packages/Python/lldbsuite/test/types/AbstractBase.py +++ b/packages/Python/lldbsuite/test/types/AbstractBase.py @@ -34,7 +34,7 @@ class GenericTester(TestBase): # module cacheing subsystem to be confused with executable name "a.out" # used for all the test cases. self.exe_name = self.testMethodName - self.golden_filename = os.path.join(os.getcwd(), "golden-output.txt") + self.golden_filename = self.getBuildArtifact("golden-output.txt") def tearDown(self): """Cleanup the test byproducts.""" @@ -95,7 +95,7 @@ class GenericTester(TestBase): if lldb.remote_platform: # process launch -o requires a path that is valid on the target self.assertIsNotNone(lldb.remote_platform.GetWorkingDirectory()) - remote_path = lldbutil.append_to_process_working_directory( + remote_path = lldbutil.append_to_process_working_directory(self, "lldb-stdout-redirect.txt") self.runCmd( 'process launch -- {remote}'.format(remote=remote_path)) @@ -113,8 +113,8 @@ class GenericTester(TestBase): quotedDisplay=False, blockCaptured=False): """Test that variables with basic types are displayed correctly.""" - - self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET) + self.runCmd("file %s" % self.getBuildArtifact(exe_name), + CURRENT_EXECUTABLE_SET) # First, capture the golden output emitted by the oracle, i.e., the # series of printf statements. @@ -210,7 +210,8 @@ class GenericTester(TestBase): blockCaptured=False): """Test that variable expressions with basic types are evaluated correctly.""" - self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET) + self.runCmd("file %s" % self.getBuildArtifact(exe_name), + CURRENT_EXECUTABLE_SET) # First, capture the golden output emitted by the oracle, i.e., the # series of printf statements. diff --git a/packages/Python/lldbsuite/test/types/TestRecursiveTypes.py b/packages/Python/lldbsuite/test/types/TestRecursiveTypes.py index 4735bcee5128a..40c028f3e6dc2 100644 --- a/packages/Python/lldbsuite/test/types/TestRecursiveTypes.py +++ b/packages/Python/lldbsuite/test/types/TestRecursiveTypes.py @@ -44,7 +44,7 @@ class RecursiveTypesTestCase(TestBase): self.print_struct() def print_struct(self): - 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/types/basic_type.cpp b/packages/Python/lldbsuite/test/types/basic_type.cpp index 3102806ab5bc4..2d7e7b2e21bf3 100644 --- a/packages/Python/lldbsuite/test/types/basic_type.cpp +++ b/packages/Python/lldbsuite/test/types/basic_type.cpp @@ -23,6 +23,9 @@ #ifdef TEST_BLOCK_CAPTURED_VARS #include <dispatch/dispatch.h> #endif +#include <cstdint> +#include <cstdio> +#include <cstdlib> class a_class { @@ -83,9 +86,6 @@ typedef struct a_union_nonzero_tag { } a_union_nonzero_t; -#include <stdint.h> -#include <stdio.h> - int main (int argc, char const *argv[]) { diff --git a/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py b/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py index 5df4c701ad9f4..11c3bc86a6ed4 100644 --- a/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py +++ b/packages/Python/lldbsuite/test/warnings/uuid/TestAddDsymCommand.py @@ -28,14 +28,14 @@ class AddDsymCommandCase(TestBase): # Call the program generator to produce main.cpp, version 1. self.generate_main_cpp(version=1) - self.buildDsym(clean=True) + self.buildDefault(dictionary={'MAKE_DSYM':'YES'}) # Insert some delay and then call the program generator to produce # main.cpp, version 2. time.sleep(5) self.generate_main_cpp(version=101) # Now call make again, but this time don't generate the dSYM. - self.buildDwarf(clean=False) + self.buildDefault(dictionary={'MAKE_DSYM':'NO'}) self.exe_name = 'a.out' self.do_add_dsym_with_error(self.exe_name) @@ -46,7 +46,7 @@ class AddDsymCommandCase(TestBase): # Call the program generator to produce main.cpp, version 1. self.generate_main_cpp(version=1) - self.buildDsym(clean=True) + self.buildDefault(dictionary={'MAKE_DSYM':'YES'}) self.exe_name = 'a.out' self.do_add_dsym_with_success(self.exe_name) @@ -57,14 +57,14 @@ class AddDsymCommandCase(TestBase): # Call the program generator to produce main.cpp, version 1. self.generate_main_cpp(version=1) - self.buildDsym(clean=True) + self.buildDefault(dictionary={'MAKE_DSYM':'YES'}) self.exe_name = 'a.out' self.do_add_dsym_with_dSYM_bundle(self.exe_name) def generate_main_cpp(self, version=0): """Generate main.cpp from main.cpp.template.""" - temp = os.path.join(os.getcwd(), self.template) + temp = os.path.join(self.getSourceDir(), self.template) with open(temp, 'r') as f: content = f.read() @@ -72,7 +72,7 @@ class AddDsymCommandCase(TestBase): '%ADD_EXTRA_CODE%', 'printf("This is version %d\\n");' % version) - src = os.path.join(os.getcwd(), self.source) + src = os.path.join(self.getBuildDir(), self.source) with open(src, 'w') as f: f.write(new_content) @@ -83,15 +83,18 @@ class AddDsymCommandCase(TestBase): def do_add_dsym_with_error(self, exe_name): """Test that the 'add-dsym' command informs the user about failures.""" - self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET) + exe_path = self.getBuildArtifact(exe_name) + self.runCmd("file " + exe_path, CURRENT_EXECUTABLE_SET) - wrong_path = os.path.join("%s.dSYM" % exe_name, "Contents") + wrong_path = os.path.join(self.getBuildDir(), + "%s.dSYM" % exe_name, "Contents") self.expect("add-dsym " + wrong_path, error=True, substrs=['invalid module path']) right_path = os.path.join( + self.getBuildDir(), "%s.dSYM" % - exe_name, + exe_path, "Contents", "Resources", "DWARF", @@ -101,13 +104,15 @@ class AddDsymCommandCase(TestBase): def do_add_dsym_with_success(self, exe_name): """Test that the 'add-dsym' command informs the user about success.""" - self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET) + exe_path = self.getBuildArtifact(exe_name) + self.runCmd("file " + exe_path, CURRENT_EXECUTABLE_SET) # This time, the UUID should match and we expect some feedback from # lldb. right_path = os.path.join( + self.getBuildDir(), "%s.dSYM" % - exe_name, + exe_path, "Contents", "Resources", "DWARF", @@ -117,9 +122,10 @@ class AddDsymCommandCase(TestBase): def do_add_dsym_with_dSYM_bundle(self, exe_name): """Test that the 'add-dsym' command informs the user about success when loading files in bundles.""" - self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET) + exe_path = self.getBuildArtifact(exe_name) + self.runCmd("file " + exe_path, CURRENT_EXECUTABLE_SET) # This time, the UUID should be found inside the bundle - right_path = "%s.dSYM" % exe_name + right_path = "%s.dSYM" % exe_path self.expect("add-dsym " + right_path, substrs=['symbol file', 'has been added to']) diff --git a/packages/Python/lldbsuite/test_event/formatter/xunit.py b/packages/Python/lldbsuite/test_event/formatter/xunit.py index 91487cd2c3a18..4c53ff8062d7d 100644 --- a/packages/Python/lldbsuite/test_event/formatter/xunit.py +++ b/packages/Python/lldbsuite/test_event/formatter/xunit.py @@ -84,7 +84,9 @@ class XunitFormatter(ResultsFormatter): """ # Get the content into unicode if isinstance(str_or_unicode, str): - unicode_content = str_or_unicode.decode('utf-8') + # If we hit decoding errors due to data corruption, replace the + # invalid characters with U+FFFD REPLACEMENT CHARACTER. + unicode_content = str_or_unicode.decode('utf-8', 'replace') else: unicode_content = str_or_unicode return self.invalid_xml_re.sub( |