diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:26:17 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:26:17 +0000 | 
| commit | e75e363cb71a7339552b9d943e78ac62b737379b (patch) | |
| tree | 29ec5bd173694acbbcbb8207114ef7ca189436ba /packages/Python/lldbsuite/test/expression_command | |
| parent | 1b306c26ade71504511d2fa75b03dfaee77f9620 (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/expression_command')
9 files changed, 23 insertions, 183 deletions
| diff --git a/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py b/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py index 0b9ad0ed6323..5eb7b309c94a 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py +++ b/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py @@ -48,28 +48,8 @@ class ExprCommandThatRestartsTestCase(TestBase):              "Restored the zeroth frame correctly")      def call_function(self): -        exe_name = "a.out" -        exe = os.path.join(os.getcwd(), exe_name) - -        target = self.dbg.CreateTarget(exe) -        self.assertTrue(target, VALID_TARGET) -        empty = lldb.SBFileSpec() -        breakpoint = target.BreakpointCreateBySourceRegex( -            'Stop here in main.', self.main_source_spec) -        self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) - -        # Launch the process, and do not stop at the entry point. -        process = target.LaunchSimple( -            None, None, self.get_process_working_directory()) - -        self.assertTrue(process, PROCESS_IS_VALID) - -        # Frame #0 should be at our breakpoint. -        threads = lldbutil.get_threads_stopped_at_breakpoint( -            process, breakpoint) - -        self.assertTrue(len(threads) == 1) -        self.thread = threads[0] +        (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,  +                                      'Stop here in main.', self.main_source_spec)          # Make sure the SIGCHLD behavior is pass/no-stop/no-notify:          return_obj = lldb.SBCommandReturnObject() diff --git a/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py b/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py index e5162609dfa6..f2ec340ac845 100644 --- a/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py +++ b/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py @@ -37,28 +37,8 @@ class ExprCommandWithThrowTestCase(TestBase):      def call_function(self):          """Test calling function that throws.""" -        exe_name = "a.out" -        exe = os.path.join(os.getcwd(), exe_name) - -        target = self.dbg.CreateTarget(exe) -        self.assertTrue(target, VALID_TARGET) - -        breakpoint = target.BreakpointCreateBySourceRegex( -            'I am about to throw.', self.main_source_spec) -        self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) - -        # Launch the process, and do not stop at the entry point. -        process = target.LaunchSimple( -            None, None, self.get_process_working_directory()) - -        self.assertTrue(process, PROCESS_IS_VALID) - -        # Frame #0 should be at our breakpoint. -        threads = lldbutil.get_threads_stopped_at_breakpoint( -            process, breakpoint) - -        self.assertTrue(len(threads) == 1) -        self.thread = threads[0] +        (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,  +                                   'I am about to throw.', self.main_source_spec)          options = lldb.SBExpressionOptions()          options.SetUnwindOnError(True) diff --git a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py index a771e7004c94..74991999d926 100644 --- a/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py +++ b/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py @@ -17,29 +17,14 @@ class ExprCharTestCase(TestBase):          self.main_source = "main.cpp"          self.main_source_spec = lldb.SBFileSpec(self.main_source) -        self.exe = os.path.join(os.getcwd(), "a.out")      def do_test(self, dictionary=None):          """These basic expression commands should work as expected."""          self.build(dictionary=dictionary) -        target = self.dbg.CreateTarget(self.exe) -        self.assertTrue(target) - -        breakpoint = target.BreakpointCreateBySourceRegex( -            '// Break here', self.main_source_spec) -        self.assertTrue(breakpoint) - -        # Launch the process, and do not stop at the entry point. -        process = target.LaunchSimple( -            None, None, self.get_process_working_directory()) -        self.assertTrue(process) - -        threads = lldbutil.get_threads_stopped_at_breakpoint( -            process, breakpoint) -        self.assertEqual(len(threads), 1) - -        frame = threads[0].GetFrameAtIndex(0) +        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,  +                                          '// Break here', self.main_source_spec) +        frame = thread.GetFrameAtIndex(0)          value = frame.EvaluateExpression("foo(c)")          self.assertTrue(value.IsValid()) diff --git a/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py b/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py index 418c5325ad08..4b096149e728 100644 --- a/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py +++ b/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py @@ -37,28 +37,8 @@ class ExprCommandWithFixits(TestBase):      def try_expressions(self):          """Test calling expressions with errors that can be fixed by the FixIts.""" -        exe_name = "a.out" -        exe = os.path.join(os.getcwd(), exe_name) - -        target = self.dbg.CreateTarget(exe) -        self.assertTrue(target, VALID_TARGET) - -        breakpoint = target.BreakpointCreateBySourceRegex( -            'Stop here to evaluate expressions', self.main_source_spec) -        self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) - -        # Launch the process, and do not stop at the entry point. -        process = target.LaunchSimple( -            None, None, self.get_process_working_directory()) - -        self.assertTrue(process, PROCESS_IS_VALID) - -        # Frame #0 should be at our breakpoint. -        threads = lldbutil.get_threads_stopped_at_breakpoint( -            process, breakpoint) - -        self.assertTrue(len(threads) == 1) -        self.thread = threads[0] +        (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,  +                                        'Stop here to evaluate expressions', self.main_source_spec)          options = lldb.SBExpressionOptions()          options.SetAutoApplyFixIts(True) diff --git a/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py b/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py index afb497e04b5b..a2d68cffe548 100644 --- a/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py +++ b/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py @@ -32,26 +32,9 @@ class Issue11581TestCase(TestBase):          """valobj.AddressOf() should return correct values."""          self.build() -        exe = os.path.join(os.getcwd(), "a.out") - -        target = self.dbg.CreateTarget(exe) -        self.assertTrue(target, VALID_TARGET) - -        breakpoint = target.BreakpointCreateBySourceRegex( -            'Set breakpoint here.', lldb.SBFileSpec("main.cpp", False)) - -        process = target.LaunchSimple( -            None, None, self.get_process_working_directory()) -        self.assertTrue(process, "Created a process.") -        self.assertTrue( -            process.GetState() == lldb.eStateStopped, -            "Stopped it too.") - -        thread_list = lldbutil.get_threads_stopped_at_breakpoint( -            process, breakpoint) -        self.assertTrue(len(thread_list) == 1) -        thread = thread_list[0] - +        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,  +                                              'Set breakpoint here.',  +                                              lldb.SBFileSpec("main.cpp", False))          self.runCmd("command script import --allow-reload s11588.py")          self.runCmd(              "type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure") diff --git a/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py b/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py index 70b862bf4867..817f6cb3944a 100644 --- a/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py +++ b/packages/Python/lldbsuite/test/expression_command/macros/TestMacros.py @@ -30,32 +30,8 @@ class TestMacros(TestBase):          src_file_spec = lldb.SBFileSpec(src_file)          self.assertTrue(src_file_spec.IsValid(), "Main source file") -        # Get the path of the executable -        cwd = os.getcwd() -        exe_file = "a.out" -        exe_path = os.path.join(cwd, exe_file) - -        # Load the executable -        target = self.dbg.CreateTarget(exe_path) -        self.assertTrue(target.IsValid(), VALID_TARGET) - -        # Set breakpoints -        bp1 = target.BreakpointCreateBySourceRegex("Break here", src_file_spec) -        self.assertTrue( -            bp1.IsValid() and bp1.GetNumLocations() >= 1, -            VALID_BREAKPOINT) - -        # Launch the process -        process = target.LaunchSimple( -            None, None, self.get_process_working_directory()) -        self.assertTrue(process.IsValid(), PROCESS_IS_VALID) - -        # Get the thread of the process -        self.assertTrue( -            process.GetState() == lldb.eStateStopped, -            PROCESS_STOPPED) -        thread = lldbutil.get_stopped_thread( -            process, lldb.eStopReasonBreakpoint) +        (target, process, thread, bp1) = lldbutil.run_to_source_breakpoint( +            self, "Break here", src_file_spec)          # Get frame for current thread          frame = thread.GetSelectedFrame() diff --git a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py index 0d1a17352a3f..b4e9a8bfeab8 100644 --- a/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py +++ b/packages/Python/lldbsuite/test/expression_command/options/TestExprOptions.py @@ -37,25 +37,10 @@ class ExprOptionsTestCase(TestBase):          # Set debugger into synchronous mode          self.dbg.SetAsync(False) -        # Create a target by the debugger. -        target = self.dbg.CreateTarget(self.exe) -        self.assertTrue(target, VALID_TARGET) +        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +            self, '// breakpoint_in_main', self.main_source_spec) -        # Set breakpoints inside main. -        breakpoint = target.BreakpointCreateBySourceRegex( -            '// breakpoint_in_main', self.main_source_spec) -        self.assertTrue(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) - -        threads = lldbutil.get_threads_stopped_at_breakpoint( -            process, breakpoint) -        self.assertEqual(len(threads), 1) - -        frame = threads[0].GetFrameAtIndex(0) +        frame = thread.GetFrameAtIndex(0)          options = lldb.SBExpressionOptions()          # test --language on C++ expression using the SB API's diff --git a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py index 7f796971d0ed..f6938b1ea98b 100644 --- a/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py +++ b/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py @@ -31,17 +31,10 @@ class SaveJITObjectsTestCase(TestBase):          src_file = "main.c"          src_file_spec = lldb.SBFileSpec(src_file) -        exe_path = os.path.join(os.getcwd(), "a.out") -        target = self.dbg.CreateTarget(exe_path) +        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +            self, "break", src_file_spec) -        breakpoint = target.BreakpointCreateBySourceRegex( -            "break", src_file_spec) - -        process = target.LaunchSimple(None, None, -                                      self.get_process_working_directory()) - -        thread = process.GetSelectedThread() -        frame = thread.GetSelectedFrame() +        frame = thread.frames[0]          cleanJITFiles()          frame.EvaluateExpression("(void*)malloc(0x1)") diff --git a/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py b/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py index 29c03b1d7ef9..7862477001ea 100644 --- a/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py +++ b/packages/Python/lldbsuite/test/expression_command/timeout/TestCallWithTimeout.py @@ -25,36 +25,14 @@ class ExprCommandWithTimeoutsTestCase(TestBase):      @expectedFlakeyFreeBSD("llvm.org/pr19605")      @expectedFailureAll(          oslist=[ -            "windows", -            "macosx"], +            "windows"],          bugnumber="llvm.org/pr21765")      def test(self):          """Test calling std::String member function."""          self.build() -        exe_name = "a.out" -        exe = os.path.join(os.getcwd(), exe_name) - -        target = self.dbg.CreateTarget(exe) -        self.assertTrue(target, VALID_TARGET) - -        breakpoint = target.BreakpointCreateBySourceRegex( -            'stop here in main.', self.main_source_spec) -        self.assertTrue(breakpoint, VALID_BREAKPOINT) -        self.runCmd("breakpoint list") - -        # Launch the process, and do not stop at the entry point. -        process = target.LaunchSimple( -            None, None, self.get_process_working_directory()) - -        self.assertTrue(process, PROCESS_IS_VALID) - -        # Frame #0 should be on self.step_out_of_malloc. -        threads = lldbutil.get_threads_stopped_at_breakpoint( -            process, breakpoint) - -        self.assertTrue(len(threads) == 1) -        thread = threads[0] +        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +            self, 'stop here in main.', self.main_source_spec)          # First set the timeout too short, and make sure we fail.          options = lldb.SBExpressionOptions() | 
