gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: query on execution of inactive statement in gdb run


From: Matthew Woehlke
Subject: Re: query on execution of inactive statement in gdb run
Date: Mon, 10 Sep 2007 11:28:36 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.0

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

[Prev in Thread] Current Thread [Next in Thread]