messing with afxDump
-
Am I in much danger doing this? I wanted to see the TRACE results w/o attaching a debugger, so I did this:
#ifdef _DEBUG
{
typedef BOOL (WINAPI* ISDEBUGGERPRESENT)();
ISDEBUGGERPRESENT pIsDebuggerPresent=(ISDEBUGGERPRESENT)GetProcAddress(GetModuleHandle("KERNEL32.DLL"),"IsDebuggerPresent");
if (pIsDebuggerPresent && !pIsDebuggerPresent())
{ // this is a debug build with no debugger, let's set the afxDump object
// to dump to a local file so that we can inspect the results
ASSERT(!afxDump.m_pFile);
CString DumpFilename;
DumpFilename.ReleaseBuffer(::GetModuleFileName(0,DumpFilename.GetBuffer(MAX_PATH),MAX_PATH)?-1:0);
DumpFilename+=".TRACE-DUMP.TXT";
afxDump.m_pFile=new CFile(DumpFilename,CFile::modeWrite|CFile::modeCreate|CFile::shareDenyWrite);
}
}
#endifI feel uneasy about it. Besides the problem of a debugger attaching to the process later on, it may step on other dependencies of which I am unaware. Is there a simple tool instead that will serve to receive and display the TRACE messages?
-
Am I in much danger doing this? I wanted to see the TRACE results w/o attaching a debugger, so I did this:
#ifdef _DEBUG
{
typedef BOOL (WINAPI* ISDEBUGGERPRESENT)();
ISDEBUGGERPRESENT pIsDebuggerPresent=(ISDEBUGGERPRESENT)GetProcAddress(GetModuleHandle("KERNEL32.DLL"),"IsDebuggerPresent");
if (pIsDebuggerPresent && !pIsDebuggerPresent())
{ // this is a debug build with no debugger, let's set the afxDump object
// to dump to a local file so that we can inspect the results
ASSERT(!afxDump.m_pFile);
CString DumpFilename;
DumpFilename.ReleaseBuffer(::GetModuleFileName(0,DumpFilename.GetBuffer(MAX_PATH),MAX_PATH)?-1:0);
DumpFilename+=".TRACE-DUMP.TXT";
afxDump.m_pFile=new CFile(DumpFilename,CFile::modeWrite|CFile::modeCreate|CFile::shareDenyWrite);
}
}
#endifI feel uneasy about it. Besides the problem of a debugger attaching to the process later on, it may step on other dependencies of which I am unaware. Is there a simple tool instead that will serve to receive and display the TRACE messages?
Scott H. Settlemier wrote: Is there a simple tool instead that will serve to receive and display the TRACE messages? Here is a tool that captures both kernel and Win32 debug output: http://www.systeminternals.com/ntw2k/freeware/debugview.shtml[^] Good luck! Mike