1"""Test SBValue::GetValueDidChange""" 2 3 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class ValueVarUpdateTestCase(TestBase): 12 13 mydir = TestBase.compute_mydir(__file__) 14 15 @add_test_categories(['pyapi']) 16 def test_with_process_launch_api(self): 17 """Test SBValue::GetValueDidChange""" 18 # Get the full path to our executable to be attached/debugged. 19 exe = self.getBuildArtifact(self.testMethodName) 20 d = {'EXE': exe} 21 self.build(dictionary=d) 22 self.setTearDownCleanup(dictionary=d) 23 target = self.dbg.CreateTarget(exe) 24 25 breakpoint = target.BreakpointCreateBySourceRegex( 26 "break here", lldb.SBFileSpec("main.c")) 27 28 self.runCmd("run", RUN_SUCCEEDED) 29 30 # The stop reason of the thread should be breakpoint. 31 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 32 substrs=['stopped', 33 'stop reason = breakpoint']) 34 35 i = self.frame().FindVariable("i") 36 i_val = i.GetValueAsUnsigned(0) 37 c = self.frame().FindVariable("c") 38 39 # Update any values from the SBValue objects so we can ask them if they 40 # changed after a continue 41 i.GetValueDidChange() 42 c.GetChildAtIndex(1).GetValueDidChange() 43 c.GetChildAtIndex(0).GetChildAtIndex(0).GetValueDidChange() 44 45 if self.TraceOn(): 46 self.runCmd("frame variable") 47 48 self.runCmd("continue") 49 50 if self.TraceOn(): 51 self.runCmd("frame variable") 52 53 self.assertTrue( 54 i_val != i.GetValueAsUnsigned(0), 55 "GetValue() is saying a lie") 56 self.assertTrue( 57 i.GetValueDidChange(), 58 "GetValueDidChange() is saying a lie") 59 60 # Check complex type 61 self.assertTrue(c.GetChildAtIndex(0).GetChildAtIndex(0).GetValueDidChange( 62 ) and not c.GetChildAtIndex(1).GetValueDidChange(), "GetValueDidChange() is saying a lie") 63