I have a C code similar to:
int f() {
for (int i = 0; i < 100; i++) {
scanf flag;
if(flag)
scanf data1;
scanf data2;
}
}
I want to break the execution only when flag == 0. How should I set the breakpoint (using gdb)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In the gdb console type
EDIT:
If you can’t
print flagwhile stopped at some-line, then either:– (A) your code is compiled with optimization (likely), or
– (B) you have a buggy compiler
If it’s (A), add
-O0in addition to-g3.If you can
print flag, then you have a buggy version ofGDB. Try upgrading to current 7.0.1 release.