forked from coolstar/wificx-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace.h
104 lines (86 loc) · 3.17 KB
/
trace.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) Microsoft Corporation. All rights reserved
--*/
#pragma once
#include <evntrace.h>
#include <TraceLoggingProvider.h>
#include <evntrace.h>
TRACELOGGING_DECLARE_PROVIDER(WiFiCxSampleTraceProvider);
#define TraceLoggingNetAdapter(adapter) \
TraceLoggingPointer((adapter), "NetAdapter")
#define TraceLoggingMtkAdapter(adapter) \
TraceLoggingNetAdapter((adapter)->NetAdapter)
#define TraceLoggingFunctionName() TraceLoggingWideString(__FUNCTIONW__, "Function")
#define TraceEntry(...) \
TraceLoggingWrite( \
WiFiCxSampleTraceProvider, \
"FunctionEntry", \
TraceLoggingLevel(TRACE_LEVEL_VERBOSE), \
TraceLoggingFunctionName(), \
__VA_ARGS__)
#define TraceEntryMtkAdapter(adapter, ...) \
TraceLoggingWrite( \
WiFiCxSampleTraceProvider, \
"FunctionEntry", \
TraceLoggingLevel(TRACE_LEVEL_VERBOSE), \
TraceLoggingFunctionName(), \
TraceLoggingMtkAdapter(adapter), \
__VA_ARGS__)
#define TraceEntryNetAdapter(netAdapter, ...) \
TraceLoggingWrite( \
WiFiCxSampleTraceProvider, \
"FunctionEntry", \
TraceLoggingLevel(TRACE_LEVEL_VERBOSE), \
TraceLoggingFunctionName(), \
TraceLoggingNetAdapter(netAdapter), \
__VA_ARGS__)
#define TraceExit(...) \
TraceLoggingWrite( \
WiFiCxSampleTraceProvider, \
"FunctionExit", \
TraceLoggingLevel(TRACE_LEVEL_VERBOSE), \
TraceLoggingFunctionName(), \
__VA_ARGS__)
#define TraceExitResult(Status, ...) \
TraceLoggingWrite( \
WiFiCxSampleTraceProvider, \
"FunctionExitResult", \
TraceLoggingLevel(TRACE_LEVEL_VERBOSE), \
TraceLoggingFunctionName(), \
TraceLoggingNTStatus((Status), "Status"), \
__VA_ARGS__)
#define LOG_NTSTATUS(Status, ...) do {\
TraceLoggingWrite( \
WiFiCxSampleTraceProvider, \
"StatusFailure", \
TraceLoggingLevel(TRACE_LEVEL_ERROR), \
TraceLoggingFunctionName(), \
TraceLoggingUInt32(__LINE__, "Line"), \
TraceLoggingNTStatus(Status, "Status"), \
__VA_ARGS__); \
} while (0,0)
#define LOG_IF_NOT_NT_SUCCESS(Expression, ...) do {\
NTSTATUS p_status = (Expression); \
if (!NT_SUCCESS(p_status)) \
{ \
LOG_NTSTATUS(p_status, \
TraceLoggingWideString(L#Expression, "Expression"), \
__VA_ARGS__); \
} \
} while(0,0)
#define GOTO_IF_NOT_NT_SUCCESS(Label, StatusLValue, Expression, ...) do {\
StatusLValue = (Expression); \
if (!NT_SUCCESS(StatusLValue)) \
{ \
LOG_NTSTATUS(StatusLValue, \
TraceLoggingWideString(L#Expression, "Expression"), \
__VA_ARGS__); \
goto Label; \
} \
} while(0,0)
#define GOTO_WITH_INSUFFICIENT_RESOURCES_IF_NULL(Label, StatusLValue, Object) \
GOTO_IF_NOT_NT_SUCCESS(Label, StatusLValue, (((Object) == NULL) ? STATUS_INSUFFICIENT_RESOURCES : STATUS_SUCCESS))