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.

97 lines
2.2 KiB

  1. /****************************************************************************
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name: debug.c
  4. Abstract: Debug routines
  5. Author: radus - 11/05/98
  6. ****************************************************************************/
  7. #if DBG
  8. #include <windows.h>
  9. #include "stdarg.h"
  10. #include "stdio.h"
  11. #include "debug.h"
  12. #include <shlwapi.h>
  13. #include <shlwapip.h>
  14. #define DEBUG_LEVEL 8
  15. VOID
  16. LibDbgPrt(
  17. DWORD dwDbgLevel,
  18. PSTR lpszFormat,
  19. ...
  20. )
  21. /*++
  22. Routine Description:
  23. Formats the incoming debug message & calls DbgPrint
  24. Arguments:
  25. DbgLevel - level of message verboseness
  26. DbgMessage - printf-style format string, followed by appropriate
  27. list of arguments
  28. Return Value:
  29. --*/
  30. {
  31. static DWORD gdwDebugLevel = DEBUG_LEVEL; //HACKHACK
  32. if (dwDbgLevel <= gdwDebugLevel)
  33. {
  34. char buf[256] = "TAPIUPR2 (xxxxxxxx): ";
  35. va_list ap;
  36. wsprintfA( &buf[10], "%08lx", GetCurrentThreadId() );
  37. buf[18] = ')';
  38. va_start(ap, lpszFormat);
  39. wvsprintfA (&buf[21],
  40. lpszFormat,
  41. ap
  42. );
  43. lstrcatA (buf, "\n");
  44. OutputDebugStringA (buf);
  45. va_end(ap);
  46. }
  47. }
  48. void DebugAssertFailure (LPCTSTR file, DWORD line, LPCTSTR condition)
  49. {
  50. TCHAR temp [0x100];
  51. CHAR sz [0x100];
  52. wsprintf(temp, TEXT("%s(%d) : Assertion failed, condition: %s\n"), file, line, condition);
  53. // Due to inconsistant header declairation I'm doing a convert here instead of fixing
  54. // the 55 places where the header difference causes a problem. This is lazy, but
  55. // this is debug only code so I really don't care. The problem is that
  56. // DebugAssertFailure is declaired TCHAR while LibDbgPrt is declaired CHAR.
  57. SHTCharToAnsi(temp, sz, 0x100);
  58. LibDbgPrt (0, sz);
  59. DebugBreak();
  60. }
  61. #endif