editing Bool variable in lldb while debugging is not working properly

i wanted to edit an Bool value while debugging. For this i tried multiple approaches but none of them is working


First, I tried to keep the debug cursor on the variable and right click on the variable and tried to edit value. Although it shows the value had changed to true , the if block is not executed


Another ways i tried are

  • expression myvariable = true
  • po myvariable = true
  • p myvariable = true.


But in all these cases , if i print the variable in xcode lldb debugger, the value shows to be changed, but the execution flow is not changed


var myvariable = some expression
if(variable){
// if block this part doesnt get executed after all these modifications. 
}

I am using swift 4.2 and Xcode 10.3. Is there any other way to accomplish this?

While this is indeed wrong, it is expected. The technical explanation is that we allocate a stack slot with the value of the variable on the side (which we call a shadow copy) so it is available throughout the function. When the expression is executed, that shadow copy gets updated, but the real value is used in the if-clause.

What we want instead is to change Swift so that behaves like clang and generates code that loads the variable from the stack before each access.
editing Bool variable in lldb while debugging is not working properly
 
 
Q