ReactOS 0.4.15-dev-8096-ga0eec98
dbgtrace.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5ModuleName:
6
7 DbgTrace.cpp
8
9Abstract:
10
11 Temporary file to be used until ETW can be used
12 for UM
13
14Author:
15
16
17
18Revision History:
19
20
21
22--*/
23
24#include "fxobjectpch.hpp"
25
26#if FX_CORE_MODE==FX_CORE_USER_MODE
27#include "strsafe.h"
28#endif
29
30#if !defined(EVENT_TRACING)
31
32VOID
35 __in PVOID FxDriverGlobals,
36 __in ULONG DebugPrintLevel,
37 __in ULONG DebugPrintFlag,
39 __in PCSTR DebugMessage,
40 ...
41 )
42
43/*++
44
45Routine Description:
46
47 Print the trace message to debugger.
48
49Arguments:
50
51 TraceEventsLevel - print level between 0 and 3, with 3 the most verbose
52
53Return Value:
54
55 None.
56
57 --*/
58 {
59#if DBG
60 UNREFERENCED_PARAMETER(FxDriverGlobals);
61
62#define TEMP_BUFFER_SIZE 1024
64 CHAR debugMessageBuffer[TEMP_BUFFER_SIZE];
66
67 va_start(list, DebugMessage);
68
69 if (DebugMessage) {
70
71 //
72 // Using new safe string functions instead of _vsnprintf.
73 // This function takes care of NULL terminating if the message
74 // is longer than the buffer.
75 //
76#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
77 status = RtlStringCbVPrintfA( debugMessageBuffer,
78 sizeof(debugMessageBuffer),
79 DebugMessage,
80 list );
81#else
82 HRESULT hr;
83 hr = StringCbVPrintfA( debugMessageBuffer,
84 sizeof(debugMessageBuffer),
85 DebugMessage,
86 list );
87
88
90 {
92 }
93 else
94 {
96 }
97#endif
98 if(!NT_SUCCESS(status)) {
99
100#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
101 DbgPrint ("WDFTrace: RtlStringCbVPrintfA failed 0x%x\n", status);
102#else
103 OutputDebugString("WDFTrace: Unable to expand: ");
104 OutputDebugString(DebugMessage);
105#endif
106 return;
107 }
108 if (DebugPrintLevel <= TRACE_LEVEL_ERROR ||
109 (DebugPrintLevel <= DebugLevel &&
110 ((DebugPrintFlag & DebugFlag) == DebugPrintFlag))) {
111#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
112 DbgPrint("WDFTrace: %s\n", debugMessageBuffer);
113#else
114 OutputDebugString("WDFTrace: ");
115 OutputDebugString(DebugMessage);
116#endif
117 }
118 }
119 va_end(list);
120
121 return;
122#else
123 UNREFERENCED_PARAMETER(FxDriverGlobals);
124 UNREFERENCED_PARAMETER(DebugPrintLevel);
125 UNREFERENCED_PARAMETER(DebugPrintFlag);
126 UNREFERENCED_PARAMETER(DebugMessage);
127#endif
128}
129
130#endif
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
LONG NTSTATUS
Definition: precomp.h:26
Definition: list.h:37
#define __in
Definition: dbghelp.h:35
VOID __cdecl DoTraceLevelMessage(__in PVOID FxDriverGlobals, __in ULONG DebugPrintLevel, __in ULONG DebugPrintFlag, __drv_formatString(FormatMessage) __in PCSTR DebugMessage,...)
Definition: dbgtrace.cpp:34
ULONG DebugFlag
Definition: fxobject.cpp:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __drv_formatString(kind)
Definition: driverspecs.h:271
NTSTATUS WinErrorToNtStatus(__in ULONG WinError)
Definition: errtostatus.cpp:60
ULONG DebugLevel
Definition: fbtusb.c:26
#define DbgPrint
Definition: hal.h:12
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define TEMP_BUFFER_SIZE
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
NTSTRSAFEAPI RtlStringCbVPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat, _In_ va_list argList)
Definition: ntstrsafe.h:1034
#define list
Definition: rosglue.h:35
#define STATUS_SUCCESS
Definition: shellext.h:65
HRESULT hr
Definition: shlfolder.c:183
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
STRSAFEAPI StringCbVPrintfA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszFormat, va_list argList)
Definition: strsafe.h:502
Definition: ps.c:97
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define FormatMessage
Definition: winbase.h:3795
#define OutputDebugString
Definition: winbase.h:3890
#define HRESULT_FACILITY(hr)
Definition: winerror.h:79
#define FACILITY_WIN32
Definition: winerror.h:27
#define HRESULT_CODE(hr)
Definition: winerror.h:76
char CHAR
Definition: xmlstorage.h:175