Prakash Barnwal wrote:
I want to run gdb and wants to execute a particular line of code which is not feasible in normal flow ;

main(){
int i = 0;

printf ("i=== %d\n",i);
if(0){
  printf("I am here\n");
}
In this case if(0) will always be false but I want to execute line (printf("I am here\n");) in gdb run. Could you please help me how to do this
?

You can't. If your compiler is at all non-braindead, code inside a conditional that is always false (e.g. 'if(0)') is omitted from the final output.

You might be able to work around this by using 'if(foo)' where 'foo' is a variable that is normally 0 but might possibly become non-zero. A very safe way might be 'if(getenv("MY_FOO"))' (which will change execution normally in the very rare condition that you set MY_FOO in the environment.

--
Matthew
A KWin crash is like a Finite Improbability Generator... only instead of undergarments, all my windows move 4 pixels to the right.



Reply via email to