63 lines · python
1# encoding: utf-82"""3Test lldb data formatter subsystem.4"""5 6 7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase13 14 15class ObjCDataFormatterKVO(ObjCDataFormatterTestCase):16 def test_kvo_with_run_command(self):17 """Test the behavior of formatters when KVO is in use."""18 self.build()19 self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(20 self, "// Set break point at this line.", lldb.SBFileSpec("main.m", False)21 )22 23 self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")24 25 # The stop reason of the thread should be breakpoint.26 self.expect(27 "thread list",28 STOPPED_DUE_TO_BREAKPOINT,29 substrs=["stopped", "stop reason = breakpoint"],30 )31 32 # This is the function to remove the custom formats in order to have a33 # clean slate for the next test case.34 def cleanup():35 self.runCmd("type format clear", check=False)36 self.runCmd("type summary clear", check=False)37 self.runCmd("type synth clear", check=False)38 39 # Execute the cleanup function during test case tear down.40 self.addTearDownHook(cleanup)41 42 # as long as KVO is implemented by subclassing, this test should succeed43 # we should be able to dynamically figure out that the KVO implementor class44 # is a subclass of Molecule, and use the appropriate summary for it45 self.runCmd("type summary add -s JustAMoleculeHere Molecule")46 self.expect("frame variable molecule", substrs=["JustAMoleculeHere"])47 self.runCmd("next")48 self.expect("thread list", substrs=["stopped", "step over"])49 self.expect("frame variable molecule", substrs=["JustAMoleculeHere"])50 51 self.runCmd("next")52 # check that NSMutableDictionary's formatter is not confused when53 # dealing with a KVO'd dictionary54 self.expect(55 "frame variable newMutableDictionary",56 substrs=["(NSDictionary *) newMutableDictionary = ", " 21 key/value pairs"],57 )58 59 lldbutil.run_break_set_by_symbol(self, "-[Molecule setAtoms:]")60 61 self.runCmd("continue")62 self.expect("frame variable _cmd", substrs=["setAtoms:"])63