Lost output of printf when using conditional breakpoint in gdb
Version of gdb is 7.4.1-debian.
Just a simple program below: Code:
1 #include <stdio.h> When set a breakpoint using command "b 7", run, and then continue if break, there are "i=0", "i=1", "i=2" in output: Code:
(gdb) b 7 Code:
(gdb) b 7 if i=2 |
for a start, add fflush(stdout); after printf
|
Quote:
I tried adding fflush(stdout); after printf, but still I can't see "i=1" and "i=2" in output: Code:
(gdb) b 8 if i=2 |
Then try command 'next' instead of 'continue'. Also, use command 'display i'.
|
Quote:
Here is the output in terminal: Code:
(gdb) b 8 if i=2 Something strange happened, value of 'i' became 2, and it shouldn't encounter the breakpoint. So I was thinking what changed value of 'i', therefore, I recalled that there is 'i=2' in command 'b 8 if i=2'. Then I tried command 'b 8 if i==2' instead of 'b 8 if i=2', the issue disappeared. And then I found the tutorial I referenced has such mistake. Thanks for your help, NevemTeve! |
All times are GMT -5. The time now is 01:43 AM. |