• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1014
  • Last Modified:

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
0
Zoppo
Asked:
Zoppo
  • 2
1 Solution
 
jkrCommented:
Have you verified this with e.g. DebugView (http://www.sysinternals.com/ntw2k/freeware/debugview.shtml)? It might just be a VS problem...
0
 
ZoppoAuthor Commented:
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...
0
 
SteveGTRCommented:
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
0
 
ZoppoAuthor Commented:
ok ... no more info ... so I accept jkr's answer...

SteveGTR, I placed a 100 point question for you:
https://secure.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20572710.html

Thanks,

have a nice daym

regards,

ZOPPO
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now