3GL   4GL   5GL  

  1. Visual C++ Visual Basic
  2. SUPERASSERT

2 , . , , . (defensive) . ( , proactive) . , , . .

, . - , , , NULL-. , : , , . , , ( ) .

: - . "" , , , , , , . , . , , .

, , , . , . , , : , , , , , , , , . -, , .

, : -, , . , , ( ) , .

. , . , , , . . " " .

  Gremlin ( ) , , ; , , goblin. .

 

, , , , . , , : , ( ) . 

  assertion (.) ( ), ( ) (true) (false). .

( false), , . . , , 1, . , , , (. . false). , , , . , , , .

- , , . , .

, ( ) , . , . , , , .

, ( ).

  Assert , ASSERT (. ).

 

, . , , .

, , . , , , " ". , , .

 

: . , , . ASSERT. , , (. . , ).

// .

// ?

BOOL GetPathltem ( int i, LPTSTR szltem, int iLen)

{

ASSERT ( ( i > 0 ) &&

( NULL != szltem ) && 

( ( iLen > 0) && ( iLen < MAX_PATH) ) && 

( FALSE = IsBadWriteStringPtr ( szltem, iLen)));

}

// .

// , , .

BOOL GetPathltem ( int i, LPTSTR szltem, int iLen)

{

ASSERT ( i > 0);

ASSERT ( NULL != szltem);

ASSERT ( ( iLen > 0) && ( iLen < MAX_PATH));

ASSERT ( FALSE == IsBadWriteStringPtr ( szltem, iLen));

}

. , , NULL

( ), . ( , 1), , .

//

BOOL EnumerateListltems ( PFNELCALLBACK pfnCallback)

{

ASSERT ( NULL != pfnCallback);

}

, ASSERT API- isBadCodePtr:

//

BOOL EnumerateListltems (PFNELCALLBACK pfnCallback)

{

ASSERT ( FALSE = IsBadCodePtr ( pfnCallback));

}

: , , . , .

 

  nCount .

 Function UpdateListEntries(ByVal nCount As Integer) as Integer

Debug.Assert nCount

.

.

.

End Function

' (nCount>0) , Assert- 

' nCount 

Function UpdateListEntries(ByVal nCount As Integer) as Integer

 Debug.Assert nCount > 0

.

.

.

End Function

, , nCount, , (nCount <= 0) Assert. (nCount > 0), , -, (. . nCount > 0 ) , -, "" (<= 0) nCount.

  UpdateListEntries , - Debug.Assert nCount > 0 ASSERTION FAILURE. .

C++ , . 3.1 . Visual Basic, - .

3.1. C/C++

GetOb j ectType

(GDI), GDI

IsBadCodePtr

IsBadReadPtr

,

IsBadStringPt

, NULL- ( )

IsBadWritePtr

,

IsWindow

, HWND-

IsBadstringPtr IsBadWritePtr . IsBadWritePtr, , . , , . , IsBadstringPtr   IsBadWritePtr.

Visual Basic , Visual Basic. 3.2. , Visual Basic, variants ByVal ByRef , . , , , .

3.2. Visual Basic

isArray

, Array

IsDate

,

IsEmpty

, variant-

IsError

,

IsMissing

, Variant

IsNull

, Variant- Null

IsNumeric

,

IsObject

,

TypeName

, .

//

 BOOL CheckDriveFreeSpace ( LPCTSTR szDrive) 

{

ULARGE_INTEGER ulgAvail; 

ULARGE_INTEGER ulgNumBytes; 

ULARGE INTEGER ulgFree;

if ( FALSE == GetDiskFreeSpaceEx ( szDrive ,

&ulgAvail ,

 &ulgNumBytes ,

 &ulgFree ))

{

ASSERT ( FALSE);

return ( FALSE); 

}

}

ASSERT, . , FALSE, . ( ) .

(Dave Angel) , ASSERT C++ NOT (!), . , , , - , ( ). . , Visual Basic.

//  

BOOL CheckDriveFreeSpace ( LPCTSTR szDrive) 

