1 | /* $Id: kDbgInternal.h 29 2009-07-01 20:30:29Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * kDbg - The Debug Info Reader, Internal Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2006-2007 Knut St. Osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person
|
---|
10 | * obtaining a copy of this software and associated documentation
|
---|
11 | * files (the "Software"), to deal in the Software without
|
---|
12 | * restriction, including without limitation the rights to use,
|
---|
13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
14 | * copies of the Software, and to permit persons to whom the
|
---|
15 | * Software is furnished to do so, subject to the following
|
---|
16 | * conditions:
|
---|
17 | *
|
---|
18 | * The above copyright notice and this permission notice shall be
|
---|
19 | * included in all copies or substantial portions of the Software.
|
---|
20 | *
|
---|
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef ___kDbgInternal_h___
|
---|
32 | #define ___kDbgInternal_h___
|
---|
33 |
|
---|
34 | #include <k/kHlpAssert.h>
|
---|
35 | #include <k/kMagics.h>
|
---|
36 | #include <k/kErrors.h>
|
---|
37 | #include <k/kDbgAll.h>
|
---|
38 |
|
---|
39 |
|
---|
40 | /** @defgroup grp_kDbgInternal Internal
|
---|
41 | * @internal
|
---|
42 | * @addtogroup grp_kDbg
|
---|
43 | * @{
|
---|
44 | */
|
---|
45 |
|
---|
46 | /** @def KDBG_STRICT
|
---|
47 | * If defined the kDbg assertions and other runtime checks will be enabled. */
|
---|
48 | #ifdef K_ALL_STRICT
|
---|
49 | # undef KDBG_STRICT
|
---|
50 | # define KDBG_STRICT
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | /** @name Our Assert macros
|
---|
54 | * @{ */
|
---|
55 | #ifdef KDBG_STRICT
|
---|
56 | # define kDbgAssert(expr) kHlpAssert(expr)
|
---|
57 | # define kDbgAssertReturn(expr, rcRet) kHlpAssertReturn(expr, rcRet)
|
---|
58 | # define kDbgAssertReturnVoid(expr) kHlpAssertReturnVoid(expr)
|
---|
59 | # define kDbgAssertMsg(expr, msg) kHlpAssertMsg(expr, msg)
|
---|
60 | # define kDbgAssertMsgReturn(expr, msg, rcRet) kHlpAssertMsgReturn(expr, msg, rcRet)
|
---|
61 | # define kDbgAssertMsgReturnVoid(expr, msg) kHlpAssertMsgReturnVoid(expr, msg)
|
---|
62 | #else /* !KDBG_STRICT */
|
---|
63 | # define kDbgAssert(expr) do { } while (0)
|
---|
64 | # define kDbgAssertReturn(expr, rcRet) do { if (!(expr)) return (rcRet); } while (0)
|
---|
65 | # define kDbgAssertMsg(expr, msg) do { } while (0)
|
---|
66 | # define kDbgAssertMsgReturn(expr, msg, rcRet) do { if (!(expr)) return (rcRet); } while (0)
|
---|
67 | #endif /* !KDBG_STRICT */
|
---|
68 |
|
---|
69 | #define kDbgAssertPtr(ptr) kDbgAssertMsg(K_VALID_PTR(ptr), ("%s = %p\n", #ptr, (ptr)))
|
---|
70 | #define kDbgAssertPtrReturn(ptr, rcRet) kDbgAssertMsgReturn(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet))
|
---|
71 | #define kDbgAssertPtrReturnVoid(ptr) kDbgAssertMsgReturnVoid(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)))
|
---|
72 | #define kDbgAssertPtrNull(ptr) kDbgAssertMsg(!(ptr) || K_VALID_PTR(ptr), ("%s = %p\n", #ptr, (ptr)))
|
---|
73 | #define kDbgAssertPtrNullReturn(ptr, rcRet) kDbgAssertMsgReturn(!(ptr) || K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet))
|
---|
74 | #define kDbgAssertPtrNullReturnVoid(ptr) kDbgAssertMsgReturnVoid(!(ptr) || K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)))
|
---|
75 | #define kDbgAssertRC(rc) kDbgAssertMsg((rc) == 0, ("%s = %d\n", #rc, (rc)))
|
---|
76 | #define kDbgAssertRCReturn(rc, rcRet) kDbgAssertMsgReturn((rc) == 0, ("%s = %d -> %d\n", #rc, (rc), (rcRet)), (rcRet))
|
---|
77 | #define kDbgAssertRCReturnVoid(rc) kDbgAssertMsgReturnVoid((rc) == 0, ("%s = %d -> %d\n", #rc, (rc), (rcRet)))
|
---|
78 | #define kDbgAssertFailed() kDbgAssert(0)
|
---|
79 | #define kDbgAssertFailedReturn(rcRet) kDbgAssertReturn(0, (rcRet))
|
---|
80 | #define kDbgAssertFailedReturnVoid() kDbgAssertReturnVoid(0)
|
---|
81 | #define kDbgAssertMsgFailed(msg) kDbgAssertMsg(0, msg)
|
---|
82 | #define kDbgAssertMsgFailedReturn(msg, rcRet) kDbgAssertMsgReturn(0, msg, (rcRet))
|
---|
83 | #define kDbgAssertMsgFailedReturnVoid(msg) kDbgAssertMsgReturnVoid(0, msg)
|
---|
84 | /** @} */
|
---|
85 |
|
---|
86 | /** Return / crash validation of a reader argument. */
|
---|
87 | #define KDBGMOD_VALIDATE_EX(pDbgMod, rc) \
|
---|
88 | do { \
|
---|
89 | kDbgAssertPtrReturn((pDbgMod), (rc)); \
|
---|
90 | kDbgAssertReturn((pDbgMod)->u32Magic == KDBGMOD_MAGIC, (rc)); \
|
---|
91 | kDbgAssertReturn((pDbgMod)->pOps != NULL, (rc)); \
|
---|
92 | } while (0)
|
---|
93 |
|
---|
94 | /** Return / crash validation of a reader argument. */
|
---|
95 | #define KDBGMOD_VALIDATE(pDbgMod) \
|
---|
96 | do { \
|
---|
97 | kDbgAssertPtrReturn((pDbgMod), KERR_INVALID_POINTER); \
|
---|
98 | kDbgAssertReturn((pDbgMod)->u32Magic == KDBGMOD_MAGIC, KERR_INVALID_HANDLE); \
|
---|
99 | kDbgAssertReturn((pDbgMod)->pOps != NULL, KERR_INVALID_HANDLE); \
|
---|
100 | } while (0)
|
---|
101 |
|
---|
102 | /** Return / crash validation of a reader argument. */
|
---|
103 | #define KDBGMOD_VALIDATE_VOID(pDbgMod) \
|
---|
104 | do { \
|
---|
105 | kDbgAssertPtrReturnVoid((pDbgMod)); \
|
---|
106 | kDbgAssertReturnVoid((pDbgMod)->u32Magic == KDBGMOD_MAGIC); \
|
---|
107 | kDbgAssertReturnVoid((pDbgMod)->pOps != NULL); \
|
---|
108 | } while (0)
|
---|
109 |
|
---|
110 |
|
---|
111 | #ifdef __cplusplus
|
---|
112 | extern "C" {
|
---|
113 | #endif
|
---|
114 |
|
---|
115 | /** @name Built-in Debug Module Readers
|
---|
116 | * @{ */
|
---|
117 | extern KDBGMODOPS const g_kDbgModWinDbgHelpOpen;
|
---|
118 | extern KDBGMODOPS const g_kDbgModLdr;
|
---|
119 | extern KDBGMODOPS const g_kDbgModCv8;
|
---|
120 | extern KDBGMODOPS const g_kDbgModDwarf;
|
---|
121 | extern KDBGMODOPS const g_kDbgModHll;
|
---|
122 | extern KDBGMODOPS const g_kDbgModStabs;
|
---|
123 | extern KDBGMODOPS const g_kDbgModSym;
|
---|
124 | extern KDBGMODOPS const g_kDbgModMapILink;
|
---|
125 | extern KDBGMODOPS const g_kDbgModMapMSLink;
|
---|
126 | extern KDBGMODOPS const g_kDbgModMapNm;
|
---|
127 | extern KDBGMODOPS const g_kDbgModMapWLink;
|
---|
128 | /** @} */
|
---|
129 |
|
---|
130 | #ifdef __cplusplus
|
---|
131 | }
|
---|
132 | #endif
|
---|
133 |
|
---|
134 | /** @} */
|
---|
135 |
|
---|
136 | #endif
|
---|
137 |
|
---|