Hi,
On Fri, Nov 28, 2008 at 3:49 PM, yogeshwar sonawane <[EMAIL PROTECTED]>wrote:

> Hi,
> Thanks for correction.
>
> Main idea:-
> I am talking about a program running in normal mode, not in gdb
> mode(not using GDB).
> Suppose the expected output should come in 10 min. Now, i run that program.
> It is running for quite some time now, like say 1hr. Still no output.
> That code has some infinite loop like explained in previous mail. But
> i dont know details. Now, by some means (like attaching GDB & doing
> something) can i make sure that the program is just looping for
> condition-check ?
>
> <snip>
>

IMO, there is no general way to do that. More so, since you say 'i dont know
details' about the program. If you attach a debugger and manually step
through the code, then, with a lot of patience, you could check whether the
same set of statements are being executed again and again i.e whether it is
in a loop. AFAIK, there is no tool which can detect an infinite loop in a
running program and that too, without knowing specific details about it.


> Putting some log statements in loop, will cause it, to print no. of
> times. Even after some looping, the expected condition occurs, still
> messages are going to be printed.
>

Not necessarily, you could have something akin to -

flag = 1;
while(condition is not true) {
if(flag == 1)
    log(condition not yet true);
flag = 0;
}
log(condition now true);

You can include timestamp in the logs to indicate how much time was spent
looping.
HTH.

Corrections welcome..

Best regards,
Pranav

Reply via email to