{

ULARGE_INTEGER ulgAvail; 

ULARGE_INTEGER ulgNuinBytes; 

ULARGE INTEGER ulgFree;

if ( FALSE = GetDiskFreeSpaceEx ( szDrive ,

&ulgAvail ,

 &ulgNumBytes, 

&ulgFree )) 

{

ASSERT ( !"GetDiskFreeSpaceEx failed!");

 return ( FALSE); 

}

}

, AND (&&). , ASSERT- :

BOOL AddToDataTree ( PTREENODE pNode) 

{

ASSERT ( ( FALSE == IsBadReadPtr 

( pNode, sizeof ( TREENODE))) && 

"Invalid parameter!");

.

.

.

}

 

, . , , . , (, ). , .

(stopDebugging) , 4, ASSERT. , (ASSERT) . , , , .

BOOL DEBUGINTERFACE_DLLINTERFACE _stdcall

StopDebugging ( LPHANDLE IpDebugSyncEvents) 

{

ASSERT ( FALSE ==

IsBadWritePtr ( IpDebugSyncEvents,

sizeof ( HANDLE) * NUM_DEBUGEVENTS)); 

if ( TRUE == IsBadWritePtr ( IpDebugSyncEvents,

sizeof ( HANDLE) * NUM_DEBUGEVENTS))

 {

SetLastError ( ERROR_INVALID_PARAMETER);

 return ( FALSE); 

}

// . 

VERIFY ( SetEvent ( IpDebugSyncEvents[ CLOSEDEBUGGER ]));

return ( TRUE);

 }

private- . , . , , , ( , ), () . , . ASSERT- . , .

, "" . . , , , .

ASSERT- . ASSERT- . . 3-1 startDebugging ( , 4), . , .

  3-1. ASSERT- ;

HANDLE DEBUGINTERFACE_DLLINTERFACE _stdcall

StartDebugging ( LPCTSTR szDebuggee , 

LPCTSTR szCmdLine , 

LPDWORD IpPID ,

 CDebugBaseUser * pUserClass ,

 LPHANDLE IpDebugSyncEvents ) 

{

// ASSERT- .

ASSERT ( FALSE == IsBadStringPtr ( szDebuggee, MAX__PATH)); 

ASSERT ( FALSE == IsBadStringPtr ( szCmdLine, MAX_PATH)); 

ASSERT ( FALSE == IsBadWritePtr ( IpPID, sizeof ( DWORD))); 

ASSERT ( FALSE == IsBadReadPtr ( pUserClass,

sizeof ( CDebugBaseUser *)));

ASSERT' ( FALSE == IsBadWritePtr ( IpDebugSyncEvents,

sizeof ( HANDLE) *

NUM_DEBUGEVENTS)); 

// .

if ( ( TRUE == IsBadStringPtr ( szDebuggee, MAX_PATH) ) ||

 ( TRUE == IsBadStringPtr ( szCmdLine, MAX_PATH) ) ||

( TRUE IsBadWritePtr ( IpPID, sizeof ( DWORD) )) || 

( TRUE == IsBadReadPtr ( pUserClass,

sizeof ( CDebugBaseUser *))) || 

( TRUE == IsBadWritePtr ( IpDebugSyncEvents,

sizeof ( HANDLE) *

NUM_DEBUGEVENTS) ) )

{

SetLastError ( ERROR_INVALID_PARAMETER);

return ( INVALID_HANDLE_VALUE); 

}

// ,

 // , HANDLE hStartAck;

// , TCHAR szStartAck [ _ ];

 // , 

if ( 0 == LoadString ( GetDllHandle () ,

IDS_DBGEVENTINIT ,

 szStartAck ,

 sizeof ( szStartAck) ))

 {

ASSERT ( !"LoadString IDS_DBGEVENTINIT failed!");

return ( INVALID_HANDLE_VALUE); 

}

