$ gdb a.out
GNU gdb 4.17.0.11 with Linux support
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) break 11 if odd > 10
#whileループ内の11行で、奇数値oddが10を超えた場合のみ停止
するように設定する。
Breakpoint 1 at 0x80483f3: file whike.c, line 11.
(gdb) run
Starting program: /home/miyao/Soft2/a.out
Breakpoint 1, main () at while.c:11
11 odd = odd+2; /* 次の奇数へ */
(gdb) print odd
$1 = 11 #oddの値を表示させると、確かに10を超える数値となっている。そ
こで、whileループの条件を確かめると、常に真になることに気づく。
(gdb) cont #次のブレイクポイントまで処理を続行する。
Continuing.
Breakpoint 1, main () at while.c:11
11 odd = odd+2; /* 次の奇数へ */
(gdb) print odd
$2 = 13 #oddの値は2ずつ増加することが確かめられる。
(gdb) quit
The program is running. Exit anyway? (y or n) y
|