Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-2001.
  5. //
  6. // File: Debug.cpp
  7. //
  8. // Contents:
  9. //
  10. //----------------------------------------------------------------------------
  11. // Debug.cpp
  12. #include "stdafx.h"
  13. #include "debug.h"
  14. #include "util.h"
  15. #ifdef DEBUG
  16. #define DoBreakpoint() DebugBreak()
  17. void DoDebugAssert(LPCTSTR pszFile, int nLine, LPCTSTR pszExpr)
  18. {
  19. TCHAR szBufferT[2048];
  20. wsprintf(OUT szBufferT, _T("Assertion: (%s)\nFile %s, line %d."), pszExpr, pszFile, nLine);
  21. int nRet = MessageBox(::GetActiveWindow(), szBufferT, _T("Send Console Message - Assertion Failed"),
  22. MB_ABORTRETRYIGNORE | MB_ICONERROR);
  23. switch (nRet)
  24. {
  25. case IDABORT:
  26. DoBreakpoint();
  27. exit(-1);
  28. case IDRETRY:
  29. DoBreakpoint();
  30. }
  31. } // DoDebugAssert()
  32. /////////////////////////////////////////////////////////////////////////////
  33. void DebugTracePrintf(
  34. const TCHAR * szFormat,
  35. ...)
  36. {
  37. va_list arglist;
  38. TCHAR sz[1024];
  39. Assert(szFormat != NULL);
  40. va_start(arglist, szFormat);
  41. wvsprintf(OUT sz, szFormat, arglist);
  42. Assert(lstrlen(sz) < LENGTH(sz));
  43. sz[LENGTH(sz) - 1] = 0; // Just in case we overflowed into sz
  44. ::OutputDebugString(sz);
  45. } // DebugTracePrintf()
  46. #endif // DEBUG