RE: how to print all debug(printf or cout) statements before the assert

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

 



> Are the printf/cout statements are run by separate threads?
No. Unless you have these different printf statements in two different threads.

> In the above program some time prinrf statement on line1 is printed. some 
> times upto line 2, some time upto line3. why?
It depends on whether the stdout is buffered or unbuffered.

> How to make sure that all the print statements, before the line causing 
> the crash , are printed?
Method 1: setvbuf(stdout, NULL, _IONBF, 0)
Method 2: fflush(stdout) wherever required

Regards,
Kannan

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of ranjith kumar
Sent: Wednesday, January 25, 2012 12:08 PM
To: gcc-help@xxxxxxxxxxx
Subject: how to print all debug(printf or cout) statements before the assert

Hi,
I have a program like

1)printf("%s %d",__FILE__,__LINE__);
2)printf("%s %d",__FILE__,__LINE__);
3)printf("%s %d",__FILE__,__LINE__);
4)assert(0);


1)My question is : are the printf/cout statements are run by separate threads?
2)In the above program some time prinrf statement on line1 is printed.
some times upto line 2, some time upto line3.
why?
3) How to make sure that all the print statements, before the line
causing the crash , are printed ?

thanks.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux