diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-06-22 19:06:48 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-06-24 20:23:44 +1000 |
commit | 7fc25bc32547277c38bbedceb39c454843af8aac (patch) | |
tree | ddc28b69bc4d39a15fd788069a5d8a0f903a0ad4 | |
parent | 57536725e6061c7f6cd0f532c07beca7cd1228c9 (diff) | |
download | wix-7fc25bc32547277c38bbedceb39c454843af8aac.tar.gz wix-7fc25bc32547277c38bbedceb39c454843af8aac.tar.bz2 wix-7fc25bc32547277c38bbedceb39c454843af8aac.zip |
Replace ExitTrace with new DUTIL_CALLBACK_TRACEERROR callback.
This allows capturing internal dutil errors and eventually supports filtering to certain parts of dutil.
Add Exit...Source macros to simplify calling both TraceError/TraceErrorDebug and Dutil_TraceErrorSource.
Make existing Exit macros call the new Exit...Source macros so the logic is in one place.
-rw-r--r-- | src/dutil/dirutil.cpp | 2 | ||||
-rw-r--r-- | src/dutil/dutil.cpp | 41 | ||||
-rw-r--r-- | src/dutil/eseutil.cpp | 6 | ||||
-rw-r--r-- | src/dutil/inc/conutil.h | 16 | ||||
-rw-r--r-- | src/dutil/inc/dutil.h | 83 | ||||
-rw-r--r-- | src/dutil/inc/gdiputil.h | 3 | ||||
-rw-r--r-- | src/dutil/inc/logutil.h | 6 |
7 files changed, 125 insertions, 32 deletions
diff --git a/src/dutil/dirutil.cpp b/src/dutil/dirutil.cpp index ddd621ac..1f06f551 100644 --- a/src/dutil/dirutil.cpp +++ b/src/dutil/dirutil.cpp | |||
@@ -254,7 +254,7 @@ extern "C" HRESULT DAPI DirEnsureDeleteEx( | |||
254 | if (FAILED(hr)) | 254 | if (FAILED(hr)) |
255 | { | 255 | { |
256 | // if we failed to delete a subdirectory, keep trying to finish any remaining files | 256 | // if we failed to delete a subdirectory, keep trying to finish any remaining files |
257 | ExitTrace(hr, "Failed to delete subdirectory; continuing: %ls", sczDelete); | 257 | ExitTraceSource(DUTIL_SOURCE_DEFAULT, hr, "Failed to delete subdirectory; continuing: %ls", sczDelete); |
258 | hr = S_OK; | 258 | hr = S_OK; |
259 | } | 259 | } |
260 | } | 260 | } |
diff --git a/src/dutil/dutil.cpp b/src/dutil/dutil.cpp index 3945d8c1..a32de516 100644 --- a/src/dutil/dutil.cpp +++ b/src/dutil/dutil.cpp | |||
@@ -13,8 +13,26 @@ static DUTIL_ASSERTDISPLAYFUNCTION Dutil_pfnDisplayAssert = NULL; | |||
13 | static BOOL Dutil_fNoAsserts = FALSE; | 13 | static BOOL Dutil_fNoAsserts = FALSE; |
14 | static REPORT_LEVEL Dutil_rlCurrentTrace = REPORT_STANDARD; | 14 | static REPORT_LEVEL Dutil_rlCurrentTrace = REPORT_STANDARD; |
15 | static BOOL Dutil_fTraceFilenames = FALSE; | 15 | static BOOL Dutil_fTraceFilenames = FALSE; |
16 | static DUTIL_CALLBACK_TRACEERROR vpfnTraceErrorCallback = NULL; | ||
16 | 17 | ||
17 | 18 | ||
19 | DAPI_(HRESULT) DutilInitialize( | ||
20 | __in_opt DUTIL_CALLBACK_TRACEERROR pfnTraceErrorCallback | ||
21 | ) | ||
22 | { | ||
23 | HRESULT hr = S_OK; | ||
24 | |||
25 | vpfnTraceErrorCallback = pfnTraceErrorCallback; | ||
26 | |||
27 | return hr; | ||
28 | } | ||
29 | |||
30 | |||
31 | DAPI_(void) DutilUninitialize() | ||
32 | { | ||
33 | vpfnTraceErrorCallback = NULL; | ||
34 | } | ||
35 | |||
18 | /******************************************************************* | 36 | /******************************************************************* |
19 | Dutil_SetAssertModule | 37 | Dutil_SetAssertModule |
20 | 38 | ||
@@ -216,7 +234,7 @@ extern "C" REPORT_LEVEL DAPI Dutil_TraceGetLevel() | |||
216 | Dutil_Trace | 234 | Dutil_Trace |
217 | 235 | ||
218 | *******************************************************************/ | 236 | *******************************************************************/ |
219 | extern "C" void DAPI Dutil_Trace( | 237 | extern "C" void DAPIV Dutil_Trace( |
220 | __in_z LPCSTR szFile, | 238 | __in_z LPCSTR szFile, |
221 | __in int iLine, | 239 | __in int iLine, |
222 | __in REPORT_LEVEL rl, | 240 | __in REPORT_LEVEL rl, |
@@ -293,7 +311,7 @@ extern "C" void DAPI Dutil_Trace( | |||
293 | Dutil_TraceError | 311 | Dutil_TraceError |
294 | 312 | ||
295 | *******************************************************************/ | 313 | *******************************************************************/ |
296 | extern "C" void DAPI Dutil_TraceError( | 314 | extern "C" void DAPIV Dutil_TraceError( |
297 | __in_z LPCSTR szFile, | 315 | __in_z LPCSTR szFile, |
298 | __in int iLine, | 316 | __in int iLine, |
299 | __in REPORT_LEVEL rl, | 317 | __in REPORT_LEVEL rl, |
@@ -380,6 +398,25 @@ extern "C" void DAPI Dutil_TraceError( | |||
380 | } | 398 | } |
381 | 399 | ||
382 | 400 | ||
401 | DAPIV_(void) Dutil_TraceErrorSource( | ||
402 | __in_z LPCSTR szFile, | ||
403 | __in int iLine, | ||
404 | __in REPORT_LEVEL rl, | ||
405 | __in UINT source, | ||
406 | __in HRESULT hr, | ||
407 | __in_z __format_string LPCSTR szFormat, | ||
408 | ... | ||
409 | ) | ||
410 | { | ||
411 | if (DUTIL_SOURCE_UNKNOWN != source && vpfnTraceErrorCallback) | ||
412 | { | ||
413 | va_list args; | ||
414 | va_start(args, szFormat); | ||
415 | vpfnTraceErrorCallback(szFile, iLine, rl, source, hr, szFormat, args); | ||
416 | va_end(args); | ||
417 | } | ||
418 | } | ||
419 | |||
383 | 420 | ||
384 | /******************************************************************* | 421 | /******************************************************************* |
385 | Dutil_RootFailure | 422 | Dutil_RootFailure |
diff --git a/src/dutil/eseutil.cpp b/src/dutil/eseutil.cpp index 1ff8e82c..599a3943 100644 --- a/src/dutil/eseutil.cpp +++ b/src/dutil/eseutil.cpp | |||
@@ -85,13 +85,13 @@ HRESULT HresultFromJetError(JET_ERR jEr) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | // Log the actual Jet error code so we have record of it before it's morphed into an HRESULT to be compatible with the rest of our code | 87 | // Log the actual Jet error code so we have record of it before it's morphed into an HRESULT to be compatible with the rest of our code |
88 | ExitTrace(hr, "Encountered Jet Error: 0x%08x", jEr); | 88 | ExitTraceSource(DUTIL_SOURCE_DEFAULT, hr, "Encountered Jet Error: 0x%08x", jEr); |
89 | 89 | ||
90 | return hr; | 90 | return hr; |
91 | } | 91 | } |
92 | 92 | ||
93 | #define ExitOnJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { ExitTrace(x, s, __VA_ARGS__); goto LExit; }} | 93 | #define ExitOnJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { ExitTraceSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__); goto LExit; }} |
94 | #define ExitOnRootJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; }} | 94 | #define ExitOnRootJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__); goto LExit; }} |
95 | 95 | ||
96 | HRESULT DAPI EseBeginSession( | 96 | HRESULT DAPI EseBeginSession( |
97 | __out JET_INSTANCE *pjiInstance, | 97 | __out JET_INSTANCE *pjiInstance, |
diff --git a/src/dutil/inc/conutil.h b/src/dutil/inc/conutil.h index a098cd4c..5f611d01 100644 --- a/src/dutil/inc/conutil.h +++ b/src/dutil/inc/conutil.h | |||
@@ -6,13 +6,19 @@ | |||
6 | extern "C" { | 6 | extern "C" { |
7 | #endif | 7 | #endif |
8 | 8 | ||
9 | #define ConsoleExitOnFailure(x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 9 | #define ConsoleExitOnFailureSource(d, x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
10 | #define ConsoleExitOnLastError(x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } } | 10 | #define ConsoleExitOnLastErrorSource(d, x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } |
11 | #define ConsoleExitOnNull(p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 11 | #define ConsoleExitOnNullSource(d, p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
12 | #define ConsoleExitOnNullWithLastError(p, x, c, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 12 | #define ConsoleExitOnNullWithLastErrorSource(d, p, x, c, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
13 | #define ConsoleExitWithLastError(x, c, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 13 | #define ConsoleExitWithLastErrorSource(d, x, c, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
14 | 14 | ||
15 | 15 | ||
16 | #define ConsoleExitOnFailure(x, c, f, ...) ConsoleExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
17 | #define ConsoleExitOnLastError(x, c, f, ...) ConsoleExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
18 | #define ConsoleExitOnNull(p, x, e, c, f, ...) ConsoleExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, c, f, __VA_ARGS__) | ||
19 | #define ConsoleExitOnNullWithLastError(p, x, c, f, ...) ConsoleExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, c, f, __VA_ARGS__) | ||
20 | #define ConsoleExitWithLastError(x, c, f, ...) ConsoleExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
21 | |||
16 | // enums | 22 | // enums |
17 | typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR; | 23 | typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR; |
18 | 24 | ||
diff --git a/src/dutil/inc/dutil.h b/src/dutil/inc/dutil.h index 3791dd5a..efaeb5a9 100644 --- a/src/dutil/inc/dutil.h +++ b/src/dutil/inc/dutil.h | |||
@@ -20,13 +20,44 @@ typedef enum REPORT_LEVEL | |||
20 | REPORT_ERROR, // always gets reported, but can never be specified | 20 | REPORT_ERROR, // always gets reported, but can never be specified |
21 | } REPORT_LEVEL; | 21 | } REPORT_LEVEL; |
22 | 22 | ||
23 | typedef enum DUTIL_SOURCE | ||
24 | { | ||
25 | DUTIL_SOURCE_UNKNOWN, | ||
26 | |||
27 | DUTIL_SOURCE_EXTERNAL = 256, | ||
28 | } DUTIL_SOURCE; | ||
29 | |||
23 | // asserts and traces | 30 | // asserts and traces |
24 | typedef BOOL (DAPI *DUTIL_ASSERTDISPLAYFUNCTION)(__in_z LPCSTR sz); | 31 | typedef BOOL (DAPI *DUTIL_ASSERTDISPLAYFUNCTION)(__in_z LPCSTR sz); |
25 | 32 | ||
33 | typedef void (CALLBACK *DUTIL_CALLBACK_TRACEERROR)( | ||
34 | __in_z LPCSTR szFile, | ||
35 | __in int iLine, | ||
36 | __in REPORT_LEVEL rl, | ||
37 | __in UINT source, | ||
38 | __in HRESULT hr, | ||
39 | __in_z __format_string LPCSTR szFormat, | ||
40 | __in va_list args | ||
41 | ); | ||
42 | |||
26 | #ifdef __cplusplus | 43 | #ifdef __cplusplus |
27 | extern "C" { | 44 | extern "C" { |
28 | #endif | 45 | #endif |
29 | 46 | ||
47 | /******************************************************************** | ||
48 | DutilInitialize - initialize dutil. | ||
49 | |||
50 | *******************************************************************/ | ||
51 | HRESULT DAPI DutilInitialize( | ||
52 | __in_opt DUTIL_CALLBACK_TRACEERROR pfnTraceErrorCallback | ||
53 | ); | ||
54 | |||
55 | /******************************************************************** | ||
56 | DutilUninitialize - uninitialize dutil. | ||
57 | |||
58 | *******************************************************************/ | ||
59 | void DAPI DutilUninitialize(); | ||
60 | |||
30 | void DAPI Dutil_SetAssertModule(__in HMODULE hAssertModule); | 61 | void DAPI Dutil_SetAssertModule(__in HMODULE hAssertModule); |
31 | void DAPI Dutil_SetAssertDisplayFunction(__in DUTIL_ASSERTDISPLAYFUNCTION pfn); | 62 | void DAPI Dutil_SetAssertDisplayFunction(__in DUTIL_ASSERTDISPLAYFUNCTION pfn); |
32 | void DAPI Dutil_Assert(__in_z LPCSTR szFile, __in int iLine); | 63 | void DAPI Dutil_Assert(__in_z LPCSTR szFile, __in int iLine); |
@@ -34,8 +65,9 @@ void DAPI Dutil_AssertSz(__in_z LPCSTR szFile, __in int iLine, __in_z LPCSTR szM | |||
34 | 65 | ||
35 | void DAPI Dutil_TraceSetLevel(__in REPORT_LEVEL ll, __in BOOL fTraceFilenames); | 66 | void DAPI Dutil_TraceSetLevel(__in REPORT_LEVEL ll, __in BOOL fTraceFilenames); |
36 | REPORT_LEVEL DAPI Dutil_TraceGetLevel(); | 67 | REPORT_LEVEL DAPI Dutil_TraceGetLevel(); |
37 | void __cdecl Dutil_Trace(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in_z __format_string LPCSTR szMessage, ...); | 68 | void DAPIV Dutil_Trace(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in_z __format_string LPCSTR szMessage, ...); |
38 | void __cdecl Dutil_TraceError(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in HRESULT hr, __in_z __format_string LPCSTR szMessage, ...); | 69 | void DAPIV Dutil_TraceError(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in HRESULT hr, __in_z __format_string LPCSTR szMessage, ...); |
70 | void DAPIV Dutil_TraceErrorSource(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in UINT source, __in HRESULT hr, __in_z __format_string LPCSTR szMessage, ...); | ||
39 | void DAPI Dutil_RootFailure(__in_z LPCSTR szFile, __in int iLine, __in HRESULT hrError); | 71 | void DAPI Dutil_RootFailure(__in_z LPCSTR szFile, __in int iLine, __in HRESULT hrError); |
40 | 72 | ||
41 | #ifdef __cplusplus | 73 | #ifdef __cplusplus |
@@ -70,28 +102,43 @@ void DAPI Dutil_RootFailure(__in_z LPCSTR szFile, __in int iLine, __in HRESULT h | |||
70 | 102 | ||
71 | #endif // DEBUG | 103 | #endif // DEBUG |
72 | 104 | ||
73 | // ExitTrace can be overriden | 105 | // DUTIL_SOURCE_DEFAULT can be overriden |
74 | #ifndef ExitTrace | 106 | #ifndef DUTIL_SOURCE_DEFAULT |
75 | #define ExitTrace TraceError | 107 | #define DUTIL_SOURCE_DEFAULT DUTIL_SOURCE_UNKNOWN |
76 | #endif | 108 | #endif |
77 | 109 | ||
78 | // Exit macros | 110 | // Exit macros |
79 | #define ExitFunction() { goto LExit; } | 111 | #define ExitFunction() { goto LExit; } |
80 | #define ExitFunction1(x) { x; goto LExit; } | 112 | #define ExitFunction1(x) { x; goto LExit; } |
81 | 113 | ||
82 | #define ExitFunctionWithLastError(x) { x = HRESULT_FROM_WIN32(::GetLastError()); goto LExit; } | 114 | #define ExitFunctionWithLastError(x) { x = HRESULT_FROM_WIN32(::GetLastError()); goto LExit; } |
83 | 115 | ||
84 | #define ExitOnLastError(x, s, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } } | 116 | #define ExitTraceSource(d, x, s, ...) { TraceError(x, s, __VA_ARGS__); (void)Dutil_TraceErrorSource(__FILE__, __LINE__, REPORT_ERROR, d, x, s, __VA_ARGS__); } |
85 | #define ExitOnLastErrorDebugTrace(x, s, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); TraceErrorDebug(x, s, __VA_ARGS__); goto LExit; } } | 117 | #define ExitTraceDebugSource(d, x, s, ...) { TraceErrorDebug(x, s, __VA_ARGS__); (void)Dutil_TraceErrorSource(__FILE__, __LINE__, REPORT_DEBUG, d, x, s, __VA_ARGS__); } |
86 | #define ExitWithLastError(x, s, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } | 118 | |
87 | #define ExitOnFailure(x, s, ...) if (FAILED(x)) { ExitTrace(x, s, __VA_ARGS__); goto LExit; } | 119 | #define ExitOnLastErrorSource(d, x, s, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } } |
88 | #define ExitOnRootFailure(x, s, ...) if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } | 120 | #define ExitOnLastErrorDebugTraceSource(d, x, s, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceDebugSource(d, x, s, __VA_ARGS__); goto LExit; } } |
89 | #define ExitOnFailureDebugTrace(x, s, ...) if (FAILED(x)) { TraceErrorDebug(x, s, __VA_ARGS__); goto LExit; } | 121 | #define ExitWithLastErrorSource(d, x, s, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } |
90 | #define ExitOnNull(p, x, e, s, ...) if (NULL == p) { x = e; Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } | 122 | #define ExitOnFailureSource(d, x, s, ...) if (FAILED(x)) { ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } |
91 | #define ExitOnNullWithLastError(p, x, s, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } | 123 | #define ExitOnRootFailureSource(d, x, s, ...) if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } |
92 | #define ExitOnNullDebugTrace(p, x, e, s, ...) if (NULL == p) { x = e; Dutil_RootFailure(__FILE__, __LINE__, x); TraceErrorDebug(x, s, __VA_ARGS__); goto LExit; } | 124 | #define ExitOnFailureDebugTraceSource(d, x, s, ...) if (FAILED(x)) { ExitTraceDebugSource(d, x, s, __VA_ARGS__); goto LExit; } |
93 | #define ExitOnInvalidHandleWithLastError(p, x, s, ...) if (INVALID_HANDLE_VALUE == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } | 125 | #define ExitOnNullSource(d, p, x, e, s, ...) if (NULL == p) { x = e; Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } |
94 | #define ExitOnWin32Error(e, x, s, ...) if (ERROR_SUCCESS != e) { x = HRESULT_FROM_WIN32(e); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } | 126 | #define ExitOnNullWithLastErrorSource(d, p, x, s, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } |
127 | #define ExitOnNullDebugTraceSource(d, p, x, e, s, ...) if (NULL == p) { x = e; Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceDebugSource(d, x, s, __VA_ARGS__); goto LExit; } | ||
128 | #define ExitOnInvalidHandleWithLastErrorSource(d, p, x, s, ...) if (INVALID_HANDLE_VALUE == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } | ||
129 | #define ExitOnWin32ErrorSource(d, e, x, s, ...) if (ERROR_SUCCESS != e) { x = HRESULT_FROM_WIN32(e); if (!FAILED(x)) { x = E_FAIL; } Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } | ||
130 | |||
131 | #define ExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__) | ||
132 | #define ExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__) | ||
133 | #define ExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__) | ||
134 | #define ExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__) | ||
135 | #define ExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__) | ||
136 | #define ExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__) | ||
137 | #define ExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, s, __VA_ARGS__) | ||
138 | #define ExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, s, __VA_ARGS__) | ||
139 | #define ExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_DEFAULT, p, x, e, s, __VA_ARGS__) | ||
140 | #define ExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, s, __VA_ARGS__) | ||
141 | #define ExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_DEFAULT, e, x, s, __VA_ARGS__) | ||
95 | 142 | ||
96 | // release macros | 143 | // release macros |
97 | #define ReleaseObject(x) if (x) { x->Release(); } | 144 | #define ReleaseObject(x) if (x) { x->Release(); } |
diff --git a/src/dutil/inc/gdiputil.h b/src/dutil/inc/gdiputil.h index 3708053c..f2145828 100644 --- a/src/dutil/inc/gdiputil.h +++ b/src/dutil/inc/gdiputil.h | |||
@@ -2,7 +2,8 @@ | |||
2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
3 | 3 | ||
4 | 4 | ||
5 | #define ExitOnGdipFailure(g, x, s, ...) { x = GdipHresultFromStatus(g); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s, __VA_ARGS__); goto LExit; } } | 5 | #define ExitOnGdipFailureSource(d, g, x, s, ...) { x = GdipHresultFromStatus(g); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, s, __VA_ARGS__); goto LExit; } } |
6 | #define ExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_DEFAULT, g, x, s, __VA_ARGS__) | ||
6 | 7 | ||
7 | #ifdef __cplusplus | 8 | #ifdef __cplusplus |
8 | extern "C" { | 9 | extern "C" { |
diff --git a/src/dutil/inc/logutil.h b/src/dutil/inc/logutil.h index ee0cd065..426506ee 100644 --- a/src/dutil/inc/logutil.h +++ b/src/dutil/inc/logutil.h | |||
@@ -6,9 +6,11 @@ | |||
6 | extern "C" { | 6 | extern "C" { |
7 | #endif | 7 | #endif |
8 | 8 | ||
9 | #define LogExitOnFailure(x, i, f, ...) if (FAILED(x)) { LogErrorId(x, i, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 9 | #define LogExitOnFailureSource(d, x, i, f, ...) if (FAILED(x)) { LogErrorId(x, i, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } |
10 | #define LogExitOnRootFailureSource(d, x, i, f, ...) if (FAILED(x)) { LogErrorId(x, i, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
10 | 11 | ||
11 | #define LogExitOnRootFailure(x, i, f, ...) if (FAILED(x)) { LogErrorId(x, i, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | 12 | #define LogExitOnFailure(x, i, f, ...) LogExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, i, f, __VA_ARGS__) |
13 | #define LogExitOnRootFailure(x, i, f, ...) LogExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, i, f, __VA_ARGS__) | ||
12 | 14 | ||
13 | typedef HRESULT (DAPI *PFN_LOGSTRINGWORKRAW)( | 15 | typedef HRESULT (DAPI *PFN_LOGSTRINGWORKRAW)( |
14 | __in_z LPCSTR szString, | 16 | __in_z LPCSTR szString, |