diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:26:05 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:26:05 +0000 | 
| commit | 14f1b3e8826ce43b978db93a62d1166055db5394 (patch) | |
| tree | 0a00ad8d3498783fe0193f3b656bca17c4c8697d /packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py | |
| parent | 4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py')
| -rw-r--r-- | packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py | 173 | 
1 files changed, 112 insertions, 61 deletions
diff --git a/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py b/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py index d035287cfa00..8516ef3281ff 100644 --- a/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py +++ b/packages/Python/lldbsuite/test/lang/objc/objc-stepping/TestObjCStepping.py @@ -3,16 +3,17 @@  from __future__ import print_function - -import os, time +import os +import time  import lldb  from lldbsuite.test.decorators import *  from lldbsuite.test.lldbtest import *  from lldbsuite.test import lldbutil +  class TestObjCStepping(TestBase): -    def getCategories (self): +    def getCategories(self):          return ['basic_process']      mydir = TestBase.compute_mydir(__file__) @@ -22,11 +23,16 @@ class TestObjCStepping(TestBase):          TestBase.setUp(self)          # Find the line numbers that we will step to in main:          self.main_source = "stepping-tests.m" -        self.source_randomMethod_line = line_number (self.main_source, '// Source randomMethod start line.') -        self.sourceBase_randomMethod_line = line_number (self.main_source, '// SourceBase randomMethod start line.') -        self.source_returnsStruct_start_line = line_number (self.main_source, '// Source returnsStruct start line.') -        self.sourceBase_returnsStruct_start_line = line_number (self.main_source, '// SourceBase returnsStruct start line.') -        self.stepped_past_nil_line = line_number (self.main_source, '// Step over nil should stop here.') +        self.source_randomMethod_line = line_number( +            self.main_source, '// Source randomMethod start line.') +        self.sourceBase_randomMethod_line = line_number( +            self.main_source, '// SourceBase randomMethod start line.') +        self.source_returnsStruct_start_line = line_number( +            self.main_source, '// Source returnsStruct start line.') +        self.sourceBase_returnsStruct_start_line = line_number( +            self.main_source, '// SourceBase returnsStruct start line.') +        self.stepped_past_nil_line = line_number( +            self.main_source, '// Step over nil should stop here.')      @skipUnlessDarwin      @add_test_categories(['pyapi']) @@ -38,57 +44,65 @@ class TestObjCStepping(TestBase):          target = self.dbg.CreateTarget(exe)          self.assertTrue(target, VALID_TARGET) -        self.main_source_spec = lldb.SBFileSpec (self.main_source) +        self.main_source_spec = lldb.SBFileSpec(self.main_source)          breakpoints_to_disable = [] -        break1 = target.BreakpointCreateBySourceRegex ("// Set first breakpoint here.", self.main_source_spec) +        break1 = target.BreakpointCreateBySourceRegex( +            "// Set first breakpoint here.", self.main_source_spec)          self.assertTrue(break1, VALID_BREAKPOINT) -        breakpoints_to_disable.append (break1) +        breakpoints_to_disable.append(break1) -        break2 = target.BreakpointCreateBySourceRegex ("// Set second breakpoint here.", self.main_source_spec) +        break2 = target.BreakpointCreateBySourceRegex( +            "// Set second breakpoint here.", self.main_source_spec)          self.assertTrue(break2, VALID_BREAKPOINT) -        breakpoints_to_disable.append (break2) +        breakpoints_to_disable.append(break2) -        break3 = target.BreakpointCreateBySourceRegex ('// Set third breakpoint here.', self.main_source_spec) +        break3 = target.BreakpointCreateBySourceRegex( +            '// Set third breakpoint here.', self.main_source_spec)          self.assertTrue(break3, VALID_BREAKPOINT) -        breakpoints_to_disable.append (break3) +        breakpoints_to_disable.append(break3) -        break4 = target.BreakpointCreateBySourceRegex ('// Set fourth breakpoint here.', self.main_source_spec) +        break4 = target.BreakpointCreateBySourceRegex( +            '// Set fourth breakpoint here.', self.main_source_spec)          self.assertTrue(break4, VALID_BREAKPOINT) -        breakpoints_to_disable.append (break4) +        breakpoints_to_disable.append(break4) -        break5 = target.BreakpointCreateBySourceRegex ('// Set fifth breakpoint here.', self.main_source_spec) +        break5 = target.BreakpointCreateBySourceRegex( +            '// Set fifth breakpoint here.', self.main_source_spec)          self.assertTrue(break5, VALID_BREAKPOINT) -        breakpoints_to_disable.append (break5) +        breakpoints_to_disable.append(break5) -        break_returnStruct_call_super = target.BreakpointCreateBySourceRegex ('// Source returnsStruct call line.', self.main_source_spec) +        break_returnStruct_call_super = target.BreakpointCreateBySourceRegex( +            '// Source returnsStruct call line.', self.main_source_spec)          self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT) -        breakpoints_to_disable.append (break_returnStruct_call_super) +        breakpoints_to_disable.append(break_returnStruct_call_super) -        break_step_nil = target.BreakpointCreateBySourceRegex ('// Set nil step breakpoint here.', self.main_source_spec) +        break_step_nil = target.BreakpointCreateBySourceRegex( +            '// Set nil step breakpoint here.', self.main_source_spec)          self.assertTrue(break_step_nil, VALID_BREAKPOINT)          # Now launch the process, and do not stop at entry point. -        process = target.LaunchSimple (None, None, self.get_process_working_directory()) +        process = target.LaunchSimple( +            None, None, self.get_process_working_directory())          self.assertTrue(process, PROCESS_IS_VALID)          # The stop reason of the thread should be breakpoint. -        threads = lldbutil.get_threads_stopped_at_breakpoint (process, break1) +        threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1)          if len(threads) != 1: -            self.fail ("Failed to stop at breakpoint 1.") +            self.fail("Failed to stop at breakpoint 1.")          thread = threads[0]          mySource = thread.GetFrameAtIndex(0).FindVariable("mySource")          self.assertTrue(mySource, "Found mySource local variable.") -        mySource_isa = mySource.GetChildMemberWithName ("isa") +        mySource_isa = mySource.GetChildMemberWithName("isa")          self.assertTrue(mySource_isa, "Found mySource->isa local variable.") -        className = mySource_isa.GetSummary () +        className = mySource_isa.GetSummary()          if self.TraceOn(): -             print(mySource_isa) +            print(mySource_isa)          # Lets delete mySource so we can check that after stepping a child variable          # with no parent persists and is useful. @@ -97,77 +111,114 @@ class TestObjCStepping(TestBase):          # Now step in, that should leave us in the Source randomMethod:          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.source_randomMethod_line, "Stepped into Source randomMethod.") +        self.assertTrue( +            line_number == self.source_randomMethod_line, +            "Stepped into Source randomMethod.") -        # Now step in again, through the super call, and that should leave us in the SourceBase randomMethod: +        # Now step in again, through the super call, and that should leave us +        # in the SourceBase randomMethod:          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod.") +        self.assertTrue( +            line_number == self.sourceBase_randomMethod_line, +            "Stepped through super into SourceBase randomMethod.") -        threads = lldbutil.continue_to_breakpoint (process, break2) -        self.assertTrue (len(threads) == 1, "Continued to second breakpoint in main.") +        threads = lldbutil.continue_to_breakpoint(process, break2) +        self.assertTrue( +            len(threads) == 1, +            "Continued to second breakpoint in main.") -        # Again, step in twice gets us to a stret method and a stret super call: +        # Again, step in twice gets us to a stret method and a stret super +        # call:          thread = threads[0]          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct.") - -        threads = lldbutil.continue_to_breakpoint (process, break_returnStruct_call_super) -        self.assertTrue (len(threads) == 1, "Stepped to the call super line in Source returnsStruct.") +        self.assertTrue( +            line_number == self.source_returnsStruct_start_line, +            "Stepped into Source returnsStruct.") + +        threads = lldbutil.continue_to_breakpoint( +            process, break_returnStruct_call_super) +        self.assertTrue( +            len(threads) == 1, +            "Stepped to the call super line in Source returnsStruct.")          thread = threads[0]          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.sourceBase_returnsStruct_start_line, "Stepped through super into SourceBase returnsStruct.") +        self.assertTrue( +            line_number == self.sourceBase_returnsStruct_start_line, +            "Stepped through super into SourceBase returnsStruct.") -        # Cool now continue to get past the call that initializes the Observer, and then do our steps in again to see that  -        # we can find our way when we're stepping through a KVO swizzled object. +        # Cool now continue to get past the call that initializes the Observer, and then do our steps in again to see that +        # we can find our way when we're stepping through a KVO swizzled +        # object. -        threads = lldbutil.continue_to_breakpoint (process, break3) -        self.assertTrue (len(threads) == 1, "Continued to third breakpoint in main, our object should now be swizzled.") +        threads = lldbutil.continue_to_breakpoint(process, break3) +        self.assertTrue( +            len(threads) == 1, +            "Continued to third breakpoint in main, our object should now be swizzled.") -        newClassName = mySource_isa.GetSummary () +        newClassName = mySource_isa.GetSummary()          if self.TraceOn(): -             print(mySource_isa) +            print(mySource_isa) -        self.assertTrue (newClassName != className, "The isa did indeed change, swizzled!") +        self.assertTrue( +            newClassName != className, +            "The isa did indeed change, swizzled!")          # Now step in, that should leave us in the Source randomMethod:          thread = threads[0]          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.source_randomMethod_line, "Stepped into Source randomMethod in swizzled object.") +        self.assertTrue( +            line_number == self.source_randomMethod_line, +            "Stepped into Source randomMethod in swizzled object.") -        # Now step in again, through the super call, and that should leave us in the SourceBase randomMethod: +        # Now step in again, through the super call, and that should leave us +        # in the SourceBase randomMethod:          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod in swizzled object.") - -        threads = lldbutil.continue_to_breakpoint (process, break4) -        self.assertTrue (len(threads) == 1, "Continued to fourth breakpoint in main.") +        self.assertTrue( +            line_number == self.sourceBase_randomMethod_line, +            "Stepped through super into SourceBase randomMethod in swizzled object.") + +        threads = lldbutil.continue_to_breakpoint(process, break4) +        self.assertTrue( +            len(threads) == 1, +            "Continued to fourth breakpoint in main.")          thread = threads[0] -        # Again, step in twice gets us to a stret method and a stret super call: +        # Again, step in twice gets us to a stret method and a stret super +        # call:          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct in swizzled object.") - -        threads = lldbutil.continue_to_breakpoint(process, break_returnStruct_call_super) -        self.assertTrue (len(threads) == 1, "Stepped to the call super line in Source returnsStruct - second time.") +        self.assertTrue( +            line_number == self.source_returnsStruct_start_line, +            "Stepped into Source returnsStruct in swizzled object.") + +        threads = lldbutil.continue_to_breakpoint( +            process, break_returnStruct_call_super) +        self.assertTrue( +            len(threads) == 1, +            "Stepped to the call super line in Source returnsStruct - second time.")          thread = threads[0]          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.sourceBase_returnsStruct_start_line, "Stepped through super into SourceBase returnsStruct in swizzled object.") +        self.assertTrue( +            line_number == self.sourceBase_returnsStruct_start_line, +            "Stepped through super into SourceBase returnsStruct in swizzled object.")          for bkpt in breakpoints_to_disable:              bkpt.SetEnabled(False) -        threads = lldbutil.continue_to_breakpoint (process, break_step_nil) -        self.assertTrue (len(threads) == 1, "Continued to step nil breakpoint.") +        threads = lldbutil.continue_to_breakpoint(process, break_step_nil) +        self.assertTrue(len(threads) == 1, "Continued to step nil breakpoint.")          thread.StepInto()          line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() -        self.assertTrue (line_number == self.stepped_past_nil_line, "Step in over dispatch to nil stepped over.") +        self.assertTrue( +            line_number == self.stepped_past_nil_line, +            "Step in over dispatch to nil stepped over.")  | 
