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

后端 未结 4 1743
执笔经年
执笔经年 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:18

    You can set a watchpoint that does not go out of scope by setting it to the memory address.

    (gdb) p &var1
    $1 = (int *) 0x41523c0
    (gdb) watch *(int *)0x41523c0
    Hardware watchpoint 1: *(int *)0x41523c0
    

    This also works for other data types and pointers.

提交回复
热议问题