diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 | 
| commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
| tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /packages/Python/lldbsuite/test/functionalities | |
| parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities')
384 files changed, 4382 insertions, 2033 deletions
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 aecbab1b363f..aa80c9976eb8 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 f825eaa86e85..a0c096865558 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 7bddc0cadccf..5827dc3b4653 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 0943d99ee834..d7c511021863 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 b348e72606ad..ad87796766c3 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 a4e3948e81ca..38848e87cc4a 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 9b116a0a0a24..46191d85296a 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 6f06ca7770c8..5014c1cd4a24 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 9630e39e0142..0123e732e35d 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 88ccc4644192..000000000000 --- 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 281ddfe7ef67..000000000000 --- 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 386eafbb0b60..7a2dc61b1b69 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 01af8369aaf1..7c7aad0bc81e 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 baf237bf0764..d064b75b91cf 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 cf1fc2cf02c9..ac0f753ccd8d 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 62ec97f43284..702644b692d8 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 000000000000..ef4ab2b159cc --- /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 3fd9b13c7119..959c7e8f95cc 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 5d7b6f9169ad..6f696be83249 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 621bd4a55f06..02fb1e0f49d4 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 09e20bc5ac35..eb4bac7e6e66 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 255b6f7fa292..6eaab0c680f5 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 214c110afcd6..b69007014b10 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 de24d8b002d7..7eb465f29599 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 b95d2cea550a..8b5352866c21 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 871363b7aed3..c9ef2a730010 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 2410f2ee82b3..7603bd90ffc5 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 0ac34a186b25..2d7f20f43fed 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 e4672fbbf1ba..4385304c88b6 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 adec9fa5dddb..e4c19fd0d3da 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 3019e1c1c557..26fe02ba56ce 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 d044827e0084..11ec67d91097 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 a934ad356ac6..4b595ab7819e 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 801c1041bbe1..06ef85cf908d 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 4dfa03d5fab4..9551ab278ebf 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 21fe084d3dfb..69dfac225258 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 fe8f430096d9..ee67dda62420 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 5881afe1f395..75d2c3690c89 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 e7a1cab7e195..06ef85cf908d 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 26041c313e57..16d5bc75473c 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 060b91f5a5ea..9f0e56dd22ee 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 f43bbb7515c1..e5e8473eedd6 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 6f93994a4664..5c3da17c254e 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 791cc70a7498..4256c70a0265 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 4dfeae3f5e19..c2084295ef79 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 d562cb1511ac..1698c0d0c35f 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 000000000000..f9707a5706ac --- /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 169daacc1a83..6c1f7b8185f6 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 975ad32689b2..c6ad75f014ee 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 9f55f64b2be5..a3b23834ee12 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 cec06e48f1cf..904fb4c90372 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 f8ce069478fd..c8f93c1db3a8 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 12a430295a77..32b2623dfb98 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 8ce4d4135d18..088d1036d1c4 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 b7664ddd8071..5a377f99128b 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 5afe649e16a2..f3d4d4de92f0 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 74be57aeef85..16d678aa2417 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 55f015403d1f..e017d56af31c 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 6786d6f009b0..5a618b11680c 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 28677b54c75d..679db2ea37bb 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 65822cab430a..8c9e2875aec5 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 85b8e30f6064..89791097a3f8 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 44348374636d..865eea241981 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 410da702b93d..18aac237672c 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 9b430c726e12..891448f00d29 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 050f5236445b..6d8a794070d7 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 2d01eb79e188..4e61b7419d5b 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 0518a75051bb..9749061f42d5 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 e192943f381e..c451d0f82792 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 710cfa8fe12c..2d09be5441ba 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 d3d93dabc7fb..81ddf597def6 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 f4f0a4859896..8b354d764e58 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 bc39d8d7b152..4643e4738229 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 1543ce6edb91..37b34f2ac8b9 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 750e29460732..605b543a1b93 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 12e62f62ee97..41a6def00c49 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 bf600219bced..2c5041142fa9 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 ebabe3076611..397a461db683 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 75d1853f6a71..cc4cfd2ceb72 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 3355ca16305b..1dd1912f4c73 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 b0b45cb831b0..4ec7f13d1152 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 9e82f11ff36b..13b38cbfa702 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 8d4132444fbd..1f7a175974f9 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 73a1b4e16bf6..4fa115e51655 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 a80f97b80157..2a1532adb4b2 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 63eb5e087e14..81a76cc65d63 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 f0857f420fc3..9c9b2473aa74 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 9b4308f54095..b36fa6ee1dc8 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 058a79317d19..9d1cbfd91286 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 bb20b0e7d98c..5f48b3541e5a 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 e1ebbd5c226d..f169b448680d 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 6a1266528d5e..7c623e9a68b5 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 4f2bd74495a9..56375874f37e 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 fc4714ea94e2..0f57f0abd9ce 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 b28a7e6bc31b..cbcce47d364d 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 2f448e8fd115..72a886ff1285 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 1e1dd3b16039..dd3d8be4ae91 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 2b157f7f6fcc..f9eb4d82025e 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 ca8928129244..a6f1a3d2f430 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 cc3033ef26e4..df39e9746c03 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 5b9b14d549e5..4574a044488c 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 1f609a41d908..24d7c220d075 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 f61a715a4d3e..4c60e403f6b0 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 4e8a1a779c0c..81a5763559d3 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 a7a00068383f..1aa93d718fc9 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 91fe509465e7..026cfc863f2c 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 9e226a100a10..aeb10984b3b8 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 a9aeacf90e43..0e1dbe4f03e2 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 90a958d7cfe2..463e2a9f190d 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 a8f99f41665f..7f3755660543 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 e25c410f91ce..267e3beedb4c 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 6809dd3c356d..1ca4a15d85cc 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 d4e9e4d30f77..042d9fbcd6a0 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 b38747d0f937..c2e02f546691 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 23da541120f6..5d05418a8b49 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 000000000000..190cf78a3b43 --- /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 000000000000..b12cab231695 --- /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 57c9e2fe5dc7..fb37838bdaff 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 e3f21eb21ec0..712de3d41f74 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 8fff07d89dca..0e3bcc0e7398 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 75d3b4e5f5c2..8bb60b8d679a 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 6e7ac2c13f31..08768a61bd9d 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 0c15c793e1fe..00eb3d00f783 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 d6303fe8b73d..d7507626e145 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 32fbf48dcc68..cc22eca993e2 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 b7f60cfac41d..55855dc8432b 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 87fc2d1802b7..1ae5e40f9780 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 85675d211235..65e32643dde3 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 6affc5a71faf..a3657026faef 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 7ffddc5ec673..87265087744c 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 49cda4ae6cc8..0bfd8df7b44e 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 83408e7b456e..4326574c254c 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 69b9dd048871..862e2b57342d 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 01271b443d17..ba50ccd0ae5e 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 0a039107d842..09888e1b469b 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 d7862d2327cf..f766699bd852 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 6d519761b7bb..e94f6c4cc407 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 29c1214564d8..54e9a3215777 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 2e66b800b15e..9435e80573e1 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 d970d11a2bab..d3cc4d98aff7 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 53073f6d910a..f6dc47f35869 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 cde0ef409621..d3c04afe91eb 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 2d4cd5782fdd..c1dc15224b1e 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 355d60ade90f..9ba3d2d0ac75 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 cee472ccb51f..52f9daf6bd45 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 47357cf4f71d..c5fec5b02d6b 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 93925829ec82..c68e3f1b3212 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 79e4e627592c..aaba15653763 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 937ac9270019..0f130b3ecbab 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 8a7102e347af..784a53da4776 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 550eae85e1d6..611869932b61 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 700c5dd94b28..92206b2d88ef 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 000000000000..5653471c1530 --- /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 000000000000..88f76b5113b4 --- /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 719f3f719934..a498f0a360ee 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 e1832fdefbee..c7c5ef405459 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 d62ccbff87fa..80240534c368 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 b7592c93704d..f311fac4c0f7 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 276760d30574..4abf1a812963 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 6529e11fafa8..e198720db57d 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 2e6fad5e1fdb..7823c639572c 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 7839a47a8f41..335d61767cd8 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 8e5cd430293d..0398a161dcd8 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 201923fb89d6..272a64e117b9 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 08ef1c7fc5e6..3d9c893bbd40 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 e962c2673faf..da1fd187d142 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 bc11bd1afb78..437cdbbc93b7 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 089fc237b054..cb1af719ac35 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 178e165f3cbe..59af2de836ff 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 b29f94bdb059..960891b9eefc 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 000000000000..3bf0c52edaed --- /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 000000000000..f70c854ed6d4 --- /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 000000000000..142861a37dff --- /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 000000000000..ef9ce7700963 --- /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 000000000000..400a93661033 --- /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 000000000000..f4e9ff5d8722 --- /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 000000000000..ebafd405e23e --- /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 000000000000..ad9b6fd4e55a --- /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 7b048fedebba..75215f89ef0b 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 3620de61a2e3..b1b9f4bc04c7 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 b233d2f768e0..4f54f5d4103b 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 9987377a83ec..d8efe65dc7f6 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 cb801242aa58..4513db2ccdfc 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 7ccfaa688b88..07f04b18bb97 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 43fa5f9d33f2..9b485b2235dd 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 9a954a201cf2..0dd9eb41a408 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 98b0c9ca1971..6302112d2fe9 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 0eb810e21787..fddca925dea2 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 c1b0877d72a4..2fcdbea3a1c4 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 5b5691efeef4..d40949b14630 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 b6b6eeacba26..a5db3c7c31f0 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 f84d8300843f..271117a0ad88 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 000000000000..c00c25822e4c --- /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 000000000000..c4c3cfe3c18e --- /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 000000000000..2050586adfa1 --- /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 000000000000..bebfa92ecfb2 --- /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 000000000000..6a7642c08b93 --- /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/functionalities/load_using_paths/main.cpp b/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp new file mode 100644 index 000000000000..4b3320479c25 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/load_using_paths/main.cpp @@ -0,0 +1,16 @@ +//===-- 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> + +int +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 dd4ab4cab2a9..db855f6302dd 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 f2126e9ffd5f..f45479bee0bf 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 f8f10a8d4f56..8e0fbaa32018 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 91342fdaf1c3..2e4bbbd53f0f 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 eb6981d04fad..b871b90961c9 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 86c5e41b0931..f805b53d3cd4 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 bbaba956acfd..59e889e8b0fd 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 b4f519cd25a8..2171a2648bde 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 be89e36b5ce0..fd9812320f2b 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 54ea33ad24a9..b81446f5a58f 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 18fcc41fa9f6..25b83ed5532f 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 9a5d320dce55..4a19a4e77607 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 63b93340cef3..879f1adebc6a 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 000000000000..a299a4308bc8 --- /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 000000000000..de6c3b7dd56f --- /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 000000000000..84ce54e45e1f --- /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 4e587b92c1d2..5960215f8047 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 c7b64d783c71..61e2adee41d5 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 c4855ca9b12d..624a6e1584e4 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 258c3d3fbb9f..befb42186112 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 c4d372cd3d30..617b4bcfaec3 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 87600bbccf9d..3c1f73515eb7 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 5465b7155f50..b915b541fb4b 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 000000000000..3d60e8bd0b94 --- /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 91436446ad99..8496ce6c04d7 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 5929a352b615..9d1cac90d856 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_launch/my_working_dir/.keep b/packages/Python/lldbsuite/test/functionalities/process_launch/my_working_dir/.keep deleted file mode 100644 index e69de29bb2d1..000000000000 --- a/packages/Python/lldbsuite/test/functionalities/process_launch/my_working_dir/.keep +++ /dev/null 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 ee1f82b14f7b..55dbc4223711 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 5085b8cce99a..80ace219aeb1 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 5b72d383f141..569ecd249b21 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 6dccaa55a103..d362e6a8ae3d 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 000000000000..823e40155ff5 --- /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 4cfb2239c06f..671331fe450f 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 96f3655542c8..00802ff89505 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 45721dd260d9..2fd2dab0184c 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 83cc48847c99..41e566438724 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 20d64b38f0ca..044d3d25b724 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 606a71ff5019..b7d0d8170b3b 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 2fc31a4e78ae..6e4dbf40e467 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 0a2756d87fbe..316233b909e7 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 97de99640f50..1ebab8837b92 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 79175562fe7a..dfc54a639ea0 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 ad08c6a9e952..984e802fdaa0 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/single-quote-in-filename-to-lldb/path with '09/.keep b/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/path with '09/.keep deleted file mode 100644 index e69de29bb2d1..000000000000 --- a/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/path with '09/.keep +++ /dev/null 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 000000000000..6bcd9c92f8ce --- /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 000000000000..2ffb94cb7754 --- /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/breakpoint/breakpoint_case_sensitivity/Makefile b/packages/Python/lldbsuite/test/functionalities/stats/Makefile index 6067ee45e984..f5a47fcc46cc 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/stats/Makefile @@ -1,6 +1,3 @@ -LEVEL = ../../../make - +LEVEL = ../../make  C_SOURCES := main.c -CFLAGS_EXTRAS += -std=c99 -  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 000000000000..48e49ed009ba --- /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 000000000000..9adb3a09a080 --- /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 000000000000..f5a47fcc46cc --- /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 000000000000..a6c38ca1d091 --- /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 000000000000..03b2213bb9a3 --- /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 45b69a5bb6eb..4f71dc87646d 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 7ec934f26e0b..446c2675f884 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 3d23f644554b..767b368cc7dc 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 74088581bad4..b76d98a333c2 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 3a18877ef2d0..88267b60b978 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 7d2900d61718..71bfff1d05d4 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 71fb8e3bb565..8e0f76f691b9 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 ba5094f6de3e..e2026267c60e 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 d1d70c58c4c7..cef24d688bf9 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/crash_with_break/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/Makefile index 4b5e0ee94222..469c0809aa24 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_break/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 2506a8231883..2506a8231883 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 8712342e5811..8712342e5811 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 275d54d2149c..275d54d2149c 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 33d1074211ee..33d1074211ee 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 560c79ed8a8f..560c79ed8a8f 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 c9cc6db96004..c9cc6db96004 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 d99107b6e9b6..d99107b6e9b6 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 442134f4a0c7..442134f4a0c7 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 28c5c68d4506..28c5c68d4506 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 2d7c984e0e1c..2d7c984e0e1c 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 2b7e1b457268..2b7e1b457268 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 0564c86dfcbd..0564c86dfcbd 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 a9f3fbb799f1..a9f3fbb799f1 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 88ab1d5e204c..88ab1d5e204c 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 232b694c80f4..232b694c80f4 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 96b610f2b90b..96b610f2b90b 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 b921ac04ccc5..b921ac04ccc5 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 b8819f286984..b8819f286984 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 b7d8cb174d24..b7d8cb174d24 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 2f3b858854b8..2f3b858854b8 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 ebb13d99fb3c..ebb13d99fb3c 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 0fbaf364045d..0fbaf364045d 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 53da6658550d..53da6658550d 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 4e6bed2d5cbc..4e6bed2d5cbc 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 d7630575cb34..d7630575cb34 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 4c4caa533734..4c4caa533734 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 687be17ddc5a..687be17ddc5a 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 025d91169451..025d91169451 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 5e95531ae09a..5e95531ae09a 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 aa57e816bb58..aa57e816bb58 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 31b583c1a65a..31b583c1a65a 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 241ea5b64a03..241ea5b64a03 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 79a54b620e53..79a54b620e53 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 6a37abdbcbb8..6a37abdbcbb8 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 67ac92b853cd..67ac92b853cd 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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/breakpoints_delayed_breakpoint_one_watchpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_one_watchpoint/Makefile deleted file mode 100644 index 4b5e0ee94222..000000000000 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/breakpoints_delayed_breakpoint_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/crash_with_signal/Makefile b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/crash_with_signal/Makefile deleted file mode 100644 index 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 4b5e0ee94222..000000000000 --- 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 5343e19ee203..b20b738825a2 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 442887ed4e13..3f26d8c76579 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 f6d6197e1f11..3998db6d3256 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 456c890673cc..c62990ccc93a 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 e41fbebf380d..8fc1e42e96d0 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 4ba04953d6f1..0343a888a0f1 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 26ee5d4084eb..3300078e8c60 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 18d88cb52113..cff9b5a8d5e5 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 75a9b8873dda..4c4e645635c1 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 42a07f353030..fdc060d135dc 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 1fb52155c266..0cbd94e199dc 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 9c8bbf1eb081..238b18837884 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 d63d5c55bc82..3bace5780639 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 deedc4b7507a..07ceb3f5f6b7 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 f9508cf6ecca..432adc0ea00e 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 8f004e6d319b..9fdf42ac4e3c 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 7721b5d84322..0509b3d37a7f 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 3eddaca3e30d..8bf897f0bba7 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 f1689a8fda00..c91ed41a2478 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 8baba9beed36..7451dde1fa59 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 3f0cae6a54c9..c68c2efff4cd 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 436fcf63d07d..93b06f6502a1 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 f4380cf7749a..6e6587387ea9 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 684e6f71d931..6565a2336563 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 f0ecd464de1d..c4d31df0989b 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 8d6311e42b93..2c7fb01f2f26 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 b0f52923cc1f..272634fcab91 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 8dcee97e32f5..5dfa08e78308 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 a5e5f572a979..d0502cc052a5 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 a855be7536ca..9c87d1759f8c 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 ae8060124ab2..46de1efe6265 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 c41600462561..a2558c77789b 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 598efbc5e030..f971942322b1 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 2416128d2efa..4bacb0bd9884 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 8e3ab853e27d..1a8fbdf5e2ba 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 9fac249936ea..d39d35f76883 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 2cfba398bac9..8e19f9b3b5b8 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 ac2c2fb8ec5a..b51cab38aa86 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 c21355a2e8f9..7302f76c1fbc 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 0c5798fdddfe..85d6c84d68ff 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 7f2e5e6e6cb5..1bfc3b2538b2 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 71686a5f5c49..e0c77b4ea6be 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 47454498e70e..b2f267364dd0 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 82865e646be5..5bb683934c1b 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 a4ceca34c086..cd819f27ec5f 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 50cd88bd8625..d9edd05d3a76 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 34502a6d1d36..a77b1e70e3dd 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 dad633f052c6..587dcabb2ba3 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 ea2580382520..cedfad9b566f 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 ee4b05c12659..5b72f5edda74 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 b53e323cf4bd..c7f7d02392eb 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 7460a1c09476..e6718f0bc6f0 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 ee6402489330..d4f78a5f3ecc 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 000000000000..3a3f4df6416b --- /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 000000000000..c25f9afbfa4e --- /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")  | 
