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.

100 lines
2.3 KiB

  1. //*******************************************************************************************
  2. //
  3. // Filename : debug.c
  4. //
  5. // Debug routines
  6. //
  7. // Copyright (c) 1994 - 1996 Microsoft Corporation. All rights reserved
  8. //
  9. //*******************************************************************************************
  10. #include "pch.h"
  11. #include "cvdebug.h"
  12. #ifdef _X86_
  13. // Use int 3 so we stop immediately in the source
  14. #define DEBUG_BREAK __try { _asm { int 3 } } __except (EXCEPTION_EXECUTE_HANDLER) {;}
  15. #else
  16. #define DEBUG_BREAK __try { DebugBreak(); } __except (EXCEPTION_EXECUTE_HANDLER) {;}
  17. #endif
  18. #ifdef DEBUG
  19. UINT g_fDebugMask = 0x00ff;
  20. UINT WINAPI SetDebugMask(UINT mask)
  21. {
  22. UINT wOld = g_fDebugMask;
  23. g_fDebugMask = mask;
  24. return wOld;
  25. }
  26. UINT WINAPI GetDebugMask()
  27. {
  28. return g_fDebugMask;
  29. }
  30. void WINAPI AssertFailed(LPCSTR pszFile, int line)
  31. {
  32. LPCSTR psz;
  33. CHAR ach[256];
  34. static CHAR szAssertFailed[] = "Assertion failed in %s on line %d\r\n";
  35. // Strip off path info from filename string, if present.
  36. //
  37. if (g_fDebugMask & DM_ASSERT)
  38. {
  39. for (psz = pszFile + lstrlenA(pszFile); psz != pszFile; psz=CharPrevA(pszFile, psz))
  40. {
  41. if ((CharPrevA(pszFile, psz)!= (psz-2)) && *(psz - 1) == '\\')
  42. break;
  43. }
  44. wsprintfA(ach, szAssertFailed, psz, line);
  45. OutputDebugStringA(ach);
  46. DEBUG_BREAK
  47. }
  48. }
  49. void _cdecl _AssertMsg(BOOL f, LPCSTR pszMsg, ...)
  50. {
  51. CHAR ach[256];
  52. if (!f && (g_fDebugMask & DM_ASSERT))
  53. {
  54. va_list ArgList;
  55. va_start(ArgList, pszMsg);
  56. wvsprintfA(ach, pszMsg, ArgList);
  57. lstrcatA(ach, "\r\n");
  58. OutputDebugStringA(ach);
  59. va_end(ArgList);
  60. DEBUG_BREAK
  61. }
  62. }
  63. void _cdecl _DebugMsg(UINT mask, LPCSTR pszMsg, ...)
  64. {
  65. CHAR ach[2*MAX_PATH+40]; // Handles 2*largest path + slop for message
  66. if (g_fDebugMask & mask)
  67. {
  68. va_list ArgList;
  69. va_start(ArgList, pszMsg);
  70. wvsprintfA(ach, pszMsg, ArgList);
  71. lstrcatA(ach, "\r\n");
  72. OutputDebugStringA(ach);
  73. va_end(ArgList);
  74. }
  75. }
  76. #endif // DEBUG
  77. #define SZ_DEBUGINI "ccshell.ini"
  78. #define SZ_DEBUGSECTION "cabview"
  79. #define SZ_MODULE "CABVIEW"
  80. #define DECLARE_DEBUG
  81. #include <ccstock.h>
  82. #include <debug.h>