How to change variables value while debugging with LLDB in Xcode?

前端 未结 3 503
南笙
南笙 2020-11-30 16:28

In Xcode, GDB allows you to change local variables while debugging (see how to change NSString value while debugging in XCode?). Does LLDB offer a similar functionality? If

3条回答
  •  忘掉有多难
    2020-11-30 17:13

    The following stuff works for me. I am using Xcode 8.

    If you want to set some variable (for example a "dict") to nil and then test the code flow, you can try the following.

    1. Put the breakpoint properly after initialised to the desired value.
    2. then execute "expression dict = nil" in lldb command line to change it. (for example "nil")
    3. Step over the break point.
    4. Check the variable "dict" in the next line. It will be nil.

    It will look something like in the console.

    (lldb) expression dict = nil
    (NSDictionary *) $5 = nil
    

提交回复
热议问题