VirtualBox

source: kStuff/trunk/kDbg/kDbgInternal.h@ 2

Last change on this file since 2 was 2, checked in by bird, 17 years ago

Imported http://svn.netlabs.org/repos/libc/trunk/kStuff, revision 3612.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.5 KB
Line 
1/* $Id: kDbgInternal.h 2 2007-11-16 16:07:14Z bird $ */
2/** @file
3 * kDbg - The Debug Info Reader, Internal Header.
4 */
5
6/*
7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-kStuff-spam@anduin.net>
8 *
9 * This file is part of kStuff.
10 *
11 * kStuff is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * In addition to the permissions in the GNU Lesser General Public
17 * License, you are granted unlimited permission to link the compiled
18 * version of this file into combinations with other programs, and to
19 * distribute those combinations without any restriction coming from
20 * the use of this file.
21 *
22 * kStuff is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with kStuff; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 * 02110-1301, USA
31 */
32
33#ifndef ___kDbgInternal_h___
34#define ___kDbgInternal_h___
35
36#include <k/kHlpAssert.h>
37#include <k/kMagics.h>
38#include <k/kErrors.h>
39#include <k/kDbgAll.h>
40
41
42/** @defgroup grp_kDbgInternal Internal
43 * @internal
44 * @addtogroup grp_kDbg
45 * @{
46 */
47
48/** @def KDBG_STRICT
49 * If defined the kDbg assertions and other runtime checks will be enabled. */
50#ifdef K_ALL_STRICT
51# undef KDBG_STRICT
52# define KDBG_STRICT
53#endif
54
55/** @name Our Assert macros
56 * @{ */
57#ifdef KDBG_STRICT
58# define kDbgAssert(expr) kHlpAssert(expr)
59# define kDbgAssertReturn(expr, rcRet) kHlpAssertReturn(expr, rcRet)
60# define kDbgAssertReturnVoid(expr) kHlpAssertReturnVoid(expr)
61# define kDbgAssertMsg(expr, msg) kHlpAssertMsg(expr, msg)
62# define kDbgAssertMsgReturn(expr, msg, rcRet) kHlpAssertMsgReturn(expr, msg, rcRet)
63# define kDbgAssertMsgReturnVoid(expr, msg) kHlpAssertMsgReturnVoid(expr, msg)
64#else /* !KDBG_STRICT */
65# define kDbgAssert(expr) do { } while (0)
66# define kDbgAssertReturn(expr, rcRet) do { if (!(expr)) return (rcRet); } while (0)
67# define kDbgAssertMsg(expr, msg) do { } while (0)
68# define kDbgAssertMsgReturn(expr, msg, rcRet) do { if (!(expr)) return (rcRet); } while (0)
69#endif /* !KDBG_STRICT */
70
71#define kDbgAssertPtr(ptr) kDbgAssertMsg(K_VALID_PTR(ptr), ("%s = %p\n", #ptr, (ptr)))
72#define kDbgAssertPtrReturn(ptr, rcRet) kDbgAssertMsgReturn(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet))
73#define kDbgAssertPtrReturnVoid(ptr) kDbgAssertMsgReturnVoid(K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)))
74#define kDbgAssertPtrNull(ptr) kDbgAssertMsg(!(ptr) || K_VALID_PTR(ptr), ("%s = %p\n", #ptr, (ptr)))
75#define kDbgAssertPtrNullReturn(ptr, rcRet) kDbgAssertMsgReturn(!(ptr) || K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)), (rcRet))
76#define kDbgAssertPtrNullReturnVoid(ptr) kDbgAssertMsgReturnVoid(!(ptr) || K_VALID_PTR(ptr), ("%s = %p -> %d\n", #ptr, (ptr), (rcRet)))
77#define kDbgAssertRC(rc) kDbgAssertMsg((rc) == 0, ("%s = %d\n", #rc, (rc)))
78#define kDbgAssertRCReturn(rc, rcRet) kDbgAssertMsgReturn((rc) == 0, ("%s = %d -> %d\n", #rc, (rc), (rcRet)), (rcRet))
79#define kDbgAssertRCReturnVoid(rc) kDbgAssertMsgReturnVoid((rc) == 0, ("%s = %d -> %d\n", #rc, (rc), (rcRet)))
80#define kDbgAssertFailed() kDbgAssert(0)
81#define kDbgAssertFailedReturn(rcRet) kDbgAssertReturn(0, (rcRet))
82#define kDbgAssertFailedReturnVoid() kDbgAssertReturnVoid(0)
83#define kDbgAssertMsgFailed(msg) kDbgAssertMsg(0, msg)
84#define kDbgAssertMsgFailedReturn(msg, rcRet) kDbgAssertMsgReturn(0, msg, (rcRet))
85#define kDbgAssertMsgFailedReturnVoid(msg) kDbgAssertMsgReturnVoid(0, msg)
86/** @} */
87
88/** Return / crash validation of a reader argument. */
89#define KDBGMOD_VALIDATE_EX(pDbgMod, rc) \
90 do { \
91 kDbgAssertPtrReturn((pDbgMod), (rc)); \
92 kDbgAssertReturn((pDbgMod)->u32Magic == KDBGMOD_MAGIC, (rc)); \
93 kDbgAssertReturn((pDbgMod)->pOps != NULL, (rc)); \
94 } while (0)
95
96/** Return / crash validation of a reader argument. */
97#define KDBGMOD_VALIDATE(pDbgMod) \
98 do { \
99 kDbgAssertPtrReturn((pDbgMod), KERR_INVALID_POINTER); \
100 kDbgAssertReturn((pDbgMod)->u32Magic == KDBGMOD_MAGIC, KERR_INVALID_HANDLE); \
101 kDbgAssertReturn((pDbgMod)->pOps != NULL, KERR_INVALID_HANDLE); \
102 } while (0)
103
104/** Return / crash validation of a reader argument. */
105#define KDBGMOD_VALIDATE_VOID(pDbgMod) \
106 do { \
107 kDbgAssertPtrReturnVoid((pDbgMod)); \
108 kDbgAssertReturnVoid((pDbgMod)->u32Magic == KDBGMOD_MAGIC); \
109 kDbgAssertReturnVoid((pDbgMod)->pOps != NULL); \
110 } while (0)
111
112
113#ifdef __cplusplus
114extern "C" {
115#endif
116
117/** @name Built-in Debug Module Readers
118 * @{ */
119extern KDBGMODOPS const g_kDbgModWinDbgHelpOpen;
120extern KDBGMODOPS const g_kDbgModLdr;
121extern KDBGMODOPS const g_kDbgModCv8;
122extern KDBGMODOPS const g_kDbgModDwarf;
123extern KDBGMODOPS const g_kDbgModHll;
124extern KDBGMODOPS const g_kDbgModStabs;
125extern KDBGMODOPS const g_kDbgModSym;
126extern KDBGMODOPS const g_kDbgModMapILink;
127extern KDBGMODOPS const g_kDbgModMapMSLink;
128extern KDBGMODOPS const g_kDbgModMapNm;
129extern KDBGMODOPS const g_kDbgModMapWLink;
130/** @} */
131
132#ifdef __cplusplus
133}
134#endif
135
136/** @} */
137
138#endif
139
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette