変数が設定した値と等しいときにGDBにブレークポイントを設定させるのが好きです。次の例を試しました。
#include <stdio.h>
main()
{
int i = 0;
for(i=0;i<7;++i)
printf("%d\n", i);
return 0;
}
GDB からの出力:
(gdb) break if ((int)i == 5)
No default breakpoint address now.
(gdb) run
Starting program: /home/SIFE/run
0
1
2
3
4
5
6
Program exited normally.
(gdb)
ご覧のとおり、GDB はブレーク ポイントを作成しませんでした。これは GDB で可能ですか?