Leaked source code of windows server 2003
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.

70 lines
1.9 KiB

  1. // REVIEW: This file has been "leveraged" off of \nt\private\shell\lib\debug.c and \nt\private\shell\inc\debug.h.
  2. // By no means it's complete but it gives an idea of the right direction. Ideally, we would share with shell
  3. // debugging closer.
  4. #include "precomp.h"
  5. #include "debug.h"
  6. #ifdef _DEBUG
  7. #undef ASSERT
  8. #ifndef __WATCOMC__
  9. #define ASSERT(f) DEBUG_BREAK
  10. #else
  11. #define ASSERT(f) void(f)
  12. #endif
  13. const CHAR FAR c_szAssertFailed[] = "Assert %s, line %d: (%s)\r\n";
  14. const WCHAR FAR c_wszAssertFailed[] = L"Assert %s, line %d: (%s)\r\n";
  15. BOOL AssertFailedA(LPCSTR pszFile, int line, LPCSTR pszEval, BOOL fBreakInside)
  16. {
  17. CHAR ach[256];
  18. LPCSTR psz;
  19. BOOL fRet = FALSE;
  20. for (psz = pszFile + StrLenA(pszFile); psz != pszFile; psz = CharPrevA(pszFile, psz))
  21. if ((CharPrevA(pszFile, psz) != (psz-2)) && *(psz - 1) == '\\')
  22. break;
  23. wnsprintfA(ach, countof(ach), c_szAssertFailed, psz, line, pszEval);
  24. OutputDebugStringA(ach);
  25. if (fBreakInside)
  26. ASSERT(0);
  27. else
  28. fRet = TRUE;
  29. return fRet;
  30. }
  31. BOOL AssertFailedW(LPCWSTR pszFile, int line, LPCWSTR pszEval, BOOL fBreakInside)
  32. {
  33. WCHAR ach[256];
  34. LPCWSTR psz;
  35. BOOL fRet = FALSE;
  36. for (psz = pszFile + StrLenW(pszFile); psz && (psz != pszFile); psz = CharPrevW(pszFile, psz))
  37. if ((CharPrevW(pszFile, psz) != (psz-2)) && *(psz - 1) == TEXT('\\'))
  38. break;
  39. if (psz == NULL) {
  40. char szFile[MAX_PATH];
  41. char szEval[256];
  42. W2Abuf(pszFile, szFile, countof(szFile));
  43. W2Abuf(pszEval, szEval, countof(szEval));
  44. return AssertFailedA(szFile, line, szEval, fBreakInside);
  45. }
  46. wnsprintfW(ach, countof(ach), c_wszAssertFailed, psz, line, pszEval);
  47. OutputDebugStringW(ach);
  48. if (fBreakInside)
  49. ASSERT(0);
  50. else
  51. fRet = TRUE;
  52. return fRet;
  53. }
  54. #endif