Changeset 417


Ignore:
Timestamp:
May 6, 2015, 9:09:40 AM (8 years ago)
Author:
roman
Message:
 
Location:
trunk/Utilities/Miscellaneous/AtlReleaseTrace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/Miscellaneous/AtlReleaseTrace/AtlReleaseTrace.cpp

    r416 r417  
    1515        ATLTRACE(atlTraceGeneral, 4, "Line %d\n", __LINE__);
    1616        ATLTRACE(atlTraceGeneral, 4, L"Line %d\n", __LINE__);
     17        for(; ; )
     18        {
     19                _Y1(_T("Line %d"), __LINE__);
     20                break;
     21                _Y2();
     22        }
    1723        return 0;
    1824}
  • trunk/Utilities/Miscellaneous/AtlReleaseTrace/roatlreleasetrace.h

    r416 r417  
    6969
    7070public:
    71         // CDebugTrace
    72         CDebugTrace() :
    73                 m_pszFileName(NULL),
    74                 m_nLineNumber(0),
    75                 m_pszFunctionName(NULL)
    76         {
    77         }
     71// CDebugTrace
    7872        CDebugTrace(LPCSTR pszFileName, INT nLineNumber, LPCSTR pszFunctionName) :
    7973                m_pszFileName(pszFileName),
     
    177171#define _Z5                     ATLTRACE
    178172#define _Z6                     ATLTRACE
     173
     174class CDebugTraceContext :
     175        public CDebugTraceBase
     176{
     177private:
     178        LPCSTR m_pszFileName;
     179        INT m_nLineNumber;
     180        LPCSTR m_pszFunctionName;
     181        CString m_sText;
     182        BOOL m_bTerminated;
     183
     184public:
     185// CDebugTraceContext
     186        CDebugTraceContext(LPCSTR pszFileName, INT nLineNumber, LPCSTR pszFunctionName) :
     187                m_pszFileName(pszFileName),
     188                m_nLineNumber(nLineNumber),
     189                m_pszFunctionName(pszFunctionName),
     190                m_bTerminated(FALSE)
     191        {
     192        }
     193        ~CDebugTraceContext()
     194        {
     195                if(!m_bTerminated)
     196                {
     197                        CString sText;
     198                        sText.Format(_T("%hs(%d): %hs: Context not terminated"), ShortFileNameFromFileName(m_pszFileName), m_nLineNumber, m_pszFunctionName);
     199                        if(!m_sText.IsEmpty())
     200                                sText.AppendFormat(_T(", %s"), m_sText);
     201                        sText.Append(_T("\r\n"));
     202                        OutputDebugString(sText);
     203                }
     204        }
     205        VOID Terminate()
     206        {
     207                m_bTerminated = TRUE;
     208        }
     209        __forceinline VOID __cdecl operator () (LPCSTR pszFormat, ...)
     210        {
     211                va_list Arguments;
     212                va_start(Arguments, pszFormat);
     213                CStringA sText;
     214                sText.FormatV(pszFormat, Arguments);
     215                m_sText.Append(CString(sText));
     216                va_end(Arguments);
     217        }
     218        __forceinline VOID __cdecl operator () (LPCWSTR pszFormat, ...)
     219        {
     220                va_list Arguments;
     221                va_start(Arguments, pszFormat);
     222                CStringW sText;
     223                sText.FormatV(pszFormat, Arguments);
     224                m_sText.Append(CString(sText));
     225                va_end(Arguments);
     226        }
     227};
     228
     229#define _Y1     CDebugTraceContext DebugTraceContext(__FILE__, __LINE__, __FUNCTION__); DebugTraceContext
     230#define _Y2 DebugTraceContext.Terminate
Note: See TracChangeset for help on using the changeset viewer.