// .

 hStartAck = CreateEvent ( NULL , //

TRUE , // FALSE ,

 // Initial state = Not szStartAck);

 // ASSERT ( FALSE != hStartAck);

 if ( FALSE == hStartAck) 

{

TRACE ( "StartDebugging : Unable to create Start Ack event\n");

return ( INVALID_HANDLE_VALUE); 

}

// .

THREADPARAMS StParams; 

stParams.lpPID = IpPID; 

stParams.pUserClass = pUserClass;

 stParams.szDebuggee = szDebuggee;

 stParams.szCmdLine = szCmdLine ;

 // HANDLE hDbgThread; 

// .

hDbgThread = (HANDLE)_beginthread ( DebugThread, 0, sstParams); 

ASSERT ( NULL != hDbgThread);

 if ( NULL == hDbgThread)

 {

TRACE ( "StartDebugging : _beginthread failed\n");

VERIFY ( CloseHandle ( hStartAck));

return ( INVALID_HANDLE_VALUE); 

}

// , ,

::WaitForSingleObject ( hStartAck, INFINITE);

// .

VERIFY ( CloseHandle ( hStartAck));

// , . ,

// , , .

DWORD dwExitCode = ~STILL_ACTIVE;

if ( FALSE == GetExitCodeThread ( hDbgThread, SdwExitCode))

{

ASSERT ( !"GetExitCodeThread failed!");

return ( INVALID_HANDLE_VALUE); 

}

ASSERT ( STILL_ACTIVE = dwExitCode);

 if ( STILL_ACTIVE != dwExitCode)

{

TRACE ( "StartDebugging : GetExitCodeThread failedXn");

return ( INVALID_HANDLE_VALUE); 

}

// ,  

// , .

 BOOL bCreateDbgSyncEvts =

CreateDebugSyncEvents ( IpDebugSyncEvents, *lpPID);

 ASSERT ( TRUE = bCreateDbgSyncEvts);

 if ( FALSE = bCreateDbgSyncEvts)

{

// . ,

// ,

//

// .

// . .

TRACE ( "StartDebugging : CreateDebugSyncEvents failedW) ;

VERIFY ( TerminateThread ( hDbgThread, (DWORD)-1));

return ( INVALID_HANDLE_VALUE);

}

return ( hDbgThread); 

}

, , , . , , 3 , . : ( ) , .

, , . , , , . , , "" , , . Microsoft Visual C++ Visual Basic , , . . , Watch ( 5, Visual C++). - ValidatePointerArray, .

#ifdef _DEBUG

void VaiidatePointerArray ( STDATA * pData, int iCount)

{

// . 

ASSERT ( FALSE == IsBadReadPtr ( pData,

iCount * sizeof ( STDATA *)));

 for ( int i = 0; i < iCount; i++) 

{

ASSERT ( pData[ i ].bFlags < DF_HIGHVAL);

ASSERT { FALSE == IsBadStringPtr ( pDataf i ].pszName,

MAX_PATH));

 }

}

#endif

void PlotDataltems ( STDATA * pData, int iCount)

#ifdef _DEBUG

VaiidatePointerArray ( pData, iCount);

#endif

}

 

VERIFY

, VERIFY, Microsoft Foundation Classes MFC). , : 0, VERIFY . , , .

, VERIFY , . , , - . - VERIFY : , , . , ResetEvent, , , . ResetEvent , . VERIFY, , , , - . , , ASSERT, VERIFY , . , , .

MFC-, , VERIFY . . VERIFY cstring: :Loadstring, . , Loadstring , VERIFY . Loadstring , . , , , . , . VERIFY, , - ?

 

Visual C++ Visual Basic

, Visual C++ Visual Basic. , -, ASSERT, .

assert, _ASSERTw _ASSERTE

assert (run-time) ANSI . - ASSERT.H. Windows- assert stderr. Windows- (GUI), assert ASSERTION FAILURE... (. . 3.1).

- Windows. _ASSERT __ASSERTE, CRTDBG.H. , _ASSERTE , . , 1, _ASSERTE, _ASSERT. - ( DCRT- 15).

Test engineers . . 

 

 

BoundsChecker NuMega , . , , . (U ^-) , . , , , .

UI User Interface, . .

. .

, , - . BoundsChecker , Windows (Windows Debugging API), (debugger) 3 (debuggee), , . , , WaitForDebugEvent . , , , .

, , , API, , , cioseHandle. , API , , . .

, , API, , ! , . : , API, , , , API .

, , , , "". Windows NT 4, , (Windows' 2000 ). , . API , , Ul- , , , Ul-, !

( ) , , . . , BoundsChecker, , , , , , .

, API. ( ), , , cioseHandle. , , , .

, CioseHandle, , Windows NT 4 Windows 2000 : "Invalid Handle exception (0x00000008)" ( (0x00000008) " "). , , .

 

assert, _ASSERT _ASSERTE , . assert .

-, 60 , , . , , Windows 2000 -. assert (stderr), . assert , , , . . UI- .

, -, , API- outputoebugstring, __CrtsetReportMode. , Microsoft, : ( , ). , .

, .

// . (-),

// , . 

//, ,  

// SendMessageTimeout, ,

// GetLastError. 0 0, 

// SendMessageTimeout -.

_ASSERTE ( NULL != pDataPacket)

if ( NULL == pDataPacket)

return ( ERR_INVALID_DATA);

}

LRESULT IRes = SendMessageTimeout ( hUIWnd,

WM_USER_NEEDNEXTPACKET,

0

(LPARAM)pDataPacket ,

SMTO_BLOCK ,

10000

&pdwRes ) ;

_ASSERTE ( FALSE != IRes);

if ( 0 == IRes)

{

// . 

DWORD dwLastErr = GetLastError ();

 if ( 0 == dwLastErr)

{

// UI .

return ( ERR_UI_IS_HUNG);

}

// - ,

// , .

return ( ERR_INVALID_DATA);

}

return ( ERR_SUCCESS);

.

.

.

, , (last error value).

_ASSERTE ( FALSE != IRes)

(. . ) , 0, UI- , , , sendMessageTimeout, . - , , . , SUPERASSERT .

ASSERT_KINDOFw ASSERT_VALID

, MFC, , MFC , . DECLARE_DYNAMIC DECLARE_SERIAL, ASSERT_KINDOF , ( cobject) . ASSERT_KINDOF cobject: :isKindOf. ASSERT_KINDOF, .

