watch if

watch if

Victor M.的头像

Hello,

I'm using idb in gdb mode to debug a code. I have a REAL*8 variable which is an array of length 50 that is changed a lot through the code. I would like to watch this variable and make the debugger stop only if some position in that array receives a negative value.

I know that I have to use watch if for doing this, but I don't know what syntax I have to use exactly. Can someone help me?

Thank you,

Victor

2 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
robert-mueller-albrecht (Intel)的头像

Hi Victor,

the condiktional watchpoint syntax is actually the same as for breakpoints in GDB*. Thus in genral something like

(gdb) watch my_arr[3] if my_arr[3] > 10

should work.

In addition the whole syntax as described for setting breakpoint conditions in the GDB* manual
http://sourceware.org/gdb/current/onlinedocs/gdb/Conditions.html#Conditions

also applies - especially if you are looking at more complex conditions.

Where it gets a bit tricky is if you are changing scope during the run. Then you may need to use hardware watchpoints:

(gdb) set can-use-hw-watchpoints

(gdb) watch *(int *)0x41523c0
Hardware watchpoint 1: *(int *)0x41523c0

Thanks, Rob

登陆并发表评论。