22Test some SBValue APIs.
33"""
44
5-
65import lldb
76from lldbsuite .test .decorators import *
87from lldbsuite .test .lldbtest import *
@@ -111,6 +110,30 @@ def test_change_value(self):
111110 actual_value , 98765 , "Got the right changed value from ptr->second_val"
112111 )
113112
113+ ptr_fourth_value = ptr_value .GetChildMemberWithName ("fourth_val" )
114+ self .assertTrue (ptr_fourth_value .IsValid (), "Got fourth_val from ptr" )
115+ fourth_actual_value = ptr_fourth_value .GetValueAsUnsigned (error , 1 )
116+ self .assertTrue (error .Success (), "Got an unsigned value for ptr->fourth_val" )
117+ self .assertEqual (fourth_actual_value , 0 )
118+
119+ result = ptr_fourth_value .SetValueFromCString ("true" )
120+ self .assertTrue (result , "Success setting ptr->fourth_val." )
121+ fourth_actual_value = ptr_fourth_value .GetValueAsSigned (error , 0 )
122+ self .assertTrue (error .Success (), "Got a changed value from ptr->fourth_val" )
123+ self .assertEqual (
124+ fourth_actual_value , 1 , "Got the right changed value from ptr->fourth_val"
125+ )
126+
127+ result = ptr_fourth_value .SetValueFromCString ("NO" )
128+ self .assertFalse (result , "Failed setting ptr->fourth_val." )
129+ fourth_actual_value = ptr_fourth_value .GetValueAsSigned (error , 0 )
130+ self .assertTrue (error .Success (), "Got the original value from ptr->fourth_val" )
131+ self .assertEqual (
132+ fourth_actual_value ,
133+ 1 ,
134+ "Got the original changed value from ptr->fourth_val" ,
135+ )
136+
114137 # gcc may set multiple locations for breakpoint
115138 breakpoint .SetEnabled (False )
116139
@@ -125,7 +148,7 @@ def test_change_value(self):
125148 )
126149
127150 expected_value = (
128- "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666"
151+ "Val - 12345 Mine - 55, 98765, 55555555, 0 . Ptr - 66, 98765, 66666666, 1 "
129152 )
130153 stdout = process .GetSTDOUT (1000 )
131154 self .assertIn (expected_value , stdout , "STDOUT showed changed values." )
0 commit comments