1""" 2Test change libc++ map 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++ map.""" 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 val_value = frame0.FindVariable("M") 44 self.assertTrue(val_value.IsValid(), "Got the SBValue for val") 45 pair0 = val_value.GetChildMemberWithName("[0]") 46 self.assertTrue(pair0.IsValid(), "Got the SBValue for [0]") 47 self.assertEqual(pair0.GetNumChildren(), 2, "Got 2 children") 48 pair0_second = pair0.GetChildMemberWithName("second") 49 self.assertTrue(pair0_second.IsValid(), "Got the SBValue for [0].second") 50 result = pair0_second.SetValueFromCString("12345") 51 self.assertTrue(result, "Setting val returned True.") 52 result = pair0_second.GetValueAsUnsigned() 53 self.assertEqual(result, 12345, "Got correct value (12345)") 54