BOOL DoSomeMFCStuffToAFrame ( CWnd * pWnd)

 {

ASSERT ( NULL != pWnd);

ASSERT_KINDOF ( CFrameWnd, pWnd);

if ( (NULL == pWnd) ||

{ FALSE == pWnd->IsKindOf ( RUNTIME_CLASS ( CFrameWnd)))) 

{

return ( FALSE);

.

.

.

// MFC-; ,

 // pWnd CFrameWnd ,

 // CFrameWnd.

.

.

.

MFC-- ASSERT_VALID AfxAssertvaiidObject, , cobject. , ASSERT_VALID Assertvaiid. . Assertvaiid , .

Debug.Assert

, Visual Basic- , C/C++, Visual Basic ( , variant). , , Visual Basic . Visual Basic Debug.Assert, .

. : Debug.Assert , , . . . , Visual Basic ,

Debug.Assert (native) . Debug.Assert (IDE) Visual Basic. , IDE Debug.Assert. Debug.Assert IDE, , , .

Debug.Assert, Advanced Visual Basic 6.0 (2nd ed., Microsoft Press, 1998) The Mandelbrot Set, . (Mark ) Visual Basic, Assertion Sourcerer. ( ). Debug.Assert . , . , Assertion Sourcerer , !

Debug.Print . 3-2 VBASSERTANDTRACE.BAS, , . SUPERASSERT, .

3-2. VBASSERTANDTRACE.BAS

Attribute VB_Name = "VBAssertAndTrace"

'''''''''''''''''''''''''''''''''''''''''''''

' Copyright () 1999-2000 John Robbins All rights reserved.

' "Debugging Applications" (Microsoft Press) 

'

' : 

' ( !) :

' Visual Basic- Assertion

' Sourcerer (Mark Pearce)

' "Advanced Microsoft Visual Basic 6.0" (2nd ed).

' Debug.Assert

'

' BugAssert, Visual Basic-

' .

' Debug.Assert :

' 1. BUGSLAYERUTIL.DLL,

' .

' 2. Debug.Assert .

' 3. ,

' ,

' BugAssert.

' 4. .

' 5. .

'

' BUGSLAYERUTIL.DLL,

' .

'''''''''''''''''''''''''''''''''''''''''''

Option Explicit

' BUGSLAYERUTIL.DLL,

' .

Public Declare Sub DiagOutputVB Lib "BugslayerUtil" _

(ByVal sMsg As String)

Public Declare Function DiagAssertVB Lib "BugslayerUtil" _ 

(ByVal dwOverrideOpts As Long, _ 

ByVal bAllowHalts As Long,

 _ ByVal sMsg As String) _

 As Long

Public Declare Function AddDiagAssertModule Lib "BugslayerUtil" _ 

(ByVal hMod As Long) _ 

As Long

Public Declare Function SetDiagAssertFile Lib "BugslayerUtil" _

  (ByVal hFile As Long) _ 

As Long

Public Declare Function SetDiagAssertOptions Lib "BugslayerUtil" _

  (ByVal dwOpts As Long) _ 

As Long

Public Declare Function SetDiagOutputFile Lib "BugslayerUtil" _ 

(ByVal dwOpts As Long) _ 

As Long

Private Declare Function GetModuleFileName Lib "kerne!32" _

 Alias "GetModuleFileNameA" _ 

(ByVal hModule As Long, _ 

ByVal IpFileName As String, _ 

ByVal nSize As Long) _

 As Long Public Declare Sub DebugBreak Lib "kerne!32" ()

' TRACE.

' . , Assertion Sourcerer

' TRACE- ( Debug.Print)

Public Sub TRACE(ByVal sMsg As String)

DiagOutputVB sMsg End Sub

' BugAssert,

 ' Assertion Sourcerer

 Public Sub BugAssert(ByVal vntiExpression As Variant, sMsg As String)

CallAssert vntiExpression, 0, sMsg 

End Sub

' SUPERASSERT.

 Public Sub SUPERASSERT{ByVal vntiExpression As Variant, sMsg As String)

CallAssert vntiExpression, 7, sMsg 

End Sub

Private Sub CallAssert{ByVal vntiExpression As Variant, _

ByVal iOpt As Long,

 _ sMsg As String)

 If (vntiExpression) Then

Exit Sub Else

' , ,

 ' InDesign.  

' .

Static bCheckedDesign As Boolean 'False . 

' , , DiagAssertVB.

 ' 1, DiagAssertVB  

' . 0, 

' VB IDE , DiagAssertVB

 ' .  

' VB IDE,  

' ! 

Static lAllowHalts As Long 

' InDesign .

 If (False = bCheckedDesign) Then 

If (True = InDesign()) Then

lAllowHalts = 0 

Else

lAllowHalts = I 

End If

bCheckedDesign = True

 End If

Dim IRet As Long

IRet = DiagAssertVB(iOpt, lAllowHalts, sMsg)

 If (I = IRet) Then

' . .

 ' ,  

' VB IDE.

If (1 = lAllowHalts) Then

DebugBreak

 End If

 End If 

End If 

End Sub

'''''''''''''''''''''''''''''''''''''''''

' "On

' Error GoTo To Hell" (.25,26 "Advanced Microsoft Visual Basic 6.0")

' InDesign , VB IDE.

' , !

'''''''''''''''''''''''''''''''''''''''

Public Function InDesign() As Boolean

' .

' Debug.Assert!

Static nCallCount As Integer

Static bRet As Boolean ' False.

nCallCount = nCallCount + 1

Select Case nCallCount

Case 1: ' ( Debug.Assert)

Debug.Assert InDesign() Case 2: ' , Debug.Assert

bRet = True

 End Select

' Debug.Assert, True, 

' . 

InDesign = bRet

' . 

nCallCount = 0

 End Function

 

SUPERASSERT

, , , , . . 3.1 SUPERASSERT. Program, File Line . , Last Error.

SUPERASSERT . API , . . , , . , GetModuieFileName , , SUPERASSERT 122, ERROR_INSUFFICIENT_BUFFER ( ) WINERROR.H. "The data area passed to a system call is too small" ( , , ), , .

. 3.1. SUPERASSERT

, Last Error . 3.1, , Windows- . ( ), SUPERASSERT . , MSDN "Message Compiler" ( ). : .

, Last Error. . . SUPERASSERT , .

SUPERASSERT: . , , ! 2 (regression-testing tool), , ( ) . - , , . SUPERASSERT, , OutputDebugsString, , . , , . , , .

SUPERASSERT . C++ BUGSLAYERUTIL.H BUGSLAYERUTIL.LIB. 3-3 DIAGASSERT.H, BUGSLAYERUTIL.H.

3-3. DIAGASSERT.H ( BUGSLAYERUTIL.H) 

/ - - - - - - - - - - - - - - - - - - - - - -

"Debugging Applications" (Microsoft Press)

Copyright () 1999-2000 John Robbins All Rights Reserved.

/- - - - - - - - - - - - - - - - - - - -

#fndef _DIAGASSERT_H

#define _DIAGASSERT_H

#ifdef _cplusplus

extern "C" {

#endif //_cplusplus

#include <tchar.h>

/////////////////////////////////////////////

            #define

//////////////////////////////////////////////

// ,

 // . //

#define DA_USEDEFAULTS OxOOOO

// ( ).

#define DA_SHOWMSGBOX OxOOOl

// OutputDebugString ( ).

// the default.

#define DA_SHOWODS 0x0002

// .

// ASSERT SUPERASSERT.

ifdefine DA_SHOWSTACKTRACE 0x0004

/*- - - - - - - - - - - - - - - - - - - - - 

: SetDiagAssertOptions 

:

ASSERT.

  :

dwOpts  

:

- - - - - - - - - - - - - - - - - - - - - */

DWORD BUGSUTIL_DLLINTERFACE _stdcall

SetDiagAssertOptions ( DWORD dwOpts);

 /*- - - - - - - - - - - - - - - - - - - - - 

: SetDiagAssertFile 

:

,     . ,      INVALID_HANDLE_VALUE. SetDiagAssertOptions ; assertion- .

.

  :

hFile

  :

 - - - - - - - - - - - - - - - - - - - - -* /

HANDLE BUGSUTILJ3LLINTERFACE _stdcall

 SetDiagAssertFile ( HANDLE hFile);

 /* - - - - - - - - - - - - - - - - - - - - - 

: AddDiagAssertModule 

DISCUSSION :

, .

 

  :

hMod

:

TRUE - .

FALSE - .

  - - - - - - - - - - - - - - - - - - - - -*/

BOOL BUGSUTIL_DLLINTERFACE _stdcall

AddDiagAssertModule ( HMODULE hMod);

/*- - - - - - - - - - - - - - - - - - - - 

: DiagAssert

  :

C++ 

:

dwOverrideOpts DA_* DiagAssert

szMsg

 szFile ,

 dwLine ,  

:

FALSE .

TRUE DebugBreak.

  - - - - - - - - - - - - - - - - - - - - - -* /

BOOL BUGSUTIL_DLLINTERFACE _stdcall

DiagAssertA ( DWORD dwOverrideOpts , 

LPCSTR szMsg , 

LPCSTR szFile DWORD dwLine ); 

BOOL BUGSUTILJDLLINTERFACE _stdcall

DiagAssertW ( DWORD dwOverrideOpts ,

 LPCWSTR szMsg , 

LPCSTR szFile

DWORD dwLine ) ;

#ifdef UNICODE

#define DiagAssert DiagAssertW ttelse

#define DiagAssert DiagAssertA

#endif

/*- - - - - - - - - - - - - - - - - - 

: DiagAssertVB 

:

Visual Basic-.

 

dwOverrideOpts DA_*

DiagAssert

bAllowHalts TRUE, Retry Ignore

 szMsg .

Visual Basic

  :

FALSE .

TRUE - DebugBreak.

 - - - - - - - - - - - - - - - - - - - */

BOOL BUGSUTILJDLLINTERFACE _stdcall

DiagAssertVB ( DWORD dwOverrideOpts,

 BOOL bAllowHalts, 

LPCSTR szMsg);

/*- - - - - - - - - - - - - - - - - - - -

: SetDiagOutputFile

  :

, ( ) trace-. , INVALID_HANDLE_VALUE.

- . 

:

hFile  

:

 - - - - - - - - - - - - - - - - - */

HANDLE BUGSUTIL_DLLINTERFACE _stdcall

SetDiagOutputFile ( HANDLE hFile);

 /*- - - - - - - - - - - - - - - - -

: DiagOutput 

:

OutputDebugString

  :

szFmt

... , szFmt 

:

.

 - - - - - - - - - - - - - - - - - -  */

void BUGSUTIL_DLLINTERFACE

DiagOutputA ( LPCSTR szFtat, ...); 

void BUGSUTIL_DLLINTERFACE

DiagOutputW ( LPCWSTR szFmt, ...);

#ifdef UNICODE

#define DiagOutput DiagOutputW

#else

idefine DiagOutput DiagOutputA

#endif

/*- - - - - - - - - - - - - - - - - - 

: DiagOutputVB

  :

OutputDebugString Visual Basic- 

:

szMsg  

:

.

- - - - - - - - - - - - - - - - - - - - - -*/

void BUGSUTIL_DLLINTERFACE _stdcall

DiagOutputVB ( LPCSTR szMsg)

/*/////////////////////////////////////

#undef

////////////////////////////////////////*/ 

#ifdef ASSERT

#undef ASSERT

#endif

 #ifdef assert

#undef assert

#endif 

#ifdef VERIFY

#undef VERIFY 

#endif

#ifdef TRACE 

3undef TRACE

 #endif

#ifdef TRACED 

#undef TRACED

 #endif

 #ifdef TRACE1

#undef TRACE1

#endif

 #ifdef TRACE2

#undef TRACE2

 #endif

#ifdef TRACE3

 #undef TRACE3 

#endif

/*////////////////////////////////////

_DEBUG

///////////////////////////////////////*/

#ifdef _DEBUG

/*//////////////////////////////////////////////

#define

/////////////////////////////////////////////*/

// ,

// SetDiagAssertOptions.

// DiagAssert ,

// .

// assert ASSERT SUPERASSERT.

// "conditional expression is constant" ("

// ") - , while(0).

// ,

// .

#pragma warning ( disable : 4127)

#ifdef PORTABLE_BUGSLAYERUTIL

#define ASSERTMACRO(a,x)                         \

do                                            \

{                                               \

if ( !(x)                                       &&\

DiagAssert ( a, _T ( #x), _FILE_, _LINE_) )     \

{                                            \

DebugBreak () ;                                \

}                                             \

} while (0)

#else //!PORTABLE_BUGSLAYERUTIL

#define ASSERTMACRO(a,x)                       \

do                                             \

{                                             \

if ( !(x)                                       &&\

DiagAssert ( a, _T ( Ix), _FILE_, _LINE_) . )   \

{                                       \ 

_asm int 3                                    \

}                                            \

} while (0)

#endif // PORTABLE_BUGSLAYERUTIL

 // . .

#define ASSERT(x) ASSERTMACRO(DA_OSEDEFAULTS, x)

 // assert.

#define assert ASSERT // , !

#define VERIFY(x) ASSERT(x)

// assert

#define SUPERASSERT(x) ASSERTMACRO ( DA_SHOWSTACKTRACE | \

DA_SHOWMSGBOX | \

 DA_SHOWODS , \

 x ,)

//

#define SETDIAGASSERTOPTIONS(x) SetDiagAssertOptions(x) 

//

#define ADDDIAGASSERTMODULE(x) AddDiagAssertModule(x)

 // TRACE

#ifdef _cplusplus

#define TRACE ::DiagOutput

#endif

#define TRACED(sz)              DiagOutput(_T("Is"), _T(sz))

#define TRACEl(sz, pi)          DiagOutput(_T(sz), pi)

 #define TRACE2(sz, pi, p2)     DiagOutput(_T(sz), pi, p2)

 #define TRACE3(sz, pi, p2, p3) DiagOutput(_T(sz), pi, p2, p3)

#else // !_DEBUG 

/*/////////////////////////////////////////

_DEBUG !!HE!!

//////////////////////////////////////////*/

 #define ASSERTMACRO(a,x)

#define ASSERT(x)

#define VERIFY(x) ((void)(x))

#define SUPERASSERT(x)

#define SETDIAGASSERTOPTIONS(x)

#define ADDDIAGASSERTMODULE(x)

#ifdef _cplusplus

//inline void TraceOutput(LPCTSTR, ...) { }

#define TRACE (void)0

#endif

#define TRACED(fmt)

#define TRACE1(fmt,argl)

 #define TRACE2(fmt,argl,arg2)

 #define TRACE3(fmt,argl,arg2,arg3)

 #endif // _DEBUG

#ifdef _cplusplus

}

#endif //_cplusplus

#endif // _DIAGASSERT_H

SUPERASSERT ASSERT assert . _ASSERT __ASSERTE , . Visual Basic ASSERT_KINDOF ASSERT_VALID. Visual Basic VBASSERTANDTRACE.BAS.

SUPERASSERT, . ASSERT , . . , , . , , , SETDIAGASSERTOPTIONS setoiagAssertcptions ASSERT DA_SHOWSTACKTRACE. SUPERASSERT , . , , . ASSERT.

?

, :

if ( INVALID_HANDLE_VALUE == hFile)

if ( hFile == INVALID_ HANDLE_VALUE)

, . , . ( ), . C/C++, Visual Basic, . - , , , .

, , , . , , . , , .

, . . . , , , .

 

, , , , , . , TRACE ( ++) Debug.Print ( Visual Basic) , , . priritf-. , , .

, . , . , , . , . 14 LIMODS, , .

, .

, . , , , , . ( , 12), . , , , .

, - ( ) . , , . .

, . , §1- . ": ". , , . , . , .

Output . www.sysinternals.com DebugView/Enterprise Edition (Mark Russinovich) , . . , , . DebugView/Enterprise Edition -, . , , -, , , , Microsoft Internet Information Services (US).

  . UNIX (grep). UNIX find, . .

 

(Francois Poulin), , , : " , , , , !" , . , , , , , , . , .

- : . , . "" , , ; , . .

:

;

;

;

;

.

, , , . (Donald Knuth) , , . , .

19 "Self-Documenting Code" (Steve McConnell) Code Complete (Microsoft Press, 1993). , , . , , .

 

, (Andy Grove) Intel Only the Paranoid Survive ( ). -. - , . . , -, . , .

: , . 1 , - . , . . , , , , , , .

1 , , , , . .

: . . - , , . (, , ). , , . , , .

, , , , - . , , , . , 9. Windows 98, , API- syminitiaiize DBGHELP.DLL , Windows 2000. , Windows 98 , Bsusyminitialize. , .

. , 50 . , , , , -. . (master sources). , , . smoke-.

() (code coverage). , , . . , , 100 , 85 , 85%- . , , .

. . . , . , ( 100%). , , TrueCoverage NuMega Visual PureCoverage Rational.

, , , 85 90 . , . , , . , , . , , , . , , , , .

, , , 1. , .

, , . ..\SourceCode\BugslayerUtil \Tests -. , . , , -. . , , , .

 

, . ,

, . SUPERASSERT , , Microsoft. , . , . , , .

, , . , , 8590%- , . , .

        3GL   4GL   5GL  

, - - , , .




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution