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