Reputation: 403
In my code, sometimes when multiple function calls can be made in a single line. I do not get which function is running right now. for example-
int foo(){
if(m==0||n==0) return 0;
return std::max(foo(a,b,m-1,n),foo(a,b,m,n-1));
}
While debugging, understanding which function was called based on all parameters becomes clumsy and sometimes doesn't even work. Is there any option to see processes within a line while debugging. I use codelite IDE.
Upvotes: 0
Views: 59
Reputation: 83517
When you are having difficulty debugging code, it usually means you are doing too much in a single line. This means you should split a complex statement into multiple statements. In your case, something like this:
int foo(){
if(m==0||n==0) return 0;
auto a = foo(a,b,m-1,n);
auto b = foo(a,b,m,n-1);
return std::max(a, b);
}
Upvotes: 3
Reputation: 13634
Alternatives to the current answer could be:
foo
calls are inlinedThese alternatives may not work, but if when they work, they allow debugging unaltered code.
Upvotes: 1