setting a breakpoint when variable reaches specific value
Is there anyway to set a breakpoint when a vari开发者_JS百科able reaches a specific value in GDB? For example, a variable take these values: 1 4 8 10 3 2 9 13 11 and I want to set a breakpoint when this variable reaches 9.
Yes, set breakpoint with condition.
break ... if value==9
You can use watchpoints for this.
watch n > 9
...should break when the Boolean expression n > 9
changes; that is, whenever n goes from smaller than or equal to 9 to bigger than 9 or vice-versa.
精彩评论