How do I set persistent and conditional watchpoints on locally scoped variables?

后端 未结 4 1736
执笔经年
执笔经年 2020-12-13 12:57
  1. If I set a watchpoint for a variable local to the current scope, it will be auto deleted when going out of the scope. Is there any way to set it once and keep it au

4条回答
  •  被撕碎了的回忆
    2020-12-13 13:29

    You can set conditions on watchpoints in the same way that you do with breakpoints. This is in the documentation but admittedly it hardly calls attention to itself.

    So watch my_var if my_var > 3 works just fine, as does the condition command.

    To recreate the watchpoint if the variable it is watching goes out of scope, have gdb do this automatically using a breakpoint at the start of the function as Zan has described.

提交回复
热议问题