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.

125 lines
2.4 KiB

  1. #include "wdmdebug.h"
  2. #pragma PAGEDCODE
  3. CDebug* CWDMDebug::create(VOID)
  4. {
  5. CDebug* d;
  6. d = new (NonPagedPool) CWDMDebug;
  7. DBG_PRINT("***** New Debug Object was created 0x%x\n",d);
  8. RETURN_VERIFIED_OBJECT(d);
  9. }
  10. #pragma PAGEDCODE
  11. VOID CWDMDebug::dispose(VOID)
  12. {
  13. LONG Usage;
  14. Usage = decrementUsage();
  15. if(Usage<=0)
  16. {
  17. trace("**** Deleting Debug Object 0x%x\n",this);
  18. self_delete();
  19. }
  20. }
  21. #pragma PAGEDCODE
  22. VOID CWDMDebug::trace (PCH Format,...)
  23. {
  24. if(!active) return;
  25. va_list argpoint;
  26. CHAR strTempo[1024];
  27. va_start(argpoint,Format);
  28. vsprintf(strTempo,Format,argpoint);
  29. va_end(argpoint);
  30. ::DBG_PRINT(strTempo);
  31. }
  32. #pragma PAGEDCODE
  33. VOID CWDMDebug::trace_no_prefix (PCH Format,...)
  34. {
  35. if(!active) return;
  36. va_list argpoint;
  37. CHAR strTempo[1024];
  38. va_start(argpoint,Format);
  39. vsprintf(strTempo,Format,argpoint);
  40. va_end(argpoint);
  41. ::DBG_PRINT_NO_PREFIX(strTempo);
  42. }
  43. #pragma PAGEDCODE
  44. VOID CWDMDebug::trace_buffer(PVOID pBuffer,ULONG BufferLength)
  45. {
  46. if(!active) return;
  47. trace_no_prefix("\n ");
  48. for(USHORT i=0;i<BufferLength;i++)
  49. {
  50. trace_no_prefix("%2.2x ", ((PUCHAR)pBuffer)[i]);
  51. if(i && !(i%10)) trace_no_prefix("\n ");
  52. }
  53. trace_no_prefix("\n");
  54. }
  55. #pragma PAGEDCODE
  56. VOID CWDMDebug::start()
  57. {
  58. active = TRUE;
  59. }
  60. #pragma PAGEDCODE
  61. VOID CWDMDebug::stop()
  62. {
  63. active = FALSE;
  64. }
  65. ///////////////////////////////////////////////////////////////////
  66. // Trace output
  67. //
  68. /*
  69. VOID Trace::Trace(TRACE_LEVEL Level, PCHAR fmt, ...)
  70. {
  71. int outLen;
  72. if (Level >= m_TraceLevel)
  73. {
  74. // Send the message
  75. va_list ap;
  76. va_start(ap, fmt);
  77. char buf[SCRATCH_BUF_SIZE];
  78. // format string to buffer
  79. outLen = _vsnprintf(buf+m_PrefixLength, SCRATCH_BUF_SIZE-m_PrefixLength, fmt, ap);
  80. // Copy prefix string to buffer
  81. if (m_Prefix != NULL)
  82. memcpy(buf, m_Prefix, m_PrefixLength);
  83. // output to debugger if requested
  84. if (m_TargetMask & TRACE_DEBUGGER)
  85. DBG_PRINT(buf);
  86. // output to monitor if requested
  87. if ((m_Post != 0) && (m_TargetMask & TRACE_MONITOR))
  88. m_Post(m_Channel, buf + (m_NeedPrefix ? 0 : m_PrefixLength));
  89. // if the last char was a newline, need prefix next time
  90. m_NeedPrefix = (buf[m_PrefixLength+outLen-1] == '\n');
  91. }
  92. // break if requested
  93. if ((BREAK_LEVEL) Level >= m_BreakLevel)
  94. DbgBreakPoint();
  95. }
  96. ///////////////////////////////////////////////////////////////////
  97. // Destructor
  98. //
  99. Trace::~Trace(VOID)
  100. {
  101. if (m_Close && (m_Channel != NULL))
  102. m_Close(m_Channel);
  103. if (m_FreeOnDestroy && m_Prefix)
  104. delete m_Prefix;
  105. }
  106. */
  107. // End of system function remapping