Can we set a GDB breakpoint on a function such that it will break into only if the function argument matches the value specified? Ex
int foo(int i) {
return i*i;
}
int main() {
foo(0);
................
foo(9);
}
How do I set a breakpoint on foo only when the argument i of foo is 5?
Sure, use "break if"
break foo if i == 5
If you have multiple variable if need to break on, just use classic if syntax :
break foo if i == 5 && j == 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With