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.

99 lines
2.2 KiB

  1. #include "shole.h"
  2. #ifdef WIN32
  3. #define DEBUG_BREAK _try { DebugBreak(); } except (EXCEPTION_EXECUTE_HANDLER) {;}
  4. #else
  5. #define DEBUG_BREAK _asm { int 3 }
  6. #endif
  7. #ifdef DEBUG
  8. //========== Debug output routines =========================================
  9. UINT wDebugMask = 0x00ff;
  10. UINT WINAPI SetDebugMask(UINT mask)
  11. {
  12. UINT wOld = wDebugMask;
  13. wDebugMask = mask;
  14. return wOld;
  15. }
  16. UINT WINAPI GetDebugMask()
  17. {
  18. return wDebugMask;
  19. }
  20. void WINAPI AssertFailed(LPCTSTR pszFile, int line)
  21. {
  22. LPCTSTR psz;
  23. TCHAR ach[256];
  24. static TCHAR szAssertFailed[] = TEXT("Assertion failed in %s on line %d\r\n");
  25. // Strip off path info from filename string, if present.
  26. //
  27. if (wDebugMask & DM_ASSERT)
  28. {
  29. for (psz = pszFile + lstrlen(pszFile); psz != pszFile; psz=CharPrev(pszFile, psz))
  30. {
  31. if ((CharPrev(pszFile, psz)!= (psz-2)) && *(psz - 1) == TEXT('\\'))
  32. break;
  33. }
  34. wsprintf(ach, szAssertFailed, psz, line);
  35. OutputDebugString(ach);
  36. DEBUG_BREAK
  37. }
  38. }
  39. #define WINCAPI __cdecl
  40. void WINCAPI _AssertMsg(BOOL f, LPCTSTR pszMsg, ...)
  41. {
  42. TCHAR ach[256];
  43. if (!f && (wDebugMask & DM_ASSERT))
  44. {
  45. #ifdef WINNT
  46. va_list ArgList;
  47. va_start(ArgList, pszMsg);
  48. wvsprintf(ach, pszMsg, ArgList);
  49. va_end(ArgList);
  50. #else
  51. wvsprintf(ach, pszMsg, (LPVOID)(&pszMsg + 1));
  52. #endif
  53. lstrcat(ach, TEXT("\r\n"));
  54. OutputDebugString(ach);
  55. DEBUG_BREAK
  56. }
  57. }
  58. void WINCAPI _DebugMsg(UINT mask, LPCTSTR pszMsg, ...)
  59. {
  60. TCHAR ach[2*MAX_PATH+40]; // Handles 2*largest path + slop for message
  61. if (wDebugMask & mask)
  62. {
  63. #ifdef WINNT
  64. va_list ArgList;
  65. va_start(ArgList, pszMsg);
  66. try {
  67. wvsprintf(ach, pszMsg, ArgList);
  68. } except (EXCEPTION_EXECUTE_HANDLER) {
  69. OutputDebugString(TEXT("SHELL32: DebugMsg exception: "));
  70. OutputDebugString(pszMsg);
  71. }
  72. va_end(ArgList);
  73. OutputDebugString(TEXT("SHELL32: "));
  74. #else
  75. wvsprintf(ach, pszMsg, (LPVOID)(&pszMsg + 1));
  76. #endif
  77. lstrcat(ach, TEXT("\r\n"));
  78. OutputDebugString(ach);
  79. }
  80. }
  81. #endif // DEBUG