1""" 2Test change libc++ std::atomic values. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class LibcxxChangeValueTestCase(TestBase): 12 def setUp(self): 13 # Call super's setUp(). 14 TestBase.setUp(self) 15 16 @add_test_categories(["libc++"]) 17 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772") 18 def test(self): 19 """Test that we can change values of libc++ std::atomic.""" 20 self.build() 21 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 22 23 bkpt = self.target().FindBreakpointByID( 24 lldbutil.run_break_set_by_source_regexp( 25 self, "Set break point at this line." 26 ) 27 ) 28 29 self.runCmd("run", RUN_SUCCEEDED) 30 31 # Get Frame #0. 32 target = self.dbg.GetSelectedTarget() 33 process = target.GetProcess() 34 self.assertState(process.GetState(), lldb.eStateStopped) 35 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) 36 self.assertTrue( 37 thread.IsValid(), 38 "There should be a thread stopped due to breakpoint condition", 39 ) 40 frame0 = thread.GetFrameAtIndex(0) 41 self.assertTrue(frame0.IsValid(), "Got a valid frame.") 42 43 q_value = frame0.FindVariable("Q") 44 self.assertTrue(q_value.IsValid(), "Got the SBValue for val") 45 inner_val = q_value.GetChildAtIndex(0) 46 self.assertTrue(inner_val.IsValid(), "Got the SBValue for inner atomic val") 47 result = inner_val.SetValueFromCString("42") 48 self.assertTrue(result, "Setting val returned True.") 49 result = inner_val.GetValueAsUnsigned() 50 self.assertEqual(result, 42, "Got correct value (42)") 51