Link to home
Start Free TrialLog in
Avatar of Zoppo
ZoppoFlag for Germany

asked on

TRACE output overflow?

Hi everybody,

I use MS VC++ 6.0 SP 5.

I encountered a problem with MFC TRACE macro:

When I need to trace a lot of messages in short time
there seems to be an internal buffer overflow which
leads to missing messages in the output window.

This can be simply reproduced with this code:

...
for ( int i = 0; i < 5000; i++ )
{
 TRACE( "Tracing a huge amount of traces in a short time ... this is line %d of 100000\n", i );
}
...

In the output window then I find messages like:
...
Tracing a huge amount of traces in a short time ... this is line 387 of 100000
Tracing a huge amount of traces in a short time ... this is line 388 of 100000
Tracing a huge amount of traces in a short time ... this is line 845 of 100000 (!)
Tracing a huge amount of traces in a short time ... this is line 846 of 100000
...
Tracing a huge amount of traces in a short time ... this is line 882 of 100000
Tracing a huge amount of traces in a short time ... this is line 883 of 100000
Tracing a huge amount of traces in a short time ... this is line 1837 of 100000 (!)
Tracing a huge amount of traces in a short time ... this is line 1838 of 100000
...

The same doesn't happen if you add i.e. a breakpoint which holds execution i.e.
ever 300 loops ... then the output is ok.

The same happens if I use ::AfxTrace directly and even with OutputDebugString.


I already find out that I can redirect TRACE in a file using something like:

...
CStdioFile file;
if ( file.Open( "dump.txt", CFile::modeCreate | CFile::modeWrite ) )
 afxDump.m_pFile = &file;

for ( int i = 0; i < 5000; i++ )
{
 TRACE( "Tracing a huge amount of traces in a short time ... this is line %d of 100000\n", i );
}

afxDump.m_pFile = NULL;
...

but it's sometimes really annoying to have the need to do this everytime I find messages are
missing (sometimes even the bigger problem is to find that messages are missing).


Is there anyone who knows a workaroung for this problem?

Thanks in advance,

ZOPPO
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zoppo

ASKER

Sorry, jkr, I didn't mention before that I already suspected it may
be a VS problem ... now I could ensure this using the DebugView
(thanks for the link ... interesting tool).

With this tool it's easier ... I don't need to modify my code
as in my question described.

Only little problem is that unfortunateley I can't get the
messages in DebugView while I debug in VS ...

Unless someone else can help me avoiding the problem
with VS the next some days the points will be yours, ok?

Have a nice weekend...
This is a known bug reported in Microsoft Knowledge Base Article - 218007: PRB: IDE May Skip Some TRACE Statements Sent in Quick Succession. See this link for more information:

http://support.microsoft.com/default.aspx?scid=kb;en-us;218007
Avatar of Zoppo

ASKER

ok ... no more info ... so I accept jkr's answer...

SteveGTR, I placed a 100 point question for you:
https://www.experts-exchange.com/questions/20572710/Points-for-SteveGTR.html

Thanks,

have a nice daym

regards,

ZOPPO