diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities')
262 files changed, 4239 insertions, 1232 deletions
| diff --git a/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py b/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py index 1bce5bed491f..6423ecf27aeb 100644 --- a/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py +++ b/packages/Python/lldbsuite/test/functionalities/abbreviation/TestAbbreviations.py @@ -8,14 +8,14 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class AbbreviationsTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFlakeyFreeBSD("llvm.org/pr22611 thread race condition breaks prompt setting")      @no_debug_info_test      def test_command_abbreviations_and_aliases (self):          command_interpreter = self.dbg.GetCommandInterpreter() diff --git a/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py b/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py index 9edbf212278c..fa6f3f306898 100644 --- a/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py +++ b/packages/Python/lldbsuite/test/functionalities/abbreviation/TestCommonShortSpellings.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class CommonShortSpellingsTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/apropos_with_process/Makefile b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/Makefile new file mode 100644 index 000000000000..8a7102e347af --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py new file mode 100644 index 000000000000..66ed3ff73298 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/TestAproposWithProcess.py @@ -0,0 +1,44 @@ +""" +Test that apropos env doesn't crash trying to touch the process plugin commmand +""" + +from __future__ import print_function + + + +import os, time +import re +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class AproposWithProcessTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        # Find the line number to break inside main(). +        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.""" +        self.build() +        exe = os.path.join(os.getcwd(), "a.out") +        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + +        # Break in main() aftre 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) + +        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']) + +        # The breakpoint should have a hit count of 1. +        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, +            substrs = [' resolved, hit count = 1']) + +        self.runCmd('apropos env') diff --git a/packages/Python/lldbsuite/test/functionalities/apropos_with_process/main.cpp b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/main.cpp new file mode 100644 index 000000000000..44c149687f21 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/apropos_with_process/main.cpp @@ -0,0 +1,15 @@ +//===-- main.cpp ------------------------------------------------*- 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[]) +{ +  return 0; // break here +} + diff --git a/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py b/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py index 02e1b9551853..b419ad97a694 100644 --- a/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py +++ b/packages/Python/lldbsuite/test/functionalities/archives/TestBSDArchives.py @@ -6,8 +6,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class BSDArchivesTestCase(TestBase): @@ -19,7 +20,8 @@ class BSDArchivesTestCase(TestBase):          # Find the line number in a(int) to break at.          self.line = line_number('a.c', '// Set file and line breakpoint inside a().') -    @expectedFailureWindows("llvm.org/pr24527") # Makefile.rules doesn't know how to build static libs on Windows. +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24527.  Makefile.rules doesn't know how to build static libs on Windows") +    @expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr27795")      def test(self):          """Break inside a() and b() defined within libfoo.a."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py b/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py index e92b967d8adf..6416bccc483d 100644 --- a/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py +++ b/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py @@ -8,18 +8,19 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbplatform +from lldbsuite.test import lldbutil  class AsanTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureLinux # non-core functionality, need to reenable and fix later (DES 2014.11.07) +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")      @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default      @skipIfRemote      @skipUnlessCompilerRt -    @expectedFailureDarwin      def test (self):          self.build ()          self.asan_tests () @@ -45,11 +46,10 @@ class AsanTestCase(TestBase):          self.runCmd("run") -        # ASan will relaunch the process to insert its library. -        self.expect("thread list", "Process should be stopped due to exec.", -            substrs = ['stopped', 'stop reason = ']) - -        self.runCmd("continue") +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue")          # the stop reason of the thread should be breakpoint.          self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, @@ -62,8 +62,8 @@ class AsanTestCase(TestBase):          # test the 'memory history' command          self.expect("memory history 'pointer'",              substrs = [ -                'Memory allocated at', 'a.out`f1', 'main.c:%d' % self.line_malloc, -                'Memory deallocated at', 'a.out`f2', 'main.c:%d' % self.line_free]) +                'Memory allocated by Thread', 'a.out`f1', 'main.c:%d' % self.line_malloc, +                'Memory deallocated by Thread', 'a.out`f2', 'main.c:%d' % self.line_free])          # do the same using SB API          process = self.dbg.GetSelectedTarget().process @@ -87,17 +87,14 @@ class AsanTestCase(TestBase):          self.assertTrue(history_thread.num_frames >= 2)          self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c")          self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc) - -        # now let's break when an ASan report occurs and try the API then -        self.runCmd("breakpoint set -n __asan_report_error") - +         +        # ASan will break when a report occurs and we'll try the API then          self.runCmd("continue") -        # the stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', 'stop reason = breakpoint']) +        self.expect("thread list", "Process should be stopped due to ASan report", +            substrs = ['stopped', 'stop reason = Use of deallocated memory detected'])          # make sure the 'memory history' command still works even when we're generating a report now          self.expect("memory history 'another_pointer'",              substrs = [ -                'Memory allocated at', 'a.out`f1', 'main.c:%d' % self.line_malloc2]) +                'Memory allocated by Thread', 'a.out`f1', 'main.c:%d' % self.line_malloc2]) diff --git a/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py b/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py index 4ef587895196..b02732ddeddf 100644 --- a/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py +++ b/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py @@ -7,20 +7,20 @@ from __future__ import print_function  import os, time +import json  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil -import json +from lldbsuite.test import lldbutil  class AsanTestReportDataCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureLinux # non-core functionality, need to reenable and fix later (DES 2014.11.07) +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")      @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default      @skipIfRemote      @skipUnlessCompilerRt -    @expectedFailureDarwin      def test(self):          self.build ()          self.asan_tests () @@ -39,16 +39,10 @@ class AsanTestReportDataCase(TestBase):          self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ])          self.runCmd("run") -        # ASan will relaunch the process to insert its library. -        self.expect("thread list", "Process should be stopped due to exec.", -            substrs = ['stopped', 'stop reason = ']) - -        # no extended info when we have no ASan report -        thread = self.dbg.GetSelectedTarget().process.GetSelectedThread() -        s = lldb.SBStream() -        self.assertFalse(thread.GetStopReasonExtendedInfoAsJSON(s)) - -        self.runCmd("continue") +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue")          self.expect("thread list", "Process should be stopped due to ASan report",              substrs = ['stopped', 'stop reason = Use of deallocated memory detected']) @@ -62,7 +56,7 @@ class AsanTestReportDataCase(TestBase):              substrs = ["access_size", "access_type", "address", "pc", "description", "heap-use-after-free"])          output_lines = self.res.GetOutput().split('\n') -        json_line = output_lines[2] +        json_line = '\n'.join(output_lines[2:])          data = json.loads(json_line)          self.assertEqual(data["description"], "heap-use-after-free")          self.assertEqual(data["instrumentation_class"], "AddressSanitizer") diff --git a/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py b/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py index 693c0a70fd62..54463c56827a 100644 --- a/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py +++ b/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  exe_name = "AttachResume"  # Must match Makefile @@ -18,8 +19,8 @@ class AttachResumeTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @skipIfRemote -    @expectedFailureFreeBSD('llvm.org/pr19310') -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310') +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_attach_continue_interrupt_detach(self):          """Test attach/continue/interrupt/detach"""          self.build() @@ -37,19 +38,20 @@ class AttachResumeTestCase(TestBase):          self.setAsync(True)          listener = self.dbg.GetListener() +        process = self.dbg.GetSelectedTarget().GetProcess()          self.runCmd("c") -        lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])          self.runCmd("process interrupt") -        lldbutil.expect_state_changes(self, listener, [lldb.eStateStopped]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])          # be sure to continue/interrupt/continue (r204504)          self.runCmd("c") -        lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])          self.runCmd("process interrupt") -        lldbutil.expect_state_changes(self, listener, [lldb.eStateStopped]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])          # Second interrupt should have no effect.          self.expect("process interrupt", patterns=["Process is not running"], error=True) @@ -58,7 +60,7 @@ class AttachResumeTestCase(TestBase):          self.runCmd("br set -f main.cpp -l %u" % (line_number('main.cpp', '// Set breakpoint here')))          self.runCmd("c") -        lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning, lldb.eStateStopped]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning, lldb.eStateStopped])          self.expect('br list', 'Breakpoint not hit',              substrs = ['hit count = 1']) @@ -66,8 +68,8 @@ class AttachResumeTestCase(TestBase):          self.expect("expr debugger_flag = false", substrs=[" = false"]);          self.runCmd("c") -        lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])          # make sure to detach while in running state (r204759)          self.runCmd("detach") -        lldbutil.expect_state_changes(self, listener, [lldb.eStateDetached]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateDetached]) 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 e4bc08711f4c..e31eac48ad7a 100644 --- a/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py +++ b/packages/Python/lldbsuite/test/functionalities/avoids-fd-leak/TestFdLeak.py @@ -8,29 +8,34 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test import lldbutil  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  def python_leaky_fd_version(test):      import sys      # Python random module leaks file descriptors on some versions. -    return sys.version_info >= (2, 7, 8) and sys.version_info < (2, 7, 10) +    if sys.version_info >= (2, 7, 8) and sys.version_info < (2, 7, 10): +        return "Python random module leaks file descriptors in this python version" +    return None  class AvoidsFdLeakTestCase(TestBase): +    NO_DEBUG_INFO_TESTCASE = True +      mydir = TestBase.compute_mydir(__file__)      @expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376") -    @expectedFailureFreeBSD("llvm.org/pr25624 still failing with Python 2.7.10") +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")      @skipIfWindows # The check for descriptor leakage needs to be implemented differently here.      @skipIfTargetAndroid() # Android have some other file descriptors open by the shell      def test_fd_leak_basic (self):          self.do_test([])      @expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376") -    @expectedFailureFreeBSD("llvm.org/pr25624 still failing with Python 2.7.10") +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")      @skipIfWindows # The check for descriptor leakage needs to be implemented differently here.      @skipIfTargetAndroid() # Android have some other file descriptors open by the shell      def test_fd_leak_log (self): @@ -53,8 +58,7 @@ class AvoidsFdLeakTestCase(TestBase):                  "Process returned non-zero status. Were incorrect file descriptors passed?")      @expectedFailure(python_leaky_fd_version, "bugs.freebsd.org/197376") -    @expectedFailureFreeBSD("llvm.org/pr25624 still failing with Python 2.7.10") -    @expectedFlakeyLinux +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25624 still failing with Python 2.7.10")      @skipIfWindows # The check for descriptor leakage needs to be implemented differently here.      @skipIfTargetAndroid() # Android have some other file descriptors open by the shell      def test_fd_leak_multitarget (self): diff --git a/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py b/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py index d31412bc783c..851e4d376b38 100644 --- a/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py +++ b/packages/Python/lldbsuite/test/functionalities/backticks/TestBackticksWithoutATarget.py @@ -8,7 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class BackticksWithNoTargetTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py new file mode 100644 index 000000000000..73b3ef5eae28 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py @@ -0,0 +1,77 @@ +""" +Test that breakpoints set on a bad address say they are bad. +""" + +from __future__ import print_function + + + +import os, time +import re +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + +class BadAddressBreakpointTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def test_bad_address_breakpoints (self): +        """Test that breakpoints set on a bad address say they are bad.""" +        self.build() +        self.address_breakpoints() + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) + +    def address_breakpoints(self): +        """Test that breakpoints set on a bad address say they are bad.""" +        exe = os.path.join(os.getcwd(), "a.out") + +        # Create a target by the debugger. +        target = self.dbg.CreateTarget(exe) +        self.assertTrue(target, VALID_TARGET) + +        # Now create a breakpoint on main.c by name 'c'. +        breakpoint = target.BreakpointCreateBySourceRegex("Set a breakpoint here", lldb.SBFileSpec("main.c")) +        self.assertTrue(breakpoint and +                        breakpoint.GetNumLocations() == 1, +                        VALID_BREAKPOINT) + +        # Get the breakpoint location from breakpoint after we verified that, +        # indeed, it has one location. +        location = breakpoint.GetLocationAtIndex(0) +        self.assertTrue(location and +                        location.IsEnabled(), +                        VALID_BREAKPOINT_LOCATION) + +        launch_info = lldb.SBLaunchInfo(None) +         +        error = lldb.SBError() + +        process = target.Launch (launch_info, error) +        self.assertTrue(process, PROCESS_IS_VALID) + +        # Did we hit our breakpoint? +        from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint  +        threads = get_threads_stopped_at_breakpoint (process, breakpoint) +        self.assertTrue(len(threads) == 1, "There should be a thread stopped at our breakpoint") + +        # The hit count for the breakpoint should be 1. +        self.assertTrue(breakpoint.GetHitCount() == 1) + +        # 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.Clear() + +        ptr = process.ReadPointerFromMemory(0x0, error) + +        if not error.Success(): +            bkpt = target.BreakpointCreateByAddress(0x0) +            for bp_loc in bkpt: +                self.assertTrue(bp_loc.IsResolved() == False) +        else: +            self.fail("Could not find an illegal address at which to set a bad breakpoint.") +             +             diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile new file mode 100644 index 000000000000..6067ee45e984 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS += -std=c99 + +include $(LEVEL)/Makefile.rules 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 new file mode 100644 index 000000000000..aa4ee14ffc5a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py @@ -0,0 +1,121 @@ +""" +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(oslist=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(oslist=['windows']) # Skip for windows platforms +    @expectedFailureAll() # Failing for unknown reason on non-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 = self.get_process_working_directory(); +                 +        # 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 and location.IsEnabled(), +                    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 new file mode 100644 index 000000000000..281ddfe7ef67 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/main.c @@ -0,0 +1,8 @@ +#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 8cf7539432ba..78d14b7d7705 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class BreakpointCommandTestCase(TestBase): @@ -21,7 +22,7 @@ class BreakpointCommandTestCase(TestBase):          cls.RemoveTempFile("output.txt")          cls.RemoveTempFile("output2.txt") -    @expectedFailureWindows("llvm.org/pr24528") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")      def test(self):          """Test a sequence of breakpoint command add, list, and delete."""          self.build() @@ -142,7 +143,7 @@ class BreakpointCommandTestCase(TestBase):          self.expect("breakpoint command list 1",              startstr = "Breakpoint 1 does not have an associated command.")          self.expect("breakpoint command list 2", error=True, -            startstr = "error: '2' is not a currently valid breakpoint id.") +            startstr = "error: '2' is not a currently valid breakpoint ID.")          # The breakpoint list now only contains breakpoint 1.          self.expect("breakpoint list -f", "Breakpoint 1 exists", 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 7a9cc744d528..4f8ab9e115de 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py @@ -8,10 +8,11 @@ from __future__ import print_function  import os  import re -import lldb -import lldbsuite.test.lldbutil as lldbutil  import sys +import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class PythonBreakpointCommandSettingTestCase(TestBase): 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 8c22c8fe869c..0d34dd85dc50 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class BreakpointConditionsTestCase(TestBase): @@ -107,11 +108,13 @@ class BreakpointConditionsTestCase(TestBase):          if arch in ['x86_64', 'i386']:              self.runCmd("breakpoint modify -c ($eax&&i)")          elif arch in ['aarch64']: -            self.runCmd("breakpoint modify -c ($x1&&i)") +            self.runCmd("breakpoint modify -c ($x0&&i)")          elif arch in ['arm']:              self.runCmd("breakpoint modify -c ($r0&&i)")          elif re.match("mips",arch):              self.runCmd("breakpoint modify -c ($r2&&i)") +        elif arch in ['s390x']: +            self.runCmd("breakpoint modify -c ($r2&&i)")          self.runCmd("run")          self.expect("process status", PROCESS_STOPPED, @@ -178,4 +181,8 @@ class BreakpointConditionsTestCase(TestBase):          # The hit count for the breakpoint should be 1.          self.assertTrue(breakpoint.GetHitCount() == 1) +        # Test that the condition expression didn't create a result variable: +        options = lldb.SBExpressionOptions() +        value = frame0.EvaluateExpression("$0", options) +        self.assertTrue(value.GetError().Fail(), "Conditions should not make result variables.")          process.Continue() 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 8a83cb627f7a..05ef1c6d94c7 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 @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class BreakpointIgnoreCountTestCase(TestBase): 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 324401ff44e1..b1e0d3deeae7 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 @@ -8,14 +8,15 @@ import os, time  import re  import unittest2  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class AvoidBreakpointInDelaySlotAPITestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipUnlessArch(archs=re.compile('mips*')) +    @skipIf(archs=no_match(re.compile('mips*')))      def test(self):          self.build()          exe = os.path.join(os.getcwd(), "a.out") 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 5c4dc219a106..707b6502e91c 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py @@ -8,15 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class BreakpointLocationsTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureWindows("llvm.org/pr24528") -    @expectedFailureAll(oslist=["linux"], compiler="clang", compiler_version=["=", "3.8"], archs=["i386"], debug_info="dwo") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")      def test(self):          """Test breakpoint enable/disable for a breakpoint ID with multiple locations."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile new file mode 100644 index 000000000000..314f1cb2f077 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules 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 new file mode 100644 index 000000000000..4ca93765b656 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py @@ -0,0 +1,43 @@ +""" +Test inferior restart when breakpoint is set on running target. +""" + +import os +import lldb +from lldbsuite.test.lldbtest import * + +class BreakpointSetRestart(TestBase): + +    mydir = TestBase.compute_mydir(__file__) +    BREAKPOINT_TEXT = 'Set a breakpoint here' + +    def test_breakpoint_set_restart(self): +        self.build() + +        cwd = os.getcwd() +        exe = os.path.join(cwd, 'a.out') +         +        target = self.dbg.CreateTarget(exe) +        self.assertTrue(target, VALID_TARGET) + +        self.dbg.SetAsync(True) +        process = target.LaunchSimple(None, None, self.get_process_working_directory()) +        self.assertTrue(process, PROCESS_IS_VALID) + +        event = lldb.SBEvent() +        # Wait for inferior to transition to running state +        while self.dbg.GetListener().WaitForEvent(2, event): +            if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning: +                break +         +        bp = target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT, +                                                  lldb.SBFileSpec(os.path.join(cwd, 'main.cpp'))) +        self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1, VALID_BREAKPOINT) + +        while self.dbg.GetListener().WaitForEvent(2, event): +            if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event): +                continue +            if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning: +                continue +            self.fail("Setting a breakpoint generated an unexpected event: %s" % lldb.SBDebugger.StateAsCString(lldb.SBProcess.GetStateFromEvent(event))) + diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp new file mode 100644 index 000000000000..e6d3a95d017f --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_set_restart/main.cpp @@ -0,0 +1,25 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <chrono> +#include <stdio.h> +#include <thread> + + +int main(int argc, char const *argv[]) +{ +    static bool done = false; +    while (!done) +    { +      std::this_thread::sleep_for(std::chrono::milliseconds{100}); +    } +    printf("Set a breakpoint here.\n"); +    return 0; +} + 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 e1de38bcad8c..4933d6d01d44 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 @@ -6,10 +6,11 @@ from __future__ import print_function  import os +import shutil  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil -import shutil +from lldbsuite.test import lldbutil  _EXE_NAME = 'CompDirSymLink'  # Must match Makefile @@ -27,21 +28,21 @@ class CompDirSymLinkTestCase(TestBase):          self.line = line_number(_SRC_FILE, '// Set break point at this line.')          self.src_path = os.path.join(os.getcwd(), _SRC_FILE) -    @skipIfHostWindows +    @skipIf(hostoslist=["windows"])      def test_symlink_paths_set(self):          pwd_symlink = self.create_src_symlink()          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) -    @skipUnlessHostLinux +    @skipIf(hostoslist=no_match(["linux"]))      def test_symlink_paths_set_procselfcwd(self):          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) -    @skipIfHostWindows +    @skipIf(hostoslist=["windows"])      def test_symlink_paths_unset(self):          pwd_symlink = self.create_src_symlink()          self.doBuild(pwd_symlink) diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py deleted file mode 100644 index af6df3764829..000000000000 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py +++ /dev/null @@ -1,59 +0,0 @@ -""" -Test continue from a breakpoint when there is a breakpoint on the next instruction also. -""" - -from __future__ import print_function - - - -import unittest2 -import lldb -import lldbsuite.test.lldbutil as lldbutil -from lldbsuite.test.lldbtest import * - -class ConsecutiveBreakpoitsTestCase(TestBase): - -    mydir = TestBase.compute_mydir(__file__) - -    @expectedFailureAll("llvm.org/pr23478", oslist = not_in(["macosx"])) -    def test (self): -        self.build () -        self.consecutive_breakpoints_tests() -         -    def consecutive_breakpoints_tests(self): -        exe = os.path.join (os.getcwd(), "a.out") - -        # Create a target by the debugger. -        target = self.dbg.CreateTarget(exe) -        self.assertTrue(target, VALID_TARGET) - -        breakpoint = target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp")) -        self.assertTrue(breakpoint and -                        breakpoint.GetNumLocations() == 1, -                        VALID_BREAKPOINT) - -        # Now launch the process, and do not stop at entry point. -        process = target.LaunchSimple (None, None, self.get_process_working_directory()) -        self.assertTrue(process, PROCESS_IS_VALID) - -        # We should be stopped at the first breakpoint -        thread = process.GetThreadAtIndex(0) -        self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint) - -        # Set breakpoint to the next instruction -        frame = thread.GetFrameAtIndex(0) -         -        address = frame.GetPCAddress() -        instructions = target.ReadInstructions(address, 2) -        self.assertTrue(len(instructions) == 2) -        address = instructions[1].GetAddress() -         -        target.BreakpointCreateByAddress(address.GetLoadAddress(target)) -        process.Continue() - -        # We should be stopped at the second breakpoint -        thread = process.GetThreadAtIndex(0) -        self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint) - -        # Run the process until termination -        process.Continue() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/Makefile index f89b52a972e9..f89b52a972e9 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/Makefile diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py new file mode 100644 index 000000000000..472479391c02 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py @@ -0,0 +1,101 @@ +""" +Test that we handle breakpoints on consecutive instructions correctly. +""" + +from __future__ import print_function + + + +import unittest2 +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class ConsecutiveBreakpointsTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def prepare_test(self): +        self.build() +        exe = os.path.join (os.getcwd(), "a.out") + +        # Create a target by the debugger. +        self.target = self.dbg.CreateTarget(exe) +        self.assertTrue(self.target, VALID_TARGET) + +        breakpoint1 = self.target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp")) +        self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, 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.assertIsNotNone(self.process, PROCESS_IS_VALID) + +        # We should be stopped at the first breakpoint +        self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, breakpoint1) +        self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 1") + +        # Set breakpoint to the next instruction +        frame = self.thread.GetFrameAtIndex(0) + +        address = frame.GetPCAddress() +        instructions = self.target.ReadInstructions(address, 2) +        self.assertTrue(len(instructions) == 2) +        self.bkpt_address = instructions[1].GetAddress() +        self.breakpoint2 = self.target.BreakpointCreateByAddress(self.bkpt_address.GetLoadAddress(self.target)) +        self.assertTrue(self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT) + +    def finish_test(self): +        # Run the process until termination +        self.process.Continue() +        self.assertEquals(self.process.GetState(), lldb.eStateExited) + +    @no_debug_info_test +    def test_continue(self): +        """Test that continue stops at the second breakpoint.""" +        self.prepare_test() + +        self.process.Continue() +        self.assertEquals(self.process.GetState(), lldb.eStateStopped) +        # We should be stopped at the second breakpoint +        self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2) +        self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2") + +        self.finish_test() + +    @no_debug_info_test +    def test_single_step(self): +        """Test that single step stops at the second breakpoint.""" +        self.prepare_test() + +        step_over = False +        self.thread.StepInstruction(step_over) + +        self.assertEquals(self.process.GetState(), lldb.eStateStopped) +        self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target), +                self.bkpt_address.GetLoadAddress(self.target)) +        self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2) +        self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2") + +        self.finish_test() + +    @no_debug_info_test +    def test_single_step_thread_specific(self): +        """Test that single step stops, even though the second breakpoint is not valid.""" +        self.prepare_test() + +        # Choose a thread other than the current one. A non-existing thread is fine. +        thread_index = self.process.GetNumThreads()+1 +        self.assertFalse(self.process.GetThreadAtIndex(thread_index).IsValid()) +        self.breakpoint2.SetThreadIndex(thread_index) + +        step_over = False +        self.thread.StepInstruction(step_over) + +        self.assertEquals(self.process.GetState(), lldb.eStateStopped) +        self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target), +                self.bkpt_address.GetLoadAddress(self.target)) +        self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete, +                "Stop reason should be 'plan complete'") + +        self.finish_test() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp index c1943f03dbf1..c1943f03dbf1 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/main.cpp diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py index dea206b9e9d2..c2aa597214ed 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py @@ -8,14 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class TestCPPBreakpointLocations(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureWindows("llvm.org/pr24764") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")      def test (self):          self.build ()          self.breakpoint_id_tests () @@ -25,7 +26,7 @@ class TestCPPBreakpointLocations(TestBase):          name = bp_dict['name']          names = bp_dict['loc_names']          bp = target.BreakpointCreateByName (name) -        self.assertTrue (bp.GetNumLocations() == len(names), "Make sure we find the right number of breakpoint locations") +        self.assertEquals(bp.GetNumLocations(), len(names), "Make sure we find the right number of breakpoint locations")          bp_loc_names = list()          for bp_loc in bp: @@ -60,3 +61,35 @@ class TestCPPBreakpointLocations(TestBase):          for bp_dict in bp_dicts:              self.verify_breakpoint_locations(target, bp_dict) + +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") +    def test_destructors(self): +        self.build() +        exe = os.path.join(os.getcwd(), "a.out") +        target = self.dbg.CreateTarget(exe) + +        # Don't skip prologue, so we can check the breakpoint address more easily +        self.runCmd("settings set target.skip-prologue false") +        try: +            names = ['~c', 'c::~c', 'c::~c()'] +            loc_names = {'a::c::~c()', 'b::c::~c()'} +            # TODO: For windows targets we should put windows mangled names here +            symbols = ['_ZN1a1cD1Ev', '_ZN1a1cD2Ev', '_ZN1b1cD1Ev', '_ZN1b1cD2Ev'] + +            for name in names: +                bp = target.BreakpointCreateByName(name) + +                bp_loc_names = { bp_loc.GetAddress().GetFunction().GetName() for bp_loc in bp } +                self.assertEquals(bp_loc_names, loc_names, "Breakpoint set on the correct symbol") + +                bp_addresses = { bp_loc.GetLoadAddress() for bp_loc in bp } +                symbol_addresses = set() +                for symbol in symbols: +                    sc_list = target.FindSymbols(symbol, lldb.eSymbolTypeCode) +                    self.assertEquals(sc_list.GetSize(), 1, "Found symbol " + symbol) +                    symbol = sc_list.GetContextAtIndex(0).GetSymbol() +                    symbol_addresses.add(symbol.GetStartAddress().GetLoadAddress(target)) + +                self.assertEquals(symbol_addresses, bp_addresses, "Breakpoint set on correct address") +        finally: +            self.runCmd("settings clear target.skip-prologue") diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp index ef582aa36ebb..01f679139249 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp/main.cpp @@ -12,8 +12,8 @@  namespace a {      class c {      public: -        c () {} -        ~c() {} +        c(); +        ~c();          void func1()           {              puts (__PRETTY_FUNCTION__); @@ -27,13 +27,16 @@ namespace a {              puts (__PRETTY_FUNCTION__);          }      }; + +    c::c() {} +    c::~c() {}  }  namespace b {      class c {      public: -        c () {} -        ~c() {} +        c(); +        ~c();          void func1()           {              puts (__PRETTY_FUNCTION__); @@ -43,6 +46,9 @@ namespace b {              puts (__PRETTY_FUNCTION__);          }      }; + +    c::c() {} +    c::~c() {}  }  namespace c { 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 f7a19098b492..2aac3a9600d3 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/cpp_exception/TestCPPExceptionBreakpoint.py @@ -8,10 +8,11 @@ from __future__ import print_function  import os  import re -import lldb -import lldbsuite.test.lldbutil as lldbutil  import sys +import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class TestCPPExceptionBreakpoint (TestBase): @@ -19,7 +20,7 @@ class TestCPPExceptionBreakpoint (TestBase):      my_var = 10      @add_test_categories(['pyapi']) -    @expectedFailureWindows("llvm.org/pr24538") # clang-cl does not support throw or catch +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538")      def test_cpp_exception_breakpoint(self):          """Test setting and hitting the C++ exception breakpoint."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py index b32c970301c9..de61f9e88f1b 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py @@ -6,14 +6,15 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DebugBreakTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipIf(archs=not_in(["i386", "i686"])) +    @skipIf(archs=no_match(["i386", "i686", "x86_64"]))      @no_debug_info_test      def test_asm_int_3(self):          """Test that intrinsics like `__debugbreak();` and `asm {"int3"}` are treated like breakpoints.""" @@ -26,13 +27,15 @@ class DebugBreakTestCase(TestBase):          # We've hit the first stop, so grab the frame.          self.assertEqual(process.GetState(), lldb.eStateStopped) -        thread = process.GetThreadAtIndex(0) +        stop_reason = lldb.eStopReasonException if (lldbplatformutil.getPlatform()=="windows" or lldbplatformutil.getPlatform()=="macosx") else lldb.eStopReasonSignal +        thread = lldbutil.get_stopped_thread(process, stop_reason) +        self.assertIsNotNone(thread, "Unable to find thread stopped at the __debugbreak()")          frame = thread.GetFrameAtIndex(0)          # We should be in funciton 'bar'.          self.assertTrue(frame.IsValid())          function_name = frame.GetFunctionName() -        self.assertTrue('bar' in function_name) +        self.assertTrue('bar' in function_name, "Unexpected function name {}".format(function_name))          # We should be able to evaluate the parameter foo.          value = frame.EvaluateExpression('*foo') diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py index 648a0f5ea07c..c48cee1bd2b2 100644 --- a/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/objc/TestObjCBreakpoints.py @@ -8,11 +8,12 @@ from __future__ import print_function  import os, time -import lldb -from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil  import shutil  import subprocess +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  @skipUnlessDarwin  class TestObjCBreakpoints(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/Makefile new file mode 100644 index 000000000000..ac984f101c18 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c a.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py new file mode 100644 index 000000000000..81cab927d214 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/TestSourceRegexBreakpoints.py @@ -0,0 +1,100 @@ +""" +Test lldb breakpoint setting by source regular expression. +This test just tests the source file & function restrictions. +""" + +from __future__ import print_function + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestSourceRegexBreakpoints(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def test_location (self): +        self.build() +        self.source_regex_locations() + +    def test_restrictions (self): +        self.build () +        self.source_regex_restrictions () + + +    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") +        target = self.dbg.CreateTarget(exe) +        self.assertTrue(target, VALID_TARGET) + +        # First look just in main: +        target_files = lldb.SBFileSpecList() +        target_files.Append(lldb.SBFileSpec("a.c")) + +        func_names = lldb.SBStringList() +        func_names.AppendString("a_func") + +        source_regex = "Set . breakpoint here" +        main_break = target.BreakpointCreateBySourceRegex (source_regex, +                                                           lldb.SBFileSpecList(), +                                                           target_files, +                                                           func_names) +        num_locations = main_break.GetNumLocations() +        self.assertTrue(num_locations == 1, "a.c in a_func should give one breakpoint, got %d."%(num_locations)) + +        loc = main_break.GetLocationAtIndex(0) +        self.assertTrue(loc.IsValid(), "Got a valid location.") +        address = loc.GetAddress() +        self.assertTrue(address.IsValid(), "Got a valid address from the location.") +         +        a_func_line = line_number("a.c", "Set A breakpoint here") +        line_entry = address.GetLineEntry() +        self.assertTrue(line_entry.IsValid(), "Got a valid line entry.") +        self.assertTrue(line_entry.line == a_func_line, "Our line number matches the one lldbtest found.") + +    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") +        target = self.dbg.CreateTarget(exe) +        self.assertTrue(target, VALID_TARGET) + +        # First look just in main: +        target_files = lldb.SBFileSpecList() +        target_files.Append(lldb.SBFileSpec("main.c")) +        source_regex = "Set . breakpoint here" +        main_break = target.BreakpointCreateBySourceRegex (source_regex, +                                                           lldb.SBFileSpecList(), +                                                           target_files, +                                                           lldb.SBStringList()) + +        num_locations = main_break.GetNumLocations() +        self.assertTrue(num_locations == 2, "main.c should have 2 matches, got %d."%(num_locations)) + +        # Now look in both files: +        target_files.Append(lldb.SBFileSpec("a.c")) + +        main_break = target.BreakpointCreateBySourceRegex (source_regex, +                                                           lldb.SBFileSpecList(), +                                                           target_files, +                                                           lldb.SBStringList()) + +        num_locations =main_break.GetNumLocations() +        self.assertTrue(num_locations == 4, "main.c and a.c should have 4 matches, got %d."%(num_locations)) + +        # Now restrict it to functions: +        func_names = lldb.SBStringList() +        func_names.AppendString("main_func") +        main_break = target.BreakpointCreateBySourceRegex (source_regex, +                                                           lldb.SBFileSpecList(), +                                                           target_files, +                                                           func_names) + +        num_locations =main_break.GetNumLocations() +        self.assertTrue(num_locations == 2, "main_func in main.c and a.c should have 2 matches, got %d."%(num_locations)) + + diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.c new file mode 100644 index 000000000000..056583f1c42c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +#include "a.h" + +static int +main_func(int input) +{ +  return printf("Set B breakpoint here: %d", input); +} + +int +a_func(int input) +{ +  input += 1; // Set A breakpoint here; +  return main_func(input); +} diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.h b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.h new file mode 100644 index 000000000000..f578ac0304cd --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/a.h @@ -0,0 +1 @@ +int a_func(int); diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/main.c new file mode 100644 index 000000000000..9c8625e877f5 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/source_regexp/main.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include "a.h" + +int +main_func(int input) +{ +  return printf("Set B breakpoint here: %d.\n", input); +} + +int +main() +{ +  a_func(10); +  main_func(10); +  printf("Set a breakpoint here:\n"); +  return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py b/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py index 312c91517f98..66ba8d07622d 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py +++ b/packages/Python/lldbsuite/test/functionalities/command_history/TestCommandHistory.py @@ -8,7 +8,9 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class CommandHistoryTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py b/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py index 2c48efa863b4..5b680ec65de5 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py +++ b/packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py @@ -8,13 +8,15 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class CommandRegexTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureHostWindows("llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")      @no_debug_info_test      def test_command_regex(self):          """Test a simple scenario of 'command regex' invocation and subsequent use.""" diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py index 542ee7a1e5f3..97e52231e818 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py @@ -87,8 +87,8 @@ class CmdPythonTestCase(TestBase):                         'For more information run'])          self.expect("help targetname", -                    substrs = ['This', 'command', 'takes', '\'raw\'', 'input', -                               'quote', 'stuff']) +                    substrs = ['Expects', '\'raw\'', 'input', +                               'help', 'raw-input'])          self.expect("longwait",                      substrs = ['Done; if you saw the delays I am doing OK']) diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py index 691045ae82ed..01c3f35bf300 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py @@ -6,7 +6,9 @@ from __future__ import print_function  import os, sys, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ImportTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py index 9800a08c06de..4f7ebebd4dd2 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py @@ -6,7 +6,9 @@ from __future__ import print_function  import os, sys, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class Rdar12586188TestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py index faa4e3b0cbff..1181462af868 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py @@ -1,5 +1,7 @@ -import TPunitA -import TPunitB +from __future__ import absolute_import + +from . import TPunitA +from . import TPunitB  def __lldb_init_module(debugger,*args):  	debugger.HandleCommand("command script add -f thepackage.TPunitA.command TPcommandA") diff --git a/packages/Python/lldbsuite/test/functionalities/command_script_alias/.categories b/packages/Python/lldbsuite/test/functionalities/command_script_alias/.categories new file mode 100644 index 000000000000..3a3f4df6416b --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/command_script_alias/.categories @@ -0,0 +1 @@ +cmdline diff --git a/packages/Python/lldbsuite/test/functionalities/command_script_alias/TestCommandScriptAlias.py b/packages/Python/lldbsuite/test/functionalities/command_script_alias/TestCommandScriptAlias.py new file mode 100644 index 000000000000..694728a9f9c0 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/command_script_alias/TestCommandScriptAlias.py @@ -0,0 +1,37 @@ +""" +Test lldb Python commands. +""" + +from __future__ import print_function + + +import os, time +import lldb +from lldbsuite.test.lldbtest import * + +class CommandScriptAliasTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def test (self): +        self.pycmd_tests () + +    def pycmd_tests (self): +        self.runCmd("command script import tcsacmd.py") +        self.runCmd("command script add -f tcsacmd.some_command_here attach") + +        # This is the function to remove the custom commands in order to have a +        # clean slate for the next test case. +        def cleanup(): +            self.runCmd('command script delete attach', check=False) + +        # Execute the cleanup function during test case tear down. +        self.addTearDownHook(cleanup) + +        # We don't want to display the stdout if not in TraceOn() mode. +        if not self.TraceOn(): +            self.HideStdout() + +        self.expect('attach a', substrs = ['Victory is mine']); +        self.runCmd("command script delete attach") +        self.runCmd('attach noprocessexistswiththisname', check=False) # this can't crash but we don't care whether the actual attach works diff --git a/packages/Python/lldbsuite/test/functionalities/command_script_alias/tcsacmd.py b/packages/Python/lldbsuite/test/functionalities/command_script_alias/tcsacmd.py new file mode 100644 index 000000000000..6c60e3ca1a55 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/command_script_alias/tcsacmd.py @@ -0,0 +1,11 @@ +from __future__ import print_function +import lldb, sys + +def some_command_here(debugger, command, result, d): +  if command == "a": +    print("Victory is mine", file=result) +    return True +  else: +    print("Sadness for all", file=result) +    return False + 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 new file mode 100644 index 000000000000..a843d08a97d4 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py @@ -0,0 +1,86 @@ +""" +Test that LLDB correctly allows scripted commands to set an immediate output file +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test.lldbpexpect import * +from lldbsuite.test import lldbutil + +class CommandScriptImmediateOutputTestCase (PExpectTest): + +    mydir = TestBase.compute_mydir(__file__) +    NO_DEBUG_INFO_TESTCASE = True + +    def setUp(self): +        # Call super's setUp(). +        PExpectTest.setUp(self) + +    @skipIfRemote # test not remote-ready llvm.org/pr24813 +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139") +    def test_command_script_immediate_output_console (self): +        """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') +        prompt = "\(lldb\) " + +        self.sendline('command script import %s' % script, patterns=[prompt]) +        self.sendline('command script add -f custom_command.command_function mycommand', patterns=[prompt]) +        self.sendline('mycommand', patterns='this is a test string, just a test string') +        self.sendline('command script delete mycommand', patterns=[prompt]) +        self.quit(gracefully=False) + +    @skipIfRemote # test not remote-ready llvm.org/pr24813 +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr26139") +    def test_command_script_immediate_output_file (self): +        """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+'} + +        starter_string = 'Starter Garbage\n' +        write_string   = 'writing to file with mode: ' + +        for path, mode in test_files.iteritems(): +            with open(path, 'w+') as init: +                init.write(starter_string) + +        script = os.path.join(os.getcwd(), 'custom_command.py') +        prompt = "\(lldb\) " + +        self.sendline('command script import %s' % script, patterns=[prompt]) + +        self.sendline('command script add -f custom_command.write_file mywrite', patterns=[prompt]) +        for path, mode in test_files.iteritems(): +            command = 'mywrite "' + path + '" ' + mode + +            self.sendline(command, patterns=[prompt]) + +        self.sendline('command script delete mywrite', patterns=[prompt]) + +        self.quit(gracefully=False) + +        for path, mode in test_files.iteritems(): +            with open(path, 'r') as result: +                if mode in ['r', 'a', 'a+']: +                    self.assertEquals(result.readline(), starter_string) +                if mode in ['w', 'w+', 'r+', 'a', 'a+']: +                    self.assertEquals(result.readline(), write_string + mode + '\n') + +            self.assertTrue(os.path.isfile(path)) +            os.remove(path) + diff --git a/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py b/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py new file mode 100644 index 000000000000..30a3cfb9093c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/custom_command.py @@ -0,0 +1,17 @@ +from __future__ import print_function + +import sys +import shlex + +def command_function(debugger, command, exe_ctx, result, internal_dict): +        result.SetImmediateOutputFile(sys.__stdout__) +        print('this is a test string, just a test string', file=result) + +def write_file(debugger, command, exe_ctx, result, internal_dict): +        args = shlex.split(command) +        path = args[0] +        mode = args[1] +        with open(path, mode) as f: +            result.SetImmediateOutputFile(f) +            if not mode in ['r']: +                print('writing to file with mode: ' + mode, file=result) diff --git a/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py b/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py index 013803e698af..0d4eb0776e79 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py +++ b/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py @@ -10,7 +10,9 @@ from __future__ import print_function  import os, sys  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class CommandSourceTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py b/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py index d7aab03c0830..7a9ded03ad20 100644 --- a/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py +++ b/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py @@ -8,7 +8,10 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbplatform +from lldbsuite.test import lldbutil  class CommandLineCompletionTestCase(TestBase): @@ -23,21 +26,21 @@ class CommandLineCompletionTestCase(TestBase):          except:              pass -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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): @@ -45,7 +48,7 @@ class CommandLineCompletionTestCase(TestBase):          self.complete_from_to('process attach --con', 'process attach --continue ')      # <rdar://problem/11052829> -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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): @@ -53,147 +56,147 @@ class CommandLineCompletionTestCase(TestBase):          self.complete_from_to('process print hello\\', 'process print hello\\',                                turn_off_re_match=True) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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']."""          self.complete_from_to('watchpoint command ', ['Available completions:', 'add', 'delete', 'list']) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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']) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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']."""          self.complete_from_to('help fi', ['Available completions:', 'file', 'finish']) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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']."""          self.complete_from_to('settings s', ['Available completions:', 'set', 'show']) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 th' completes to 'settings set thread-format'."""          self.complete_from_to('settings set th', 'settings set thread-format') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 th' completes to 'settings clear thread-format'."""          self.complete_from_to('settings clear th', 'settings clear thread-format') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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-') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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): @@ -204,21 +207,21 @@ class CommandLineCompletionTestCase(TestBase):                                 'target.prefer-dynamic-value',                                 'target.process.']) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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.') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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.') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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): @@ -229,7 +232,7 @@ class CommandLineCompletionTestCase(TestBase):                                 'target.process.thread.step-avoid-regexp',                                 'target.process.thread.trace-thread']) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679")      @skipIfFreeBSD # timing out on the FreeBSD buildbot      @no_debug_info_test      def test_target_space(self): @@ -239,22 +242,22 @@ class CommandLineCompletionTestCase(TestBase):                                ['Available completions:', 'create', 'delete', 'list',                                 'modules', 'select', 'stop-hook', 'variable']) -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") +    @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 ') -    @expectedFailureHostWindows("llvm.org/pr24679") -    @expectedFailureDarwin("llvm.org/pr25485") +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr24679") +    @expectedFailureAll(oslist=lldbplatform.darwin_all, bugnumber="llvm.org/pr25485")      def test_symbol_name(self):          self.build()          self.complete_from_to('''file a.out diff --git a/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py b/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py index 3ae7a20b4c7d..7fcb44f0b3ec 100644 --- a/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py +++ b/packages/Python/lldbsuite/test/functionalities/conditional_break/TestConditionalBreak.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  # rdar://problem/8532131  # lldb not able to digest the clang-generated debug info correctly with respect to function name @@ -32,6 +33,7 @@ class ConditionalBreakTestCase(TestBase):          self.build()          self.simulate_conditional_break_by_user() +    @expectedFailureAll(oslist=["windows"], 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") @@ -64,7 +66,8 @@ class ConditionalBreakTestCase(TestBase):          for j in range(10):              if self.TraceOn():                  print("j is: ", j) -            thread = process.GetThreadAtIndex(0) +            thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) +            self.assertIsNotNone(thread, "Expected one thread to be stopped at the breakpoint")              if thread.GetNumFrames() >= 2:                  frame0 = thread.GetFrameAtIndex(0) @@ -82,8 +85,8 @@ class ConditionalBreakTestCase(TestBase):                      # And the local variable 'val' should have a value of (int) 3.                      val = frame1.FindVariable("val") -                    self.assertTrue(val.GetTypeName() == "int", "'val' has int type") -                    self.assertTrue(val.GetValue() == "3", "'val' has a value of 3") +                    self.assertEqual("int", val.GetTypeName()) +                    self.assertEqual("3", val.GetValue())                      break              process.Continue() 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 94cdfdfeb343..fb3511ebd91d 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/TestFormattersBoolRefPtr.py @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DataFormatterBoolRefPtr(TestBase): @@ -56,6 +57,8 @@ class DataFormatterBoolRefPtr(TestBase):                      substrs = ['YES'])          self.expect('frame variable no_ref',                      substrs = ['NO']) +        self.expect('frame variable unset_ref', +                    substrs = ['12'])          # Now check that we use the right summary for BOOL* @@ -63,6 +66,8 @@ class DataFormatterBoolRefPtr(TestBase):                      substrs = ['YES'])          self.expect('frame variable no_ptr',                      substrs = ['NO']) +        self.expect('frame variable unset_ptr', +                    substrs = ['12'])          # Now check that we use the right summary for BOOL @@ -70,3 +75,5 @@ class DataFormatterBoolRefPtr(TestBase):                      substrs = ['YES'])          self.expect('frame variable no',                      substrs = ['NO']) +        self.expect('frame variable unset', +                    substrs = ['12']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm index a2461fd9da91..22c8790a7541 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/boolreference/main.mm @@ -11,17 +11,19 @@  int main (int argc, const char * argv[])  { -          NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];  	BOOL yes  = YES;  	BOOL no = NO; +    BOOL unset = 12;  	BOOL &yes_ref = yes;  	BOOL &no_ref = no; +	BOOL &unset_ref = unset;  	BOOL* yes_ptr = &yes;  	BOOL* no_ptr = &no; +	BOOL* unset_ptr = &unset;      [pool drain];// Set break point at this line.      return 0; 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 7cd2a49b4717..914c5260ac24 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/compactvectors/TestCompactVectors.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class CompactVectorsFormattingTestCase(TestBase): 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 db426cac6e59..f8209f03d0c2 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class CategoriesDataFormatterTestCase(TestBase): @@ -154,6 +155,7 @@ class CategoriesDataFormatterTestCase(TestBase):          self.runCmd("type category enable Category1")          self.runCmd("type summary list -w Category1") +        self.expect("type summary list -w NoSuchCategoryHere", substrs=['no matching results found'])          self.expect("frame variable r1 r2 r3",                  substrs = ['r1 = Category1', 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 2ca737156a1a..99443a04f672 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class CppDataFormatterTestCase(TestBase): @@ -21,7 +22,7 @@ class CppDataFormatterTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// Set break point at this line.') -    @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462: Data formatters have problems on Windows")      def test_with_run_command(self):          """Test that that file and class static variables display correctly."""          self.build() 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 0f254a67d5a6..2c2e08431175 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DataFormatterDisablingTestCase(TestBase): @@ -21,7 +22,7 @@ class DataFormatterDisablingTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// Set break point at this line.') -    @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows")      def test_with_run_command(self):          """Check that we can properly disable all data formatter categories."""          self.build() @@ -61,6 +62,8 @@ class DataFormatterDisablingTestCase(TestBase):          self.expect('frame variable string1', matching=False, substrs = ['hello world']) +        self.expect('type summary list', substrs=['Category: system (disabled)']) +          self.expect('type category list', substrs = ['system','disabled',])          # now enable and check that we are back to normal 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 94df520d29b3..e9ac79ad08e2 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 @@ -48,7 +48,9 @@ class NamedSummariesDataFormatterTestCase(TestBase):          self.runCmd("type summary add --summary-string \"First: x=${var.x} y=${var.y} dummy=${var.dummy}\" First")          self.runCmd("type summary add --summary-string \"Second: x=${var.x} y=${var.y%hex}\" Second")          self.runCmd("type summary add --summary-string \"Third: x=${var.x} z=${var.z}\" Third") -                     +         +        self.expect('type summary list', substrs=['AllUseIt']) +                  self.expect("frame variable first",              substrs = ['First: x=12']) 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 e12ddca2eea7..d7d4118d1d6a 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 @@ -7,11 +7,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ObjCDataFormatterTestCase(TestBase): @@ -66,11 +67,6 @@ class ObjCDataFormatterTestCase(TestBase):          """Test formatters for NSException."""          self.appkit_tester_impl(self.nsexception_data_formatter_commands) -    @skipUnlessDarwin -    def test_nsmisc_with_run_command(self): -        """Test formatters for misc NS classes.""" -        self.appkit_tester_impl(self.nsmisc_data_formatter_commands) -      @skipUnlessDarwin      def test_nsdate_with_run_command(self): @@ -191,7 +187,7 @@ 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 num4 num5 num6 num7 num8_Y num8_N num9', +        self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num9',                      substrs = ['(NSNumber *) num1 = ',' (int)5',                      '(NSNumber *) num2 = ',' (float)3.1',                      '(NSNumber *) num3 = ',' (double)3.14', @@ -199,13 +195,8 @@ class ObjCDataFormatterTestCase(TestBase):                      '(NSNumber *) num5 = ',' (char)65',                      '(NSNumber *) num6 = ',' (long)255',                      '(NSNumber *) num7 = ','2000000', -                    '(NSNumber *) num8_Y = ',' @"1"', -                    '(NSNumber *) num8_N = ',' @"0"',                      '(NSNumber *) num9 = ',' (short)-31616']) -        self.expect('frame variable decimal_one', -                    substrs = ['(NSDecimalNumber *) decimal_one = 0x','1']) -          self.expect('frame variable num_at1 num_at2 num_at3 num_at4',                      substrs = ['(NSNumber *) num_at1 = ',' (int)12',                      '(NSNumber *) num_at2 = ',' (int)-12', @@ -213,26 +204,19 @@ class ObjCDataFormatterTestCase(TestBase):                      '(NSNumber *) num_at4 = ',' (double)-12.5'])      def nscontainers_data_formatter_commands(self): -        self.expect('frame variable newArray newDictionary newMutableDictionary cfdict_ref mutable_dict_ref cfarray_ref mutable_array_ref', +        self.expect('frame variable newArray newDictionary newMutableDictionary cfarray_ref mutable_array_ref',                      substrs = ['(NSArray *) newArray = ','@"50 elements"',                      '(NSDictionary *) newDictionary = ',' 12 key/value pairs',                      '(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs', -                    '(CFDictionaryRef) cfdict_ref = ','3 key/value pairs', -                    '(CFMutableDictionaryRef) mutable_dict_ref = ','12 key/value pairs',                      '(CFArrayRef) cfarray_ref = ','@"3 elements"',                      '(CFMutableArrayRef) mutable_array_ref = ','@"11 elements"']) -        self.expect('frame variable nscounted_set', -                    substrs = ['(NSCountedSet *) nscounted_set = ','5 elements']) -          self.expect('frame variable iset1 iset2 imset',                      substrs = ['4 indexes','512 indexes','10 indexes']) -        self.expect('frame variable mutable_bag_ref cfbag_ref binheap_ref', -                    substrs = ['(CFMutableBagRef) mutable_bag_ref = ','@"17 values"', -                    '(CFBagRef) cfbag_ref = ','@"15 values"', -                    '(CFBinaryHeapRef) binheap_ref = ','@"21 items"']) -                     +        self.expect('frame variable binheap_ref', +                    substrs = ['(CFBinaryHeapRef) binheap_ref = ','@"21 items"']) +          self.expect('expression -d run -- [NSArray new]', substrs=['@"0 elements"'])      def nsdata_data_formatter_commands(self): @@ -258,6 +242,9 @@ class ObjCDataFormatterTestCase(TestBase):          self.expect('frame variable nserror',                      substrs = ['domain: @"Foobar" - code: 12']) +        self.expect('frame variable nserrorptr', +                    substrs = ['domain: @"Foobar" - code: 12']) +          self.expect('frame variable nserror->_userInfo',                      substrs = ['2 key/value pairs']) @@ -272,24 +259,10 @@ class ObjCDataFormatterTestCase(TestBase):      def nsexception_data_formatter_commands(self):          self.expect('frame variable except0 except1 except2 except3', -                    substrs = ['(NSException *) except0 = ','name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"', -                    '(NSException *) except1 = ','name:@"TheGuyWhoHasNoName~1" reason:@"cuz it\'s funny"', -                    '(NSException *) except2 = ','name:@"TheGuyWhoHasNoName`2" reason:@"cuz it\'s funny"', -                    '(NSException *) except3 = ','name:@"TheGuyWhoHasNoName/3" reason:@"cuz it\'s funny"']) - -    def nsmisc_data_formatter_commands(self): -        self.expect('frame variable localhost', -                    substrs = ['<NSHost ','> localhost ((','"127.0.0.1"']) - -        if self.getArchitecture() in ['i386', 'x86_64']: -            self.expect('frame variable my_task', -                        substrs = ['<NS','Task: 0x']) - -        self.expect('frame variable range_value', -                    substrs = ['NSRange: {4, 4}']) - -        self.expect('frame variable port', -                    substrs = ['(NSMachPort *) port = ',' mach port: ']) +                    substrs = ['(NSException *) except0 = ','name: @"TheGuyWhoHasNoName" - reason: @"cuz it\'s funny"', +                    '(NSException *) except1 = ','name: @"TheGuyWhoHasNoName~1" - reason: @"cuz it\'s funny"', +                    '(NSException *) except2 = ','name: @"TheGuyWhoHasNoName`2" - reason: @"cuz it\'s funny"', +                    '(NSException *) except3 = ','name: @"TheGuyWhoHasNoName/3" - reason: @"cuz it\'s funny"'])      def nsdate_data_formatter_commands(self):          self.expect('frame variable date1 date2', @@ -298,16 +271,18 @@ class ObjCDataFormatterTestCase(TestBase):          # this test might fail if we hit the breakpoint late on December 31st of some given year          # and midnight comes between hitting the breakpoint and running this line of code          # hopefully the output will be revealing enough in that case :-) -        now_year = str(datetime.datetime.now().year) +        now_year = '%s-' % str(datetime.datetime.now().year) -        self.expect('frame variable date3 date4', -                    substrs = [now_year,'1970']) +        self.expect('frame variable date3', substrs = [now_year]) +        self.expect('frame variable date4', substrs = ['1970']) +        self.expect('frame variable date5', substrs = [now_year])          self.expect('frame variable date1_abs date2_abs',                      substrs = ['1985-04','2011-01']) -        self.expect('frame variable date3_abs date4_abs', -                    substrs = [now_year,'1970']) +        self.expect('frame variable date3_abs', substrs = [now_year]) +        self.expect('frame variable date4_abs', substrs = ['1970']) +        self.expect('frame variable date5_abs', substrs = [now_year])          self.expect('frame variable cupertino home europe',                      substrs = ['@"America/Los_Angeles"', @@ -385,7 +360,6 @@ class ObjCDataFormatterTestCase(TestBase):              self.runCmd('type format clear', check=False)              self.runCmd('type summary clear', check=False)              self.runCmd('type synth clear', check=False) -            self.runCmd('log timers disable', check=False)          # Execute the cleanup function during test case tear down. @@ -406,7 +380,6 @@ class ObjCDataFormatterTestCase(TestBase):           '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)',           '(Point) point = (v=7, h=12)',           '(Point *) point_ptr = (v=7, h=12)', -         'name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"',           '1985',           'foo_selector_impl']; 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 6eb7e021f70b..020e2fc6227a 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 @@ -415,41 +415,6 @@ int main (int argc, const char * argv[])  	    CFStringRef cfstring_ref = CFSTR("HELLO WORLD"); - -	    CFSetRef set_ref = CFSetCreate(NULL, data_set, 3, NULL); - -	    CFMutableSetRef mutable_set_ref = CFSetCreateMutable(NULL, 5, NULL); - -	    CFSetAddValue(mutable_set_ref, str1); -	    CFSetAddValue(mutable_set_ref, str2); -	    CFSetAddValue(mutable_set_ref, str3); -	    CFSetAddValue(mutable_set_ref, str4); -	    CFSetAddValue(mutable_set_ref, str5); -	    CFSetAddValue(mutable_set_ref, str6); -	    CFSetAddValue(mutable_set_ref, str7); -	    CFSetAddValue(mutable_set_ref, str8); -	    CFSetAddValue(mutable_set_ref, str9); -	    CFSetAddValue(mutable_set_ref, str10); -	    CFSetAddValue(mutable_set_ref, str11); -	    CFSetAddValue(mutable_set_ref, str12); - - -	    CFDictionaryRef cfdict_ref = CFDictionaryCreate(NULL, data_set, data_set, 3, NULL, NULL); -	    CFMutableDictionaryRef mutable_dict_ref = CFDictionaryCreateMutable(NULL, 16, NULL, NULL); - -	    CFDictionarySetValue(mutable_dict_ref, str1, str1); -	    CFDictionarySetValue(mutable_dict_ref, str2, str2); -	    CFDictionarySetValue(mutable_dict_ref, str3, str3); -	    CFDictionarySetValue(mutable_dict_ref, str4, str1); -	    CFDictionarySetValue(mutable_dict_ref, str5, str2); -	    CFDictionarySetValue(mutable_dict_ref, str6, str3); -	    CFDictionarySetValue(mutable_dict_ref, str7, str1); -	    CFDictionarySetValue(mutable_dict_ref, str8, str2); -	    CFDictionarySetValue(mutable_dict_ref, str9, str3); -	    CFDictionarySetValue(mutable_dict_ref, str10, str1); -	    CFDictionarySetValue(mutable_dict_ref, str11, str2); -	    CFDictionarySetValue(mutable_dict_ref, str12, str3); -  	    CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL);  	    CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL); @@ -466,31 +431,6 @@ int main (int argc, const char * argv[])  	    CFArraySetValueAtIndex(mutable_array_ref, 9, str11);  	    CFArraySetValueAtIndex(mutable_array_ref, 10, str12); -	    CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL); - -	    CFBagSetValue(mutable_bag_ref, strB10); -	    CFBagSetValue(mutable_bag_ref, str1); -	    CFBagSetValue(mutable_bag_ref, str2); -	    CFBagSetValue(mutable_bag_ref, str3); -	    CFBagSetValue(mutable_bag_ref, str4); -	    CFBagSetValue(mutable_bag_ref, str5); -	    CFBagSetValue(mutable_bag_ref, str6); -	    CFBagSetValue(mutable_bag_ref, str7); -	    CFBagSetValue(mutable_bag_ref, str8); -	    CFBagSetValue(mutable_bag_ref, str9); -	    CFBagSetValue(mutable_bag_ref, str10); -	    CFBagSetValue(mutable_bag_ref, str11); -	    CFBagSetValue(mutable_bag_ref, str12); -	    CFBagSetValue(mutable_bag_ref, strA1); -	    CFBagSetValue(mutable_bag_ref, strA2); -	    CFBagSetValue(mutable_bag_ref, strA3); - -	    CFBagRef cfbag_ref = CFBagCreateCopy(NULL, mutable_bag_ref); - -	    CFBagSetValue(mutable_bag_ref, strB8); -	    CFBagSetValue(mutable_bag_ref, strC4); - -  	    CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL);  	    CFBinaryHeapAddValue(binheap_ref, str1);  	    CFBinaryHeapAddValue(binheap_ref, str2); @@ -520,6 +460,7 @@ int main (int argc, const char * argv[])  	    NSDictionary *error_userInfo = @{@"a": @1, @"b" : @2};  	    NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar" code:12 userInfo:error_userInfo]; +	    NSError **nserrorptr = &nserror;  	    NSBundle* bundle_string = [[NSBundle alloc] initWithPath:@"/System/Library/Frameworks/Accelerate.framework"];  	    NSBundle* bundle_url = [[NSBundle alloc] initWithURL:[[NSURL alloc] initWithString:@"file://localhost/System/Library/Frameworks/Cocoa.framework"]]; @@ -540,8 +481,6 @@ int main (int argc, const char * argv[])  	    NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"cuz it's funny" userInfo:nil];  	    NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"cuz it's funny" userInfo:nil]; -	    NSMachPort *port = [NSMachPort port]; -  	    NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"];  	    NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];  	    NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2]; @@ -550,22 +489,14 @@ int main (int argc, const char * argv[])  		NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"];  		NSDate *date3 = [NSDate date];  		NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60]; +    NSDate *date5 = [NSDate dateWithTimeIntervalSinceReferenceDate: floor([[NSDate date] timeIntervalSinceReferenceDate])];  		CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1);  		CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2);  		CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3);  		CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4); +		CFAbsoluteTime date5_abs = CFDateGetAbsoluteTime(date5); -	    NSCountedSet *nscounted_set = [[NSCountedSet alloc] initWithCapacity:5]; - -	    [nscounted_set addObject:str0]; -	    [nscounted_set addObject:str1]; -	    [nscounted_set addObject:str0]; -	    [nscounted_set addObject:str0]; -	    [nscounted_set addObject:@"foo1"]; -	    [nscounted_set addObject:@"foo2"]; -	    [nscounted_set addObject:@"foo3"]; -	  	    NSIndexSet *iset1 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)];  	    NSIndexSet *iset2 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)]; @@ -598,21 +529,12 @@ int main (int argc, const char * argv[])  		NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"];  		NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"]; -		NSHost *localhost = [NSHost hostWithAddress:@"127.0.0.1"]; - -#ifndef IOS -		NSTask *my_task = [[NSTask alloc] init]; -#endif - -  	CFGregorianUnits cf_greg_units = {1,3,5,12,5,7};  	CFGregorianDate cf_greg_date = CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL);  	CFRange cf_range = {4,4};  	NSPoint ns_point = {4,4};  	NSRange ns_range = {4,4}; -	 -	NSValue *range_value = [NSValue valueWithRange:ns_range]; -	 +		  	NSRect ns_rect = {{1,1},{5,5}};  	NSRect* ns_rect_ptr = &ns_rect;  	NSRectArray ns_rect_arr = &ns_rect; 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 e11c45e9038e..f5c792593772 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 @@ -8,10 +8,11 @@ from __future__ import print_function  import os, time +import datetime  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class NSStringDataFormatterTestCase(TestBase): 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 1281f17ab58a..3c9be04a2f6c 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 @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DataFormatterOneIsSingularTestCase(TestBase): @@ -64,14 +65,6 @@ class DataFormatterOneIsSingularTestCase(TestBase):                      substrs = ['1 key/value pair'])          self.expect('frame variable dict', matching=False,                      substrs = ['1 key/value pairs']) -        self.expect('frame variable mutable_bag_ref', -                    substrs = ['@"1 value"']) -        self.expect('frame variable mutable_bag_ref', matching=False, -                    substrs = ['1 values']) -        self.expect('frame variable nscounted_set', -                    substrs = ['1 element']) -        self.expect('frame variable nscounted_set', matching=False, -                    substrs = ['1 elements'])          self.expect('frame variable imset',                      substrs = ['1 index'])          self.expect('frame variable imset', matching=False, @@ -80,10 +73,6 @@ class DataFormatterOneIsSingularTestCase(TestBase):                      substrs = ['@"1 item"'])          self.expect('frame variable binheap_ref', matching=False,                      substrs = ['1 items']) -        self.expect('frame variable nsset', -                    substrs = ['1 element']) -        self.expect('frame variable nsset', matching=False, -                    substrs = ['1 elements'])          self.expect('frame variable immutableData',                      substrs = ['1 byte'])          self.expect('frame variable immutableData', matching=False, diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m index 7204d3c7b202..71ab8a746bb6 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-proper-plurals/main.m @@ -11,32 +11,21 @@  int main (int argc, const char * argv[])  { -     -    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; -     +  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];  	NSArray* key = [NSArray arrayWithObjects:@"foo",nil];  	NSArray* value = [NSArray arrayWithObjects:@"key",nil];  	NSDictionary *dict = [NSDictionary dictionaryWithObjects:value forKeys:key]; -    CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL); -    CFBagSetValue(mutable_bag_ref, CFSTR("Hello world")); +  NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init]; +  [imset addIndex:4]; -    NSCountedSet *nscounted_set = [[NSCountedSet alloc] initWithCapacity:5]; -    [nscounted_set addObject:@"foo"]; +  CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL); +  CFBinaryHeapAddValue(binheap_ref, CFSTR("Hello world")); -    NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init]; -    [imset addIndex:4]; +  NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:1]; -    CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL); -    CFBinaryHeapAddValue(binheap_ref, CFSTR("Hello world")); - -    NSSet* nsset = [[NSSet alloc] initWithObjects:@"foo",nil]; - -    NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:1]; - - -    [pool drain];// Set break point at this line. -    return 0; +  [pool drain];// Set break point at this line. +  return 0;  } 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 d202ff5d64e1..c7ff28874c5a 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class PythonSynthDataFormatterTestCase(TestBase): @@ -43,6 +44,8 @@ class PythonSynthDataFormatterTestCase(TestBase):          self.runCmd("run", RUN_SUCCEEDED) +        process = self.dbg.GetSelectedTarget().GetProcess() +          # The stop reason of the thread should be breakpoint.          self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,              substrs = ['stopped', @@ -61,39 +64,46 @@ class PythonSynthDataFormatterTestCase(TestBase):          # print the f00_1 variable without a synth          self.expect("frame variable f00_1", -            substrs = ['a = 0', -                       'b = 1', -                       'r = 33']); +            substrs = ['a = 1', +                       'b = 2', +                       'r = 34']);          # now set up the synth          self.runCmd("script from fooSynthProvider import *")          self.runCmd("type synth add -l fooSynthProvider foo") +        self.expect("type synthetic list foo", substrs=['fooSynthProvider']) + +        # note that the value of fake_a depends on target byte order +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            fake_a_val = 0x02000000 +        else: +            fake_a_val = 0x00000100          # check that we get the two real vars and the fake_a variables          self.expect("frame variable f00_1", -                    substrs = ['r = 33', -                               'fake_a = 16777216', -                               'a = 0']); +                    substrs = ['r = 34', +                               'fake_a = %d' % fake_a_val, +                               'a = 1']);          # check that we do not get the extra vars          self.expect("frame variable f00_1", matching=False, -                    substrs = ['b = 1']); +                    substrs = ['b = 2']);          # check access to members by name          self.expect('frame variable f00_1.fake_a', -                substrs = ['16777216']) +                    substrs = ['%d' % fake_a_val])          # check access to members by index          self.expect('frame variable f00_1[1]', -                    substrs = ['16777216']) +                    substrs = ['%d' % fake_a_val])          # put synthetic children in summary in several combinations          self.runCmd("type summary add --summary-string \"fake_a=${svar.fake_a}\" foo")          self.expect('frame variable f00_1', -                    substrs = ['fake_a=16777216']) +                    substrs = ['fake_a=%d' % fake_a_val])          self.runCmd("type summary add --summary-string \"fake_a=${svar[1]}\" foo")          self.expect('frame variable f00_1', -            substrs = ['fake_a=16777216']) +                    substrs = ['fake_a=%d' % fake_a_val])          # clear the summary          self.runCmd("type summary delete foo") @@ -101,23 +111,39 @@ class PythonSynthDataFormatterTestCase(TestBase):          # check that the caching does not span beyond the stopoint          self.runCmd("n") +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            fake_a_val = 0x02000000 +        else: +            fake_a_val = 0x00000200 +          self.expect("frame variable f00_1", -                    substrs = ['r = 33', -                               'fake_a = 16777216', -                               'a = 1']); +                    substrs = ['r = 34', +                               'fake_a = %d' % fake_a_val, +                               'a = 2']);          # check that altering the object also alters fake_a          self.runCmd("expr f00_1.a = 280") + +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            fake_a_val = 0x02000001 +        else: +            fake_a_val = 0x00011800 +          self.expect("frame variable f00_1", -                    substrs = ['r = 33', -                               'fake_a = 16777217', +                    substrs = ['r = 34', +                               'fake_a = %d' % fake_a_val,                                 'a = 280']);          # check that expanding a pointer does the right thing +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            fake_a_val = 0x0d000000 +        else: +            fake_a_val = 0x00000c00 +          self.expect("frame variable --ptr-depth 1 f00_ptr", -            substrs = ['r = 45', -                       'fake_a = 218103808', -                       'a = 12']) +                    substrs = ['r = 45', +                               'fake_a = %d' % fake_a_val, +                               'a = 12'])          # now add a filter.. it should fail          self.expect("type filter add foo --child b --child j", error=True, @@ -129,7 +155,7 @@ class PythonSynthDataFormatterTestCase(TestBase):                         'j = 17'])          self.expect("frame variable --ptr-depth 1 f00_ptr",                      substrs = ['r = 45', -                               'fake_a = 218103808', +                               'fake_a = %d' % fake_a_val,                                 'a = 12'])          # now delete the synth and add the filter @@ -137,11 +163,11 @@ class PythonSynthDataFormatterTestCase(TestBase):          self.runCmd("type filter add foo --child b --child j")          self.expect('frame variable f00_1', -                        substrs = ['b = 1', -                                   'j = 17']) +                        substrs = ['b = 2', +                                   'j = 18'])          self.expect("frame variable --ptr-depth 1 f00_ptr", matching=False,                      substrs = ['r = 45', -                               'fake_a = 218103808', +                               'fake_a = %d' % fake_a_val,                                 'a = 12'])          # now add the synth and it should fail @@ -162,11 +188,11 @@ class PythonSynthDataFormatterTestCase(TestBase):          self.runCmd("type synth add -l fooSynthProvider foo")          self.expect('frame variable f00_1', matching=False, -                    substrs = ['b = 1', -                               'j = 17']) +                    substrs = ['b = 2', +                               'j = 18'])          self.expect("frame variable --ptr-depth 1 f00_ptr",                       substrs = ['r = 45', -                               'fake_a = 218103808', +                               'fake_a = %d' % fake_a_val,                                 'a = 12'])          # check the listing @@ -183,8 +209,8 @@ class PythonSynthDataFormatterTestCase(TestBase):          self.expect("frame variable f00_1",                      substrs = ['a = 280', -                               'b = 1', -                               'j = 17']); +                               'b = 2', +                               'j = 18']);          self.expect("frame variable f00_1", matching=False,                  substrs = ['fake_a = ']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp index 48b29dcfd6e4..f45a2abfb9f1 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp @@ -48,7 +48,7 @@ struct wrapint  int main()  { -    foo f00_1(0); +    foo f00_1(1);      foo *f00_ptr = new foo(12);      f00_1.a++; // Set break point at this 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 324b372cb11e..7ebc1c14ce13 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 @@ -52,6 +52,7 @@ class ScriptDataFormatterTestCase(TestBase):          script = 'a = valobj.GetChildMemberWithName(\'integer\'); a_val = a.GetValue(); str = \'Hello from Python, \' + a_val + \' time\'; return str + (\'!\' if a_val == \'1\' else \'s!\');'          self.runCmd("type summary add i_am_cool --python-script \"%s\"" % script) +        self.expect('type summary list i_am_cool', substrs=[script])          self.expect("frame variable one",              substrs = ['Hello from Python', diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile index b438bbb970f6..a92cffcc319b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile @@ -1,6 +1,7 @@  LEVEL = ../../../make  CXX_SOURCES := main.cpp +USE_LIBSTDCPP := 1  # clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD   # targets.  Other targets do not, which causes this test to fail. @@ -12,8 +13,3 @@ endif  include $(LEVEL)/Makefile.rules  CXXFLAGS += -O0 - -ifeq (,$(findstring gcc,$(CC))) -CXXFLAGS += -stdlib=libstdc++ -LDFLAGS += -stdlib=libstdc++ -endif 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 38e700812d05..c186f1465cf5 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 @@ -8,15 +8,16 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class SkipSummaryDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureFreeBSD("llvm.org/pr20548") # fails to build on lab.llvm.org buildbot -    @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr20548 fails to build on lab.llvm.org buildbot") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows")      def test_with_run_command(self):          """Test data formatter commands."""          self.build() 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 ca8858dbad9b..b3f8ba7d048e 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 @@ -8,14 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class SmartArrayDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows")      def test_with_run_command(self):          """Test data formatter commands."""          self.build() @@ -35,6 +36,8 @@ class SmartArrayDataFormatterTestCase(TestBase):          self.runCmd("run", RUN_SUCCEEDED) +        process = self.dbg.GetSelectedTarget().GetProcess() +          # The stop reason of the thread should be breakpoint.          self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,              substrs = ['stopped', @@ -310,39 +313,81 @@ class SmartArrayDataFormatterTestCase(TestBase):          self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"float [7]\"")          self.runCmd("type summary add --summary-string \"arr = ${var%y}\" \"int [5]\"") -        self.expect("frame variable flarr", -                    substrs = ['flarr = arr =', -                               '00 00 9d 42,00 80 9a 42,00 00 9c 42,00 40 98 42,00 80 99 42,00 c0 99 42,00 00 9a 42']) -         -        self.expect("frame variable other.flarr", -                    substrs = ['flarr = arr =', -                               '00 00 cc 41,00 00 ca 41,00 00 c9 41,00 00 d6 41,00 00 db 41,00 00 dc 41,00 00 d1 41']) - -        self.expect("frame variable intarr", -                    substrs = ['intarr = arr =', -                               '01 00 00 00,01 00 00 00,02 00 00 00,03 00 00 00,05 00 00 00']) -         -        self.expect("frame variable other.intarr", -                    substrs = ['intarr = arr = ', -                               '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00']) +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable flarr", +                        substrs = ['flarr = arr =', +                                   '00 00 9d 42,00 80 9a 42,00 00 9c 42,00 40 98 42,00 80 99 42,00 c0 99 42,00 00 9a 42']) +        else: +            self.expect("frame variable flarr", +                        substrs = ['flarr = arr =', +                                   '42 9d 00 00,42 9a 80 00,42 9c 00 00,42 98 40 00,42 99 80 00,42 99 c0 00,42 9a 00 00']) + +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable other.flarr", +                        substrs = ['flarr = arr =', +                                   '00 00 cc 41,00 00 ca 41,00 00 c9 41,00 00 d6 41,00 00 db 41,00 00 dc 41,00 00 d1 41']) +        else: +            self.expect("frame variable other.flarr", +                        substrs = ['flarr = arr =', +                                   '41 cc 00 00,41 ca 00 00,41 c9 00 00,41 d6 00 00,41 db 00 00,41 dc 00 00,41 d1 00 00']) + +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable intarr", +                        substrs = ['intarr = arr =', +                                   '01 00 00 00,01 00 00 00,02 00 00 00,03 00 00 00,05 00 00 00']) +        else: +            self.expect("frame variable intarr", +                        substrs = ['intarr = arr =', +                                   '00 00 00 01,00 00 00 01,00 00 00 02,00 00 00 03,00 00 00 05']) + +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable other.intarr", +                        substrs = ['intarr = arr = ', +                                   '09 00 00 00,08 00 00 00,07 00 00 00,06 00 00 00,05 00 00 00']) +        else: +            self.expect("frame variable other.intarr", +                        substrs = ['intarr = arr = ', +                                   '00 00 00 09,00 00 00 08,00 00 00 07,00 00 00 06,00 00 00 05'])          self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"float [7]\"")          self.runCmd("type summary add --summary-string \"arr = ${var%Y}\" \"int [5]\"") -        self.expect("frame variable flarr", -                    substrs = ['flarr = arr =', -                               '00 00 9d 42             ...B,00 80 9a 42             ...B,00 00 9c 42             ...B,00 40 98 42             .@.B,00 80 99 42             ...B,00 c0 99 42             ...B,00 00 9a 42             ...B']) -         -        self.expect("frame variable other.flarr", -                    substrs = ['flarr = arr =', -                               '00 00 cc 41             ...A,00 00 ca 41             ...A,00 00 c9 41             ...A,00 00 d6 41             ...A,00 00 db 41             ...A,00 00 dc 41             ...A,00 00 d1 41             ...A']) -         -        self.expect("frame variable intarr", -                    substrs = ['intarr = arr =', -                               '....,01 00 00 00', -                               '....,05 00 00 00']) -         -        self.expect("frame variable other.intarr", -                    substrs = ['intarr = arr = ', -                               '09 00 00 00', -                               '....,07 00 00 00']) +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable flarr", +                        substrs = ['flarr = arr =', +                                   '00 00 9d 42             ...B,00 80 9a 42             ...B,00 00 9c 42             ...B,00 40 98 42             .@.B,00 80 99 42             ...B,00 c0 99 42             ...B,00 00 9a 42             ...B']) +        else: +            self.expect("frame variable flarr", +                        substrs = ['flarr = arr =', +                                   '42 9d 00 00             B...,42 9a 80 00             B...,42 9c 00 00             B...,42 98 40 00             B.@.,42 99 80 00             B...,42 99 c0 00             B...,42 9a 00 00             B...']) + +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable other.flarr", +                        substrs = ['flarr = arr =', +                                   '00 00 cc 41             ...A,00 00 ca 41             ...A,00 00 c9 41             ...A,00 00 d6 41             ...A,00 00 db 41             ...A,00 00 dc 41             ...A,00 00 d1 41             ...A']) +        else: +            self.expect("frame variable other.flarr", +                        substrs = ['flarr = arr =', +                                   '41 cc 00 00             A...,41 ca 00 00             A...,41 c9 00 00             A...,41 d6 00 00             A...,41 db 00 00             A...,41 dc 00 00             A...,41 d1 00 00             A...']) + +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable intarr", +                        substrs = ['intarr = arr =', +                                   '....,01 00 00 00', +                                   '....,05 00 00 00']) +        else: +            self.expect("frame variable intarr", +                        substrs = ['intarr = arr =', +                                   '....,00 00 00 01', +                                   '....,00 00 00 05']) + +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            self.expect("frame variable other.intarr", +                        substrs = ['intarr = arr = ', +                                   '09 00 00 00', +                                   '....,07 00 00 00']) +        else: +            self.expect("frame variable other.intarr", +                        substrs = ['intarr = arr = ', +                                   '00 00 00 09', +                                   '....,00 00 00 07']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile new file mode 100644 index 000000000000..fdd717119d95 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../../../make +CXX_SOURCES := main.cpp +CXXFLAGS += -std=c++11 +USE_LIBCPP := 1 +include $(LEVEL)/Makefile.rules 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 new file mode 100644 index 000000000000..083f713c259d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py @@ -0,0 +1,52 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class LibCxxAtomicTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def get_variable(self, name): +        var = self.frame().FindVariable(name) +        var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) +        var.SetPreferSyntheticValue(True) +        return var + +    @skipIf(compiler="gcc") +    @skipIfWindows # libc++ not ported to Windows yet +    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) + +        bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + +        self.runCmd("run", RUN_SUCCEEDED) + +        lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + +        # The stop reason of the thread should be breakpoint. +        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, +            substrs = ['stopped', +                       'stop reason = breakpoint']) +         +        s = self.get_variable('s') +        i = self.get_variable('i') +         +        if self.TraceOn(): print(s) +        if self.TraceOn(): print(i) +         +        self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5") +        self.assertTrue(s.GetNumChildren() == 2, "s has two children") +        self.assertTrue(s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1, "s.x == 1") +        self.assertTrue(s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2, "s.y == 2") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp new file mode 100644 index 000000000000..0eb2418c628a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp @@ -0,0 +1,26 @@ +//===-- main.cpp --------------------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <atomic> + +struct S { +    int x = 1; +    int y = 2; +}; + +int main () +{ +    std::atomic<S> s; +    s.store(S()); +    std::atomic<int> i; +    i.store(5); +     +    return 0; // Set break point at this line. +} + 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 e01f1b6679fc..d452c1be69bf 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 @@ -8,16 +8,17 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class InitializerListTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @skipIfWindows # libc++ not ported to Windows yet -    @skipIfGcc -    @expectedFailureLinux # fails on clang 3.5 and tot +    @skipIf(compiler="gcc") +    @expectedFailureAll(oslist=["linux"], bugnumber="fails on clang 3.5 and tot")      def test(self):          """Test that that file and class static variables display correctly."""          self.build() 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 a87a2ed2d434..23f6956cf3f0 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxIteratorDataFormatterTestCase(TestBase): @@ -21,7 +22,7 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// Set break point at this line.') -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet      def test_with_run_command(self):          """Test that libc++ iterators format properly.""" 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 18ee31a86106..6fcdc37465db 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time, re  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxListDataFormatterTestCase(TestBase): @@ -24,8 +25,9 @@ class LibcxxListDataFormatterTestCase(TestBase):          self.line3 = line_number('main.cpp', '// Set third break point at this line.')          self.line4 = line_number('main.cpp', '// Set fourth break point at this line.') -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet +    @expectedFailureAll(oslist=["macosx"], bugnumber="rdar://25499635")      def test_with_run_command(self):          """Test that that file and class static variables display correctly."""          self.build() 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 167cb2b887af..9e68e1dbc004 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 @@ -9,16 +9,18 @@ from __future__ import print_function  import os, time, re  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxListDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet      @add_test_categories(["pyapi"]) +    @skipIfDarwin  # rdar://25499635      def test_with_run_command(self):          self.build()          exe = os.path.join(os.getcwd(), "a.out") 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 70a98f9c2cae..cecc3178b318 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 @@ -8,14 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxMapDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet      def test_with_run_command(self):          """Test that that file and class static variables display correctly.""" 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 d0ca73d3251d..eb74818c91f5 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 @@ -9,14 +9,16 @@ from __future__ import print_function  import os, time  import lldb  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class LibcxxMultiMapDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @skipIfWindows # libc++ not ported to Windows yet -    @skipIfGcc +    @skipIf(compiler="gcc")      def test_with_run_command(self):          """Test that that file and class static variables display correctly."""          self.build() 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 384f6130d0c0..cfdfd07ddec1 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 @@ -8,14 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxMultiSetDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet      def test_with_run_command(self):          """Test that that file and class static variables display 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 fcbfb0a8f0ed..00c1e548cf6b 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 @@ -8,62 +8,63 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxSetDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet      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.")) +#        bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))          self.runCmd("run", RUN_SUCCEEDED) -        lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       'stop reason = breakpoint']) - -        # This is the function to remove the custom formats in order to have a -        # clean slate for the next test case. -        def cleanup(): -            self.runCmd('type format clear', check=False) -            self.runCmd('type summary clear', check=False) -            self.runCmd('type filter clear', check=False) -            self.runCmd('type synth clear', check=False) -            self.runCmd("settings set target.max-children-count 256", check=False) - -        # Execute the cleanup function during test case tear down. -        self.addTearDownHook(cleanup) - -        self.expect('image list', substrs = self.getLibcPlusPlusLibs()) - -        self.expect("frame variable ii",substrs = ["size=0","{}"]) -        lldbutil.continue_to_breakpoint(self.process(), bkpt) -        self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[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) -        self.expect("frame variable ii",substrs = ["size=0","{}"]) -        lldbutil.continue_to_breakpoint(self.process(), bkpt) -        self.expect("frame variable ii",substrs = ["size=0","{}"]) -        self.expect("frame variable ss",substrs = ["size=0","{}"]) -        lldbutil.continue_to_breakpoint(self.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) -        self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) -        self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[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) -        self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"']) +#        lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) +# +#        # The stop reason of the thread should be breakpoint. +#        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, +#            substrs = ['stopped', +#                       'stop reason = breakpoint']) +# +#        # This is the function to remove the custom formats in order to have a +#        # clean slate for the next test case. +#        def cleanup(): +#            self.runCmd('type format clear', check=False) +#            self.runCmd('type summary clear', check=False) +#            self.runCmd('type filter clear', check=False) +#            self.runCmd('type synth clear', check=False) +#            self.runCmd("settings set target.max-children-count 256", check=False) +# +#        # Execute the cleanup function during test case tear down. +#        self.addTearDownHook(cleanup) +# +#        self.expect('image list', substrs = self.getLibcPlusPlusLibs()) +# +#        self.expect("frame variable ii",substrs = ["size=0","{}"]) +#        lldbutil.continue_to_breakpoint(self.process(), bkpt) +#        self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[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) +#        self.expect("frame variable ii",substrs = ["size=0","{}"]) +#        lldbutil.continue_to_breakpoint(self.process(), bkpt) +#        self.expect("frame variable ii",substrs = ["size=0","{}"]) +#        self.expect("frame variable ss",substrs = ["size=0","{}"]) +#        lldbutil.continue_to_breakpoint(self.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) +#        self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) +#        self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[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) +#        self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"']) 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 942124255f55..76eedb8c8919 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 @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxStringDataFormatterTestCase(TestBase): @@ -22,7 +23,7 @@ class LibcxxStringDataFormatterTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// Set break point at this line.') -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet      def test_with_run_command(self):          """Test that that file and class static variables display correctly.""" 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 5e6ec2519323..4765cd70f67c 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 @@ -8,15 +8,16 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxUnorderedDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @skipIfWindows # libc++ not ported to Windows yet -    @skipIfGcc +    @skipIf(compiler="gcc")      def test_with_run_command(self):          """Test that that file and class static variables display correctly."""          self.build() @@ -72,4 +73,5 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase):      def look_for_content_and_continue(self, var_name, patterns):          self.expect( ("frame variable %s" % var_name), patterns=patterns) +        self.expect( ("frame variable %s" % var_name), patterns=patterns)          self.runCmd("continue") 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 9771a819aa6b..fe3b6c115e31 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxVBoolDataFormatterTestCase(TestBase): @@ -21,7 +22,7 @@ class LibcxxVBoolDataFormatterTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// Set break point at this line.') -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows.      def test_with_run_command(self):          """Test that that file and class static variables display correctly.""" 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 f8cd65be0931..9a145fba73e8 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 @@ -8,14 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LibcxxVectorDataFormatterTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipIfGcc +    @skipIf(compiler="gcc")      @skipIfWindows # libc++ not ported to Windows yet      def test_with_run_command(self):          """Test that that file and class static variables display correctly.""" 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 6742c9e71701..dbaa37daa2d1 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class StdIteratorDataFormatterTestCase(TestBase): @@ -22,7 +23,7 @@ class StdIteratorDataFormatterTestCase(TestBase):          self.line = line_number('main.cpp', '// Set break point at this line.')      @skipIfWindows # libstdcpp not ported to Windows -    @expectedFailureIcc # llvm.org/pr15301 LLDB prints incorrect sizes of STL containers +    @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers")      def test_with_run_command(self):          """Test that libstdcpp iterators format properly."""          self.build() 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 5147d18da0fe..55658af1f2a3 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class StdListDataFormatterTestCase(TestBase): 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 e21c4e94c2c4..ff99255aec0c 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class StdMapDataFormatterTestCase(TestBase): @@ -21,7 +22,7 @@ class StdMapDataFormatterTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// Set break point at this line.') -    @expectedFailureIcc   # llvm.org/pr15301: LLDB prints incorrect size of libstdc++ containers +    @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers")      @skipIfWindows # libstdcpp not ported to Windows      @skipIfFreeBSD      def test_with_run_command(self): diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile new file mode 100644 index 000000000000..88cb026aba1c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile @@ -0,0 +1,15 @@ +LEVEL = ../../../../../make + +CXX_SOURCES := main.cpp + +CXXFLAGS := -O0 +USE_LIBSTDCPP := 1 + +# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD +# targets.  Other targets do not, which causes this test to fail. +# This flag enables FullDebugInfo for all targets. +ifneq (,$(findstring clang,$(CC))) +  CFLAGS_EXTRAS += -fno-limit-debug-info +endif + +include $(LEVEL)/Makefile.rules 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 new file mode 100644 index 000000000000..20b1a3d21156 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py @@ -0,0 +1,46 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +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 +    def test_with_run_command(self): +        self.build() +        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + +        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.expect("frame variable nsp", substrs = ['nsp = nullptr']) +        self.expect("frame variable isp", substrs = ['isp = 123']) +        self.expect("frame variable ssp", substrs = ['ssp = "foobar"']) + +        self.expect("frame variable nwp", substrs = ['nwp = nullptr']) +        self.expect("frame variable iwp", substrs = ['iwp = 123']) +        self.expect("frame variable swp", substrs = ['swp = "foobar"']) +         +        self.runCmd("continue") + +        self.expect("frame variable nsp", substrs = ['nsp = nullptr']) +        self.expect("frame variable isp", substrs = ['isp = nullptr']) +        self.expect("frame variable ssp", substrs = ['ssp = nullptr']) + +        self.expect("frame variable nwp", substrs = ['nwp = nullptr']) +        self.expect("frame variable iwp", substrs = ['iwp = nullptr']) +        self.expect("frame variable swp", substrs = ['swp = nullptr']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp new file mode 100644 index 000000000000..7ba50875a6db --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp @@ -0,0 +1,20 @@ +#include <memory> +#include <string> + +int +main() +{ +    std::shared_ptr<char> nsp; +    std::shared_ptr<int> isp(new int{123}); +    std::shared_ptr<std::string> ssp = std::make_shared<std::string>("foobar"); + +    std::weak_ptr<char> nwp; +    std::weak_ptr<int> iwp = isp; +    std::weak_ptr<std::string> swp = ssp; + +    nsp.reset(); // Set break point at this line. +    isp.reset(); +    ssp.reset(); + +    return 0; // 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 2d6af24c6afc..fde2f791183a 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 @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class StdStringDataFormatterTestCase(TestBase): 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 9e73009aba83..f5cf7c04c3a7 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class StdVBoolDataFormatterTestCase(TestBase): @@ -21,8 +22,8 @@ class StdVBoolDataFormatterTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// Set break point at this line.') -    @expectedFailureFreeBSD("llvm.org/pr20548") # fails to build on lab.llvm.org buildbot -    @expectedFailureIcc # llvm.org/pr15301: lldb does not print the correct sizes of STL containers when building with ICC +    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') +    @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers")      @skipIfWindows # libstdcpp not ported to Windows.      @skipIfDarwin      def test_with_run_command(self): 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 ed4313657e93..4a352ef41c17 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class StdVectorDataFormatterTestCase(TestBase): @@ -22,7 +23,7 @@ class StdVectorDataFormatterTestCase(TestBase):          self.line = line_number('main.cpp', '// Set break point at this line.')      @skipIfFreeBSD -    @expectedFailureIcc # llvm.org/pr15301 LLDB prints incorrect sizes of STL containers +    @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers")      @skipIfWindows # libstdcpp not ported to Windows      def test_with_run_command(self):          """Test that that file and class static variables display correctly.""" diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/Makefile new file mode 100644 index 000000000000..314f1cb2f077 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules 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 new file mode 100644 index 000000000000..6a03456e5c32 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py @@ -0,0 +1,56 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class DataFormatterSynthTypeTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        # Find the line number to break at. +        self.line = line_number('main.cpp', 'break here') + +    @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser +    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) + +        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + +        self.runCmd("run", RUN_SUCCEEDED) + +        # The stop reason of the thread should be breakpoint. +        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, +            substrs = ['stopped', +                       'stop reason = breakpoint']) + +        # This is the function to remove the custom formats in order to have a +        # clean slate for the next test case. +        def cleanup(): +            self.runCmd('type format clear', check=False) +            self.runCmd('type summary clear', check=False) +            self.runCmd('type filter clear', check=False) +            self.runCmd('type synth clear', check=False) + +        # Execute the cleanup function during test case tear down. +        self.addTearDownHook(cleanup) + +        self.runCmd("script from myIntSynthProvider import *") +        self.runCmd("type synth add -l myIntSynthProvider myInt") + +        self.expect('frame variable x', substrs=['ThisTestPasses']) +        self.expect('frame variable y', substrs=['ThisTestPasses']) +        self.expect('frame variable z', substrs=['ThisTestPasses']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/main.cpp new file mode 100644 index 000000000000..accbf0a5a578 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/main.cpp @@ -0,0 +1,29 @@ +class myInt { +    private: int theValue; +    public: myInt() : theValue(0) {} +    public: myInt(int _x) : theValue(_x) {} +    int val() { return theValue; } +}; + +class myArray { +public: +    int array[16]; +}; + +class hasAnInt { +    public: +        myInt theInt; +        hasAnInt() : theInt(42) {}   +}; + +myInt operator + (myInt x, myInt y) { return myInt(x.val() + y.val()); } + +int main() { +    myInt x{3}; +    myInt y{4}; +    myInt z {x+y}; +    hasAnInt hi; +    myArray ma; + +    return z.val(); // break here +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py new file mode 100644 index 000000000000..42737140b112 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthtype/myIntSynthProvider.py @@ -0,0 +1,36 @@ +class myIntSynthProvider(object): +	def __init__(self, valobj, dict): +		self.valobj = valobj; +		self.val = self.valobj.GetChildMemberWithName("theValue") +	def num_children(self): +		return 0; +	def get_child_at_index(self, index): +	    return None +	def get_child_index(self, name): +	    return None +	def update(self): +		return False +	def has_children(self): +	    return False +	def get_type_name(self): +	    return "ThisTestPasses" + + +class myArraySynthProvider(object): +    def __init__(self, valobj, dict): +        self.valobj = valobj +        self.array = self.valobj.GetChildMemberWithName("array") + +    def num_children(self, max_count): +        if 16 < max_count: +            return 16 +        return max_count + +    def get_child_at_index(self, index): +        return None # Keep it simple when this is not tested here. + +    def get_child_index(self, name): +        return None # Keep it simple when this is not tested here. + +    def has_children(self): +        return 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 8d6e5df37a5c..e7a34647a6de 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DataFormatterSynthValueTestCase(TestBase): @@ -22,7 +23,7 @@ class DataFormatterSynthValueTestCase(TestBase):          self.line = line_number('main.cpp', 'break here')      @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser -    @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows")      def test_with_run_command(self):          """Test using Python synthetic children provider to provide a value."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py index 8ae09d691940..886d09fda456 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py @@ -2,4 +2,4 @@ from __future__ import absolute_import  from lldbsuite.test import lldbinline -lldbinline.MakeInlineTest(__file__, globals(), [lldbinline.expectedFailureWindows("llvm.org/pr24663")]) +lldbinline.MakeInlineTest(__file__, globals(), [lldbinline.expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")]) 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 a12f9c841a7f..871cc19373a4 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class NSArraySyntheticTestCase(TestBase): 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 13d493ecbdcc..5ee54c3a2952 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class NSDictionarySyntheticTestCase(TestBase): 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 6c558001bb04..d1680434d3b9 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/nssetsynth/TestNSSetSynthetic.py @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class NSSetSyntheticTestCase(TestBase): 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 4fb6176e9e4f..4158ec8a661c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/ostypeformatting/TestFormattersOsType.py @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DataFormatterOSTypeTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/Makefile new file mode 100644 index 000000000000..314f1cb2f077 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py new file mode 100644 index 000000000000..700b7418118a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/TestPrintArray.py @@ -0,0 +1,70 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import datetime +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class PrintArrayTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def test_print_array(self): +        """Test that expr -Z works""" +        self.build() +        self.printarray_data_formatter_commands() + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        # Find the line number to break at. +        self.line = line_number('main.cpp', 'break here') + +    def printarray_data_formatter_commands(self): +        """Test that expr -Z works""" +        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + +        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + +        self.runCmd("run", RUN_SUCCEEDED) + +        # The stop reason of the thread should be breakpoint. +        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, +            substrs = ['stopped', +                       'stop reason = breakpoint']) + +        # This is the function to remove the custom formats in order to have a +        # clean slate for the next test case. +        def cleanup(): +            self.runCmd('type format clear', check=False) +            self.runCmd('type summary clear', check=False) +            self.runCmd('type synth clear', check=False) + +        # Execute the cleanup function during test case tear down. +        self.addTearDownHook(cleanup) +         +        self.expect('expr --element-count 3 -- data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) +        self.expect('expr data', substrs=['int *', '$', '0x']) +        self.expect('expr -f binary --element-count 0 -- data', substrs=['int *', '$', '0b']) +        self.expect('expr -f hex --element-count 3 -- data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) +        self.expect('expr -f binary --element-count 2 -- data', substrs=['int *', '$', '0x', '[0] = 0b', '1', '[1] = 0b', '11']) +        self.expect('parray 3 data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) +        self.expect('parray `1 + 1 + 1` data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) +        self.expect('parray `data[1]` data', substrs=['[0] = 1', '[1] = 3', '[2] = 5']) +        self.expect('parray/x 3 data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) +        self.expect('parray/x `data[1]` data', substrs=['[0] = 0x', '1', '[1] = 0x', '3', '[2] = 0x', '5']) + +        # check error conditions +        self.expect('expr --element-count 10 -- 123', error=True, substrs=['expression cannot be used with --element-count as it does not refer to a pointer']) +        self.expect('expr --element-count 10 -- (void*)123', error=True, substrs=['expression cannot be used with --element-count as it refers to a pointer to void']) +        self.expect('parray data', error=True, substrs=["invalid element count 'data'"]) +        self.expect('parray data data', error=True, substrs=["invalid element count 'data'"]) +        self.expect('parray', error=True, substrs=['Not enough arguments provided']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/main.cpp new file mode 100644 index 000000000000..b2d6309947ad --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/parray/main.cpp @@ -0,0 +1,29 @@ +//===-- main.cpp -------------------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <functional> +#include <stdlib.h> + +template<typename ElemType> +ElemType* alloc(size_t count, std::function<ElemType(size_t)> get) +{ +  ElemType *elems = new ElemType[count]; +  for(size_t i = 0; i < count; i++) +    elems[i] = get(i); +  return elems; +} + +int main (int argc, const char * argv[]) +{ +  int* data = alloc<int>(5, [] (size_t idx) -> int { +    return 2 * idx + 1; +  }); +  return 0; // break here +} + diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/Makefile new file mode 100644 index 000000000000..261658b10ae8 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/Makefile @@ -0,0 +1,9 @@ +LEVEL = ../../../make + +OBJCXX_SOURCES := main.mm + +CFLAGS_EXTRAS += -w + +include $(LEVEL)/Makefile.rules + +LDFLAGS += -framework Foundation diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py new file mode 100644 index 000000000000..7eb26a569867 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/TestPrintObjectArray.py @@ -0,0 +1,60 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import datetime +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class PrintObjectArrayTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @skipUnlessDarwin +    def test_print_array(self): +        """Test that expr -O -Z works""" +        self.build() +        self.printarray_data_formatter_commands() + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        # Find the line number to break at. +        self.line = line_number('main.mm', 'break here') + +    def printarray_data_formatter_commands(self): +        """Test that expr -O -Z works""" +        self.runCmd("file 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) + +        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']) + +        # This is the function to remove the custom formats in order to have a +        # clean slate for the next test case. +        def cleanup(): +            self.runCmd('type format clear', check=False) +            self.runCmd('type summary clear', check=False) +            self.runCmd('type synth clear', check=False) + +        # Execute the cleanup function during test case tear down. +        self.addTearDownHook(cleanup) + +        self.expect('expr --element-count 3 --object-description -- objects', substrs=['3735928559', '4276993775', '3203398366', 'Hello', 'World', 'Two =', '1 =']) +        self.expect('poarray 3 objects', substrs=['3735928559', '4276993775', '3203398366', 'Hello', 'World', 'Two =', '1 =']) +        self.expect('expr --element-count 3 --object-description --description-verbosity=full -- objects', substrs=['[0] =', '3735928559', '4276993775', '3203398366', '[1] =', 'Hello', 'World', '[2] =', 'Two =', '1 =']) +        self.expect('parray 3 objects', substrs=['[0] = 0x', '[1] = 0x', '[2] = 0x']) +        self.expect('expr --element-count 3 -d run -- objects', substrs=['3 elements', '2 elements', '2 key/value pairs']) +        self.expect('expr --element-count 3 -d run --ptr-depth=1 -- objects', substrs=['3 elements', '2 elements', '2 key/value pairs', '3735928559', '4276993775', '3203398366', '"Hello"', '"World"']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/main.mm b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/main.mm new file mode 100644 index 000000000000..9ef61e6a73f2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/poarray/main.mm @@ -0,0 +1,30 @@ +//===-- main.cpp -------------------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import <Foundation/Foundation.h> + +struct ThreeObjects +{ +  id one; +  id two; +  id three; +}; + +int main() +{ +  NSArray *array1 = @[@0xDEADBEEF, @0xFEEDBEEF, @0xBEEFFADE]; +  NSArray *array2 = @[@"Hello", @"World"]; +  NSDictionary *dictionary = @{@1: array2, @"Two": array2}; +  ThreeObjects *tobjects = new ThreeObjects(); +  tobjects->one = array1; +  tobjects->two = array2; +  tobjects->three = dictionary; +  id* objects = (id*)tobjects; +  return 0; // break here +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py index 80305e303d03..791ce27dad00 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/setvaluefromcstring/TestSetValueFromCString.py @@ -1,4 +1,4 @@ -import lldbsuite.test.lldbinline as lldbinline -import lldbsuite.test.lldbtest as lldbtest +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.skipIfFreeBSD,lldbtest.skipIfLinux,lldbtest.skipIfWindows]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIfFreeBSD,decorators.skipIfLinux,decorators.skipIfWindows]) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py index 69f7d48c8b6c..e26344f2711a 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/stringprinter/TestStringPrinter.py @@ -1,4 +1,4 @@ -import lldbsuite.test.lldbinline as lldbinline -import lldbsuite.test.lldbtest as lldbtest +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.expectedFailureWindows("llvm.org/pr24772")]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772")]) 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 0550f57ae62a..e8b6c1ad95f5 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class SyntheticCappingTestCase(TestBase): @@ -30,6 +31,8 @@ class SyntheticCappingTestCase(TestBase):          self.runCmd("run", RUN_SUCCEEDED) +        process = self.dbg.GetSelectedTarget().GetProcess() +          # The stop reason of the thread should be breakpoint.          self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,              substrs = ['stopped', @@ -51,25 +54,31 @@ class SyntheticCappingTestCase(TestBase):          self.runCmd("script from fooSynthProvider import *")          self.runCmd("type synth add -l fooSynthProvider foo") +        # note that the value of fake_a depends on target byte order +        if process.GetByteOrder() == lldb.eByteOrderLittle: +            fake_a_val = 0x02000000 +        else: +            fake_a_val = 0x00000100 +          # check that the synthetic children work, so we know we are doing the right thing          self.expect("frame variable f00_1", -                    substrs = ['r = 33', -                               'fake_a = 16777216', -                               'a = 0']); +                    substrs = ['r = 34', +                               'fake_a = %d' % fake_a_val, +                               'a = 1']);          # check that capping works          self.runCmd("settings set target.max-children-count 2", check=False)          self.expect("frame variable f00_1",                      substrs = ['...', -                               'fake_a = 16777216', -                               'a = 0']); +                               'fake_a = %d' % fake_a_val, +                               'a = 1']);          self.expect("frame variable f00_1", matching=False, -                    substrs = ['r = 33']); +                    substrs = ['r = 34']);          self.runCmd("settings set target.max-children-count 256", check=False)          self.expect("frame variable f00_1", matching=True, -                    substrs = ['r = 33']); +                    substrs = ['r = 34']); diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py index fb95ac2b54d0..1a7e5679c0b8 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/fooSynthProvider.py @@ -1,21 +1,21 @@  import lldb  class fooSynthProvider: -     def __init__(self, valobj, dict): -         self.valobj = valobj; -         self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) -     def num_children(self): -         return 3; -     def get_child_at_index(self, index): -         if index == 0: -             child = self.valobj.GetChildMemberWithName('a'); -         if index == 1: -             child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type); -         if index == 2: -             child = self.valobj.GetChildMemberWithName('r'); -         return child; -     def get_child_index(self, name): -         if name == 'a': -             return 0; -         if name == 'fake_a': -             return 1; -    	 return 2; +    def __init__(self, valobj, dict): +        self.valobj = valobj; +        self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) +    def num_children(self): +        return 3; +    def get_child_at_index(self, index): +        if index == 0: +            child = self.valobj.GetChildMemberWithName('a'); +        if index == 1: +            child = self.valobj.CreateChildAtOffset ('fake_a', 1, self.int_type); +        if index == 2: +            child = self.valobj.GetChildMemberWithName('r'); +        return child; +    def get_child_index(self, name): +        if name == 'a': +            return 0; +        if name == 'fake_a': +            return 1; +        return 2; diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp index b921915b91c5..fec7907e0031 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthcapping/main.cpp @@ -48,7 +48,7 @@ struct wrapint  int main()  { -    foo f00_1(0); +    foo f00_1(1);      foo *f00_ptr = new foo(12);      f00_1.a++; // Set break point at this line. 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 6b70a88b9f2c..23a31da685de 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/synthupdate/TestSyntheticFilterRecompute.py @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class SyntheticFilterRecomputingTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py new file mode 100644 index 000000000000..6568056f761b --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py @@ -0,0 +1,31 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TypeSummaryListArgumentTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) + +    @no_debug_info_test +    def test_type_summary_list_with_arg(self): +        """Test that the 'type summary list' command handles command line arguments properly""" +        self.expect('type summary list Foo', substrs=['Category: default', 'Category: system']) +        self.expect('type summary list char', substrs=['char *', 'unsigned char']) + +        self.expect('type summary list -w default', substrs=['system'], matching=False) +        self.expect('type summary list -w system unsigned', substrs=['default', '0-9'], matching=False) +        self.expect('type summary list -w system char', substrs=['unsigned char *'], matching=True) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile new file mode 100644 index 000000000000..314f1cb2f077 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules 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 new file mode 100644 index 000000000000..63a4a3a4ba8c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py @@ -0,0 +1,61 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TypeSummaryListScriptTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def test_typesummarylist_script(self): +        """Test data formatter commands.""" +        self.build() +        self.data_formatter_commands() + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        # Find the line number to break at. +        self.line = line_number('main.cpp', 'Break here') + +    def data_formatter_commands(self): +        """Test printing out Python summary formatters.""" +        self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + +        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + +        self.runCmd("run", RUN_SUCCEEDED) + +        # The stop reason of the thread should be breakpoint. +        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, +            substrs = ['stopped', +                       'stop reason = breakpoint']) + +        # This is the function to remove the custom formats in order to have a +        # clean slate for the next test case. +        def cleanup(): +            self.runCmd('type category delete TSLSFormatters', check=False) +            self.runCmd('type format clear', check=False) +            self.runCmd('type summary clear', check=False) +            self.runCmd('type filter clear', check=False) +            self.runCmd('type synth clear', check=False) + +        self.addTearDownHook(cleanup) + +        self.runCmd("command script import tslsformatters.py") + +        self.expect("frame variable myStruct", substrs=['A data formatter at work']) +         +        self.expect('type summary list', substrs=['Struct_SummaryFormatter']) +        self.expect('type summary list Struct', substrs=['Struct_SummaryFormatter']) + + diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp new file mode 100644 index 000000000000..2de37041f263 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/main.cpp @@ -0,0 +1,15 @@ +#include <stdio.h> + +typedef struct Struct +{ +  int one; +  int two; +} Struct; + +int +main() +{ +  Struct myStruct = {10, 20}; +  printf ("Break here: %d\n.", myStruct.one); +  return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py new file mode 100644 index 000000000000..d1ce8b7db17a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/type_summary_list_script/tslsformatters.py @@ -0,0 +1,10 @@ +import lldb + +def Struct_SummaryFormatter(valobj, internal_dict): +    return 'A data formatter at work' + +category = lldb.debugger.CreateCategory("TSLSFormatters") +category.SetEnabled(True) +summary = lldb.SBTypeSummary.CreateWithFunctionName("tslsformatters.Struct_SummaryFormatter", lldb.eTypeOptionCascade) +spec = lldb.SBTypeNameSpecifier("Struct", False) +category.AddTypeSummary(spec, summary) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py index 30b66e062827..41b8c3499ccd 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/TestTypedefArray.py @@ -1,4 +1,4 @@ -import lldbsuite.test.lldbinline as lldbinline -import lldbsuite.test.lldbtest as lldbtest +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators -lldbinline.MakeInlineTest(__file__, globals(), [lldbtest.expectedFailureGcc]) +lldbinline.MakeInlineTest(__file__, globals(), [decorators.expectedFailureAll(compiler="gcc")]) 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 4d060c332f93..f3eced625898 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 @@ -7,10 +7,11 @@ from __future__ import print_function  import os, time +import os.path  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil -import os.path +from lldbsuite.test import lldbutil  class PythonSynthDataFormatterTestCase(TestBase): 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 05899a24ad22..365ddff3c7e8 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class VectorTypesFormattingTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py b/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py index f10736bd75c0..efbaa69eef57 100644 --- a/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py +++ b/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py @@ -8,15 +8,17 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DeadStripTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureWindows("llvm.org/pr24778") -    @expectedFailureDwo("llvm.org/pr25087") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") +    @expectedFailureAll(debug_info="dwo", bugnumber="llvm.org/pr25087") +    @expectedFailureAll(oslist=["linux"], debug_info="gmodules", bugnumber="llvm.org/pr27865")      @skipIfFreeBSD # The -dead_strip linker option isn't supported on FreeBSD versions of ld.      def test(self):          """Test breakpoint works correctly with dead-code stripping.""" diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py index df2308de7605..be0ea1441333 100644 --- a/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py @@ -8,14 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class DisassemblyTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureWindows # Function name prints fully demangled instead of name-only +    @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") @@ -41,7 +42,10 @@ class DisassemblyTestCase(TestBase):              instructions = [' add ', ' ldr ', ' str ']          elif re.match("mips" , arch):              breakpoint_opcodes = ["break"] -            instructions = ['lw', 'sw', 'jr'] +            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())) 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 ac039990b5bf..37593768f4a8 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 @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class DynamicValueChildCountTestCase(TestBase): @@ -31,11 +32,8 @@ class DynamicValueChildCountTestCase(TestBase):          self.main_sixth_call_line = line_number('pass-to-base.cpp',                                                         '// Break here and check b has 0 children again') -    @expectedFailureLinux("llvm.org/pr23039") -    @expectedFailureFreeBSD("llvm.org/pr19311") # continue at a breakpoint does not work -    @expectedFailureWindows("llvm.org/pr24663") -    @expectedFailurei386("to be figured out")      @add_test_categories(['pyapi']) +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")      def test_get_dynamic_vals(self):          """Test fetching C++ dynamic values from pointers & references."""          """Get argument vals for the call stack when stopped on a breakpoint.""" diff --git a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py b/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py index eddaa3cc9840..4b1880dee96f 100644 --- a/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py +++ b/packages/Python/lldbsuite/test/functionalities/embedded_interpreter/TestConvenienceVariables.py @@ -6,7 +6,9 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ConvenienceVariablesCase(TestBase): @@ -20,7 +22,7 @@ class ConvenienceVariablesCase(TestBase):      @skipIfFreeBSD # llvm.org/pr17228      @skipIfRemote -    @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")      def test_with_run_commands(self):          """Test convenience variables lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py index 9321a308a83c..912d51fb6b02 100644 --- a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py +++ b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py @@ -8,9 +8,10 @@ from __future__ import print_function  import lldb  import os  import time +from lldbsuite.support import seven +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil -import lldbsuite.support.seven as seven +from lldbsuite.test import lldbutil  def execute_command (command):      #print('%% %s' % (command)) @@ -55,15 +56,18 @@ class ExecTestCase(TestBase):              self.assertTrue(process.GetState() == lldb.eStateStopped,                              STOPPED_DUE_TO_BREAKPOINT) -            thread = process.GetThreadAtIndex (0) +            threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint) +            self.assertTrue(len(threads) == 1) -            self.assertTrue (thread.IsValid(), -                             "Process stopped at 'main' should have a valid thread"); +            # 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. -            stop_reason = thread.GetStopReason() -             -            self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint, -                             "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint"); +            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.")              # Run and we should stop due to exec              process.Continue() @@ -71,15 +75,11 @@ class ExecTestCase(TestBase):              self.assertTrue(process.GetState() == lldb.eStateStopped,                              "Process should be stopped at __dyld_start") -            thread = process.GetThreadAtIndex (0) -         -            self.assertTrue (thread.IsValid(), -                             "Process stopped at exec should have a valid thread"); -         -            stop_reason = thread.GetStopReason() -         -            self.assertTrue (stop_reason == lldb.eStopReasonExec, -                             "Thread in process stopped on exec should have a stop reason of eStopReasonExec"); -         +            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) +            self.assertTrue(len(threads) == 1, "Stopped at breakpoint in exec'ed process.") 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 a54b45822a6a..1492fe069220 100644 --- a/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py +++ b/packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ExprDoesntDeadlockTestCase(TestBase): @@ -19,9 +20,8 @@ class ExprDoesntDeadlockTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureFreeBSD('llvm.org/pr17946') -    @expectedFlakeyLinux # failed 1/365 test runs, line 61, thread.IsValid() -    @expectedFailureWindows # Windows doesn't have pthreads, need to port this test. +    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946') +    @expectedFailureAll(oslist=["windows"], bugnumber="Windows doesn't have pthreads, test needs to be ported")      def test_with_run_command(self):          """Test that expr will time out and allow other threads to run if it blocks."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py b/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py index 19a2dba2109a..6d2763c1ead1 100644 --- a/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py +++ b/packages/Python/lldbsuite/test/functionalities/fat_archives/TestFatArchives.py @@ -8,9 +8,10 @@ from __future__ import print_function  import lldb  import os  import time -from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil  import lldbsuite.support.seven as seven +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  def execute_command (command):      # print('%% %s' % (command)) diff --git a/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py b/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py index cc962150bc8c..0ba036124b03 100644 --- a/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py +++ b/packages/Python/lldbsuite/test/functionalities/format/TestFormats.py @@ -8,13 +8,15 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class TestFormats(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureHostWindows("llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")      def test_formats(self):          """Test format string functionality."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py index 950b021b69ce..ceeb2eadaf4f 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py @@ -6,55 +6,56 @@ from __future__ import print_function  import os, time  import lldb -import lldbsuite.test.lldbutil as lldbutil -import lldbsuite.test.lldbplatformutil as lldbplatformutil +from lldbsuite.test import lldbutil +from lldbsuite.test import lldbplatformutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import *  class AssertingInferiorTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") -    @expectedFailurei386("llvm.org/pr25338") -    @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386']) +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") +    @expectedFailureAll(oslist=["linux"], archs=["arm"], bugnumber="llvm.org/pr25338") +    @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips')      def test_inferior_asserting(self):          """Test that lldb reliably catches the inferior asserting (command)."""          self.build()          self.inferior_asserting() -    @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")      @expectedFailureAndroid(api_levels=list(range(16 + 1))) # b.android.com/179836      def test_inferior_asserting_register(self):          """Test that lldb reliably reads registers from the inferior after asserting (command)."""          self.build()          self.inferior_asserting_registers() -    @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") -    @expectedFailurei386("llvm.org/pr25338") -    @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386']) +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") +    @expectedFailureAll(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr25338") +    @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips')      def test_inferior_asserting_disassemble(self):          """Test that lldb reliably disassembles frames after asserting (command)."""          self.build()          self.inferior_asserting_disassemble()      @add_test_categories(['pyapi']) -    @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")      def test_inferior_asserting_python(self):          """Test that lldb reliably catches the inferior asserting (Python API)."""          self.build()          self.inferior_asserting_python() -    @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") -    @expectedFailurei386("llvm.org/pr25338") -    @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386']) +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") +    @expectedFailureAll(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr25338") +    @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips')      def test_inferior_asserting_expr(self):          """Test that the lldb expression interpreter can read from the inferior after asserting (command)."""          self.build()          self.inferior_asserting_expr() -    @expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") -    @expectedFailurei386("llvm.org/pr25338") -    @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386']) +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows") +    @expectedFailureAll(oslist=["linux"], archs=["aarch64", "arm"], bugnumber="llvm.org/pr25338") +    @expectedFailureAll(bugnumber="llvm.org/pr26592", triple = '^mips')      def test_inferior_asserting_step(self):          """Test that lldb functions correctly after stepping through a call to assert()."""          self.build() @@ -64,7 +65,8 @@ class AssertingInferiorTestCase(TestBase):          lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True)      def check_stop_reason(self): -        if matchAndroid(api_levels=list(range(1, 16+1)))(self): +        matched = lldbplatformutil.match_android_device(self.getArchitecture(), valid_api_levels=list(range(1, 16+1))) +        if matched:              # On android until API-16 the abort() call ended in a sigsegv instead of in a sigabrt              stop_reason = 'stop reason = signal SIGSEGV'          else: diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py b/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py index 830c7f69355f..359846c314f6 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py @@ -6,15 +6,17 @@ from __future__ import print_function  import os, time  import lldb -from lldbsuite.test import configuration +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import configuration +from lldbsuite.test import lldbutil  class ChangedInferiorTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipIfHostWindows +    @skipIf(hostoslist=["windows"]) +    @no_debug_info_test      def test_inferior_crashing(self):          """Test lldb reloads the inferior after it was changed during the session."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py index c547df116c16..fd6a9abce36e 100644 --- a/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py +++ b/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py @@ -6,55 +6,56 @@ from __future__ import print_function  import os, time  import lldb -import lldbsuite.test.lldbutil as lldbutil -import lldbsuite.test.lldbplatformutil as lldbplatformutil +from lldbsuite.test import lldbutil +from lldbsuite.test import lldbplatformutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import *  class CrashingInferiorTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureFreeBSD("llvm.org/pr23699 SIGSEGV is reported as exception, not signal") -    @expectedFailureWindows("llvm.org/pr24778") # This actually works, but the test relies on the output format instead of the API +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")      def test_inferior_crashing(self):          """Test that lldb reliably catches the inferior crashing (command)."""          self.build()          self.inferior_crashing() -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")      def test_inferior_crashing_register(self):          """Test that lldb reliably reads registers from the inferior after crashing (command)."""          self.build()          self.inferior_crashing_registers()      @add_test_categories(['pyapi']) -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")      def test_inferior_crashing_python(self):          """Test that lldb reliably catches the inferior crashing (Python API)."""          self.build()          self.inferior_crashing_python() -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")      def test_inferior_crashing_expr(self):          """Test that the lldb expression interpreter can read from the inferior after crashing (command)."""          self.build()          self.inferior_crashing_expr() -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")      def test_inferior_crashing_step(self):          """Test that stepping after a crash behaves correctly."""          self.build()          self.inferior_crashing_step() -    @expectedFailureFreeBSD('llvm.org/pr24939') -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939') +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")      @expectedFailureAndroid(archs=['aarch64'], api_levels=list(range(21 + 1))) # No eh_frame for sa_restorer      def test_inferior_crashing_step_after_break(self):          """Test that lldb functions correctly after stepping through a crash."""          self.build()          self.inferior_crashing_step_after_break() -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")      @skipIfLinux # Inferior exits after stepping after a segfault. This is working as intended IMHO.      def test_inferior_crashing_expr_step_and_expr(self):          """Test that lldb expressions work before and after stepping after a crash.""" 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 8afc81f6892a..0d1992d7b4b1 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 @@ -6,57 +6,57 @@ from __future__ import print_function  import os, time  import lldb -import lldbsuite.test.lldbutil as lldbutil -import lldbsuite.test.lldbplatformutil as lldbplatformutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbplatformutil +from lldbsuite.test import lldbutil  class CrashingRecursiveInferiorTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureFreeBSD("llvm.org/pr23699 SIGSEGV is reported as exception, not signal") -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_recursive_inferior_crashing(self):          """Test that lldb reliably catches the inferior crashing (command)."""          self.build()          self.recursive_inferior_crashing() -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_recursive_inferior_crashing_register(self):          """Test that lldb reliably reads registers from the inferior after crashing (command)."""          self.build()          self.recursive_inferior_crashing_registers()      @add_test_categories(['pyapi']) -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_recursive_inferior_crashing_python(self):          """Test that lldb reliably catches the inferior crashing (Python API)."""          self.build()          self.recursive_inferior_crashing_python() -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_recursive_inferior_crashing_expr(self):          """Test that the lldb expression interpreter can read from the inferior after crashing (command)."""          self.build()          self.recursive_inferior_crashing_expr() -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_recursive_inferior_crashing_step(self):          """Test that stepping after a crash behaves correctly."""          self.build()          self.recursive_inferior_crashing_step() -    @expectedFailureFreeBSD('llvm.org/pr24939') -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939') +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      @expectedFailureAndroid(archs=['aarch64'], api_levels=list(range(21 + 1))) # No eh_frame for sa_restorer      def test_recursive_inferior_crashing_step_after_break(self):          """Test that lldb functions correctly after stepping through a crash."""          self.build()          self.recursive_inferior_crashing_step_after_break() -    @expectedFailureFreeBSD('llvm.org/pr15989') # Couldn't allocate space for the stack frame      @skipIfLinux # Inferior exits after stepping after a segfault. This is working as intended IMHO. -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_recursive_inferior_crashing_expr_step_and_expr(self):          """Test that lldb expressions work before and after stepping after a crash."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py index 023f6f31e395..8257106888d6 100644 --- a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py +++ b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py @@ -6,18 +6,16 @@ from __future__ import print_function  import os, time, sys  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class TestInlineStepping(TestBase):      mydir = TestBase.compute_mydir(__file__)      @add_test_categories(['pyapi']) -    @expectedFailureFreeBSD('llvm.org/pr17214') -    @expectedFailureIcc # Not really a bug.  ICC combines two inlined functions. -    # failed 1/365 dosep runs, (i386-clang), TestInlineStepping.py:237 failed to stop at first breakpoint in main -    @expectedFailureAll(oslist=["linux"], archs=["i386"]) +    @expectedFailureAll(compiler="icc", bugnumber="# Not really a bug.  ICC combines two inlined functions.")      def test_with_python_api(self):          """Test stepping over and into inlined functions."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py index c7abf3464412..336260a8e4a3 100644 --- a/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py +++ b/packages/Python/lldbsuite/test/functionalities/jitloader_gdb/TestJITLoaderGDB.py @@ -2,13 +2,12 @@  from __future__ import print_function - -  import unittest2  import os  import lldb +from lldbsuite.test import lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil  import re @@ -16,7 +15,7 @@ class JITLoaderGDBTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @skipTestIfFn(lambda x: True, "llvm.org/pr24702", "Skipped because the test crashes the test runner") +    @skipTestIfFn(lambda : "Skipped because the test crashes the test runner", bugnumber="llvm.org/pr24702")      @unittest2.expectedFailure("llvm.org/pr24702")      def test_bogus_values(self):          """Test that we handle inferior misusing the GDB JIT interface""" 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 8f712dc21110..28d8cccacfcf 100644 --- a/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py +++ b/packages/Python/lldbsuite/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py @@ -8,16 +8,15 @@ from __future__ import print_function  import lldb  import os  import time +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LaunchWithShellExpandTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureFreeBSD("llvm.org/pr22627 process launch w/ shell expansion not working") -    @expectedFailureLinux("llvm.org/pr22627 process launch w/ shell expansion not working") -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows", "linux", "freebsd"], bugnumber="llvm.org/pr24778 llvm.org/pr22627")      def test(self):          self.build()          exe = os.path.join (os.getcwd(), "a.out") @@ -31,7 +30,7 @@ class LaunchWithShellExpandTestCase(TestBase):          breakpoint = target.BreakpointCreateBySourceRegex ('break here', lldb.SBFileSpec ("main.cpp", False))          self.assertTrue(breakpoint, VALID_BREAKPOINT) -        self.runCmd("process launch -X true -w %s -- fi*.tx?" % (os.getcwd())) +        self.runCmd("process launch -X true -w %s -- fi*.tx? () > <" % (os.getcwd()))          process = self.process() @@ -52,7 +51,11 @@ class LaunchWithShellExpandTestCase(TestBase):          self.expect("frame variable argv[2]", substrs=['file2.txt'])          self.expect("frame variable argv[3]", substrs=['file3.txt'])          self.expect("frame variable argv[4]", substrs=['file4.txy']) +        self.expect("frame variable argv[5]", substrs=['()']) +        self.expect("frame variable argv[6]", substrs=['>']) +        self.expect("frame variable argv[7]", substrs=['<'])          self.expect("frame variable argv[5]", substrs=['file5.tyx'], matching=False) +        self.expect("frame variable argv[8]", substrs=['file5.tyx'], matching=False)          self.runCmd("process kill") diff --git a/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py b/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py new file mode 100644 index 000000000000..a2a43bf2fabd --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py @@ -0,0 +1,60 @@ +""" +Test lldb 'commands regex' command which allows the user to create a regular expression command. +""" + +from __future__ import print_function + + + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestHomeDirectory(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") +    @no_debug_info_test +    def test_tilde_home_directory(self): +        """Test that we can resolve "~/" in paths correctly.  +        When a path starts with "~/", we use llvm::sys::path::home_directory() to +        resolve the home directory. This currently relies on "HOME" being set in the +        environment. While this is usually set, we can't rely upon that. We might  +        eventually get a fix into llvm::sys::path::home_directory() so it doesn't rely +        on having to have an environment variable set, but until then we have work around +        code in FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) to ensure +        this always works. This test tests that we get the correct answer for with and +        without "HOME" being set in the environment.""" +        import pexpect +        prompt = "(lldb) " + +        child = pexpect.spawn('%s --no-use-colors %s' % (lldbtest_config.lldbExec, self.lldbOption)) +        # Turn on logging for what the child sends back. +        if self.TraceOn(): +            child.logfile_read = sys.stdout +        # So that the spawned lldb session gets shutdown durng teardown. +        self.child = child + +        # Resolve "~/." to the full path of our home directory + "/." +        if 'HOME' in os.environ:  +            home_dir = os.environ['HOME'] +            if self.TraceOn(): +                print("home directory is: '%s'" % (home_dir)) +            if os.path.exists(home_dir): +                home_dir_slash_dot = home_dir + '/.' +                child.expect_exact(prompt) +                child.sendline('''script str(lldb.SBFileSpec("~/.", True))''') +                child.expect_exact(home_dir) +                child.expect_exact(prompt) +                child.sendline('''script import os; os.unsetenv('HOME'); str(lldb.SBFileSpec("~/", True))'''); +                child.expect_exact(home_dir) +                child.expect_exact(prompt) +            elif self.TraceOn(): +                print('''home directory "%s" doesn't exist, skipping home directory test''' % (home_dir)) +        elif self.TraceOn(): +            print('"HOME" not in environment, skipping home directory test') + +        child.sendline('quit') diff --git a/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py index 481e7c887bd0..3a703b2ee04e 100644 --- a/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py +++ b/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently  class LoadUnloadTestCase(TestBase): @@ -125,7 +126,6 @@ class LoadUnloadTestCase(TestBase):              substrs = [new_dylib])      @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support -    @skipUnlessListedRemote(['android'])      @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): @@ -182,7 +182,6 @@ class LoadUnloadTestCase(TestBase):      @expectedFailureAll(bugnumber="llvm.org/pr25805", hostoslist=["windows"], compiler="gcc", archs=["i386"], triple='.*-android')      @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support -    @skipUnlessListedRemote(['android'])      @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.""" @@ -241,7 +240,6 @@ class LoadUnloadTestCase(TestBase):          self.runCmd("process continue")      @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support -    @skipUnlessListedRemote(['android'])      def test_load_unload(self):          """Test breakpoint by name works correctly with dlopen'ing.""" @@ -283,7 +281,6 @@ class LoadUnloadTestCase(TestBase):              substrs = [' resolved, hit count = 2'])      @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support -    @skipUnlessListedRemote(['android'])      @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.""" @@ -313,7 +310,6 @@ class LoadUnloadTestCase(TestBase):                        'stop reason = step over'])      @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support -    @skipUnlessListedRemote(['android'])      @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently      @unittest2.expectedFailure("llvm.org/pr25806")      def test_static_init_during_load (self): diff --git a/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py b/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py index 1316a01c924c..d9f2b2231895 100644 --- a/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py +++ b/packages/Python/lldbsuite/test/functionalities/longjmp/TestLongjmp.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class LongjmpTestCase(TestBase): @@ -20,8 +21,8 @@ class LongjmpTestCase(TestBase):      @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp      @skipIfFreeBSD # llvm.org/pr17214 -    @expectedFailureLinux("llvm.org/pr20231") -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_step_out(self):          """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-out."""          self.build() @@ -29,8 +30,8 @@ class LongjmpTestCase(TestBase):      @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp      @skipIfFreeBSD # llvm.org/pr17214 -    @expectedFailureLinux("llvm.org/pr20231") -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_step_over(self):          """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-over a longjmp."""          self.build() @@ -38,8 +39,8 @@ class LongjmpTestCase(TestBase):      @skipIfDarwin # llvm.org/pr16769: LLDB on Mac OS X dies in function ReadRegisterBytes in GDBRemoteRegisterContext.cpp      @skipIfFreeBSD # llvm.org/pr17214 -    @expectedFailureLinux("llvm.org/pr20231") -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20231") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      def test_step_back_out(self):          """Test stepping when the inferior calls setjmp/longjmp, in particular, thread step-out after thread step-in."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/memory/cache/Makefile b/packages/Python/lldbsuite/test/functionalities/memory/cache/Makefile new file mode 100644 index 000000000000..314f1cb2f077 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/memory/cache/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py b/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py new file mode 100644 index 000000000000..a65882d3fa43 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py @@ -0,0 +1,64 @@ +""" +Test the MemoryCache L1 flush. +""" + +from __future__ import print_function + + + +import os, time +import re +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class MemoryCacheTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        # Find the line number to break inside main(). +        self.line = line_number('main.cpp', '// Set break point at this line.') + +    @expectedFlakeyOS(oslist=["windows"]) +    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") +        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + +        # 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) + +        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']) + +        # The breakpoint should have a hit count of 1. +        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, +            substrs = [' resolved, hit count = 1']) + +        # Read a chunk of memory containing &my_ints[0]. The number of bytes read +        # must be greater than m_L2_cache_line_byte_size to make sure the L1 +        # cache is used. +        self.runCmd('memory read -f d -c 201 `&my_ints - 100`') + +        # Check the value of my_ints[0] is the same as set in main.cpp. +        line = self.res.GetOutput().splitlines()[100] +        self.assertTrue(0x00000042 == int(line.split(':')[1], 0)) + +        # Change the value of my_ints[0] in memory. +        self.runCmd("memory write -s 4 `&my_ints` AA") + +        # Re-read the chunk of memory. The cache line should have been +        # flushed because of the 'memory write'. +        self.runCmd('memory read -f d -c 201 `&my_ints - 100`') + +        # Check the value of my_ints[0] have been updated correctly. +        line = self.res.GetOutput().splitlines()[100] +        self.assertTrue(0x000000AA == int(line.split(':')[1], 0)) diff --git a/packages/Python/lldbsuite/test/functionalities/memory/cache/main.cpp b/packages/Python/lldbsuite/test/functionalities/memory/cache/main.cpp new file mode 100644 index 000000000000..7f25e2f4bf68 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/memory/cache/main.cpp @@ -0,0 +1,14 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main () +{ +    int my_ints[] = {0x42}; +    return 0; // Set break point at this line. +} diff --git a/packages/Python/lldbsuite/test/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py b/packages/Python/lldbsuite/test/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py new file mode 100644 index 000000000000..7d959ec504c8 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py @@ -0,0 +1,48 @@ +""" +Test that commands do not try and hold on to stale CommandInterpreters in a multiple debuggers scenario +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class MultipleDebuggersCommandsTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @no_debug_info_test +    def test_multipledebuggers_commands(self): +        """Test that commands do not try and hold on to stale CommandInterpreters in a multiple debuggers scenario""" +        source_init_files = False +        magic_text = "The following commands may relate to 'env'" +         +        debugger_1 = lldb.SBDebugger.Create(source_init_files) +        interpreter_1 = debugger_1.GetCommandInterpreter() +         +        retobj = lldb.SBCommandReturnObject() +        interpreter_1.HandleCommand("apropos env", retobj) +        self.assertTrue(magic_text in str(retobj), "[interpreter_1]: the output does not contain the correct words") +         +        if self.TraceOn(): print(str(retobj)) +         +        lldb.SBDebugger.Destroy(debugger_1) +         +        # now do this again with a different debugger - we shouldn't crash +         +        debugger_2 = lldb.SBDebugger.Create(source_init_files) +        interpreter_2 = debugger_2.GetCommandInterpreter() +         +        retobj = lldb.SBCommandReturnObject() +        interpreter_2.HandleCommand("apropos env", retobj) +        self.assertTrue(magic_text in str(retobj), "[interpreter_2]: the output does not contain the correct words") +         +        if self.TraceOn(): print(str(retobj)) +         +        lldb.SBDebugger.Destroy(debugger_2) +         diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/Makefile b/packages/Python/lldbsuite/test/functionalities/nested_alias/Makefile new file mode 100644 index 000000000000..8a7102e347af --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py b/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py new file mode 100644 index 000000000000..6a74ddb727df --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py @@ -0,0 +1,68 @@ +""" +Test that an alias can reference other aliases without crashing. +""" + +from __future__ import print_function + + + +import os, time +import re +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class NestedAliasTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        # Find the line number to break inside main(). +        self.line = line_number('main.cpp', '// break here') + +    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") +        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + +        # Break in main() aftre 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) + +        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']) + +        # The breakpoint should have a hit count of 1. +        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, +            substrs = [' resolved, hit count = 1']) + +        # This is the function to remove the custom aliases in order to have a +        # clean slate for the next test case. +        def cleanup(): +            self.runCmd('command unalias read', check=False) +            self.runCmd('command unalias rd', check=False) +            self.runCmd('command unalias fo', check=False) +            self.runCmd('command unalias foself', check=False) + +        # Execute the cleanup function during test case tear down. +        self.addTearDownHook(cleanup) + +        self.runCmd('command alias read memory read -f A') +        self.runCmd('command alias rd read -c 3') +         +        self.expect('memory read -f A -c 3 `&my_ptr[0]`', substrs=['deadbeef', 'main.cpp:', 'feedbeef']) +        self.expect('rd `&my_ptr[0]`', substrs=['deadbeef', 'main.cpp:', 'feedbeef']) + +        self.expect('memory read -f A -c 3 `&my_ptr[0]`', substrs=['deadfeed'], matching=False) +        self.expect('rd `&my_ptr[0]`', substrs=['deadfeed'], matching=False) + +        self.runCmd('command alias fo frame variable -O --') +        self.runCmd('command alias foself fo self') +         +        self.expect('help foself', substrs=['--show-all-children', '--raw-output'], matching=False) +        self.expect('help foself', substrs=['Show variables for the current', 'stack frame.'], matching=True) diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp b/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp new file mode 100644 index 000000000000..4424cf30c3a4 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp @@ -0,0 +1,22 @@ +//===-- main.cpp ------------------------------------------------*- 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[]) +{ +  void* my_ptr[] = { +    reinterpret_cast<void*>(0xDEADBEEF), +    reinterpret_cast<void*>(main), +    reinterpret_cast<void*>(0xFEEDBEEF), +    reinterpret_cast<void*>(0xFEEDDEAD), +    reinterpret_cast<void*>(0xDEADFEED) +  }; +  return 0; // break here +} + diff --git a/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py b/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py index 4f4a22ed6067..0fdc43bb9feb 100644 --- a/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py +++ b/packages/Python/lldbsuite/test/functionalities/object-file/TestImageListMultiArchitecture.py @@ -9,16 +9,19 @@ from __future__ import print_function  import os.path +import re +  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil -import re +from lldbsuite.test import lldbutil  class TestImageListMultiArchitecture(TestBase):      mydir = TestBase.compute_mydir(__file__)      @no_debug_info_test +    @skipIfRemote      def test_image_list_shows_multiple_architectures(self):          """Test that image list properly shows the correct architecture for a set of different architecture object files."""          images = { diff --git a/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py b/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py index f718b62f95ea..db577dc5bacd 100644 --- a/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py +++ b/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py @@ -8,8 +8,9 @@ from __future__ import print_function  import lldb  import os  import time +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class TestPaths(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py b/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py index 6b3eedaf603a..9599f83d6a53 100644 --- a/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py +++ b/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py @@ -8,7 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class PlatformCommandTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py b/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py index b62c30bcf4e7..619ed7afe328 100644 --- a/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py +++ b/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class PluginCommandTestCase(TestBase): @@ -18,7 +19,7 @@ class PluginCommandTestCase(TestBase):      @skipIfNoSBHeaders      @skipIfHostIncompatibleWithRemote # Requires a compatible arch and platform to link against the host's built lldb lib. -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      @no_debug_info_test      def test_load_plugin(self):          """Test that plugins that load commands work correctly.""" diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py new file mode 100644 index 000000000000..fd5bb00d0565 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/TestLinuxCore.py @@ -0,0 +1,164 @@ +""" +Test basics of linux 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 LinuxCoreTestCase(TestBase): +    NO_DEBUG_INFO_TESTCASE = True + +    mydir = TestBase.compute_mydir(__file__) + +    _i386_pid   = 32306 +    _x86_64_pid = 32259 +    _s390x_pid  = 1045 + +    _i386_regions   = 4 +    _x86_64_regions = 5 +    _s390x_regions  = 2 + +    @skipIf(bugnumber="llvm.org/pr26947") +    def test_i386(self): +        """Test that lldb can read the process information from an i386 linux core file.""" +        self.do_test("i386", self._i386_pid, self._i386_regions) + +    def test_x86_64(self): +        """Test that lldb can read the process information from an x86_64 linux core file.""" +        self.do_test("x86_64", self._x86_64_pid, self._x86_64_regions) + +    # This seems to hang on non-s390x platforms for some reason.  Disabling for now. +    @skipIf(archs=no_match(['s390x']))  +    def test_s390x(self): +        """Test that lldb can read the process information from an s390x linux core file.""" +        self.do_test("s390x", self._s390x_pid, self._s390x_regions) + +    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("x86_64.out",  "x86_64-pid.out") +            shutil.copyfile("x86_64.core", "x86_64-pid.core") +            with open("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("x86_64-pid", os.getpid(), self._x86_64_regions) +        finally: +            self.RemoveTempFile("x86_64-pid.out") +            self.RemoveTempFile("x86_64-pid.core") + +    def test_two_cores_same_pid(self): +        """Test that we handle the situation if we have two core files with the same PID +        around""" +        alttarget = self.dbg.CreateTarget("altmain.out") +        altprocess = alttarget.LoadCore("altmain.core") +        self.assertTrue(altprocess, PROCESS_IS_VALID) +        self.assertEqual(altprocess.GetNumThreads(), 1) +        self.assertEqual(altprocess.GetProcessID(), self._x86_64_pid) + +        altframe = altprocess.GetSelectedThread().GetFrameAtIndex(0) +        self.assertEqual(altframe.GetFunctionName(), "_start") +        self.assertEqual(altframe.GetLineEntry().GetLine(), line_number("altmain.c", "Frame _start")) + +        error = lldb.SBError() +        F = altprocess.ReadCStringFromMemory(altframe.FindVariable("F").GetValueAsUnsigned(), 256, error) +        self.assertTrue(error.Success()) +        self.assertEqual(F, "_start") + +        # without destroying this process, run the test which opens another core file with the +        # same pid +        self.do_test("x86_64", self._x86_64_pid, self._x86_64_regions) + +    def check_memory_regions(self, process, region_count): +        region_list = process.GetMemoryRegions() +        self.assertEqual(region_list.GetSize(), region_count) + +        region = lldb.SBMemoryRegionInfo() + +        # Check we have the right number of regions. +        self.assertEqual(region_list.GetSize(), region_count); + +        # Check that getting a region beyond the last in the list fails. +        self.assertFalse(region_list.GetMemoryRegionAtIndex(region_count, region)); + +        # Check each region is valid. +        for i in range(region_list.GetSize()): +            # Check we can actually get this region. +            self.assertTrue(region_list.GetMemoryRegionAtIndex(i, region)) + +            #Every region in the list should be mapped. +            self.assertTrue(region.IsMapped()) + +            # Test the address at the start of a region returns it's enclosing region. +            begin_address = region.GetRegionBase() +            region_at_begin = lldb.SBMemoryRegionInfo() +            error = process.GetMemoryRegionInfo(begin_address, region_at_begin) +            self.assertEqual(region, region_at_begin) + +            # Test an address in the middle of a region returns it's enclosing region. +            middle_address = (region.GetRegionBase() + region.GetRegionEnd()) / 2l +            region_at_middle = lldb.SBMemoryRegionInfo() +            error = process.GetMemoryRegionInfo(middle_address, region_at_middle) +            self.assertEqual(region, region_at_middle) + +            # Test the address at the end of a region returns it's enclosing region. +            end_address = region.GetRegionEnd() - 1l +            region_at_end = lldb.SBMemoryRegionInfo() +            error = process.GetMemoryRegionInfo(end_address, region_at_end) +            self.assertEqual(region, region_at_end) + +            # Check that quering the end address does not return this region but +            # the next one. +            next_region = lldb.SBMemoryRegionInfo() +            error = process.GetMemoryRegionInfo(region.GetRegionEnd(), next_region) +            self.assertNotEqual(region, next_region) +            self.assertEqual(region.GetRegionEnd(), next_region.GetRegionBase()) + +        # Check that query beyond the last region returns an unmapped region +        # that ends at LLDB_INVALID_ADDRESS +        last_region = lldb.SBMemoryRegionInfo() +        region_list.GetMemoryRegionAtIndex(region_count - 1, last_region) +        end_region = lldb.SBMemoryRegionInfo() +        error = process.GetMemoryRegionInfo(last_region.GetRegionEnd(), end_region) +        self.assertFalse(end_region.IsMapped()) +        self.assertEqual(last_region.GetRegionEnd(), end_region.GetRegionBase()) +        self.assertEqual(end_region.GetRegionEnd(), lldb.LLDB_INVALID_ADDRESS) + +    def do_test(self, filename, pid, region_count): +        target = self.dbg.CreateTarget(filename + ".out") +        process = target.LoadCore(filename + ".core") +        self.assertTrue(process, PROCESS_IS_VALID) +        self.assertEqual(process.GetNumThreads(), 1) +        self.assertEqual(process.GetProcessID(), pid) + +        thread = process.GetSelectedThread() +        self.assertTrue(thread) +        self.assertEqual(thread.GetThreadID(), pid) +        backtrace = ["bar", "foo", "_start"] +        self.assertEqual(thread.GetNumFrames(), len(backtrace)) +        for i in range(len(backtrace)): +            frame = thread.GetFrameAtIndex(i) +            self.assertTrue(frame) +            self.assertEqual(frame.GetFunctionName(), backtrace[i]) +            self.assertEqual(frame.GetLineEntry().GetLine(), +                    line_number("main.c", "Frame " + backtrace[i])) +            self.assertEqual(frame.FindVariable("F").GetValueAsUnsigned(), ord(backtrace[i][0])) + +        self.check_memory_regions(process, region_count) + +        self.dbg.DeleteTarget(target) diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.c b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.c new file mode 100644 index 000000000000..da49a00996e1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.c @@ -0,0 +1,6 @@ +void _start(void) +{ +    const char *F = "_start"; +    char *boom = (char *)0; +    *boom = 47; // Frame _start +} diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.core b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.coreBinary files differ new file mode 100644 index 000000000000..423413070c7a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.core diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.out b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.outBinary files differ new file mode 100755 index 000000000000..2fddf3e8f803 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/altmain.out diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/i386.core b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/i386.coreBinary files differ new file mode 100644 index 000000000000..f8deff474d1f --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/i386.core diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/i386.out b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/i386.outBinary files differ new file mode 100755 index 000000000000..3cdd4eeca103 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/i386.out diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/main.c b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/main.c new file mode 100644 index 000000000000..f5bde4171ca5 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/main.c @@ -0,0 +1,17 @@ +static void bar(char *boom) +{ +    char F = 'b'; +    *boom = 47; // Frame bar +} + +static void foo(char *boom, void (*boomer)(char *)) +{ +    char F = 'f'; +    boomer(boom); // Frame foo +} + +void _start(void) +{ +    char F = '_'; +    foo(0, bar); // Frame _start +} diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh new file mode 100755 index 000000000000..efe1b801df34 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/make-core.sh @@ -0,0 +1,40 @@ +#! /bin/bash + +set -e -x + +file=$1 +if [ -z "$file" ]; then +    cat <<EOF +Please supply the main source file as the first argument. +EOF +    exit 1 +fi + +if grep -q '^|' </proc/sys/kernel/core_pattern; then +    cat <<EOF +Your system uses a crash report tool ($(cat /proc/sys/kernel/core_pattern)). Core files +will not be generated.  Please reset /proc/sys/kernel/core_pattern (requires root +privileges) to enable core generation. +EOF +    exit 1 +fi + +ulimit -c 1000 +real_limit=$(ulimit -c) +if [ $real_limit -lt 100 ]; then +    cat <<EOF +Unable to increase the core file limit. Core file may be truncated! +To fix this, increase HARD core file limit (ulimit -H -c 1000). This may require root +privileges. +EOF +fi + +${CC:-cc} -nostdlib -static -g $CFLAGS "$file" -o a.out + +cat <<EOF +Executable file is in a.out. +Core file will be saved according to pattern $(cat /proc/sys/kernel/core_pattern). +EOF + +ulimit -s 8 # Decrease stack size to 8k => smaller core files. +exec ./a.out diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/s390x.core b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/s390x.coreBinary files differ new file mode 100644 index 000000000000..b97fc43e967d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/s390x.core diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/s390x.out b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/s390x.outBinary files differ new file mode 100755 index 000000000000..640fbdc257d9 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/s390x.out diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/x86_64.core b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/x86_64.coreBinary files differ new file mode 100644 index 000000000000..e2fa69e4558e --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/x86_64.core diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/x86_64.out b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/x86_64.outBinary files differ new file mode 100755 index 000000000000..842402fd519d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/linux-core/x86_64.out diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py index 1dda59ac374b..89d1974b6703 100644 --- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py @@ -7,8 +7,9 @@ from six import iteritems  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class MiniDumpTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py b/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py new file mode 100644 index 000000000000..08debab538f5 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py @@ -0,0 +1,76 @@ +""" +Test basics of a mini dump taken of a 32-bit process running in WoW64 + +WoW64 is the subsystem that lets 32-bit processes run in 64-bit Windows.  If you +capture a mini dump of a process running under WoW64 with a 64-bit debugger, you +end up with a dump of the WoW64 layer.  In that case, LLDB must do extra work to +get the 32-bit register contexts. +""" + +from __future__ import print_function +from six import iteritems + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class Wow64MiniDumpTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @skipUnlessWindows  # for now mini-dump debugging is limited to Windows hosts +    @no_debug_info_test +    def test_wow64_mini_dump(self): +        """Test that lldb can read the process information from the minidump.""" +        # target create -c fizzbuzz_wow64.dmp +        target = self.dbg.CreateTarget("") +        process = target.LoadCore("fizzbuzz_wow64.dmp") +        self.assertTrue(process, PROCESS_IS_VALID) +        self.assertEqual(process.GetNumThreads(), 1) +        self.assertEqual(process.GetProcessID(), 0x1E9C) + +    @skipUnlessWindows  # for now mini-dump debugging is limited to Windows hosts +    @no_debug_info_test +    def test_thread_info_in_wow64_mini_dump(self): +        """Test that lldb can read the thread information from the minidump.""" +        # target create -c fizzbuzz_wow64.dmp +        target = self.dbg.CreateTarget("") +        process = target.LoadCore("fizzbuzz_wow64.dmp") +        # This process crashed due to an access violation (0xc0000005), but the +        # minidump doesn't have an exception record--perhaps the crash handler +        # ate it. +        # TODO:  See if we can recover the exception information from the TEB, +        # which, according to Windbg, has a pointer to an exception list. + +        # In the dump, none of the threads are stopped, so we cannot use +        # lldbutil.get_stopped_thread. +        thread = process.GetThreadAtIndex(0) +        self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone) + +    @skipUnlessWindows  # for now mini-dump debugging is limited to Windows hosts +    @no_debug_info_test +    def test_stack_info_in_wow64_mini_dump(self): +        """Test that we can see a trivial stack in a VS-generate mini dump.""" +        # target create -c fizzbuzz_no_heap.dmp +        target = self.dbg.CreateTarget("") +        process = target.LoadCore("fizzbuzz_wow64.dmp") +        self.assertGreaterEqual(process.GetNumThreads(), 1) +        # This process crashed due to an access violation (0xc0000005), but the +        # minidump doesn't have an exception record--perhaps the crash handler +        # ate it. +        # TODO:  See if we can recover the exception information from the TEB, +        # which, according to Windbg, has a pointer to an exception list. + +        # In the dump, none of the threads are stopped, so we cannot use +        # lldbutil.get_stopped_thread. +        thread = process.GetThreadAtIndex(0) +        # The crash is in main, so there should be at least one frame on the stack. +        self.assertGreaterEqual(thread.GetNumFrames(), 1) +        frame = thread.GetFrameAtIndex(0) +        self.assertTrue(frame.IsValid()) +        pc = frame.GetPC() +        eip = frame.FindRegister("pc") +        self.assertTrue(eip.IsValid()) +        self.assertEqual(pc, eip.GetValueAsUnsigned()) diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz.cpp new file mode 100644 index 000000000000..295d4a1f24db --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz.cpp @@ -0,0 +1,31 @@ +// A sample program for getting minidumps on Windows. + +#include <iostream> + +bool +fizz(int x) +{ +    return x % 3 == 0; +} + +bool +buzz(int x) +{ +    return x % 5 == 0; +} + +int +main() +{ +    int *buggy = 0; + +    for (int i = 1; i <= 100; ++i) +    { +        if (fizz(i)) std::cout << "fizz"; +        if (buzz(i)) std::cout << "buzz"; +        if (!fizz(i) && !buzz(i)) std::cout << i; +        std::cout << '\n'; +    } + +    return *buggy; +} diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmp b/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmpBinary files differ new file mode 100644 index 000000000000..3d97186f2cd2 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/postmortem/wow64_minidump/fizzbuzz_wow64.dmp diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py b/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py index 83906b546300..e4eb302d83d1 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py +++ b/packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  exe_name = "ProcessAttach"  # Must match Makefile 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 ed9d58f90888..3d1d7fdc7907 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 @@ -9,7 +9,9 @@ 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  exe_name = 'AttachDenied'  # Must match Makefile @@ -17,12 +19,6 @@ class AttachDeniedTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    def run_platform_command(self, cmd): -        platform = self.dbg.GetSelectedPlatform() -        shell_command = lldb.SBPlatformShellCommand(cmd) -        err = platform.Run(shell_command) -        return (err, shell_command.GetStatus(), shell_command.GetOutput()) -      @skipIfWindows      @skipIfiOSSimulator      def test_attach_to_process_by_id_denied(self): @@ -39,21 +35,7 @@ class AttachDeniedTestCase(TestBase):          popen = self.spawnSubprocess(exe, [pid_file_path])          self.addTearDownHook(self.cleanupSubprocesses) -        max_attempts = 5 -        for i in range(max_attempts): -            err, retcode, msg = self.run_platform_command("ls %s" % pid_file_path) -            if err.Success() and retcode == 0: -                break -            else: -                print(msg) -            if i < max_attempts: -                # Exponential backoff! -                time.sleep(pow(2, i) * 0.25) -        else: -            self.fail("Child PID file %s not found even after %d attempts." % (pid_file_path, max_attempts)) -        err, retcode, pid = self.run_platform_command("cat %s" % (pid_file_path)) -        self.assertTrue(err.Success() and retcode == 0, -                        "Failed to read file %s: %s, retcode: %d" % (pid_file_path, err.GetCString(), retcode)) +        pid = lldbutil.wait_for_file_on_target(self, pid_file_path)          self.expect('process attach -p ' + pid,                      startstr = 'error: attach failed:', diff --git a/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py b/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py index 25be37b2b12d..c20d66aa3ab0 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py +++ b/packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py @@ -6,8 +6,9 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ChangeProcessGroupTestCase(TestBase): @@ -35,23 +36,7 @@ class ChangeProcessGroupTestCase(TestBase):          popen = self.spawnSubprocess(exe, [pid_file_path])          self.addTearDownHook(self.cleanupSubprocesses) -        max_attempts = 5 -        for i in range(max_attempts): -            err, retcode, msg = self.run_platform_command("ls %s" % pid_file_path) -            if err.Success() and retcode == 0: -                break -            else: -                print(msg) -            if i < max_attempts: -                # Exponential backoff! -                time.sleep(pow(2, i) * 0.25) -        else: -            self.fail("Child PID file %s not found even after %d attempts." % (pid_file_path, max_attempts)) - -        err, retcode, pid = self.run_platform_command("cat %s" % (pid_file_path)) - -        self.assertTrue(err.Success() and retcode == 0, -                "Failed to read file %s: %s, retcode: %d" % (pid_file_path, err.GetCString(), retcode)) +        pid = lldbutil.wait_for_file_on_target(self, pid_file_path)          # make sure we cleanup the forked child also          def cleanupChild(): @@ -99,9 +84,3 @@ class ChangeProcessGroupTestCase(TestBase):          # run to completion          process.Continue()          self.assertEqual(process.GetState(), lldb.eStateExited) - -    def run_platform_command(self, cmd): -        platform = self.dbg.GetSelectedPlatform() -        shell_command = lldb.SBPlatformShellCommand(cmd) -        err = platform.Run(shell_command) -        return (err, shell_command.GetStatus(), shell_command.GetOutput()) diff --git a/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py b/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py index 3131000be428..5998edb3c7e0 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py +++ b/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py @@ -4,11 +4,16 @@ Test lldb process launch flags.  from __future__ import print_function +import copy +import os +import time - -import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +import six  class ProcessLaunchTestCase(TestBase): @@ -17,9 +22,11 @@ class ProcessLaunchTestCase(TestBase):      def setUp(self):          # Call super's setUp().          TestBase.setUp(self) -        # disable "There is a running process, kill it and restart?" prompt          self.runCmd("settings set auto-confirm true") -        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm")) + +    def tearDown(self): +        self.runCmd("settings clear auto-confirm") +        TestBase.tearDown(self)      @not_remote_testsuite_ready      def test_io (self): @@ -109,7 +116,7 @@ class ProcessLaunchTestCase(TestBase):      # rdar://problem/9056462      # The process launch flag '-w' for setting the current working directory not working?      @not_remote_testsuite_ready -    @expectedFailureLinux("llvm.org/pr20265") +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr20265")      def test_set_working_dir (self):          """Test that '-w dir' sets the working dir when running the inferior."""          d = {'CXX_SOURCES' : 'print_cwd.cpp'} @@ -180,8 +187,9 @@ class ProcessLaunchTestCase(TestBase):              self.fail(err_msg)      def test_environment_with_special_char (self): -        """Test that environment variables containing '*' and '}' are communicated correctly to the lldb-server.""" -        d = {'CXX_SOURCES' : 'print_env.cpp'} +        """Test that environment variables containing '*' and '}' are handled correctly by the inferior.""" +        source = 'print_env.cpp' +        d = {'CXX_SOURCES' : source}          self.build(dictionary=d)          self.setTearDownCleanup(d)          exe = os.path.join (os.getcwd(), "a.out") @@ -189,19 +197,19 @@ class ProcessLaunchTestCase(TestBase):          evil_var = 'INIT*MIDDLE}TAIL'          target = self.dbg.CreateTarget(exe) -        process = target.LaunchSimple(None, ['EVIL=' + evil_var], self.get_process_working_directory()) -        self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) - -        out = process.GetSTDOUT(len(evil_var)) -        self.assertIsNotNone(out, "Encountered an error reading the process's output") +        main_source_spec = lldb.SBFileSpec(source) +        breakpoint = target.BreakpointCreateBySourceRegex('// Set breakpoint here.', main_source_spec) -        out = out[:len(evil_var)] -        if out != evil_var: -            self.fail('The environment variable was mis-coded: %s\n' % repr(out)) +        process = target.LaunchSimple(None, ['EVIL=' + evil_var], self.get_process_working_directory()) +        self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -        newline = process.GetSTDOUT(1) -        self.assertIsNotNone(newline, "Encountered an error reading the process's output") +        threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint) +        self.assertEqual(len(threads), 1) +        frame = threads[0].GetFrameAtIndex(0) +        sbvalue = frame.EvaluateExpression("evil") +        value = sbvalue.GetSummary().strip('"') -        newline = newline[0] -        if newline != '\r' and newline != '\n': -            self.fail('Garbage at end of environment variable') +        self.assertEqual(value, evil_var) +        process.Continue() +        self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) +        pass diff --git a/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp b/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp index cbb9b2175916..8c6df8ea01a4 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp +++ b/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp @@ -5,7 +5,6 @@  int main (int argc, char **argv)  {    char *evil = getenv("EVIL"); -  puts(evil); -  return 0; +  return 0;  // Set breakpoint here.  } 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 0578bcf44b4c..1c01e2138c2e 100644 --- a/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py +++ b/packages/Python/lldbsuite/test/functionalities/process_save_core/TestProcessSaveCore.py @@ -6,7 +6,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ProcessSaveCoreTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/ptr_refs/Makefile b/packages/Python/lldbsuite/test/functionalities/ptr_refs/Makefile new file mode 100644 index 000000000000..0d70f2595019 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/ptr_refs/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py b/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py new file mode 100644 index 000000000000..81db42d8e3c6 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/ptr_refs/TestPtrRefs.py @@ -0,0 +1,43 @@ +""" +Test the ptr_refs tool on Darwin +""" + +from __future__ import print_function + +import os +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestPtrRefs(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @skipUnlessDarwin +    def test_ptr_refs(self): +        """Test format string functionality.""" +        self.build() +        exe_name = 'a.out' +        exe = os.path.join(os.getcwd(), exe_name) +     +        target = self.dbg.CreateTarget(exe) +        self.assertTrue(target, VALID_TARGET) + +        main_file_spec = lldb.SBFileSpec ('main.c') +        breakpoint = target.BreakpointCreateBySourceRegex('break', main_file_spec) +        self.assertTrue(breakpoint and +                        breakpoint.GetNumLocations() == 1, +                        VALID_BREAKPOINT) + +        process = target.LaunchSimple (None, None, self.get_process_working_directory()) +        self.assertTrue(process, PROCESS_IS_VALID) + +        # Frame #0 should be on self.line1 and the break condition should hold. +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint condition") + +        frame = thread.GetFrameAtIndex(0)        + +        self.dbg.HandleCommand("script import lldb.macosx.heap") +        self.expect("ptr_refs my_ptr", substrs=["malloc", "stack"]); diff --git a/packages/Python/lldbsuite/test/functionalities/ptr_refs/main.c b/packages/Python/lldbsuite/test/functionalities/ptr_refs/main.c new file mode 100644 index 000000000000..4053f9997276 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/ptr_refs/main.c @@ -0,0 +1,27 @@ +//===-- 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> +#include <stdlib.h> +#include <string.h> + +struct referent { +    const char *p; +}; + +int main (int argc, char const *argv[]) +{ +    const char *my_ptr = strdup("hello"); +    struct referent *r = malloc(sizeof(struct referent)); +    r->p = my_ptr; + +    printf("%p\n", r); // break here + +    return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py b/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py index c5d4650aa371..21de3ab7cc37 100644 --- a/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py +++ b/packages/Python/lldbsuite/test/functionalities/register/TestRegisters.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, sys, time  import re  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class RegisterCommandsTestCase(TestBase): @@ -25,7 +26,7 @@ class RegisterCommandsTestCase(TestBase):          TestBase.tearDown(self)      @skipIfiOSSimulator -    @skipUnlessArch(['amd64', 'arm', 'i386', 'x86_64']) +    @skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64']))      def test_register_commands(self):          """Test commands related to registers, in particular vector registers."""          self.build() @@ -48,7 +49,7 @@ class RegisterCommandsTestCase(TestBase):      @skipIfiOSSimulator      @skipIfTargetAndroid(archs=["i386"]) # Writing of mxcsr register fails, presumably due to a kernel/hardware problem -    @skipUnlessArch(['amd64', 'arm', 'i386', 'x86_64']) +    @skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64']))      def test_fp_register_write(self):          """Test commands that write to registers, in particular floating-point registers."""          self.build() @@ -57,14 +58,14 @@ class RegisterCommandsTestCase(TestBase):      @skipIfiOSSimulator      @expectedFailureAndroid(archs=["i386"]) # "register read fstat" always return 0xffff      @skipIfFreeBSD    #llvm.org/pr25057 -    @skipUnlessArch(['amd64', 'i386', 'x86_64']) +    @skipIf(archs=no_match(['amd64', 'i386', 'x86_64']))      def test_fp_special_purpose_register_read(self):          """Test commands that read fpu special purpose registers."""          self.build()          self.fp_special_purpose_register_read()      @skipIfiOSSimulator -    @skipUnlessArch(['amd64', 'arm', 'i386', 'x86_64']) +    @skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64']))      def test_register_expressions(self):          """Test expression evaluation with commands related to registers."""          self.build() @@ -85,21 +86,21 @@ class RegisterCommandsTestCase(TestBase):              self.expect("expr -- ($rax & 0xffffffff) == $eax", substrs = ['true'])      @skipIfiOSSimulator -    @skipUnlessArch(['amd64', 'x86_64']) +    @skipIf(archs=no_match(['amd64', 'x86_64']))      def test_convenience_registers(self):          """Test convenience registers."""          self.build()          self.convenience_registers()      @skipIfiOSSimulator -    @skipUnlessArch(['amd64', 'x86_64']) +    @skipIf(archs=no_match(['amd64', 'x86_64']))      def test_convenience_registers_with_process_attach(self):          """Test convenience registers after a 'process attach'."""          self.build()          self.convenience_registers_with_process_attach(test_16bit_regs=False)      @skipIfiOSSimulator -    @skipUnlessArch(['amd64', 'x86_64']) +    @skipIf(archs=no_match(['amd64', 'x86_64']))      def test_convenience_registers_16bit_with_process_attach(self):          """Test convenience registers after a 'process attach'."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py b/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py index 0ed56de35699..8636abadd104 100644 --- a/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py +++ b/packages/Python/lldbsuite/test/functionalities/rerun/TestRerun.py @@ -8,8 +8,9 @@ from __future__ import print_function  import lldb  import os  import time +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class TestRerun(TestBase): @@ -31,19 +32,9 @@ class TestRerun(TestBase):          self.runCmd("process launch 1 2 3")          process = self.process() - -        self.assertTrue(process.GetState() == lldb.eStateStopped, -                        STOPPED_DUE_TO_BREAKPOINT) - -        thread = process.GetThreadAtIndex (0) - -        self.assertTrue (thread.IsValid(), -                         "Process stopped at 'main' should have a valid thread"); - -        stop_reason = thread.GetStopReason() -         -        self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint, -                         "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint"); +        thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) +        self.assertIsNotNone(thread, "Process should be stopped at a breakpoint in main") +        self.assertTrue(thread.IsValid(), "Stopped thread is not valid")          self.expect("frame variable argv[1]", substrs=['1'])          self.expect("frame variable argv[2]", substrs=['2']) @@ -57,19 +48,10 @@ class TestRerun(TestBase):          self.runCmd("process launch")          process = self.process() -         -        self.assertTrue(process.GetState() == lldb.eStateStopped, -                        STOPPED_DUE_TO_BREAKPOINT) - -        thread = process.GetThreadAtIndex (0) +        thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint) -        self.assertTrue (thread.IsValid(), -                         "Process stopped at 'main' should have a valid thread"); - -        stop_reason = thread.GetStopReason() -         -        self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint, -                         "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint"); +        self.assertIsNotNone(thread, "Process should be stopped at a breakpoint in main"); +        self.assertTrue(thread.IsValid(), "Stopped thread is not valid")          self.expect("frame variable argv[1]", substrs=['1'])          self.expect("frame variable argv[2]", substrs=['2']) diff --git a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py index 246eb5c3fdbd..81d93294b5a5 100644 --- a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ReturnValueTestCase(TestBase): @@ -19,7 +20,7 @@ class ReturnValueTestCase(TestBase):      @expectedFailureAll(oslist=["macosx","freebsd"], archs=["i386"])      @expectedFailureAll(oslist=["linux"], compiler="clang", compiler_version=["<=", "3.6"], archs=["i386"])      @expectedFailureAll(bugnumber="llvm.org/pr25785", hostoslist=["windows"], compiler="gcc", archs=["i386"], triple='.*-android') -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      @add_test_categories(['pyapi'])      def test_with_python(self):          """Test getting return values from stepping out.""" diff --git a/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py b/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py index 3acad5f87be0..294aa6725155 100644 --- a/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py +++ b/packages/Python/lldbsuite/test/functionalities/set-data/TestSetData.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class SetDataTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py b/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py index 971b82a7c75d..1da4d701a590 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py +++ b/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py @@ -6,8 +6,9 @@ from __future__ import print_function  import os, time, signal  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class SendSignalTestCase(TestBase): @@ -20,7 +21,7 @@ class SendSignalTestCase(TestBase):          # Find the line number to break inside main().          self.line = line_number('main.c', 'Put breakpoint here') -    @expectedFailureFreeBSD("llvm.org/pr23318: does not report running state") +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23318: does not report running state")      @skipIfWindows # Windows does not support signals      def test_with_run_command(self):          """Test that lldb command 'process signal SIGUSR1' sends a signal to the inferior process.""" 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 feed5bfb3c76..d8dbb7f68936 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py +++ b/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py @@ -5,10 +5,12 @@ from __future__ import print_function  import os +import re +  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil -import re +from lldbsuite.test import lldbutil  class HandleSegvTestCase(TestBase): @@ -17,7 +19,7 @@ class HandleSegvTestCase(TestBase):      @skipIfWindows # signals do not exist on Windows      @skipIfDarwin -    @expectedFailureFreeBSD("llvm.org/pr23699 SIGSEGV is reported as exception, not signal") +    @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")      def test_inferior_handle_sigsegv(self):          self.build()          exe = os.path.join(os.getcwd(), "a.out") diff --git a/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py index 39e7753397d1..2c30f69d7b20 100644 --- a/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py +++ b/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py @@ -6,9 +6,11 @@ from __future__ import print_function  import os  import lldb -from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil  import re +from lldbsuite.test.lldbplatformutil import getDarwinOSTriples +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  @skipIfWindows # signals do not exist on Windows @@ -148,8 +150,7 @@ class RaiseTestCase(TestBase):          # reset signal handling to default          self.set_handle(signal, default_pass, default_stop, default_notify) -    @expectedFailureLinux("llvm.org/pr24530") # the signal the inferior generates gets lost -    @expectedFailureDarwin("llvm.org/pr24530") # the signal the inferior generates gets lost +    @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""" 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 6a2dd74d3956..6f5882636cb6 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 @@ -8,7 +8,9 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class SingleQuoteInCommandLineTestCase(TestBase): @@ -25,7 +27,7 @@ class SingleQuoteInCommandLineTestCase(TestBase):          except:              pass -    @expectedFailureHostWindows("llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")      @no_debug_info_test      def test_lldb_invocation_with_single_quote_in_filename(self):          """Test that 'lldb my_file_name' works where my_file_name is a string with a single quote char in it.""" 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 6c1f2c3da41b..8b9c91217de4 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 @@ -8,10 +8,12 @@ from __future__ import print_function  import os  import re -import lldb -import lldbsuite.test.lldbutil as lldbutil  import sys + +import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ReturnValueTestCase(TestBase): @@ -25,7 +27,8 @@ class ReturnValueTestCase(TestBase):          self.do_step_out_past_nodebug()      @add_test_categories(['pyapi']) -    @expectedFailureGcc("llvm.org/pr19247") +    @decorators.expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr28549") +    @decorators.expectedFailureAll(compiler="clang", compiler_version=[">=", "3.9"], archs=["i386"], bugnumber="llvm.org/pr28549")      def test_step_over_with_python(self):          """Test stepping over using avoid-no-debug with dwarf."""          self.build() @@ -33,7 +36,8 @@ class ReturnValueTestCase(TestBase):          self.do_step_over_past_nodebug()      @add_test_categories(['pyapi']) -    @expectedFailureGcc("llvm.org/pr19247") +    @decorators.expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr28549") +    @decorators.expectedFailureAll(compiler="clang", compiler_version=[">=", "3.9"], archs=["i386"], bugnumber="llvm.org/pr28549")      def test_step_in_with_python(self):          """Test stepping in using avoid-no-debug with dwarf."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py index 753491339c4c..93f846a06870 100644 --- a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py +++ b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class StopHookCmdTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py index 7785d85772e2..c42c1e563881 100644 --- a/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py +++ b/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py @@ -8,8 +8,10 @@ from __future__ import print_function  import os  import lldb -from lldbsuite.test import configuration +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import configuration +from lldbsuite.test import lldbutil  class StopHookMechanismTestCase(TestBase): @@ -26,7 +28,7 @@ class StopHookMechanismTestCase(TestBase):      @skipIfFreeBSD # llvm.org/pr15037      @expectedFlakeyLinux('llvm.org/pr15037') # stop-hooks sometimes fail to fire on Linux -    @expectedFailureHostWindows("llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")      def test(self):          """Test the stop-hook mechanism."""          self.build() 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 c7fb53d495e6..57395832dc21 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 @@ -8,8 +8,10 @@ from __future__ import print_function  import os, time  import lldb -from lldbsuite.test import configuration +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import configuration +from lldbsuite.test import lldbutil  class StopHookForMultipleThreadsTestCase(TestBase): @@ -29,7 +31,7 @@ class StopHookForMultipleThreadsTestCase(TestBase):      @expectedFlakeyFreeBSD("llvm.org/pr15037")      @expectedFlakeyLinux("llvm.org/pr15037") # stop hooks sometimes fail to fire on Linux -    @expectedFailureHostWindows("llvm.org/pr22274: need a pexpect replacement for windows") +    @expectedFailureAll(hostoslist=["windows"], bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")      def test_stop_hook_multiple_threads(self):          """Test that lldb stop-hook works for multiple threads."""          self.build(dictionary=self.d) diff --git a/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py b/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py index 0ab965d2aa16..126f6e4dab80 100644 --- a/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py +++ b/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py @@ -8,8 +8,9 @@ from __future__ import print_function  import lldb  import sys +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class targetCommandTestCase(TestBase): 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 91bc68577a43..902adacb2abd 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/TestBacktraceAll.py @@ -5,8 +5,9 @@ Test regression for Bug 25251.  import os, time  import unittest2  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class BreakpointAfterJoinTestCase(TestBase): 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 43397a122391..8ef0fb0a000d 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class BreakpointAfterJoinTestCase(TestBase): @@ -21,9 +22,9 @@ class BreakpointAfterJoinTestCase(TestBase):          # Find the line number for our breakpoint.          self.breakpoint = line_number('main.cpp', '// Set breakpoint here') -    @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained +    @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") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained")      def test(self):          """Test breakpoint handling after a thread join."""          self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp index a63079524ee2..f9f33fda82bb 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp @@ -19,24 +19,12 @@  volatile int g_test = 0; -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing()   - -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) -  // A barrier to synchronize all the threads. -std::atomic_int g_barrier1; +pseudo_barrier_t g_barrier1;  // A barrier to keep the threads from exiting until after the breakpoint has  // been passed. -std::atomic_int g_barrier2; +pseudo_barrier_t g_barrier2;  void *  break_thread_func () diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py index 9eb25b68765a..30adcccd203f 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentEvents.py @@ -17,11 +17,11 @@ from __future__ import print_function  import unittest2  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  @skipIfWindows -@expectedFailureAll(archs=['mips64', 'mips64el']) # Atomic sequences are not supported yet for MIPS in LLDB.   class ConcurrentEventsTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) @@ -30,24 +30,28 @@ class ConcurrentEventsTestCase(TestBase):      ## Tests for multiple threads that generate a single event.      #      @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_many_breakpoints(self):          """Test 100 breakpoints from 100 threads."""          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_breakpoint_threads=100)      @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_many_watchpoints(self):          """Test 100 watchpoints from 100 threads."""          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_watchpoint_threads=100)      @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_many_signals(self):          """Test 100 signals from 100 threads."""          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_signal_threads=100)      @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_many_crash(self):          """Test 100 threads that cause a segfault."""          self.build(dictionary=self.getBuildFlags()) @@ -58,18 +62,21 @@ class ConcurrentEventsTestCase(TestBase):      ## Tests for concurrent signal and breakpoint      #      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_signal_break(self):          """Test signal and a breakpoint in multiple threads."""          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_breakpoint_threads=1, num_signal_threads=1)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_delay_signal_break(self):          """Test (1-second delay) signal and a breakpoint in multiple threads."""          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_breakpoint_threads=1, num_delay_signal_threads=1)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_signal_delay_break(self):          """Test signal and a (1 second delay) breakpoint in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -81,6 +88,7 @@ class ConcurrentEventsTestCase(TestBase):      #      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_watch_break(self):          """Test watchpoint and a breakpoint in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -88,6 +96,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_delay_watch_break(self):          """Test (1-second delay) watchpoint and a breakpoint in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -95,6 +104,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_watch_break_delay(self):          """Test watchpoint and a (1 second delay) breakpoint in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -105,6 +115,7 @@ class ConcurrentEventsTestCase(TestBase):      #      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_signal_watch(self):          """Test a watchpoint and a signal in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -112,6 +123,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_delay_signal_watch(self):          """Test a watchpoint and a (1 second delay) signal in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -119,7 +131,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock -    @expectedFailureAll("llvm.org/pr16714", oslist=["linux"], archs=["i386"]) +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_signal_delay_watch(self):          """Test a (1 second delay) watchpoint and a signal in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -130,12 +142,14 @@ class ConcurrentEventsTestCase(TestBase):      ## Tests for multiple breakpoint threads      #      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_breakpoint_threads(self):          """Test two threads that trigger a breakpoint. """          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_breakpoint_threads=2)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_breakpoint_one_delay_breakpoint_threads(self):          """Test threads that trigger a breakpoint where one thread has a 1 second delay. """          self.build(dictionary=self.getBuildFlags()) @@ -143,12 +157,14 @@ class ConcurrentEventsTestCase(TestBase):                                 num_delay_breakpoint_threads=1)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_breakpoints_one_signal(self):          """Test two threads that trigger a breakpoint and one signal thread. """          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_breakpoint_threads=2, num_signal_threads=1)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_breakpoint_delay_breakpoint_one_signal(self):          """Test two threads that trigger a breakpoint (one with a 1 second delay) and one signal thread. """          self.build(dictionary=self.getBuildFlags()) @@ -157,6 +173,7 @@ class ConcurrentEventsTestCase(TestBase):                                 num_signal_threads=1)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_breakpoints_one_delay_signal(self):          """Test two threads that trigger a breakpoint and one (1 second delay) signal thread. """          self.build(dictionary=self.getBuildFlags()) @@ -164,6 +181,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_breakpoints_one_watchpoint(self):          """Test two threads that trigger a breakpoint and one watchpoint thread. """          self.build(dictionary=self.getBuildFlags()) @@ -171,6 +189,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_breakpoints_delayed_breakpoint_one_watchpoint(self):          """Test a breakpoint, a delayed breakpoint, and one watchpoint thread. """          self.build(dictionary=self.getBuildFlags()) @@ -183,6 +202,7 @@ class ConcurrentEventsTestCase(TestBase):      #      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_watchpoint_threads(self):          """Test two threads that trigger a watchpoint. """          self.build(dictionary=self.getBuildFlags()) @@ -190,6 +210,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_watchpoint_with_delay_watchpoint_threads(self):          """Test two threads that trigger a watchpoint where one thread has a 1 second delay. """          self.build(dictionary=self.getBuildFlags()) @@ -198,6 +219,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_watchpoints_one_breakpoint(self):          """Test two threads that trigger a watchpoint and one breakpoint thread. """          self.build(dictionary=self.getBuildFlags()) @@ -205,6 +227,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_watchpoints_one_delay_breakpoint(self):          """Test two threads that trigger a watchpoint and one (1 second delay) breakpoint thread. """          self.build(dictionary=self.getBuildFlags()) @@ -212,6 +235,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_watchpoint_delay_watchpoint_one_breakpoint(self):          """Test two threads that trigger a watchpoint (one with a 1 second delay) and one breakpoint thread. """          self.build(dictionary=self.getBuildFlags()) @@ -221,6 +245,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_two_watchpoints_one_signal(self):          """Test two threads that trigger a watchpoint and one signal thread. """          self.build(dictionary=self.getBuildFlags()) @@ -231,6 +256,7 @@ class ConcurrentEventsTestCase(TestBase):      #      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_signal_watch_break(self):          """Test a signal/watchpoint/breakpoint in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -240,6 +266,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_signal_watch_break(self):          """Test one signal thread with 5 watchpoint and breakpoint threads."""          self.build(dictionary=self.getBuildFlags()) @@ -249,6 +276,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_signal_watch_break(self):          """Test with 5 watchpoint and breakpoint threads."""          self.build(dictionary=self.getBuildFlags()) @@ -260,6 +288,7 @@ class ConcurrentEventsTestCase(TestBase):      ## Test for crashing threads happening concurrently with other events      #      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_crash_with_break(self):          """ Test a thread that crashes while another thread hits a breakpoint."""          self.build(dictionary=self.getBuildFlags()) @@ -267,12 +296,14 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_crash_with_watchpoint(self):          """ Test a thread that crashes while another thread hits a watchpoint."""          self.build(dictionary=self.getBuildFlags())          self.do_thread_actions(num_crash_threads=1, num_watchpoint_threads=1)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_crash_with_signal(self):          """ Test a thread that crashes while another thread generates a signal."""          self.build(dictionary=self.getBuildFlags()) @@ -280,6 +311,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_crash_with_watchpoint_breakpoint_signal(self):          """ Test a thread that crashes while other threads generate a signal and hit a watchpoint and breakpoint. """          self.build(dictionary=self.getBuildFlags()) @@ -290,6 +322,7 @@ class ConcurrentEventsTestCase(TestBase):      @skipIfFreeBSD # timing out on buildbot      @skipIfRemoteDueToDeadlock +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_delayed_crash_with_breakpoint_watchpoint(self):          """ Test a thread with a delayed crash while other threads hit a watchpoint and a breakpoint. """          self.build(dictionary=self.getBuildFlags()) @@ -298,6 +331,7 @@ class ConcurrentEventsTestCase(TestBase):                                 num_watchpoint_threads=1)      @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(triple = '^mips') # Atomic sequences are not supported yet for MIPS in LLDB.      def test_delayed_crash_with_breakpoint_signal(self):          """ Test a thread with a delayed crash while other threads generate a signal and hit a breakpoint. """          self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp index ac2535cd2bff..10b55bff3ba4 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp @@ -23,22 +23,10 @@ using namespace std;  #include <sys/types.h>  #include <unistd.h> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) -  typedef std::vector<std::pair<unsigned, void*(*)(void*)> > action_counts;  typedef std::vector<pthread_t> thread_vector; -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier;  int g_breakpoint = 0;  int g_sigusr1_count = 0;  std::atomic_int g_watchme; 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 24b5bf0dad36..edd1e885ca9e 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class CreateDuringStepTestCase(TestBase): @@ -19,9 +20,10 @@ class CreateDuringStepTestCase(TestBase):          TestBase.setUp(self)          self.breakpoint = line_number('main.cpp', '// Set breakpoint here') -    @expectedFailureWindows("llvm.org/pr24778") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")      @expectedFailureAndroid("llvm.org/pr24497", archs=['arm', 'aarch64']) -    @expectedFailureAll(archs=['mips', 'mipsel', 'mips64', 'mips64el'])    # IO error due to breakpoint at invalid address +    @expectedFailureAll(oslist=["linux"], archs=["arm"], bugnumber="llvm.org/pr24497") +    @expectedFailureAll(triple = re.compile('^mips'))    # IO error due to breakpoint at invalid address      def test_step_inst_with(self):          """Test thread creation during step-inst handling."""          self.build(dictionary=self.getBuildFlags()) @@ -38,11 +40,8 @@ class CreateDuringStepTestCase(TestBase):          # The stop reason should be breakpoint.          self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) -        self.assertEqual(lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint).IsValid(), 1, -                STOPPED_DUE_TO_BREAKPOINT) - -        thread = process.GetThreadAtIndex(0) -        self.assertTrue(thread and thread.IsValid(), "Thread is valid") +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertTrue(thread.IsValid(), STOPPED_DUE_TO_BREAKPOINT)          # Keep stepping until the inferior crashes          while process.GetState() == lldb.eStateStopped and not lldbutil.is_thread_crashed(self, thread): 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 977254343aa0..1cb97355395f 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class CreateAfterAttachTestCase(TestBase): @@ -29,7 +30,6 @@ class CreateAfterAttachTestCase(TestBase):                     # for FreeBSD.      @skipIfRemote      @skipIfWindows # Windows doesn't have fork. -    @expectedFlakeyLinux("llvm.org/pr16229") # 1/100 dosep, build 3546, clang-3.5 x84_64      @skipIfiOSSimulator      def test_create_after_attach_with_fork(self):          """Test thread creation after process attach.""" 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 046a86509c0f..9401826e304e 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 @@ -8,35 +8,36 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class CreateDuringStepTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @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") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test_step_inst(self):          """Test thread creation during step-inst handling."""          self.build(dictionary=self.getBuildFlags())          self.create_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step') -    @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @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") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test_step_over(self):          """Test thread creation during step-over handling."""          self.build(dictionary=self.getBuildFlags())          self.create_during_step_base("thread step-over -m all-threads", 'stop reason = step over') -    @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @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") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test_step_in(self):          """Test thread creation during step-in handling."""          self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp index 3a00248c022a..70681fd11603 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp @@ -13,19 +13,9 @@  #include <atomic>  #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized.  #define do_nothing() -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier;  volatile int g_thread_created = 0;  volatile int g_test = 0; 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 f999ffe108f3..2c394263d36e 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ExitDuringBreakpointTestCase(TestBase): @@ -21,10 +22,10 @@ class ExitDuringBreakpointTestCase(TestBase):          # Find the line number for our breakpoint.          self.breakpoint = line_number('main.cpp', '// Set breakpoint here') -    @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @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") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test(self):          """Test thread exit during breakpoint handling."""          self.build(dictionary=self.getBuildFlags()) 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 3570637207d2..a032da835ea6 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 @@ -19,27 +19,15 @@  volatile int g_test = 0; -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing()   - -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) -  // A barrier to synchronize all the threads except the one that will exit. -std::atomic_int g_barrier1; +pseudo_barrier_t g_barrier1;  // A barrier to synchronize all the threads including the one that will exit. -std::atomic_int g_barrier2; +pseudo_barrier_t g_barrier2;  // A barrier to keep the first group of threads from exiting until after the  // breakpoint has been passed. -std::atomic_int g_barrier3; +pseudo_barrier_t g_barrier3;  void *  break_thread_func () 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 67d1c96fd342..af4a022ed0c1 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 @@ -8,42 +8,31 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ExitDuringStepTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24681") -    def test_thread_state_is_stopped(self): -        """Test thread exit during step handling.""" -        self.build(dictionary=self.getBuildFlags()) -        self.exit_during_step_base("thread step-in -m all-threads", 'stop reason = step in', True) -      @skipIfFreeBSD # llvm.org/pr21411: test is hanging -    @expectedFailureWindows("llvm.org/pr24681")      def test(self):          """Test thread exit during step handling."""          self.build(dictionary=self.getBuildFlags()) -        self.exit_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step', False) +        self.exit_during_step_base("thread step-inst -m all-threads", 'stop reason = instruction step')      @skipIfFreeBSD # llvm.org/pr21411: test is hanging -    @expectedFailureWindows("llvm.org/pr24681")      def test_step_over(self):          """Test thread exit during step-over handling."""          self.build(dictionary=self.getBuildFlags()) -        self.exit_during_step_base("thread step-over -m all-threads", 'stop reason = step over', False) +        self.exit_during_step_base("thread step-over -m all-threads", 'stop reason = step over')      @skipIfFreeBSD # llvm.org/pr21411: test is hanging -    @expectedFailureWindows("llvm.org/pr24681")      def test_step_in(self):          """Test thread exit during step-in handling."""          self.build(dictionary=self.getBuildFlags()) -        self.exit_during_step_base("thread step-in -m all-threads", 'stop reason = step in', False) +        self.exit_during_step_base("thread step-in -m all-threads", 'stop reason = step in')      def setUp(self):          # Call super's setUp(). @@ -52,7 +41,7 @@ class ExitDuringStepTestCase(TestBase):          self.breakpoint = line_number('main.cpp', '// Set breakpoint here')          self.continuepoint = line_number('main.cpp', '// Continue from here') -    def exit_during_step_base(self, step_cmd, step_stop_reason, test_thread_state): +    def exit_during_step_base(self, step_cmd, step_stop_reason):          """Test thread exit during step handling."""          exe = os.path.join(os.getcwd(), "a.out")          self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -76,37 +65,16 @@ class ExitDuringStepTestCase(TestBase):          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads          num_threads = process.GetNumThreads() -          # Make sure we see all three threads -        self.assertTrue(num_threads == 3, 'Number of expected threads and actual threads do not match.') - -        # Get the thread objects -        thread1 = process.GetThreadAtIndex(0) -        thread2 = process.GetThreadAtIndex(1) -        thread3 = process.GetThreadAtIndex(2) - -        # Make sure all threads are stopped -        if test_thread_state: -            self.assertTrue(thread1.IsStopped(), "Thread 1 didn't stop during breakpoint") -            self.assertTrue(thread2.IsStopped(), "Thread 2 didn't stop during breakpoint") -            self.assertTrue(thread3.IsStopped(), "Thread 3 didn't stop during breakpoint") -            return - -        # Find the thread that is stopped at the breakpoint -        stepping_thread = None -        for thread in process: -            expected_bp_desc = "breakpoint %s." % self.bp_num -            stop_desc = thread.GetStopDescription(100) -            if stop_desc and (expected_bp_desc in stop_desc): -                stepping_thread = thread -                break -        self.assertTrue(stepping_thread != None, "unable to find thread stopped at %s" % expected_bp_desc) +        self.assertGreaterEqual(num_threads, 3, 'Number of expected threads and actual threads do not match.') + +        stepping_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, self.bp_num) +        self.assertIsNotNone(stepping_thread, "Could not find a thread stopped at the breakpoint")          current_line = self.breakpoint          stepping_frame = stepping_thread.GetFrameAtIndex(0) -        self.assertTrue(current_line == stepping_frame.GetLineEntry().GetLine(), "Starting line for stepping doesn't match breakpoint line.") +        self.assertEqual(current_line, stepping_frame.GetLineEntry().GetLine(), "Starting line for stepping doesn't match breakpoint line.")          # Keep stepping until we've reached our designated continue point          while current_line != self.continuepoint: @@ -122,16 +90,16 @@ class ExitDuringStepTestCase(TestBase):              current_line = frame.GetLineEntry().GetLine() -            self.assertTrue(current_line >= self.breakpoint, "Stepped to unexpected line, " + str(current_line)) -            self.assertTrue(current_line <= self.continuepoint, "Stepped to unexpected line, " + str(current_line)) +            self.assertGreaterEqual(current_line, self.breakpoint, "Stepped to unexpected line, " + str(current_line)) +            self.assertLessEqual(current_line, self.continuepoint, "Stepped to unexpected line, " + str(current_line))          self.runCmd("thread list")          # Update the number of threads -        num_threads = process.GetNumThreads() +        new_num_threads = process.GetNumThreads()          # Check to see that we reduced the number of threads as expected -        self.assertTrue(num_threads == 2, 'Number of expected threads and actual threads do not match after thread exit.') +        self.assertEqual(new_num_threads, num_threads-1, 'Number of threads did not reduce by 1 after thread exit.')          self.expect("thread list", 'Process state is stopped due to step',                  substrs = ['stopped', @@ -141,4 +109,4 @@ class ExitDuringStepTestCase(TestBase):          self.runCmd("continue")          # At this point, the inferior process should have exited. -        self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) +        self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp index d1b364b8baa2..45adf28ce813 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp @@ -12,20 +12,10 @@  #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized.  #define do_nothing() -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) -  // A barrier to synchronize thread start. -volatile int g_barrier; +pseudo_barrier_t g_barrier;  volatile int g_thread_exited = 0; diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py index 768e2fe4f87a..4c55bcd982a7 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ThreadJumpTestCase(TestBase): 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 9dd212412216..d4b1eb32a9ae 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/TestMultipleBreakpoints.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class MultipleBreakpointTestCase(TestBase): @@ -21,10 +22,10 @@ class MultipleBreakpointTestCase(TestBase):          # Find the line number for our breakpoint.          self.breakpoint = line_number('main.cpp', '// Set breakpoint here') -    @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @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") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test(self):          """Test simultaneous breakpoints in multiple threads."""          self.build(dictionary=self.getBuildFlags()) @@ -55,7 +56,7 @@ class MultipleBreakpointTestCase(TestBase):          num_threads = process.GetNumThreads()          # Make sure we see all three threads -        self.assertTrue(num_threads == 3, 'Number of expected threads and actual threads do not match.') +        self.assertTrue(num_threads >= 3, 'Number of expected threads and actual threads do not match.')          # Get the thread objects          thread1 = process.GetThreadAtIndex(0) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp index 01f4b8f98ea7..c3d695dbc745 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp @@ -15,19 +15,7 @@  #include <atomic>  #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier;  volatile int g_test = 0; diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py index 4938ec50453e..5afb57bf4ba8 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -9,25 +9,26 @@ from __future__ import print_function  import unittest2  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ThreadStateTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureDarwin("rdar://15367566") -    @expectedFailureFreeBSD('llvm.org/pr15824') -    @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained +    @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") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18190 thread states not properly maintained")      def test_state_after_breakpoint(self):          """Test thread state after breakpoint."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False))          self.thread_state_after_breakpoint_test()      @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly -    @expectedFailureDarwin('llvm.org/pr23669') -    @expectedFailureFreeBSD('llvm.org/pr15824') -    @expectedFailureWindows("llvm.org/pr24660") +    @expectedFailureAll(oslist=lldbplatformutil.getDarwinOSTriples(), bugnumber="llvm.org/pr23669") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr15824") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660")      def test_state_after_continue(self):          """Test thread state after continue."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -35,7 +36,7 @@ class ThreadStateTestCase(TestBase):      @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly      @expectedFailureDarwin('llvm.org/pr23669') -    @expectedFailureWindows("llvm.org/pr24660") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660")      @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained      def test_state_after_expression(self):          """Test thread state after expression.""" @@ -43,14 +44,14 @@ class ThreadStateTestCase(TestBase):          self.thread_state_after_expression_test()      @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test_process_interrupt(self):          """Test process interrupt."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False))          self.process_interrupt_test()      @unittest2.expectedFailure("llvm.org/pr15824") # thread states not properly maintained -    @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")      def test_process_state(self):          """Test thread states (comprehensive)."""          self.build(dictionary=self.getBuildFlags(use_cpp11=False)) @@ -69,28 +70,17 @@ class ThreadStateTestCase(TestBase):          self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)          # This should create a breakpoint in the main thread. -        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) +        bp = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1)          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Make sure the thread is in the stopped state.          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") @@ -99,11 +89,11 @@ class ThreadStateTestCase(TestBase):          # Kill the process          self.runCmd("process kill") -    def wait_for_running_event(self): +    def wait_for_running_event(self, process):          listener = self.dbg.GetListener()          if lldb.remote_platform: -            lldbutil.expect_state_changes(self, listener, [lldb.eStateConnected]) -        lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) +            lldbutil.expect_state_changes(self, listener, process, [lldb.eStateConnected]) +        lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])      def thread_state_after_continue_test(self):          """Test thread state after continue.""" @@ -117,28 +107,17 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change.          self.dbg.SetAsync(True)          self.runCmd("continue") -        self.wait_for_running_event() +        self.wait_for_running_event(process)          # Check the thread state. It should be running.          self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") @@ -162,23 +141,12 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Get the inferior out of its loop          self.runCmd("expression g_test = 1") @@ -202,25 +170,17 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change.          self.dbg.SetAsync(True)          self.runCmd("continue") -        self.wait_for_running_event() +        self.wait_for_running_event(process)          # Go back to synchronous interactions          self.dbg.SetAsync(False) @@ -228,11 +188,7 @@ class ThreadStateTestCase(TestBase):          # Stop the process          self.runCmd("process interrupt") -        # The stop reason of the thread should be signal. -        self.expect("process status", STOPPED_DUE_TO_SIGNAL, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = signal']) +        self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)          # Get the inferior out of its loop          self.runCmd("expression g_test = 1") @@ -252,23 +208,11 @@ class ThreadStateTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() - -        # Get the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') - -        # Get the thread object -        thread = process.GetThreadAtIndex(0) +        thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +        self.assertIsNotNone(thread)          # Make sure the thread is in the stopped state.          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") @@ -277,7 +221,7 @@ class ThreadStateTestCase(TestBase):          # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change.          self.dbg.SetAsync(True)          self.runCmd("continue") -        self.wait_for_running_event() +        self.wait_for_running_event(process)          # Check the thread state. It should be running.          self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") @@ -289,11 +233,7 @@ class ThreadStateTestCase(TestBase):          # Stop the process          self.runCmd("process interrupt") -        # The stop reason of the thread should be signal. -        self.expect("process status", STOPPED_DUE_TO_SIGNAL, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = signal']) +        self.assertEqual(thread.GetState(), lldb.eStopReasonSignal)          # Check the thread state          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after process stop.") @@ -306,20 +246,12 @@ class ThreadStateTestCase(TestBase):          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after expression evaluation.")          self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after expression evaluation.") -        # The stop reason of the thread should be signal. -        self.expect("process status", STOPPED_DUE_TO_SIGNAL, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = signal']) +        self.assertEqual(thread.GetState(), lldb.eStopReasonSignal)          # Run to breakpoint 2          self.runCmd("continue") -        # The stop reason of the thread should be breakpoint. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint']) +        self.assertEqual(thread.GetState(), lldb.eStopReasonBreakpoint)          # Make sure both threads are stopped          self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 2.") @@ -329,4 +261,4 @@ class ThreadStateTestCase(TestBase):          self.runCmd("continue")          # At this point, the inferior process should have exited. -        self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) +        self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) 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 b2d966c4c0f3..735ee80d624e 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/TestThreadStepOut.py @@ -8,35 +8,36 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ThreadStepOutTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @skipIfLinux                              # Test occasionally times out on the Linux build bot -    @expectedFailureLinux("llvm.org/pr23477") # Test occasionally times out on the Linux build bot -    @expectedFailureFreeBSD("llvm.org/pr18066") # inferior does not exit -    @expectedFailureWindows # Test crashes +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr18066 inferior does not exit") +    @expectedFailureAll(oslist=["windows"])      def test_step_single_thread(self):          """Test thread step out on one thread via command interpreter. """          self.build(dictionary=self.getBuildFlags())          self.step_out_test(self.step_out_single_thread_with_cmd)      @skipIfLinux                              # Test occasionally times out on the Linux build bot -    @expectedFailureLinux("llvm.org/pr23477") # Test occasionally times out on the Linux build bot -    @expectedFailureFreeBSD("llvm.org/pr19347") # 2nd thread stops at breakpoint -    @expectedFailureWindows # Test crashes +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") +    @expectedFailureAll(oslist=["windows"])      def test_step_all_threads(self):          """Test thread step out on all threads via command interpreter. """          self.build(dictionary=self.getBuildFlags())          self.step_out_test(self.step_out_all_threads_with_cmd)      @skipIfLinux                              # Test occasionally times out on the Linux build bot -    @expectedFailureLinux("llvm.org/pr23477") # Test occasionally times out on the Linux build bot -    @expectedFailureFreeBSD("llvm.org/pr19347") -    @expectedFailureWindows("llvm.org/pr24681") +    @expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr23477 Test occasionally times out on the Linux build bot") +    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr19347 2nd thread stops at breakpoint") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24681")      def test_python(self):          """Test thread step out on one thread via Python API (dwarf)."""          self.build(dictionary=self.getBuildFlags()) diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp index b4c6216d6bfe..31f9a1576b92 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp @@ -13,19 +13,7 @@  #include <atomic>  #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier; +pseudo_barrier_t g_barrier;  volatile int g_test = 0; 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 f785401277a4..2ba6f2e57f2b 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py @@ -24,7 +24,6 @@ class ThreadExitTestCase(TestBase):          self.break_3 = line_number('main.cpp', '// Set third breakpoint here')          self.break_4 = line_number('main.cpp', '// Set fourth breakpoint here') -    @expectedFailureWindows("llvm.org/pr24681")      def test(self):          """Test thread exit handling."""          self.build(dictionary=self.getBuildFlags()) @@ -32,10 +31,10 @@ class ThreadExitTestCase(TestBase):          self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)          # This should create a breakpoint with 1 location. -        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) -        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) -        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_3, num_expected_locations=1) -        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_4, num_expected_locations=1) +        bp1_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) +        bp2_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) +        bp3_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_3, num_expected_locations=1) +        bp4_id = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_4, num_expected_locations=1)          # The breakpoint list should show 1 locations.          self.expect("breakpoint list -f", "Breakpoint location shown correctly", @@ -46,71 +45,46 @@ class ThreadExitTestCase(TestBase):          # Run the program.          self.runCmd("run", RUN_SUCCEEDED) - -        # The stop reason of the thread should be breakpoint 1. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 1", -            substrs = ['stopped', -                       '* thread #1', -                       'stop reason = breakpoint 1', -                       'thread #2']) -          # Get the target process          target = self.dbg.GetSelectedTarget()          process = target.GetProcess() +        stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp1_id) +        self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 1") +          # Get the number of threads          num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 2, 'Number of expected threads and actual threads do not match at breakpoint 1.') +        self.assertGreaterEqual(num_threads, 2, 'Number of expected threads and actual threads do not match at breakpoint 1.')          # Run to the second breakpoint          self.runCmd("continue") - -        # The stop reason of the thread should be breakpoint 1. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 2", -            substrs = ['stopped', -                       'thread #1', -                       'thread #2', -                       'stop reason = breakpoint 2', -                       'thread #3']) +        stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp2_id) +        self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 2")          # Update the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 3, 'Number of expected threads and actual threads do not match at breakpoint 2.') +        new_num_threads = process.GetNumThreads() +        self.assertEqual(new_num_threads, num_threads+1, 'Number of expected threads did not increase by 1 at bp 2.')          # Run to the third breakpoint          self.runCmd("continue") - -        # The stop reason of the thread should be breakpoint 3. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 3", -            substrs = ['stopped', -                       'thread #1', -                       'stop reason = breakpoint 3', -                       'thread #3', -                       ]) +        stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp3_id) +        self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 3")          # Update the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 2, 'Number of expected threads and actual threads do not match at breakpoint 3.') +        new_num_threads = process.GetNumThreads() +        self.assertEqual(new_num_threads, num_threads, 'Number of expected threads is not equal to original number of threads at bp 3.')          # Run to the fourth breakpoint          self.runCmd("continue") - -        # The stop reason of the thread should be breakpoint 4. -        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 4", -            substrs = ['stopped', -                       'thread #1', -                       'stop reason = breakpoint 4']) +        stopped_thread = lldbutil.get_one_thread_stopped_at_breakpoint_id(process, bp4_id) +        self.assertIsNotNone(stopped_thread, "Process is not stopped at breakpoint 4")          # Update the number of threads -        num_threads = process.GetNumThreads() - -        self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match at breakpoint 4.') +        new_num_threads = process.GetNumThreads() +        self.assertEqual(new_num_threads, num_threads-1, 'Number of expected threads did not decrease by 1 at bp 4.')          # Run to completion          self.runCmd("continue")          # At this point, the inferior process should have exited. -        self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) +        self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) 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 e498db7895d2..c57db9f48527 100644 --- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp @@ -12,21 +12,9 @@  #include <atomic>  #include <thread> -// Note that although hogging the CPU while waiting for a variable to change -// would be terrible in production code, it's great for testing since it -// avoids a lot of messy context switching to get multiple threads synchronized. -#define do_nothing() - -#define pseudo_barrier_wait(bar) \ -    --bar;                       \ -    while (bar > 0)              \ -        do_nothing(); - -#define pseudo_barrier_init(bar, count) (bar = count) - -std::atomic_int g_barrier1; -std::atomic_int g_barrier2; -std::atomic_int g_barrier3; +pseudo_barrier_t g_barrier1; +pseudo_barrier_t g_barrier2; +pseudo_barrier_t g_barrier3;  void *  thread1 () 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 3c69b6667f7d..12bacabd0d78 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 @@ -9,15 +9,16 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ThreadSpecificBreakTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @add_test_categories(['pyapi']) -    @expectedFailureWindows # Thread specific breakpoints cause the inferior to crash +    @expectedFailureAll(oslist=["windows"])      def test_python(self):          """Test that we obey thread conditioned breakpoints."""          self.build() 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 68c96a0fba75..ccb58c965b3f 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 @@ -10,17 +10,17 @@ from __future__ import print_function  import os, time  import re  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class ThreadSpecificBreakPlusConditionTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @skipIfFreeBSD # test frequently times out or hangs -    @expectedFailureFreeBSD('llvm.org/pr18522') # hits break in another thread in testrun +    @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522') # hits break in another thread in testrun      @add_test_categories(['pyapi']) -    @expectedFlakeyLinux # this test fails 6/100 dosep runs      def test_python(self):          """Test that we obey thread conditioned breakpoints."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/basic/Makefile b/packages/Python/lldbsuite/test/functionalities/tsan/basic/Makefile new file mode 100644 index 000000000000..c930ae563fc1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/basic/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS := -fsanitize=thread -g + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py b/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py new file mode 100644 index 000000000000..44fa9cedc86c --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py @@ -0,0 +1,118 @@ +""" +Tests basic ThreadSanitizer support (detecting a data race). +""" + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import json + +class TsanBasicTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") +    @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default +    @skipIfRemote +    @skipUnlessCompilerRt +    @skipUnlessThreadSanitizer +    def test (self): +        self.build () +        self.tsan_tests () + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) +        self.line_malloc = line_number('main.c', '// malloc line') +        self.line_thread1 = line_number('main.c', '// thread1 line') +        self.line_thread2 = line_number('main.c', '// thread2 line') + +    def tsan_tests (self): +        exe = os.path.join (os.getcwd(), "a.out") +        self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + +        self.runCmd("run") + +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue") + +        # the stop reason of the thread should be breakpoint. +        self.expect("thread list", "A data race should be detected", +            substrs = ['stopped', 'stop reason = Data race detected']) + +        self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation) + +        # test that the TSan dylib is present +        self.expect("image lookup -n __tsan_get_current_report", "__tsan_get_current_report should be present", +            substrs = ['1 match found']) + +        # We should be stopped in __tsan_on_report +        process = self.dbg.GetSelectedTarget().process +        thread = process.GetSelectedThread() +        frame = thread.GetSelectedFrame() +        self.assertTrue("__tsan_on_report" in frame.GetFunctionName()) + +        # The stopped thread backtrace should contain either line1 or line2 from main.c. +        found = False +        for i in range(0, thread.GetNumFrames()): +            frame = thread.GetFrameAtIndex(i) +            if frame.GetLineEntry().GetFileSpec().GetFilename() == "main.c": +                if frame.GetLineEntry().GetLine() == self.line_thread1: +                    found = True +                if frame.GetLineEntry().GetLine() == self.line_thread2: +                    found = True +        self.assertTrue(found) + +        self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", +            substrs = ["instrumentation_class", "description", "mops"]) + +        output_lines = self.res.GetOutput().split('\n') +        json_line = '\n'.join(output_lines[2:]) +        data = json.loads(json_line) +        self.assertEqual(data["instrumentation_class"], "ThreadSanitizer") +        self.assertEqual(data["issue_type"], "data-race") +        self.assertEqual(len(data["mops"]), 2) + +        backtraces = thread.GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeAddressSanitizer) +        self.assertEqual(backtraces.GetSize(), 0) + +        backtraces = thread.GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeThreadSanitizer) +        self.assertTrue(backtraces.GetSize() >= 2) + +        # First backtrace is a memory operation +        thread = backtraces.GetThreadAtIndex(0) +        found = False +        for i in range(0, thread.GetNumFrames()): +            frame = thread.GetFrameAtIndex(i) +            if frame.GetLineEntry().GetFileSpec().GetFilename() == "main.c": +                if frame.GetLineEntry().GetLine() == self.line_thread1: +                    found = True +                if frame.GetLineEntry().GetLine() == self.line_thread2: +                    found = True +        self.assertTrue(found) + +        # Second backtrace is a memory operation +        thread = backtraces.GetThreadAtIndex(1) +        found = False +        for i in range(0, thread.GetNumFrames()): +            frame = thread.GetFrameAtIndex(i) +            if frame.GetLineEntry().GetFileSpec().GetFilename() == "main.c": +                if frame.GetLineEntry().GetLine() == self.line_thread1: +                    found = True +                if frame.GetLineEntry().GetLine() == self.line_thread2: +                    found = True +        self.assertTrue(found) + +        self.runCmd("continue") + +        # the stop reason of the thread should be a SIGABRT. +        self.expect("thread list", "We should be stopped due a SIGABRT", +            substrs = ['stopped', 'stop reason = signal SIGABRT']) + +        # test that we're in pthread_kill now (TSan abort the process) +        self.expect("thread list", "We should be stopped in pthread_kill", +            substrs = ['pthread_kill']) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c new file mode 100644 index 000000000000..c082b01a57c7 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c @@ -0,0 +1,37 @@ +//===-- 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 <pthread.h> +#include <stdio.h> +#include <stdlib.h> + +char *pointer; + +void *f1(void *p) { +    pointer[0] = 'x'; // thread1 line +    return NULL; +} + +void *f2(void *p) { +    pointer[0] = 'y'; // thread2 line +    return NULL; +} + +int main (int argc, char const *argv[]) +{ +    pointer = (char *)malloc(10); // malloc line + +    pthread_t t1, t2; +    pthread_create(&t1, NULL, f1, NULL); +    pthread_create(&t2, NULL, f2, NULL); + +    pthread_join(t1, NULL); +    pthread_join(t2, NULL); + +    return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/Makefile b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/Makefile new file mode 100644 index 000000000000..a58194779074 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp +CFLAGS_EXTRAS := -fsanitize=thread -g + +include $(LEVEL)/Makefile.rules 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 new file mode 100644 index 000000000000..230ff982da0d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/TestTsanCPPGlobalLocation.py @@ -0,0 +1,54 @@ +""" +Tests that TSan correctly reports the filename and line number of a racy global C++ variable. +""" + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import json + +class TsanCPPGlobalLocationTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") +    @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default +    @skipIfRemote +    @skipUnlessCompilerRt +    @skipUnlessThreadSanitizer +    def test (self): +        self.build () +        self.tsan_tests () + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) + +    def tsan_tests (self): +        exe = os.path.join (os.getcwd(), "a.out") +        self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + +        self.runCmd("run") + +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue") + +        # the stop reason of the thread should be breakpoint. +        self.expect("thread list", "A data race should be detected", +            substrs = ['stopped', 'stop reason = Data race detected']) + +        self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", +            substrs = ["instrumentation_class", "description", "mops"]) + +        output_lines = self.res.GetOutput().split('\n') +        json_line = '\n'.join(output_lines[2:]) +        data = json.loads(json_line) +        self.assertEqual(data["instrumentation_class"], "ThreadSanitizer") +        self.assertEqual(data["issue_type"], "data-race") + +        self.assertTrue(data["location_filename"].endswith("/main.cpp")) +        self.assertEqual(data["location_line"], line_number('main.cpp', '// global variable')) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/main.cpp b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/main.cpp new file mode 100644 index 000000000000..80f72ae83cf7 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/cpp_global_location/main.cpp @@ -0,0 +1,38 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +long my_global_variable;  // global variable + +void *f1(void *p) { +    my_global_variable = 42; +    return NULL; +} + +void *f2(void *p) { +    my_global_variable = 43; +    return NULL; +} + +int main (int argc, char const *argv[]) +{ +    pthread_t t1; +    pthread_create(&t1, NULL, f1, NULL); + +    pthread_t t2; +    pthread_create(&t2, NULL, f2, NULL); + +    pthread_join(t1, NULL); +    pthread_join(t2, NULL); + +    return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/global_location/Makefile b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/Makefile new file mode 100644 index 000000000000..c930ae563fc1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS := -fsanitize=thread -g + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py new file mode 100644 index 000000000000..b268c46fead3 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/TestTsanGlobalLocation.py @@ -0,0 +1,54 @@ +""" +Tests that TSan correctly reports the filename and line number of a racy global variable. +""" + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import json + +class TsanGlobalLocationTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") +    @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default +    @skipIfRemote +    @skipUnlessCompilerRt +    @skipUnlessThreadSanitizer +    def test (self): +        self.build () +        self.tsan_tests () + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) + +    def tsan_tests (self): +        exe = os.path.join (os.getcwd(), "a.out") +        self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + +        self.runCmd("run") + +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue") + +        # the stop reason of the thread should be breakpoint. +        self.expect("thread list", "A data race should be detected", +            substrs = ['stopped', 'stop reason = Data race detected']) + +        self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", +            substrs = ["instrumentation_class", "description", "mops"]) + +        output_lines = self.res.GetOutput().split('\n') +        json_line = '\n'.join(output_lines[2:]) +        data = json.loads(json_line) +        self.assertEqual(data["instrumentation_class"], "ThreadSanitizer") +        self.assertEqual(data["issue_type"], "data-race") +         +        self.assertTrue(data["location_filename"].endswith("/main.c")) +        self.assertEqual(data["location_line"], line_number('main.c', '// global variable')) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/global_location/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/main.c new file mode 100644 index 000000000000..caa2c3cb43cd --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/global_location/main.c @@ -0,0 +1,38 @@ +//===-- 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 <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +long my_global_variable;  // global variable + +void *f1(void *p) { +    my_global_variable = 42; +    return NULL; +} + +void *f2(void *p) { +    my_global_variable = 43; +    return NULL; +} + +int main (int argc, char const *argv[]) +{ +    pthread_t t1; +    pthread_create(&t1, NULL, f1, NULL); + +    pthread_t t2; +    pthread_create(&t2, NULL, f2, NULL); + +    pthread_join(t1, NULL); +    pthread_join(t2, NULL); + +    return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/multiple/Makefile b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/Makefile new file mode 100644 index 000000000000..c930ae563fc1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS := -fsanitize=thread -g + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py new file mode 100644 index 000000000000..c22501141cca --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py @@ -0,0 +1,69 @@ +""" +Test ThreadSanitizer when multiple different issues are found. +""" + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import json + +class TsanMultipleTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") +    @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default +    @skipIfRemote +    @skipUnlessCompilerRt +    @skipUnlessThreadSanitizer +    def test (self): +        self.build () +        self.tsan_tests () + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) + +    def tsan_tests (self): +        exe = os.path.join (os.getcwd(), "a.out") +        self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + +        self.runCmd("env TSAN_OPTIONS=abort_on_error=0") + +        self.runCmd("run") + +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue") + +        report_count = 0 +        while self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() == lldb.eStopReasonInstrumentation: +            report_count += 1 + +            stop_description = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopDescription(100) + +            self.assertTrue( +                 (stop_description == "Data race detected") or +                 (stop_description == "Use of deallocated memory detected") or +                 (stop_description == "Thread leak detected") or +                 (stop_description == "Use of an uninitialized or destroyed mutex detected") or +                 (stop_description == "Unlock of an unlocked mutex (or by a wrong thread) detected") +            ) + +            self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", +                substrs = ["instrumentation_class", "description", "mops"]) + +            output_lines = self.res.GetOutput().split('\n') +            json_line = '\n'.join(output_lines[2:]) +            data = json.loads(json_line) +            self.assertEqual(data["instrumentation_class"], "ThreadSanitizer") + +            backtraces = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeThreadSanitizer) +            self.assertTrue(backtraces.GetSize() >= 1) + +            self.runCmd("continue") + +        self.assertEqual(self.dbg.GetSelectedTarget().process.GetState(), lldb.eStateExited, PROCESS_EXITED) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/multiple/main.m b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/main.m new file mode 100644 index 000000000000..f7c48b45422b --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/multiple/main.m @@ -0,0 +1,138 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#import <Foundation/Foundation.h> +#import <pthread.h> + +long my_global; + +void *Thread1(void *arg) { +    my_global = 42; +    return NULL; +} + +void *Thread2(void *arg) { +    my_global = 144; +    return NULL; +} + +void TestDataRace1() { +    pthread_t t1, t2; +    pthread_create(&t1, NULL, Thread1, NULL); +    pthread_create(&t2, NULL, Thread2, NULL); +     +    pthread_join(t1, NULL); +    pthread_join(t2, NULL); +} + +void TestInvalidMutex() { +    pthread_mutex_t m = {0}; +    pthread_mutex_lock(&m); +     +    pthread_mutex_init(&m, NULL); +    pthread_mutex_lock(&m); +    pthread_mutex_unlock(&m); +    pthread_mutex_destroy(&m); +    pthread_mutex_lock(&m); +} + +void TestMutexWrongLock() { +    pthread_mutex_t m = {0}; +    pthread_mutex_init(&m, NULL); +    pthread_mutex_unlock(&m); +} + +long some_global; + +void TestDataRaceBlocks1() { +    dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); +     +    for (int i = 0; i < 2; i++) { +        dispatch_async(q, ^{ +            some_global++;  // race 1 +             +            usleep(100000);  // force the blocks to be on different threads +        }); +    } +     +    usleep(100000); +    dispatch_barrier_sync(q, ^{ }); +} + +void TestDataRaceBlocks2() { +    dispatch_queue_t q = dispatch_queue_create("my.queue2", DISPATCH_QUEUE_CONCURRENT); +     +    char *c; +     +    c = malloc((rand() % 1000) + 10); +    for (int i = 0; i < 2; i++) { +        dispatch_async(q, ^{ +            c[0] = 'x';  // race 2 +            fprintf(stderr, "tid: %p\n", pthread_self()); +            usleep(100000);  // force the blocks to be on different threads +        }); +    } +    dispatch_barrier_sync(q, ^{ }); +     +    free(c); +} + +void TestUseAfterFree() { +    char *c; +     +    c = malloc((rand() % 1000) + 10); +    free(c); +    c[0] = 'x'; +} + +void TestRacePipe() { +    dispatch_queue_t q = dispatch_queue_create("my.queue3", DISPATCH_QUEUE_CONCURRENT); +     +    int a[2]; +    pipe(a); +    int fd = a[0]; +     +    for (int i = 0; i < 2; i++) { +        dispatch_async(q, ^{ +            write(fd, "abc", 3); +            usleep(100000);  // force the blocks to be on different threads +        }); +        dispatch_async(q, ^{ +            close(fd); +            usleep(100000); +        }); +    } +     +    dispatch_barrier_sync(q, ^{ }); +} + +void TestThreadLeak() { +    pthread_t t1; +    pthread_create(&t1, NULL, Thread1, NULL); +} + +int main(int argc, const char * argv[]) { +    TestDataRace1(); +     +    TestInvalidMutex(); +     +    TestMutexWrongLock(); +     +    TestDataRaceBlocks1(); +     +    TestDataRaceBlocks2(); +     +    TestUseAfterFree(); +     +    TestRacePipe(); +     +    TestThreadLeak(); + +    return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/Makefile b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/Makefile new file mode 100644 index 000000000000..c930ae563fc1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS := -fsanitize=thread -g + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py new file mode 100644 index 000000000000..ed620093c1f3 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py @@ -0,0 +1,40 @@ +""" +Tests ThreadSanitizer's support to detect a leaked thread. +""" + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import json + +class TsanThreadLeakTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") +    @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default +    @skipIfRemote +    @skipUnlessCompilerRt +    @skipUnlessThreadSanitizer +    def test (self): +        self.build () +        self.tsan_tests () + +    def tsan_tests (self): +        exe = os.path.join (os.getcwd(), "a.out") +        self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + +        self.runCmd("run") + +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue") + +        # the stop reason of the thread should be breakpoint. +        self.expect("thread list", "A thread leak should be detected", +            substrs = ['stopped', 'stop reason = Thread leak detected']) + +        self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/main.c new file mode 100644 index 000000000000..3c17e228487b --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/main.c @@ -0,0 +1,24 @@ +//===-- 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 <pthread.h> +#include <stdio.h> +#include <stdlib.h> + +void *f1(void *p) { +    printf("hello\n"); +    return NULL; +} + +int main (int argc, char const *argv[]) +{ +    pthread_t t1; +    pthread_create(&t1, NULL, f1, NULL); + +    return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/Makefile b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/Makefile new file mode 100644 index 000000000000..c930ae563fc1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +CFLAGS_EXTRAS := -fsanitize=thread -g + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py new file mode 100644 index 000000000000..c7905bcb1c1d --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py @@ -0,0 +1,68 @@ +""" +Tests that TSan and LLDB have correct thread numbers. +""" + +import os, time +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import json + +class TsanThreadNumbersTestCase(TestBase): + +    mydir = TestBase.compute_mydir(__file__) + +    @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") +    @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default +    @skipIfRemote +    @skipUnlessCompilerRt +    @skipUnlessThreadSanitizer +    def test (self): +        self.build () +        self.tsan_tests () + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) + +    def tsan_tests (self): +        exe = os.path.join (os.getcwd(), "a.out") +        self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ]) + +        self.runCmd("run") + +        stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() +        if stop_reason == lldb.eStopReasonExec: +            # On OS X 10.10 and older, we need to re-exec to enable interceptors. +            self.runCmd("continue") + +        # the stop reason of the thread should be breakpoint. +        self.expect("thread list", "A data race should be detected", +            substrs = ['stopped', 'stop reason = Data race detected']) + +        self.assertEqual(self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), lldb.eStopReasonInstrumentation) + +        report_thread_id = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetIndexID() + +        self.expect("thread info -s", "The extended stop info should contain the TSan provided fields", +            substrs = ["instrumentation_class", "description", "mops"]) + +        output_lines = self.res.GetOutput().split('\n') +        json_line = '\n'.join(output_lines[2:]) +        data = json.loads(json_line) +        self.assertEqual(data["instrumentation_class"], "ThreadSanitizer") +        self.assertEqual(data["issue_type"], "data-race") +        self.assertEqual(len(data["mops"]), 2) + +        self.assertEqual(data["mops"][0]["thread_id"], report_thread_id) + +        other_thread_id = data["mops"][1]["thread_id"] +        self.assertTrue(other_thread_id != report_thread_id) +        other_thread = self.dbg.GetSelectedTarget().process.GetThreadByIndexID(other_thread_id) +        self.assertTrue(other_thread.IsValid()) + +        self.runCmd("thread select %d" % other_thread_id) + +        self.expect("thread backtrace", "The other thread should be stopped in f1 or f2", +            substrs = ["a.out", "main.c"]) diff --git a/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/main.c b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/main.c new file mode 100644 index 000000000000..04ebb723c3b7 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/main.c @@ -0,0 +1,58 @@ +//===-- 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 <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +char *pointer; + +void *nothing(void *p) { +    return NULL; +} + +void *f1(void *p) { +    pointer[0] = 'x'; +    sleep(100); +    return NULL; +} + +void *f2(void *p) { +    pointer[0] = 'y'; +    sleep(100); +    return NULL; +} + +int main (int argc, char const *argv[]) +{ +    pointer = (char *)malloc(10); + +    for (int i = 0; i < 3; i++) { +        pthread_t t; +        pthread_create(&t, NULL, nothing, NULL); +        pthread_join(t, NULL); +    } + +    pthread_t t1; +    pthread_create(&t1, NULL, f1, NULL); + +    for (int i = 0; i < 3; i++) { +        pthread_t t; +        pthread_create(&t, NULL, nothing, NULL); +        pthread_join(t, NULL); +    } + +    pthread_t t2; +    pthread_create(&t2, NULL, f2, NULL); + +    pthread_join(t1, NULL); +    pthread_join(t2, NULL); + +    return 0; +} diff --git a/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py b/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py index 5697c2c37283..cebba1b4c573 100644 --- a/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py +++ b/packages/Python/lldbsuite/test/functionalities/tty/TestTerminal.py @@ -9,8 +9,9 @@ from __future__ import print_function  import unittest2  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class LaunchInTerminalTestCase(TestBase): diff --git a/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py b/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py index 5a238b7d3542..2bf10204ea6b 100644 --- a/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py +++ b/packages/Python/lldbsuite/test/functionalities/type_completion/TestTypeCompletion.py @@ -8,14 +8,15 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class TypeCompletionTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailureIcc # often fails with 'NameAndAddress should be valid' +    @expectedFailureAll(compiler="icc", bugnumber="often fails with 'NameAndAddress should be valid.")      # Fails with gcc 4.8.1 with llvm.org/pr15301 LLDB prints incorrect sizes of STL containers      def test_with_run_command(self):          """Check that types only get completed when necessary.""" diff --git a/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py b/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py index ca0b1f1d1e53..774eb437b78e 100644 --- a/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py +++ b/packages/Python/lldbsuite/test/functionalities/type_lookup/TestTypeLookup.py @@ -6,11 +6,12 @@ from __future__ import print_function +import datetime  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import datetime -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class TypeLookupTestCase(TestBase): @@ -41,3 +42,4 @@ class TypeLookupTestCase(TestBase):          self.expect('type lookup NSURL', substrs=['NSURL'])          self.expect('type lookup NSArray', substrs=['NSArray'])          self.expect('type lookup NSObject', substrs=['NSObject', 'isa']) +        self.expect('type lookup PleaseDontBeARealTypeThatExists', substrs=["no type was found matching 'PleaseDontBeARealTypeThatExists'"]) diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile new file mode 100644 index 000000000000..289d25698ffb --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +CFLAGS ?= -g -fomit-frame-pointer + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py new file mode 100644 index 000000000000..e17d5d36d394 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py @@ -0,0 +1,51 @@ +""" +Test that we can backtrace correctly from Non ABI functions on the stack +""" + +from __future__ import print_function + + + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class EHFrameBasedUnwind(TestBase): +    mydir = TestBase.compute_mydir(__file__) + +	 +    @skipUnlessPlatform(['linux']) +    @skipIf(archs=["aarch64", "arm", "i386", "i686"]) +    def test (self): +        """Test that we can backtrace correctly from Non ABI  functions on the stack""" +        self.build() +        self.setTearDownCleanup() + +        exe = os.path.join(os.getcwd(), "a.out") +        target = self.dbg.CreateTarget(exe) + +        self.assertTrue(target, VALID_TARGET) + +        lldbutil.run_break_set_by_symbol (self, "func") + +        process = target.LaunchSimple (["abc", "xyz"], None, self.get_process_working_directory()) + +        if not process: +            self.fail("SBTarget.Launch() failed") + +        if process.GetState() != lldb.eStateStopped: +            self.fail("Process should be in the 'stopped' state, " +                      "instead the actual state is: '%s'" % +                      lldbutil.state_type_to_str(process.GetState())) + +        stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) +        self.expect(stacktraces, exe=False, +            substrs = ['(int)argc=3']) + +        self.runCmd("thread step-inst") + +        stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) +        self.expect(stacktraces, exe=False, +            substrs = ['(int)argc=3']) diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c new file mode 100644 index 000000000000..f62f7d814f38 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c @@ -0,0 +1,20 @@ +void func() { +	__asm__ ( +		"pushq $0x10;" +		".cfi_def_cfa_offset 16;" +		"jmp label;" +		"movq $0x48, %rax;" +"label: subq $0x38, %rax;" +		"movq $0x48, %rcx;" +		"movq $0x48, %rdx;" +		"movq $0x48, %rax;" +		"popq %rax;" +	); + +} + + +int main(int argc, char const *argv[]) +{ +	func(); +}
\ No newline at end of file diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py index c0a311f7ac9e..62c6c16080a3 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py @@ -8,13 +8,13 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class NoreturnUnwind(TestBase):      mydir = TestBase.compute_mydir(__file__) -    @expectedFailurei386("llvm.org/pr25338")      @skipIfWindows # clang-cl does not support gcc style attributes.      def test (self):          """Test that we can backtrace correctly with 'noreturn' functions on the stack""" diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py index ddfb1122b6f1..d2b36412f1f0 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/sigtramp/TestSigtrampUnwind.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class SigtrampUnwind(TestBase):      mydir = TestBase.compute_mydir(__file__) diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py index 3f88e7b6e1aa..20532c6fc675 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/standard/TestStandardUnwind.py @@ -17,8 +17,9 @@ from __future__ import print_function  import unittest2  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  test_source_dirs = ["."] 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 763ecc94c2eb..cbea7d22cc44 100644 --- a/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py +++ b/packages/Python/lldbsuite/test/functionalities/value_md5_crash/TestValueMD5Crash.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class ValueMD5CrashTestCase(TestBase): @@ -21,7 +22,7 @@ class ValueMD5CrashTestCase(TestBase):          # Find the line number to break at.          self.line = line_number('main.cpp', '// break here') -    @expectedFailureWindows("llvm.org/pr24663") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")      def test_with_run_command(self):          """Verify that the hash computing logic for ValueObject's values can't crash us."""          self.build() 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 f0a0b5ab99d0..933f21a90bbf 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/TestWatchLocation.py @@ -9,8 +9,9 @@ from __future__ import print_function  import os, time  import re  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class HelloWatchLocationTestCase(TestBase): @@ -30,8 +31,11 @@ class HelloWatchLocationTestCase(TestBase):          self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows -    @expectedFailureAll(archs=['mips', 'mipsel', 'mips64', 'mips64el']) # Most of the MIPS boards provide only one H/W watchpoints, and S/W watchpoints are not supported yet +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(triple = re.compile('^mips')) # Most of the MIPS boards provide only one H/W watchpoints, and S/W watchpoints are not supported yet +    @expectedFailureAll(archs=['s390x']) # SystemZ also currently supports only one H/W watchpoint +    @expectedFailureAll(oslist=["linux"], archs=["arm", "aarch64"], bugnumber="llvm.org/pr27795") +    @skipIfDarwin      def test_hello_watchlocation(self):          """Test watching a location with '-s size' option."""          self.build(dictionary=self.d) @@ -52,9 +56,6 @@ class HelloWatchLocationTestCase(TestBase):                         'stop reason = breakpoint'])          # Now let's set a write-type watchpoint pointed to by 'g_char_ptr'. -        # The main.cpp, by design, misbehaves by not following the agreed upon -        # protocol of using a mutex while accessing the global pool and by not -        # incrmenting the global pool by 2.          self.expect("watchpoint set expression -w write -s 1 -- g_char_ptr", WATCHPOINT_CREATED,              substrs = ['Watchpoint created', 'size = 1', 'type = w'])          # Get a hold of the watchpoint id just created, it is used later on to diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp index 59b0afc6d5f7..e20a6d988c84 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchlocation/main.cpp @@ -43,15 +43,13 @@ uint32_t  access_pool (bool flag = false)  {      static std::mutex g_access_mutex; -    if (!flag) -        g_access_mutex.lock(); +    g_access_mutex.lock();      char old_val = *g_char_ptr;      if (flag)          do_bad_thing_with_location(g_char_ptr, old_val + 1); -    if (!flag) -        g_access_mutex.unlock(); +    g_access_mutex.unlock();      return *g_char_ptr;  } 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 57467c38d5f8..5214c7f5e089 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class HelloWatchpointTestCase(TestBase): @@ -31,7 +32,7 @@ class HelloWatchpointTestCase(TestBase):          self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")      def test_hello_watchpoint_using_watchpoint_set(self):          """Test a simple sequence of watchpoint creation and watchpoint hit."""          self.build(dictionary=self.d) 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 2318214a0d5c..af8306c9a20e 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/TestWatchpointMultipleThreads.py @@ -9,15 +9,16 @@ from __future__ import print_function  import os, time  import re  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class WatchpointForMultipleThreadsTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @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() @@ -25,7 +26,7 @@ class WatchpointForMultipleThreadsTestCase(TestBase):          self.hello_multiple_threads()      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @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.build() @@ -57,9 +58,6 @@ class WatchpointForMultipleThreadsTestCase(TestBase):                         'stop reason = breakpoint'])          # Now let's set a write-type watchpoint for variable 'g_val'. -        # The main.cpp, by design, misbehaves by not following the agreed upon -        # protocol of using a mutex while accessing the global pool and by not -        # writing to the variable.          self.expect("watchpoint set variable -w write g_val", WATCHPOINT_CREATED,              substrs = ['Watchpoint created', 'size = 4', 'type = w']) @@ -101,9 +99,6 @@ class WatchpointForMultipleThreadsTestCase(TestBase):                         'stop reason = breakpoint'])          # Now let's set a write-type watchpoint for variable 'g_val'. -        # The main.cpp, by design, misbehaves by not following the agreed upon -        # protocol of using a mutex while accessing the global pool and by not -        # writing to the variable.          self.expect("watchpoint set variable -w write g_val", WATCHPOINT_CREATED,              substrs = ['Watchpoint created', 'size = 4', 'type = w']) 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 8a31041f8fca..7f2e5e6e6cb5 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/multiple_threads/main.cpp @@ -23,8 +23,7 @@ uint32_t  access_pool (bool flag = false)  {      static std::mutex g_access_mutex; -    if (!flag) -        g_access_mutex.lock(); +    g_access_mutex.lock();      uint32_t old_val = g_val;      if (flag) @@ -33,17 +32,14 @@ access_pool (bool flag = false)          g_val = old_val + 1;      } -    if (!flag) -        g_access_mutex.unlock(); +    g_access_mutex.unlock();      return g_val;  }  void  thread_func (uint32_t thread_index)  { -    // Break here in order to allow the thread -    // to inherit the global watchpoint state. -    printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); +    printf ("%s (thread index = %u) starting...\n", __FUNCTION__, thread_index);      uint32_t count = 0;      uint32_t val; 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 f51da36b72d7..22011f11352c 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 @@ -5,8 +5,9 @@ from __future__ import print_function  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class TestStepOverWatchpoint(TestBase): @@ -17,8 +18,9 @@ class TestStepOverWatchpoint(TestBase):          return ['basic_process']      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureLinux(bugnumber="llvm.org/pr26031", archs=['arm']) -    @expectedFailureWindows("llvm.org/pr24446") +    @expectedFailureAll(oslist=["linux"], archs=['aarch64', 'arm'], bugnumber="llvm.org/pr26031") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ      def test(self):          """Test stepping over watchpoints."""          self.build() @@ -73,7 +75,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 arch in ['mips', 'mipsel', 'mips64', 'mips64el']: +        if re.match("^mips",arch):              self.runCmd("watchpoint delete 1")          # resolve_location=True, read=False, write=True 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 339de45a085a..4ce05af96e2e 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class WatchpointCommandsTestCase(TestBase): @@ -30,7 +31,8 @@ class WatchpointCommandsTestCase(TestBase):          self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ      def test_rw_watchpoint(self):          """Test read_write watchpoint and expect to stop two times."""          self.build(dictionary=self.d) @@ -90,7 +92,8 @@ class WatchpointCommandsTestCase(TestBase):              substrs = ['hit_count = 2'])      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ      def test_rw_watchpoint_delete(self):          """Test delete watchpoint and expect not to stop for watchpoint."""          self.build(dictionary=self.d) @@ -135,7 +138,8 @@ class WatchpointCommandsTestCase(TestBase):              substrs = ['exited'])      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ      def test_rw_watchpoint_set_ignore_count(self):          """Test watchpoint ignore count and expect to not to stop at all."""          self.build(dictionary=self.d) @@ -184,7 +188,8 @@ class WatchpointCommandsTestCase(TestBase):              substrs = ['hit_count = 2', 'ignore_count = 2'])      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ      def test_rw_disable_after_first_stop(self):          """Test read_write watchpoint but disable it after the first stop."""          self.build(dictionary=self.d) @@ -243,7 +248,8 @@ class WatchpointCommandsTestCase(TestBase):              substrs = ['hit_count = 1'])      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ      def test_rw_disable_then_enable(self):          """Test read_write watchpoint, disable initially, then enable it."""          self.build(dictionary=self.d) 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 f2bf90866330..ee276dd5687f 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class WatchpointLLDBCommandTestCase(TestBase): @@ -29,7 +30,8 @@ class WatchpointLLDBCommandTestCase(TestBase):          self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")      def test_watchpoint_command(self):          """Test 'watchpoint command'."""          self.build(dictionary=self.d) @@ -83,7 +85,8 @@ class WatchpointLLDBCommandTestCase(TestBase):              substrs = ['(int32_t)', 'cookie = 777'])      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")      def test_watchpoint_command_can_disable_a_watchpoint(self):          """Test that 'watchpoint command' action can disable a watchpoint after it is triggered."""          self.build(dictionary=self.d) 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 a476aebb8db9..f6ea4fc16861 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class WatchpointPythonCommandTestCase(TestBase): @@ -29,8 +30,9 @@ class WatchpointPythonCommandTestCase(TestBase):          self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}      @skipIfFreeBSD # timing out on buildbot -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported +    @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710")      def test_watchpoint_command(self):          """Test 'watchpoint command'."""          self.build(dictionary=self.d) @@ -85,3 +87,57 @@ class WatchpointPythonCommandTestCase(TestBase):          # The watchpoint command "forced" our global variable 'cookie' to become 777.          self.expect("frame variable --show-globals cookie",              substrs = ['(int32_t)', 'cookie = 777']) + +    @skipIfFreeBSD # timing out on buildbot +    @expectedFailureAll(bugnumber="llvm.org/pr28055: continue in watchpoint commands disables the watchpoint") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported +    @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") +    def test_continue_in_watchpoint_command(self): +        """Test continue in a watchpoint command.""" +        self.build(dictionary=self.d) +        self.setTearDownCleanup(dictionary=self.d) + +        exe = os.path.join(os.getcwd(), self.exe_name) +        self.runCmd("file " + exe, 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.line, num_expected_locations=1) +#        self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, +#            startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % +#                       (self.source, self.line))# + +        # 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']) + +        # Now let's set a write-type watchpoint for 'global'. +        self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED, +            substrs = ['Watchpoint created', 'size = 4', 'type = w', +                       '%s:%d' % (self.source, self.decl)]) + +        cmd_script_file = os.path.join(os.getcwd(), "watchpoint_command.py") +        self.runCmd("command script import '%s'"%(cmd_script_file)) + +        self.runCmd('watchpoint command add -F watchpoint_command.watchpoint_command') + +        # List the watchpoint command we just added. +        self.expect("watchpoint command list 1", +            substrs = ['watchpoint_command.watchpoint_command']) + +        self.runCmd("process continue") + +        # We should be stopped again due to the watchpoint (write type). +        # The stop reason of the thread should be watchpoint. +        self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, +            substrs = ['stop reason = watchpoint']) + +        # We should have hit the watchpoint once, set cookie to 888, then continued to the +        # second hit and set it to 999 +        self.expect("frame variable --show-globals cookie", +            substrs = ['(int32_t)', 'cookie = 999']) diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/watchpoint_command.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/watchpoint_command.py new file mode 100644 index 000000000000..575a5160d219 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/watchpoint_command.py @@ -0,0 +1,14 @@ +import lldb + +num_hits = 0 +def watchpoint_command (frame, wp, dict): +    global num_hits +    if num_hits == 0: +        print ("I stopped the first time") +        frame.EvaluateExpression("cookie = 888") +        num_hits += 1 +        frame.thread.process.Continue() +    else: +        print ("I stopped the %d time"%(num_hits)) +        frame.EvaluateExpression("cookie = 999") + 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 355204a4ce1e..64e01e5cb937 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class WatchpointConditionCmdTestCase(TestBase): @@ -29,7 +30,8 @@ class WatchpointConditionCmdTestCase(TestBase):          self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")      def test_watchpoint_cond(self):          """Test watchpoint condition."""          self.build(dictionary=self.d) 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 e4d6e019c20e..fdeb4b8fa3b5 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py @@ -6,8 +6,9 @@ from __future__ import print_function  import os, time  import lldb -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil  class TestWatchpointEvents (TestBase): @@ -21,7 +22,8 @@ class TestWatchpointEvents (TestBase):      @add_test_categories(['pyapi'])      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr27710") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")      def test_with_python_api(self):          """Test that adding, deleting and modifying watchpoints sends the appropriate events."""          self.build() @@ -58,7 +60,7 @@ class TestWatchpointEvents (TestBase):          self.listener.StartListeningForEvents (self.target_bcast, lldb.SBTarget.eBroadcastBitWatchpointChanged)          error = lldb.SBError() -        local_watch = local_var.Watch(True, True, True, error) +        local_watch = local_var.Watch(True, False, True, error)          if not error.Success():              self.fail ("Failed to make watchpoint for local_var: %s"%(error.GetCString())) 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 73752d2d18d5..c66ddb512884 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 @@ -8,15 +8,16 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class TestValueOfVectorVariableTestCase(TestBase):      mydir = TestBase.compute_mydir(__file__)      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["windows"], 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) diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c index 98f8c477eb31..ac2370e32d2a 100644 --- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/main.c @@ -6,7 +6,7 @@  // License. See LICENSE.TXT for details.  //  //===----------------------------------------------------------------------===// -typedef char v4i8 __attribute__ ((vector_size(4))); +typedef signed char v4i8 __attribute__ ((vector_size(4)));  v4i8 global_vector = {1, 2, 3, 4};  int 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 9301a6f9fd00..735a5678c4f9 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 @@ -8,8 +8,9 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import * -import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test import lldbutil  class WatchLocationUsingWatchpointSetTestCase(TestBase): @@ -27,8 +28,8 @@ class WatchLocationUsingWatchpointSetTestCase(TestBase):          # Build dictionary to have unique executable names for each test method.      @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported -    @expectedFailureLinux(bugnumber="llvm.org/pr26031", archs=['arm']) -    @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows +    @expectedFailureAll(oslist=["linux"], archs=['aarch64', 'arm'], bugnumber="llvm.org/pr26031") +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")      def test_watchlocation_using_watchpoint_set(self):          """Test watching a location with 'watchpoint set expression -w write -s size' option."""          self.build() 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 27c759e6fb64..43597ec28f59 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 @@ -8,6 +8,7 @@ from __future__ import print_function  import os, time  import lldb +from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import *  import lldbsuite.test.lldbutil as lldbutil @@ -24,6 +25,7 @@ class WatchpointSetErrorTestCase(TestBase):          self.line = line_number(self.source, '// Set break point at this line.')          # Build dictionary to have unique executable names for each test method. +    @expectedFailureAll(oslist=["windows"])      def test_error_cases_with_watchpoint_set(self):          """Test error cases with the 'watchpoint set' command."""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/Makefile b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/Makefile new file mode 100644 index 000000000000..b09a579159d4 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py new file mode 100644 index 000000000000..55e36649ce10 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/TestWatchpointSizes.py @@ -0,0 +1,117 @@ +""" +Test watchpoint size cases (1-byte, 2-byte, 4-byte). +Make sure we can watch all bytes, words or double words individually +when they are packed in a 8-byte region. + +""" + +from __future__ import print_function + +import os, time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class WatchpointSizeTestCase(TestBase): +    NO_DEBUG_INFO_TESTCASE = True + +    mydir = TestBase.compute_mydir(__file__) + +    def setUp(self): +        # Call super's setUp(). +        TestBase.setUp(self) + +        # Source filename. +        self.source = 'main.c' + +        # Output filename. +        self.exe_name = 'a.out' +        self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name} + +    @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ +    def test_byte_size_watchpoints_with_byte_selection(self): +        """Test to selectively watch different bytes in a 8-byte array.""" +        self.run_watchpoint_size_test('byteArray', 8, '1') + +    @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ +    def test_two_byte_watchpoints_with_word_selection(self): +        """Test to selectively watch different words in an 8-byte word array.""" +        self.run_watchpoint_size_test('wordArray', 4, '2') + +    @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported +    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows") +    @expectedFailureAll(archs=['s390x']) # Read-write watchpoints not supported on SystemZ +    def test_four_byte_watchpoints_with_dword_selection(self): +        """Test to selectively watch two double words in an 8-byte dword array.""" +        self.run_watchpoint_size_test('dwordArray', 2, '4') + +    def run_watchpoint_size_test(self, arrayName, array_size, watchsize): +        self.build(dictionary=self.d) +        self.setTearDownCleanup(dictionary=self.d) + +        exe = os.path.join(os.getcwd(), self.exe_name) +        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + +        # Detect line number after which we are going to increment arrayName. +        loc_line = line_number('main.c', '// About to write ' + arrayName) + +        # Set a breakpoint on the line detected above. +        lldbutil.run_break_set_by_file_and_line (self, "main.c",loc_line, +            num_expected_locations=1, loc_exact=True) + +        # Run the program. +        self.runCmd("run", RUN_SUCCEEDED) + +        for i in range(array_size): +            # 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']) + +            # Set a read_write type watchpoint arrayName +            watch_loc=arrayName+"[" + str(i) + "]" +            self.expect("watchpoint set variable -w read_write " + watch_loc, +                WATCHPOINT_CREATED, +            substrs = ['Watchpoint created', 'size = ' + watchsize, 'type = rw']) + +            # Use the '-v' option to do verbose listing of the watchpoint. +            # The hit count should be 0 initially. +            self.expect("watchpoint list -v", substrs = ['hit_count = 0']) + +            self.runCmd("process continue") + +            # We should be stopped due to the watchpoint. +            # The stop reason of the thread should be watchpoint. +            self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, +            substrs = ['stopped', 'stop reason = 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']) + +            self.runCmd("process continue") + +            # We should be stopped due to the watchpoint. +            # The stop reason of the thread should be watchpoint. +            self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT, +            substrs = ['stopped', 'stop reason = watchpoint']) + +            # Use the '-v' option to do verbose listing of the watchpoint. +            # The hit count should now be 1. +            # Verify hit_count has been updated after value has been read. +            self.expect("watchpoint list -v", +                substrs = ['hit_count = 2']) + +            # Delete the watchpoint immediately, but set auto-confirm to true first. +            self.runCmd("settings set auto-confirm true") +            self.expect("watchpoint delete", substrs = ['All watchpoints removed.']) +            # Restore the original setting of auto-confirm. +            self.runCmd("settings clear auto-confirm") + +            self.runCmd("process continue") diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/main.c new file mode 100644 index 000000000000..ed9fed1e2113 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_size/main.c @@ -0,0 +1,66 @@ +//===-- 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> +#include <stdint.h> + +uint64_t pad0 = 0; +uint8_t byteArray[8] = {0}; +uint64_t pad1 = 0; +uint16_t wordArray[4] = {0}; +uint64_t pad2 = 0; +uint32_t dwordArray[2] = {0}; + +int main(int argc, char** argv) { + +    int i; +    uint8_t localByte; +    uint16_t localWord; +    uint32_t localDword; + +    for (i = 0; i < 8; i++) +    { +        printf("About to write byteArray[%d] ...\n", i); // About to write byteArray +        pad0++; +        byteArray[i] = 7; +        pad1++; +        localByte = byteArray[i]; // Here onwards we should'nt be stopped in loop +        byteArray[i]++; +        localByte = byteArray[i]; +    } + +    pad0 = 0; +    pad1 = 0; + +    for (i = 0; i < 4; i++) +    { +        printf("About to write wordArray[%d] ...\n", i); // About to write wordArray +        pad0++; +        wordArray[i] = 7; +        pad1++; +        localWord = wordArray[i]; // Here onwards we should'nt be stopped in loop +        wordArray[i]++; +        localWord = wordArray[i]; +    } + +    pad0 = 0; +    pad1 = 0; + +    for (i = 0; i < 2; i++) +    { +        printf("About to write dwordArray[%d] ...\n", i); // About to write dwordArray +        pad0++; +        dwordArray[i] = 7; +        pad1++; +        localDword = dwordArray[i]; // Here onwards we shouldn't be stopped in loop +        dwordArray[i]++; +        localDword = dwordArray[i]; +    } + +    return 0; +} | 
