home *** CD-ROM | disk | FTP | other *** search
- /*
- * Debug.c
- * $Header: /bcsample/BUGBNCHX/MAINERR/DEBUG.C 1 5/28/96 1:11p Dave $
- *
- * Description:
- * Diagnostic support routines
- *
- * Notes:
- * Much of the implementation was taken from the Win32
- * sample, MCITEST.
- *
- ***********************************************************************
- *
- * Nu-Mega Technologies, Inc.
- * P.O. Box 7780
- * Nashua, NH 03060
- *
- * (c) Copyright 1994, 1995 Nu-Mega Technologies, Inc.
- * ALL RIGHTS RESERVED.
- *
- ***********************************************************************
- *
- **********************************************************************/
-
- #include "stdafx.h"
- #include <stdarg.h>
- #include "debug.h"
-
- #if _DEBUG
-
- extern LPCTSTR GetAppName ( ) ;
-
-
- // Used by the WinVerify macro when
- // evaluating the expression to be
- // verified.
- DWORD __dwEval;
-
- // Sends output to the current debug output device.
- void dDbgOut ( LPTSTR lpszFormat, ... )
- {
- int i ;
- TCHAR buf[ 256 ] ;
- va_list va ;
-
- i = wsprintf ( buf , _T ( "%s: " ) , GetAppName ( ) ) ;
-
- va_start ( va , lpszFormat ) ;
- i += wvsprintf ( buf + i , lpszFormat , va ) ;
- va_end ( va ) ;
-
- buf[ i++ ] = _T ( '\n' ) ;
- buf[ i ] = 0 ;
-
- OutputDebugString ( buf ) ;
- }
-
- // Shows an assert message box.
- void dDbgAssert( LPTSTR szExp, LPTSTR szFile, int nLine)
- {
- TCHAR bufTmp[ 256 ] ;
- int iResponse ;
- HWND hWnd ;
-
- wsprintf ( bufTmp,
- _T ( "Expression: %s\nFile: %s, Line: %d\n\nAbort: Exit Process\nRetry: Enter Debugger\nIgnore: Continue" ) ,
- szExp ,
- szFile ,
- nLine ) ;
-
- // try to use the active window, but NULL is ok if there
- // isn't one.
- hWnd = GetActiveWindow ( ) ;
-
- iResponse = MessageBox ( hWnd ,
- bufTmp ,
- _T ( "Assertion Failure" ) ,
- MB_TASKMODAL
- | MB_ICONEXCLAMATION
- | MB_DEFBUTTON3
- | MB_ABORTRETRYIGNORE ) ;
-
- switch ( iResponse )
- {
- case 0:
- dprintf ( ( _T ( "Assert message box failed" ) ) ) ;
- dprintf1 ( ( _T ( " Expression: %s" ) , szExp ) ) ;
- dprintf2 ( ( _T ( " File: %s, Line: %d" ) , szFile , nLine ) ) ;
- break;
- case IDABORT:
- ExitProcess ( 1 ) ;
- break;
- case IDRETRY:
- DebugBreak ( ) ;
- break;
- case IDIGNORE:
- break;
- }
- }
-
- #endif
-