How to set a conditional breakpoint in Xcode based on an object string property?

后端 未结 5 1098
鱼传尺愫
鱼传尺愫 2020-12-02 05:21

I\'m looking to be able to have the debugger break when it reaches a particular string match. As an example, I might have something like this:

Foo myObj = [s         


        
5条回答
  •  离开以前
    2020-12-02 05:44

    Here is how you do using XCode lldb conditional breakpoints.

    First, double click the break point (or right click edit breakpoint), you can see a dialog popup.

    Here is what those option means:

    1. Condition: The breakpoint will only fire under this condition.
    2. Ignore: The amount of times the condition needs to meet before fire the breakpoint
    3. Action: Action that runs after the breakpoint breaks.
    4. Options: Automatically continue after evaluating actions

    Here is a summary. For the above example in image, it means that when the variable buildingId is equal to 13, break here. If I add ignore time to 1, then it will ignore the first time when buildingId is equal to 13 and break at the second time the condition is met.

    For actions, when you press add actions, there will be a list of choice. Usually what I do is to use the Debugger Command po to print variables that I need to check and I believe that there are better ways using the actions then I do.

    It seems that you have to recompile and run the app if you change the conditions at runtime

提交回复
热议问题