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.

240 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. plotdbg.c
  5. Abstract:
  6. This module contains all plotter's debugging functions
  7. Author:
  8. 15-Nov-1993 Mon 17:57:24 created
  9. [Environment:]
  10. GDI Device Driver - Plotter.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #if DBG
  17. BOOL DoPlotWarn = FALSE;
  18. VOID
  19. cdecl
  20. PlotDbgPrint(
  21. LPSTR pszFormat,
  22. ...
  23. )
  24. /*++
  25. Routine Description:
  26. This fucntion output the debug informat to the debugger
  27. Arguments:
  28. pszFormat - format string
  29. ... - variable data
  30. Return Value:
  31. VOID
  32. Author:
  33. 15-Nov-1993 Mon 17:57:59 created
  34. Revision History:
  35. --*/
  36. {
  37. va_list vaList;
  38. #if defined(UMODE) || defined(USERMODE_DRIVER)
  39. static WCHAR wOutBuf[768];
  40. static WCHAR wFormatBuf[256];
  41. size_t cch;
  42. //
  43. // We assume that UNICODE flag is turn on for the compilation, bug the
  44. // format string passed to here is ASCII version, so we need to convert
  45. // it to LPWSTR before the wvsprintf()
  46. //
  47. if (!SUCCEEDED(StringCchLengthA(pszFormat, CCHOF(wFormatBuf), &cch)))
  48. {
  49. return;
  50. }
  51. va_start(vaList, pszFormat);
  52. MultiByteToWideChar(CP_ACP, 0, pszFormat, -1, wFormatBuf, CCHOF(wFormatBuf));
  53. if (!SUCCEEDED(StringCchVPrintfW(wOutBuf, CCHOF(wOutBuf), wFormatBuf, vaList)))
  54. {
  55. return;
  56. }
  57. va_end(vaList);
  58. OutputDebugString((LPCTSTR)wOutBuf);
  59. OutputDebugString(TEXT("\n"));
  60. #else
  61. va_start(vaList, pszFormat);
  62. EngDebugPrint("PLOT",pszFormat,vaList);
  63. va_end(vaList);
  64. #endif
  65. }
  66. VOID
  67. PlotDbgType(
  68. INT Type
  69. )
  70. /*++
  71. Routine Description:
  72. this function output the ERROR/WARNING message
  73. Arguments:
  74. Type
  75. Return Value:
  76. Author:
  77. 15-Nov-1993 Mon 22:53:01 created
  78. Revision History:
  79. --*/
  80. {
  81. extern TCHAR DebugDLLName[];
  82. #if defined(UMODE) || defined(USERMODE_DRIVER)
  83. if (Type) {
  84. OutputDebugString((Type < 0) ? TEXT("ERROR: ") : TEXT("WARNING: "));
  85. }
  86. OutputDebugString(DebugDLLName);
  87. OutputDebugString(TEXT("!"));
  88. #else
  89. PlotDbgPrint("%s: %ws!\n",
  90. (Type < 0) ? "ERROR" : "WARNING",
  91. DebugDLLName);
  92. #endif
  93. }
  94. VOID
  95. _PlotAssert(
  96. LPSTR pMsg,
  97. LPSTR pFalseExp,
  98. LPSTR pFilename,
  99. UINT LineNo,
  100. DWORD_PTR Exp,
  101. BOOL Stop
  102. )
  103. /*++
  104. Routine Description:
  105. This function output assertion message and false expression to the debugger
  106. then break into the debugger
  107. Arguments:
  108. pMsg - Message to displayed
  109. pFlaseExp - false expression
  110. pFilename - plotter source filename
  111. LineNo - line number of the flase expression
  112. Return Value:
  113. VOID
  114. Author:
  115. 15-Nov-1993 Mon 18:47:30 created
  116. Revision History:
  117. --*/
  118. {
  119. PlotDbgPrint("\n");
  120. if ((pMsg) && (*pMsg)) {
  121. PlotDbgPrint(pMsg, Exp);
  122. }
  123. if (pFalseExp && pFilename) {
  124. PlotDbgPrint("Assertion failed (%hs) in %hs line %u",
  125. pFalseExp, pFilename, LineNo);
  126. }
  127. if (Stop) {
  128. DebugBreak();
  129. }
  130. }
  131. #endif // DBG