VirtualBox

source: vbox/trunk/include/VBox/AssertGuest.h@ 103224

Last change on this file since 103224 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 59.3 KB
RevLine 
[1]1/** @file
[71606]2 * VirtualBox - Guest input assertions.
[1]3 */
4
5/*
[98103]6 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
[1]7 *
[96407]8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
[5999]10 *
[96407]11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
[5999]24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
[96407]26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
[5999]28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
[96407]32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
[1]34 */
35
[76558]36#ifndef VBOX_INCLUDED_AssertGuest_h
37#define VBOX_INCLUDED_AssertGuest_h
[76507]38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
[1]41
[71606]42#include <VBox/cdefs.h>
43#include <iprt/assert.h>
[1]44
45
[71606]46/** @defgroup grp_vbox_assert_guest VBox Guest Input Assertion Macros
[13314]47 * @{
48 */
[8563]49
50
[71606]51/** @name Guest input assertions
[1]52 *
[71606]53 * These assertions will only trigger when VBOX_STRICT_GUEST is defined. When
54 * it is undefined they will all be no-ops and generate no code, unless they
55 * have other side effected (i.e. the _RETURN, _STMT, _BREAK variations).
[13306]56 *
[71606]57 * The assertions build on top of the functions in iprt/assert.h.
[13306]58 *
59 * @{
60 */
61
[25647]62
[71606]63/** @def ASSERT_GUEST_PANIC()
64 * If VBOX_STRICT_GUEST is defined this macro will invoke RTAssertDoPanic if
65 * RTAssertShouldPanic returns true. If VBOX_STRICT_GUEST isn't defined it won't
66 * do any thing.
[13306]67 */
[71606]68#if defined(VBOX_STRICT_GUEST) && !defined(VBOX_STRICT_GUEST_DONT_PANIC)
69# define ASSERT_GUEST_PANIC() do { if (RTAssertShouldPanic()) RTAssertDoPanic(); } while (0)
[13306]70#else
[71606]71# define ASSERT_GUEST_PANIC() do { } while (0)
[13306]72#endif
73
[71606]74/** Wrapper around RTAssertMsg1Weak that prefixes the expression. */
75#define ASSERT_GUEST_MSG1(szExpr, iLine, pszFile, pszFunction) \
76 RTAssertMsg1Weak("guest-input: " szExpr, iLine, pszFile, pszFunction)
[13306]77
78
[71606]79/** @def ASSERT_GUEST
[18050]80 * Assert that an expression is true. If false, hit breakpoint.
[71606]81 * @param a_Expr Expression which should be true.
[1]82 */
[71606]83#ifdef VBOX_STRICT_GUEST
84# define ASSERT_GUEST(a_Expr) \
[1]85 do { \
[71606]86 if (RT_LIKELY(!!(a_Expr))) \
[55865]87 { /* likely */ } \
88 else \
[1]89 { \
[71606]90 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
91 ASSERT_GUEST_PANIC(); \
[1]92 } \
93 } while (0)
94#else
[71606]95# define ASSERT_GUEST(a_Expr) do { } while (0)
[1]96#endif
97
98
[71606]99/** @def ASSERT_GUEST_STMT
[24729]100 * Assert that an expression is true. If false, hit breakpoint and execute the
101 * statement.
[71606]102 * @param a_Expr Expression which should be true.
103 * @param a_Stmt Statement to execute on failure.
[24729]104 */
[71606]105#ifdef VBOX_STRICT_GUEST
106# define ASSERT_GUEST_STMT(a_Expr, a_Stmt) \
[24729]107 do { \
[71606]108 if (RT_LIKELY(!!(a_Expr))) \
[55865]109 { /* likely */ } \
110 else \
[24729]111 { \
[71606]112 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
113 ASSERT_GUEST_PANIC(); \
114 a_Stmt; \
[24729]115 } \
116 } while (0)
117#else
[71606]118# define ASSERT_GUEST_STMT(a_Expr, a_Stmt) \
[24729]119 do { \
[71606]120 if (RT_LIKELY(!!(a_Expr))) \
[55865]121 { /* likely */ } \
122 else \
[24729]123 { \
[71606]124 a_Stmt; \
[24729]125 } \
126 } while (0)
127#endif
128
129
[71606]130/** @def ASSERT_GUEST_RETURN
[1]131 * Assert that an expression is true and returns if it isn't.
[71606]132 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[1]133 *
[71606]134 * @param a_Expr Expression which should be true.
135 * @param a_rc What is to be presented to return.
[1]136 */
[71606]137#ifdef VBOX_STRICT_GUEST
138# define ASSERT_GUEST_RETURN(a_Expr, a_rc) \
[1]139 do { \
[71606]140 if (RT_LIKELY(!!(a_Expr))) \
[55865]141 { /* likely */ } \
142 else \
[1]143 { \
[71606]144 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
145 ASSERT_GUEST_PANIC(); \
146 return (a_rc); \
[1]147 } \
148 } while (0)
149#else
[71606]150# define ASSERT_GUEST_RETURN(a_Expr, a_rc) \
[1]151 do { \
[71606]152 if (RT_LIKELY(!!(a_Expr))) \
[55865]153 { /* likely */ } \
154 else \
[71606]155 return (a_rc); \
[1]156 } while (0)
157#endif
158
[71606]159/** @def ASSERT_GUEST_STMT_RETURN
[15640]160 * Assert that an expression is true, if it isn't execute the given statement
161 * and return rc.
162 *
[71606]163 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before executing the statement and
[15640]164 * returning.
165 *
[71606]166 * @param a_Expr Expression which should be true.
167 * @param a_Stmt Statement to execute before returning on failure.
168 * @param a_rc What is to be presented to return.
[15640]169 */
[71606]170#ifdef VBOX_STRICT_GUEST
171# define ASSERT_GUEST_STMT_RETURN(a_Expr, a_Stmt, a_rc) \
[15640]172 do { \
[71606]173 if (RT_LIKELY(!!(a_Expr))) \
[55865]174 { /* likely */ } \
175 else \
[15640]176 { \
[71606]177 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
178 ASSERT_GUEST_PANIC(); \
179 a_Stmt; \
180 return (a_rc); \
[15640]181 } \
182 } while (0)
183#else
[71606]184# define ASSERT_GUEST_STMT_RETURN(a_Expr, a_Stmt, a_rc) \
[15640]185 do { \
[71606]186 if (RT_LIKELY(!!(a_Expr))) \
[55865]187 { /* likely */ } \
188 else \
[15640]189 { \
[71606]190 a_Stmt; \
191 return (a_rc); \
[15640]192 } \
193 } while (0)
194#endif
195
[71606]196/** @def ASSERT_GUEST_RETURN_VOID
[1]197 * Assert that an expression is true and returns if it isn't.
[71606]198 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[1]199 *
[71606]200 * @param a_Expr Expression which should be true.
[1]201 */
[71606]202#ifdef VBOX_STRICT_GUEST
203# define ASSERT_GUEST_RETURN_VOID(a_Expr) \
[1]204 do { \
[71606]205 if (RT_LIKELY(!!(a_Expr))) \
[55865]206 { /* likely */ } \
207 else \
[1]208 { \
[71606]209 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
210 ASSERT_GUEST_PANIC(); \
[1]211 return; \
212 } \
213 } while (0)
214#else
[71606]215# define ASSERT_GUEST_RETURN_VOID(a_Expr) \
[1]216 do { \
[71606]217 if (RT_LIKELY(!!(a_Expr))) \
[55865]218 { /* likely */ } \
219 else \
[1]220 return; \
221 } while (0)
222#endif
223
[71606]224/** @def ASSERT_GUEST_STMT_RETURN_VOID
[15640]225 * Assert that an expression is true, if it isn't execute the given statement
226 * and return.
227 *
[71606]228 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[15640]229 *
[71606]230 * @param a_Expr Expression which should be true.
231 * @param a_Stmt Statement to execute before returning on failure.
[15640]232 */
[71606]233#ifdef VBOX_STRICT_GUEST
234# define ASSERT_GUEST_STMT_RETURN_VOID(a_Expr, a_Stmt) \
[15640]235 do { \
[71606]236 if (RT_LIKELY(!!(a_Expr))) \
[55865]237 { /* likely */ } \
238 else \
[15640]239 { \
[71606]240 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
241 ASSERT_GUEST_PANIC(); \
242 a_Stmt; \
[15640]243 return; \
244 } \
245 } while (0)
246#else
[71606]247# define ASSERT_GUEST_STMT_RETURN_VOID(a_Expr, a_Stmt) \
[15640]248 do { \
[71606]249 if (RT_LIKELY(!!(a_Expr))) \
[55865]250 { /* likely */ } \
251 else \
[15640]252 { \
[71606]253 a_Stmt; \
[15640]254 return; \
255 } \
256 } while (0)
257#endif
[1]258
[15640]259
[71606]260/** @def ASSERT_GUEST_BREAK
[1]261 * Assert that an expression is true and breaks if it isn't.
[71606]262 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before breaking.
[1]263 *
[71606]264 * @param a_Expr Expression which should be true.
[1]265 */
[71606]266#ifdef VBOX_STRICT_GUEST
267# define ASSERT_GUEST_BREAK(a_Expr) \
268 if (RT_LIKELY(!!(a_Expr))) \
[55865]269 { /* likely */ } \
270 else if (1) \
[8579]271 { \
[71606]272 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
273 ASSERT_GUEST_PANIC(); \
[1]274 break; \
[65948]275 } else \
276 break
[1]277#else
[71606]278# define ASSERT_GUEST_BREAK(a_Expr) \
279 if (RT_LIKELY(!!(a_Expr))) \
[55865]280 { /* likely */ } \
281 else \
282 break
[1]283#endif
284
[71606]285/** @def ASSERT_GUEST_CONTINUE
[60053]286 * Assert that an expression is true and continue if it isn't.
[71606]287 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before continuing.
[60053]288 *
[71606]289 * @param a_Expr Expression which should be true.
[60053]290 */
[71606]291#ifdef VBOX_STRICT_GUEST
292# define ASSERT_GUEST_CONTINUE(a_Expr) \
293 if (RT_LIKELY(!!(a_Expr))) \
[60053]294 { /* likely */ } \
295 else if (1) \
296 { \
[71606]297 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
298 ASSERT_GUEST_PANIC(); \
[60055]299 continue; \
[60053]300 } else do {} while (0)
301#else
[71606]302# define ASSERT_GUEST_CONTINUE(a_Expr) \
303 if (RT_LIKELY(!!(a_Expr))) \
[60053]304 { /* likely */ } \
305 else \
[60055]306 continue
[60053]307#endif
308
[71606]309/** @def ASSERT_GUEST_STMT_BREAK
[6076]310 * Assert that an expression is true and breaks if it isn't.
[71606]311 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before doing break.
[6076]312 *
[71606]313 * @param a_Expr Expression which should be true.
314 * @param a_Stmt Statement to execute before break in case of a failed assertion.
[6076]315 */
[71606]316#ifdef VBOX_STRICT_GUEST
317# define ASSERT_GUEST_STMT_BREAK(a_Expr, a_Stmt) \
318 if (RT_LIKELY(!!(a_Expr))) \
[55865]319 { /* likely */ } \
320 else if (1) \
321 { \
[71606]322 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
323 ASSERT_GUEST_PANIC(); \
324 a_Stmt; \
[8578]325 break; \
326 } else do {} while (0)
[6076]327#else
[71606]328# define ASSERT_GUEST_STMT_BREAK(a_Expr, a_Stmt) \
329 if (RT_LIKELY(!!(a_Expr))) \
[55865]330 { /* likely */ } \
331 else if (1) \
332 { \
[71606]333 a_Stmt; \
[8578]334 break; \
[8579]335 } else do {} while (0)
[6076]336#endif
[1]337
[6076]338
[71606]339/** @def ASSERT_GUEST_MSG
[1]340 * Assert that an expression is true. If it's not print message and hit breakpoint.
[71606]341 * @param a_Expr Expression which should be true.
[1]342 * @param a printf argument list (in parenthesis).
343 */
[71606]344#ifdef VBOX_STRICT_GUEST
345# define ASSERT_GUEST_MSG(a_Expr, a) \
[1]346 do { \
[71606]347 if (RT_LIKELY(!!(a_Expr))) \
[55865]348 { /* likely */ } \
349 else \
[1]350 { \
[71606]351 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
[25528]352 RTAssertMsg2Weak a; \
[71606]353 ASSERT_GUEST_PANIC(); \
[1]354 } \
355 } while (0)
356#else
[71606]357# define ASSERT_GUEST_MSG(a_Expr, a) do { } while (0)
[1]358#endif
359
[71606]360/** @def ASSERT_GUEST_MSG_STMT
[25984]361 * Assert that an expression is true. If it's not print message and hit
362 * breakpoint and execute the statement.
363 *
[71606]364 * @param a_Expr Expression which should be true.
[25984]365 * @param a printf argument list (in parenthesis).
[71606]366 * @param a_Stmt Statement to execute in case of a failed assertion.
[25984]367 *
368 * @remarks The expression and statement will be evaluated in all build types.
369 */
[71606]370#ifdef VBOX_STRICT_GUEST
371# define ASSERT_GUEST_MSG_STMT(a_Expr, a, a_Stmt) \
[25984]372 do { \
[71606]373 if (RT_LIKELY(!!(a_Expr))) \
[55865]374 { /* likely */ } \
375 else \
[25984]376 { \
[71606]377 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25984]378 RTAssertMsg2Weak a; \
[71606]379 ASSERT_GUEST_PANIC(); \
380 a_Stmt; \
[25984]381 } \
382 } while (0)
383#else
[71606]384# define ASSERT_GUEST_MSG_STMT(a_Expr, a, a_Stmt) \
[25984]385 do { \
[71606]386 if (RT_LIKELY(!!(a_Expr))) \
[55865]387 { /* likely */ } \
388 else \
[25984]389 { \
[71606]390 a_Stmt; \
[25984]391 } \
392 } while (0)
393#endif
394
[71606]395/** @def ASSERT_GUEST_MSG_RETURN
[1]396 * Assert that an expression is true and returns if it isn't.
[71606]397 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[1]398 *
[71606]399 * @param a_Expr Expression which should be true.
[1]400 * @param a printf argument list (in parenthesis).
[71606]401 * @param a_rc What is to be presented to return.
[1]402 */
[71606]403#ifdef VBOX_STRICT_GUEST
404# define ASSERT_GUEST_MSG_RETURN(a_Expr, a, a_rc) \
[1]405 do { \
[71606]406 if (RT_LIKELY(!!(a_Expr))) \
[55865]407 { /* likely */ } \
408 else \
[1]409 { \
[71606]410 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
[25528]411 RTAssertMsg2Weak a; \
[71606]412 ASSERT_GUEST_PANIC(); \
413 return (a_rc); \
[1]414 } \
415 } while (0)
416#else
[71606]417# define ASSERT_GUEST_MSG_RETURN(a_Expr, a, a_rc) \
[1]418 do { \
[71606]419 if (RT_LIKELY(!!(a_Expr))) \
[55865]420 { /* likely */ } \
421 else \
[71606]422 return (a_rc); \
[1]423 } while (0)
424#endif
425
[71606]426/** @def ASSERT_GUEST_MSG_STMT_RETURN
[15668]427 * Assert that an expression is true, if it isn't execute the statement and
428 * return.
429 *
[71606]430 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[15668]431 *
[71606]432 * @param a_Expr Expression which should be true.
[15668]433 * @param a printf argument list (in parenthesis).
[71606]434 * @param a_Stmt Statement to execute before returning in case of a failed
[37354]435 * assertion.
[71606]436 * @param a_rc What is to be presented to return.
[15668]437 */
[71606]438#ifdef VBOX_STRICT_GUEST
439# define ASSERT_GUEST_MSG_STMT_RETURN(a_Expr, a, a_Stmt, a_rc) \
[15668]440 do { \
[71606]441 if (RT_LIKELY(!!(a_Expr))) \
[55865]442 { /* likely */ } \
443 else \
[15668]444 { \
[71606]445 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]446 RTAssertMsg2Weak a; \
[71606]447 ASSERT_GUEST_PANIC(); \
448 a_Stmt; \
449 return (a_rc); \
[15668]450 } \
451 } while (0)
452#else
[71606]453# define ASSERT_GUEST_MSG_STMT_RETURN(a_Expr, a, a_Stmt, a_rc) \
[15668]454 do { \
[71606]455 if (RT_LIKELY(!!(a_Expr))) \
[55865]456 { /* likely */ } \
457 else \
[15668]458 { \
[71606]459 a_Stmt; \
460 return (a_rc); \
[15668]461 } \
462 } while (0)
463#endif
464
[71606]465/** @def ASSERT_GUEST_MSG_RETURN_VOID
[1]466 * Assert that an expression is true and returns if it isn't.
[71606]467 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[1]468 *
[71606]469 * @param a_Expr Expression which should be true.
[1]470 * @param a printf argument list (in parenthesis).
471 */
[71606]472#ifdef VBOX_STRICT_GUEST
473# define ASSERT_GUEST_MSG_RETURN_VOID(a_Expr, a) \
[1]474 do { \
[71606]475 if (RT_LIKELY(!!(a_Expr))) \
[55865]476 { /* likely */ } \
477 else \
[1]478 { \
[71606]479 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
[25528]480 RTAssertMsg2Weak a; \
[71606]481 ASSERT_GUEST_PANIC(); \
[1]482 return; \
483 } \
484 } while (0)
485#else
[71606]486# define ASSERT_GUEST_MSG_RETURN_VOID(a_Expr, a) \
[1]487 do { \
[71606]488 if (RT_LIKELY(!!(a_Expr))) \
[55865]489 { /* likely */ } \
490 else \
[1]491 return; \
492 } while (0)
493#endif
494
[71606]495/** @def ASSERT_GUEST_MSG_STMT_RETURN_VOID
[15668]496 * Assert that an expression is true, if it isn't execute the statement and
497 * return.
498 *
[71606]499 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[15668]500 *
[71606]501 * @param a_Expr Expression which should be true.
[15668]502 * @param a printf argument list (in parenthesis).
[71606]503 * @param a_Stmt Statement to execute before return in case of a failed assertion.
[15668]504 */
[71606]505#ifdef VBOX_STRICT_GUEST
506# define ASSERT_GUEST_MSG_STMT_RETURN_VOID(a_Expr, a, a_Stmt) \
[15668]507 do { \
[71606]508 if (RT_LIKELY(!!(a_Expr))) \
[55865]509 { /* likely */ } \
510 else \
[15668]511 { \
[71606]512 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]513 RTAssertMsg2Weak a; \
[71606]514 ASSERT_GUEST_PANIC(); \
515 a_Stmt; \
[15668]516 return; \
517 } \
518 } while (0)
519#else
[71606]520# define ASSERT_GUEST_MSG_STMT_RETURN_VOID(a_Expr, a, a_Stmt) \
[15668]521 do { \
[71606]522 if (RT_LIKELY(!!(a_Expr))) \
[55865]523 { /* likely */ } \
524 else \
[15668]525 { \
[71606]526 a_Stmt; \
[15668]527 return; \
528 } \
529 } while (0)
530#endif
[1]531
[15668]532
[71606]533/** @def ASSERT_GUEST_MSG_BREAK
[1]534 * Assert that an expression is true and breaks if it isn't.
[71606]535 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before returning.
[1]536 *
[71606]537 * @param a_Expr Expression which should be true.
[1]538 * @param a printf argument list (in parenthesis).
539 */
[71606]540#ifdef VBOX_STRICT_GUEST
541# define ASSERT_GUEST_MSG_BREAK(a_Expr, a) \
542 if (RT_LIKELY(!!(a_Expr))) \
[55865]543 { /* likely */ } \
544 else if (1) \
[8580]545 { \
[71606]546 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]547 RTAssertMsg2Weak a; \
[71606]548 ASSERT_GUEST_PANIC(); \
[1]549 break; \
[65948]550 } else \
551 break
[1]552#else
[71606]553# define ASSERT_GUEST_MSG_BREAK(a_Expr, a) \
554 if (RT_LIKELY(!!(a_Expr))) \
[55865]555 { /* likely */ } \
556 else \
557 break
[1]558#endif
559
[71606]560/** @def ASSERT_GUEST_MSG_STMT_BREAK
[6076]561 * Assert that an expression is true and breaks if it isn't.
[71606]562 * In VBOX_STRICT_GUEST mode it will hit a breakpoint before doing break.
[6076]563 *
[71606]564 * @param a_Expr Expression which should be true.
[6076]565 * @param a printf argument list (in parenthesis).
[71606]566 * @param a_Stmt Statement to execute before break in case of a failed assertion.
[6076]567 */
[71606]568#ifdef VBOX_STRICT_GUEST
569# define ASSERT_GUEST_MSG_STMT_BREAK(a_Expr, a, a_Stmt) \
570 if (RT_LIKELY(!!(a_Expr))) \
[55865]571 { /* likely */ } \
572 else if (1) \
573 { \
[71606]574 ASSERT_GUEST_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]575 RTAssertMsg2Weak a; \
[71606]576 ASSERT_GUEST_PANIC(); \
577 a_Stmt; \
[8575]578 break; \
[65948]579 } else \
580 break
[6076]581#else
[71606]582# define ASSERT_GUEST_MSG_STMT_BREAK(a_Expr, a, a_Stmt) \
583 if (RT_LIKELY(!!(a_Expr))) \
[55865]584 { /* likely */ } \
585 else if (1) \
586 { \
[71606]587 a_Stmt; \
[8575]588 break; \
[65948]589 } else \
590 break
[6076]591#endif
[1]592
[71606]593/** @def ASSERT_GUEST_FAILED
[60070]594 * An assertion failed, hit breakpoint.
[1]595 */
[71606]596#ifdef VBOX_STRICT_GUEST
597# define ASSERT_GUEST_FAILED() \
[1]598 do { \
[71606]599 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
600 ASSERT_GUEST_PANIC(); \
[1]601 } while (0)
602#else
[71606]603# define ASSERT_GUEST_FAILED() do { } while (0)
[1]604#endif
605
[71608]606/** @def ASSERT_GUEST_FAILED_STMT
[60070]607 * An assertion failed, hit breakpoint and execute statement.
[60065]608 */
[71606]609#ifdef VBOX_STRICT_GUEST
610# define ASSERT_GUEST_FAILED_STMT(a_Stmt) \
[60065]611 do { \
[71606]612 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
613 ASSERT_GUEST_PANIC(); \
614 a_Stmt; \
[60065]615 } while (0)
616#else
[71606]617# define ASSERT_GUEST_FAILED_STMT(a_Stmt) do { a_Stmt; } while (0)
[60065]618#endif
619
[71606]620/** @def ASSERT_GUEST_FAILED_RETURN
621 * An assertion failed, hit breakpoint (VBOX_STRICT_GUEST mode only) and return.
[1]622 *
[71606]623 * @param a_rc The a_rc to return.
[1]624 */
[71606]625#ifdef VBOX_STRICT_GUEST
626# define ASSERT_GUEST_FAILED_RETURN(a_rc) \
[1]627 do { \
[71606]628 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
629 ASSERT_GUEST_PANIC(); \
630 return (a_rc); \
[1]631 } while (0)
632#else
[71606]633# define ASSERT_GUEST_FAILED_RETURN(a_rc) \
[1]634 do { \
[71606]635 return (a_rc); \
[1]636 } while (0)
637#endif
638
[71606]639/** @def ASSERT_GUEST_FAILED_STMT_RETURN
640 * An assertion failed, hit breakpoint (VBOX_STRICT_GUEST mode only), execute a
[15640]641 * statement and return a value.
642 *
[71606]643 * @param a_Stmt The statement to execute before returning.
644 * @param a_rc The value to return.
[1]645 */
[71606]646#ifdef VBOX_STRICT_GUEST
647# define ASSERT_GUEST_FAILED_STMT_RETURN(a_Stmt, a_rc) \
[1]648 do { \
[71606]649 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
650 ASSERT_GUEST_PANIC(); \
651 a_Stmt; \
652 return (a_rc); \
[1]653 } while (0)
654#else
[71606]655# define ASSERT_GUEST_FAILED_STMT_RETURN(a_Stmt, a_rc) \
[1]656 do { \
[71606]657 a_Stmt; \
658 return (a_rc); \
[1]659 } while (0)
660#endif
661
[71606]662/** @def ASSERT_GUEST_FAILED_RETURN_VOID
663 * An assertion failed, hit breakpoint (VBOX_STRICT_GUEST mode only) and return.
[15398]664 */
[71606]665#ifdef VBOX_STRICT_GUEST
666# define ASSERT_GUEST_FAILED_RETURN_VOID() \
[15398]667 do { \
[71606]668 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
669 ASSERT_GUEST_PANIC(); \
[15640]670 return; \
[15398]671 } while (0)
672#else
[71606]673# define ASSERT_GUEST_FAILED_RETURN_VOID() \
[15398]674 do { \
[15640]675 return; \
[15398]676 } while (0)
677#endif
678
[71606]679/** @def ASSERT_GUEST_FAILED_STMT_RETURN_VOID
680 * An assertion failed, hit breakpoint (VBOX_STRICT_GUEST mode only), execute a
[15398]681 * statement and return.
682 *
[71606]683 * @param a_Stmt The statement to execute before returning.
[15398]684 */
[71606]685#ifdef VBOX_STRICT_GUEST
686# define ASSERT_GUEST_FAILED_STMT_RETURN_VOID(a_Stmt) \
[15398]687 do { \
[71606]688 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
689 ASSERT_GUEST_PANIC(); \
690 a_Stmt; \
[15398]691 return; \
692 } while (0)
693#else
[71606]694# define ASSERT_GUEST_FAILED_STMT_RETURN_VOID(a_Stmt) \
[15398]695 do { \
[71606]696 a_Stmt; \
[15398]697 return; \
698 } while (0)
699#endif
700
701
[71606]702/** @def ASSERT_GUEST_FAILED_BREAK
703 * An assertion failed, hit breakpoint (VBOX_STRICT_GUEST mode only) and break.
[8581]704 */
[71606]705#ifdef VBOX_STRICT_GUEST
706# define ASSERT_GUEST_FAILED_BREAK() \
[8581]707 if (1) { \
[71606]708 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
709 ASSERT_GUEST_PANIC(); \
[8581]710 break; \
[65948]711 } else \
712 break
[8581]713#else
[71606]714# define ASSERT_GUEST_FAILED_BREAK() \
[8581]715 if (1) \
716 break; \
[65948]717 else \
718 break
[8581]719#endif
720
[71606]721/** @def ASSERT_GUEST_FAILED_STMT_BREAK
722 * An assertion failed, hit breakpoint (VBOX_STRICT_GUEST mode only), execute
[1]723 * the given statement and break.
724 *
[71606]725 * @param a_Stmt Statement to execute before break.
[1]726 */
[71606]727#ifdef VBOX_STRICT_GUEST
728# define ASSERT_GUEST_FAILED_STMT_BREAK(a_Stmt) \
[1]729 if (1) { \
[71606]730 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
731 ASSERT_GUEST_PANIC(); \
732 a_Stmt; \
[1]733 break; \
[65948]734 } else \
735 break
[1]736#else
[71606]737# define ASSERT_GUEST_FAILED_STMT_BREAK(a_Stmt) \
[1]738 if (1) { \
[71606]739 a_Stmt; \
[1]740 break; \
[65948]741 } else \
742 break
[1]743#endif
744
745
[71606]746/** @def ASSERT_GUEST_MSG_FAILED
[1]747 * An assertion failed print a message and a hit breakpoint.
748 *
749 * @param a printf argument list (in parenthesis).
750 */
[71606]751#ifdef VBOX_STRICT_GUEST
752# define ASSERT_GUEST_MSG_FAILED(a) \
[1]753 do { \
[71606]754 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \
[25528]755 RTAssertMsg2Weak a; \
[71606]756 ASSERT_GUEST_PANIC(); \
[1]757 } while (0)
758#else
[71606]759# define ASSERT_GUEST_MSG_FAILED(a) do { } while (0)
[1]760#endif
761
[71608]762/** @def ASSERT_GUEST_MSG_FAILED_RETURN
[71606]763 * An assertion failed, hit breakpoint with message (VBOX_STRICT_GUEST mode only) and return.
[1]764 *
765 * @param a printf argument list (in parenthesis).
[71606]766 * @param a_rc What is to be presented to return.
[1]767 */
[71606]768#ifdef VBOX_STRICT_GUEST
769# define ASSERT_GUEST_MSG_FAILED_RETURN(a, a_rc) \
[1]770 do { \
[71606]771 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]772 RTAssertMsg2Weak a; \
[71606]773 ASSERT_GUEST_PANIC(); \
774 return (a_rc); \
[1]775 } while (0)
776#else
[71606]777# define ASSERT_GUEST_MSG_FAILED_RETURN(a, a_rc) \
[1]778 do { \
[71606]779 return (a_rc); \
[1]780 } while (0)
781#endif
782
[71606]783/** @def ASSERT_GUEST_MSG_FAILED_RETURN_VOID
784 * An assertion failed, hit breakpoint with message (VBOX_STRICT_GUEST mode only) and return.
[1]785 *
786 * @param a printf argument list (in parenthesis).
787 */
[71606]788#ifdef VBOX_STRICT_GUEST
789# define ASSERT_GUEST_MSG_FAILED_RETURN_VOID(a) \
[1]790 do { \
[71606]791 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]792 RTAssertMsg2Weak a; \
[71606]793 ASSERT_GUEST_PANIC(); \
[1]794 return; \
795 } while (0)
796#else
[71606]797# define ASSERT_GUEST_MSG_FAILED_RETURN_VOID(a) \
[1]798 do { \
799 return; \
800 } while (0)
801#endif
802
803
[71606]804/** @def ASSERT_GUEST_MSG_FAILED_BREAK
805 * An assertion failed, hit breakpoint with message (VBOX_STRICT_GUEST mode only) and break.
[1]806 *
807 * @param a printf argument list (in parenthesis).
808 */
[71606]809#ifdef VBOX_STRICT_GUEST
810# define ASSERT_GUEST_MSG_FAILED_BREAK(a) \
[1]811 if (1) { \
[71606]812 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]813 RTAssertMsg2Weak a; \
[71606]814 ASSERT_GUEST_PANIC(); \
[1]815 break; \
[65948]816 } else \
817 break
[1]818#else
[71606]819# define ASSERT_GUEST_MSG_FAILED_BREAK(a) \
[8582]820 if (1) \
[1]821 break; \
[65948]822 else \
823 break
[1]824#endif
825
[71606]826/** @def ASSERT_GUEST_MSG_FAILED_STMT_BREAK
827 * An assertion failed, hit breakpoint (VBOX_STRICT_GUEST mode only), execute
[8582]828 * the given statement and break.
[6076]829 *
830 * @param a printf argument list (in parenthesis).
[71606]831 * @param a_Stmt Statement to execute before break.
[6076]832 */
[71606]833#ifdef VBOX_STRICT_GUEST
834# define ASSERT_GUEST_MSG_FAILED_STMT_BREAK(a, a_Stmt) \
[8578]835 if (1) { \
[71606]836 ASSERT_GUEST_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[25528]837 RTAssertMsg2Weak a; \
[71606]838 ASSERT_GUEST_PANIC(); \
839 a_Stmt; \
[6076]840 break; \
[65948]841 } else \
842 break
[6076]843#else
[71606]844# define ASSERT_GUEST_MSG_FAILED_STMT_BREAK(a, a_Stmt) \
[8582]845 if (1) { \
[71606]846 a_Stmt; \
[6076]847 break; \
[65948]848 } else \
849 break
[6076]850#endif
[1]851
[13306]852/** @} */
[6076]853
[6814]854
[13306]855
[71606]856/** @name Guest input release log assertions
[6814]857 *
[71606]858 * These assertions will work like normal strict assertion when VBOX_STRICT_GUEST is
859 * defined and LogRel statements when VBOX_STRICT_GUEST is undefined. Typically
860 * used for important guest input that it would be helpful to find in VBox.log
861 * if the guest doesn't get it right.
[6814]862 *
[13306]863 * @{
[6814]864 */
865
[71606]866
867/** @def ASSERT_GUEST_LOGREL_MSG1
[25528]868 * RTAssertMsg1Weak (strict builds) / LogRel wrapper (non-strict).
[6814]869 */
[71606]870#ifdef VBOX_STRICT_GUEST
871# define ASSERT_GUEST_LOGREL_MSG1(szExpr, iLine, pszFile, pszFunction) \
872 RTAssertMsg1Weak("guest-input: " szExpr, iLine, pszFile, pszFunction)
[6814]873#else
[71606]874# define ASSERT_GUEST_LOGREL_MSG1(szExpr, iLine, pszFile, pszFunction) \
875 LogRel(("ASSERT_GUEST_LOGREL %s(%d) %s: %s\n", (pszFile), (iLine), (pszFunction), (szExpr) ))
[6814]876#endif
877
[71606]878/** @def ASSERT_GUEST_LOGREL_MSG2
[25528]879 * RTAssertMsg2Weak (strict builds) / LogRel wrapper (non-strict).
[6814]880 */
[71606]881#ifdef VBOX_STRICT_GUEST
882# define ASSERT_GUEST_LOGREL_MSG2(a) RTAssertMsg2Weak a
[6814]883#else
[71606]884# define ASSERT_GUEST_LOGREL_MSG2(a) LogRel(a)
[6814]885#endif
886
[71606]887/** @def ASSERT_GUEST_LOGREL
[6814]888 * Assert that an expression is true.
889 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
890 *
[71606]891 * @param a_Expr Expression which should be true.
[6814]892 */
[71606]893#define ASSERT_GUEST_LOGREL(a_Expr) \
[6814]894 do { \
[71606]895 if (RT_LIKELY(!!(a_Expr))) \
[55865]896 { /* likely */ } \
897 else \
[6814]898 { \
[71606]899 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
900 ASSERT_GUEST_PANIC(); \
[6814]901 } \
902 } while (0)
903
[71608]904/** @def ASSERT_GUEST_LOGREL_RETURN
[71606]905 * Assert that an expression is true, return \a a_rc if it isn't.
[6814]906 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
907 *
[71606]908 * @param a_Expr Expression which should be true.
909 * @param a_rc What is to be presented to return.
[6814]910 */
[71606]911#define ASSERT_GUEST_LOGREL_RETURN(a_Expr, a_rc) \
[6814]912 do { \
[71606]913 if (RT_LIKELY(!!(a_Expr))) \
[55865]914 { /* likely */ } \
915 else \
[6814]916 { \
[71606]917 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
918 ASSERT_GUEST_PANIC(); \
919 return (a_rc); \
[6814]920 } \
921 } while (0)
922
[71606]923/** @def ASSERT_GUEST_LOGREL_RETURN_VOID
[6814]924 * Assert that an expression is true, return void if it isn't.
925 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
926 *
[71606]927 * @param a_Expr Expression which should be true.
[6814]928 */
[71606]929#define ASSERT_GUEST_LOGREL_RETURN_VOID(a_Expr) \
[6814]930 do { \
[71606]931 if (RT_LIKELY(!!(a_Expr))) \
[55865]932 { /* likely */ } \
933 else \
[6814]934 { \
[71606]935 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
936 ASSERT_GUEST_PANIC(); \
[6814]937 return; \
938 } \
939 } while (0)
940
[71606]941/** @def ASSERT_GUEST_LOGREL_BREAK
[6814]942 * Assert that an expression is true, break if it isn't.
943 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
944 *
[71606]945 * @param a_Expr Expression which should be true.
[6814]946 */
[71606]947#define ASSERT_GUEST_LOGREL_BREAK(a_Expr) \
948 if (RT_LIKELY(!!(a_Expr))) \
[55865]949 { /* likely */ } \
950 else if (1) \
[6814]951 { \
[71606]952 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
953 ASSERT_GUEST_PANIC(); \
[6814]954 break; \
955 } \
[65948]956 else \
957 break
[6814]958
[71606]959/** @def ASSERT_GUEST_LOGREL_STMT_BREAK
960 * Assert that an expression is true, execute \a a_Stmt and break if it isn't.
[6814]961 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
962 *
[71606]963 * @param a_Expr Expression which should be true.
964 * @param a_Stmt Statement to execute before break in case of a failed assertion.
[6814]965 */
[71606]966#define ASSERT_GUEST_LOGREL_STMT_BREAK(a_Expr, a_Stmt) \
967 if (RT_LIKELY(!!(a_Expr))) \
[55865]968 { /* likely */ } \
969 else if (1) \
[6814]970 { \
[71606]971 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
972 ASSERT_GUEST_PANIC(); \
973 a_Stmt; \
[6814]974 break; \
[65948]975 } else \
976 break
[6814]977
[71606]978/** @def ASSERT_GUEST_LOGREL_MSG
[6814]979 * Assert that an expression is true.
980 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
981 *
[71606]982 * @param a_Expr Expression which should be true.
[6814]983 * @param a printf argument list (in parenthesis).
984 */
[71606]985#define ASSERT_GUEST_LOGREL_MSG(a_Expr, a) \
[6814]986 do { \
[71606]987 if (RT_LIKELY(!!(a_Expr))) \
[55865]988 { /* likely */ } \
989 else\
[6814]990 { \
[71606]991 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
992 ASSERT_GUEST_LOGREL_MSG2(a); \
993 ASSERT_GUEST_PANIC(); \
[6814]994 } \
995 } while (0)
996
[71606]997/** @def ASSERT_GUEST_LOGREL_MSG_STMT
998 * Assert that an expression is true, execute \a a_Stmt and break if it isn't
[33520]999 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1000 *
[71606]1001 * @param a_Expr Expression which should be true.
[33520]1002 * @param a printf argument list (in parenthesis).
[71606]1003 * @param a_Stmt Statement to execute in case of a failed assertion.
[33520]1004 */
[71606]1005#define ASSERT_GUEST_LOGREL_MSG_STMT(a_Expr, a, a_Stmt) \
[33520]1006 do { \
[71606]1007 if (RT_LIKELY(!!(a_Expr))) \
[55865]1008 { /* likely */ } \
1009 else\
[33520]1010 { \
[71606]1011 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1012 ASSERT_GUEST_LOGREL_MSG2(a); \
1013 ASSERT_GUEST_PANIC(); \
1014 a_Stmt; \
[33520]1015 } \
1016 } while (0)
1017
[71606]1018/** @def ASSERT_GUEST_LOGREL_MSG_RETURN
1019 * Assert that an expression is true, return \a a_rc if it isn't.
[6814]1020 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1021 *
[71606]1022 * @param a_Expr Expression which should be true.
[6814]1023 * @param a printf argument list (in parenthesis).
[71606]1024 * @param a_rc What is to be presented to return.
[6814]1025 */
[71606]1026#define ASSERT_GUEST_LOGREL_MSG_RETURN(a_Expr, a, a_rc) \
[6814]1027 do { \
[71606]1028 if (RT_LIKELY(!!(a_Expr))) \
[55865]1029 { /* likely */ } \
1030 else\
[6814]1031 { \
[71606]1032 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1033 ASSERT_GUEST_LOGREL_MSG2(a); \
1034 ASSERT_GUEST_PANIC(); \
1035 return (a_rc); \
[6814]1036 } \
1037 } while (0)
1038
[71606]1039/** @def ASSERT_GUEST_LOGREL_MSG_STMT_RETURN
1040 * Assert that an expression is true, execute @a a_Stmt and return @a rcRet if it
[33520]1041 * isn't.
1042 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1043 *
[71606]1044 * @param a_Expr Expression which should be true.
[33520]1045 * @param a printf argument list (in parenthesis).
[71606]1046 * @param a_Stmt Statement to execute before returning in case of a failed
[33520]1047 * assertion.
[37354]1048 * @param rcRet What is to be presented to return.
[33520]1049 */
[71606]1050#define ASSERT_GUEST_LOGREL_MSG_STMT_RETURN(a_Expr, a, a_Stmt, rcRet) \
[33520]1051 do { \
[71606]1052 if (RT_LIKELY(!!(a_Expr))) \
[55865]1053 { /* likely */ } \
1054 else\
[33520]1055 { \
[71606]1056 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1057 ASSERT_GUEST_LOGREL_MSG2(a); \
1058 ASSERT_GUEST_PANIC(); \
1059 a_Stmt; \
[37354]1060 return (rcRet); \
[33520]1061 } \
1062 } while (0)
1063
[71606]1064/** @def ASSERT_GUEST_LOGREL_MSG_RETURN_VOID
[6814]1065 * Assert that an expression is true, return (void) if it isn't.
1066 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1067 *
[71606]1068 * @param a_Expr Expression which should be true.
[6814]1069 * @param a printf argument list (in parenthesis).
1070 */
[71606]1071#define ASSERT_GUEST_LOGREL_MSG_RETURN_VOID(a_Expr, a) \
[6814]1072 do { \
[71606]1073 if (RT_LIKELY(!!(a_Expr))) \
[55865]1074 { /* likely */ } \
1075 else\
[6814]1076 { \
[71606]1077 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1078 ASSERT_GUEST_LOGREL_MSG2(a); \
1079 ASSERT_GUEST_PANIC(); \
[6814]1080 return; \
1081 } \
1082 } while (0)
1083
[71606]1084/** @def ASSERT_GUEST_LOGREL_MSG_BREAK
[6814]1085 * Assert that an expression is true, break if it isn't.
1086 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1087 *
[71606]1088 * @param a_Expr Expression which should be true.
[6814]1089 * @param a printf argument list (in parenthesis).
1090 */
[71606]1091#define ASSERT_GUEST_LOGREL_MSG_BREAK(a_Expr, a) \
1092 if (RT_LIKELY(!!(a_Expr))) \
[55865]1093 { /* likely */ } \
1094 else if (1) \
[6814]1095 { \
[71606]1096 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1097 ASSERT_GUEST_LOGREL_MSG2(a); \
1098 ASSERT_GUEST_PANIC(); \
[6814]1099 break; \
1100 } \
[65948]1101 else \
1102 break
[6814]1103
[71606]1104/** @def ASSERT_GUEST_LOGREL_MSG_STMT_BREAK
1105 * Assert that an expression is true, execute \a a_Stmt and break if it isn't.
[6814]1106 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1107 *
[71606]1108 * @param a_Expr Expression which should be true.
[6814]1109 * @param a printf argument list (in parenthesis).
[71606]1110 * @param a_Stmt Statement to execute before break in case of a failed assertion.
[6814]1111 */
[71606]1112#define ASSERT_GUEST_LOGREL_MSG_STMT_BREAK(a_Expr, a, a_Stmt) \
1113 if (RT_LIKELY(!!(a_Expr))) \
[55865]1114 { /* likely */ } \
1115 else if (1) \
[6814]1116 { \
[71606]1117 ASSERT_GUEST_LOGREL_MSG1(#a_Expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
1118 ASSERT_GUEST_LOGREL_MSG2(a); \
1119 ASSERT_GUEST_PANIC(); \
1120 a_Stmt; \
[6814]1121 break; \
[65948]1122 } else \
1123 break
[6814]1124
[71606]1125/** @def ASSERT_GUEST_LOGREL_FAILED
[6814]1126 * An assertion failed.
1127 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1128 */
[71606]1129#define ASSERT_GUEST_LOGREL_FAILED() \
[6814]1130 do { \
[71610]1131 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1132 ASSERT_GUEST_PANIC(); \
[6814]1133 } while (0)
1134
[71606]1135/** @def ASSERT_GUEST_LOGREL_FAILED_RETURN
[6814]1136 * An assertion failed.
1137 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1138 *
[71606]1139 * @param a_rc What is to be presented to return.
[6814]1140 */
[71606]1141#define ASSERT_GUEST_LOGREL_FAILED_RETURN(a_rc) \
[6814]1142 do { \
[71610]1143 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1144 ASSERT_GUEST_PANIC(); \
1145 return (a_rc); \
[6814]1146 } while (0)
1147
[71606]1148/** @def ASSERT_GUEST_LOGREL_FAILED_RETURN_VOID
[6814]1149 * An assertion failed, hit a breakpoint and return.
1150 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1151 */
[71606]1152#define ASSERT_GUEST_LOGREL_FAILED_RETURN_VOID() \
[6814]1153 do { \
[71610]1154 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1155 ASSERT_GUEST_PANIC(); \
[6814]1156 return; \
1157 } while (0)
1158
[71606]1159/** @def ASSERT_GUEST_LOGREL_FAILED_BREAK
[6814]1160 * An assertion failed, break.
1161 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1162 */
[71606]1163#define ASSERT_GUEST_LOGREL_FAILED_BREAK() \
[6814]1164 if (1) \
1165 { \
[71610]1166 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1167 ASSERT_GUEST_PANIC(); \
[6814]1168 break; \
[65948]1169 } else \
1170 break
[6814]1171
[71606]1172/** @def ASSERT_GUEST_LOGREL_FAILED_STMT_BREAK
1173 * An assertion failed, execute \a a_Stmt and break.
[6814]1174 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1175 *
[71606]1176 * @param a_Stmt Statement to execute before break.
[6814]1177 */
[71606]1178#define ASSERT_GUEST_LOGREL_FAILED_STMT_BREAK(a_Stmt) \
[6814]1179 if (1) \
1180 { \
[71610]1181 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1182 ASSERT_GUEST_PANIC(); \
1183 a_Stmt; \
[6814]1184 break; \
[65948]1185 } else \
1186 break
[6814]1187
[71606]1188/** @def ASSERT_GUEST_LOGREL_MSG_FAILED
[6814]1189 * An assertion failed.
1190 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1191 *
1192 * @param a printf argument list (in parenthesis).
1193 */
[71606]1194#define ASSERT_GUEST_LOGREL_MSG_FAILED(a) \
[6814]1195 do { \
[71610]1196 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1197 ASSERT_GUEST_LOGREL_MSG2(a); \
1198 ASSERT_GUEST_PANIC(); \
[6814]1199 } while (0)
1200
[71606]1201/** @def ASSERT_GUEST_LOGREL_MSG_FAILED_STMT
1202 * An assertion failed, execute @a a_Stmt.
[47619]1203 *
1204 * Strict builds will hit a breakpoint, non-strict will only do LogRel. The
1205 * statement will be executed in regardless of build type.
1206 *
1207 * @param a printf argument list (in parenthesis).
[71606]1208 * @param a_Stmt Statement to execute after raising/logging the assertion.
[47619]1209 */
[71606]1210#define ASSERT_GUEST_LOGREL_MSG_FAILED_STMT(a, a_Stmt) \
[47619]1211 do { \
[71610]1212 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1213 ASSERT_GUEST_LOGREL_MSG2(a); \
1214 ASSERT_GUEST_PANIC(); \
1215 a_Stmt; \
[47619]1216 } while (0)
1217
[71606]1218/** @def ASSERT_GUEST_LOGREL_MSG_FAILED_RETURN
1219 * An assertion failed, return \a a_rc.
[6814]1220 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1221 *
1222 * @param a printf argument list (in parenthesis).
[71606]1223 * @param a_rc What is to be presented to return.
[6814]1224 */
[71606]1225#define ASSERT_GUEST_LOGREL_MSG_FAILED_RETURN(a, a_rc) \
[6814]1226 do { \
[71610]1227 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1228 ASSERT_GUEST_LOGREL_MSG2(a); \
1229 ASSERT_GUEST_PANIC(); \
1230 return (a_rc); \
[6814]1231 } while (0)
1232
[71606]1233/** @def ASSERT_GUEST_LOGREL_MSG_FAILED_STMT_RETURN
1234 * An assertion failed, execute @a a_Stmt and return @a a_rc.
[37354]1235 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1236 *
1237 * @param a printf argument list (in parenthesis).
[71606]1238 * @param a_Stmt Statement to execute before returning in case of a failed
[37354]1239 * assertion.
[71606]1240 * @param a_rc What is to be presented to return.
[37354]1241 */
[71606]1242#define ASSERT_GUEST_LOGREL_MSG_FAILED_STMT_RETURN(a, a_Stmt, a_rc) \
[37354]1243 do { \
[71610]1244 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1245 ASSERT_GUEST_LOGREL_MSG2(a); \
1246 ASSERT_GUEST_PANIC(); \
1247 a_Stmt; \
1248 return (a_rc); \
[37354]1249 } while (0)
1250
[71606]1251/** @def ASSERT_GUEST_LOGREL_MSG_FAILED_RETURN_VOID
[6814]1252 * An assertion failed, return void.
1253 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1254 *
1255 * @param a printf argument list (in parenthesis).
1256 */
[71606]1257#define ASSERT_GUEST_LOGREL_MSG_FAILED_RETURN_VOID(a) \
[6814]1258 do { \
[71610]1259 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1260 ASSERT_GUEST_LOGREL_MSG2(a); \
1261 ASSERT_GUEST_PANIC(); \
[6814]1262 return; \
1263 } while (0)
1264
[71606]1265/** @def ASSERT_GUEST_LOGREL_MSG_FAILED_STMT_RETURN_VOID
1266 * An assertion failed, execute @a a_Stmt and return void.
[37354]1267 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1268 *
1269 * @param a printf argument list (in parenthesis).
[71606]1270 * @param a_Stmt Statement to execute before returning in case of a failed
[37354]1271 * assertion.
1272 */
[71606]1273#define ASSERT_GUEST_LOGREL_MSG_FAILED_STMT_RETURN_VOID(a, a_Stmt) \
[37354]1274 do { \
[71610]1275 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1276 ASSERT_GUEST_LOGREL_MSG2(a); \
1277 ASSERT_GUEST_PANIC(); \
1278 a_Stmt; \
[37354]1279 return; \
1280 } while (0)
1281
[71606]1282/** @def ASSERT_GUEST_LOGREL_MSG_FAILED_BREAK
[6814]1283 * An assertion failed, break.
1284 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1285 *
1286 * @param a printf argument list (in parenthesis).
1287 */
[71606]1288#define ASSERT_GUEST_LOGREL_MSG_FAILED_BREAK(a) \
[6814]1289 if (1)\
1290 { \
[71610]1291 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1292 ASSERT_GUEST_LOGREL_MSG2(a); \
1293 ASSERT_GUEST_PANIC(); \
[6814]1294 break; \
[65948]1295 } else \
1296 break
[6814]1297
[71606]1298/** @def ASSERT_GUEST_LOGREL_MSG_FAILED_STMT_BREAK
1299 * An assertion failed, execute \a a_Stmt and break.
[6814]1300 * Strict builds will hit a breakpoint, non-strict will only do LogRel.
1301 *
1302 * @param a printf argument list (in parenthesis).
[71606]1303 * @param a_Stmt Statement to execute before break.
[6814]1304 */
[71606]1305#define ASSERT_GUEST_LOGREL_MSG_FAILED_STMT_BREAK(a, a_Stmt) \
[6814]1306 if (1) \
1307 { \
[71610]1308 ASSERT_GUEST_LOGREL_MSG1("failed", __LINE__, __FILE__, __PRETTY_FUNCTION__); \
[71606]1309 ASSERT_GUEST_LOGREL_MSG2(a); \
1310 ASSERT_GUEST_PANIC(); \
1311 a_Stmt; \
[6814]1312 break; \
[65948]1313 } else \
1314 break
[6814]1315
[13306]1316/** @} */
[6814]1317
1318
[13306]1319/** @name Convenience Assertions Macros
1320 * @{
1321 */
1322
[71606]1323/** @def ASSERT_GUEST_RC
[1]1324 * Asserts a iprt status code successful.
1325 *
1326 * On failure it will print info about the rc and hit a breakpoint.
1327 *
1328 * @param rc iprt status code.
[21646]1329 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1330 */
[71606]1331#define ASSERT_GUEST_RC(rc) ASSERT_GUEST_MSG_RC(rc, ("%Rra\n", (rc)))
[1]1332
[71606]1333/** @def ASSERT_GUEST_RC_STMT
[60065]1334 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and execute
1335 * @a stmt if it isn't.
1336 *
1337 * @param rc iprt status code.
1338 * @param stmt Statement to execute before returning in case of a failed
1339 * assertion.
1340 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1341 */
[71606]1342#define ASSERT_GUEST_RC_STMT(rc, stmt) ASSERT_GUEST_MSG_RC_STMT(rc, ("%Rra\n", (rc)), stmt)
[60065]1343
[71606]1344/** @def ASSERT_GUEST_RC_RETURN
[1]1345 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1346 *
1347 * @param rc iprt status code.
1348 * @param rcRet What is to be presented to return.
[21646]1349 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1350 */
[71606]1351#define ASSERT_GUEST_RC_RETURN(rc, rcRet) ASSERT_GUEST_MSG_RC_RETURN(rc, ("%Rra\n", (rc)), rcRet)
[1]1352
[71606]1353/** @def ASSERT_GUEST_RC_STMT_RETURN
[37354]1354 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1355 * @a stmt and returns @a rcRet if it isn't.
1356 *
1357 * @param rc iprt status code.
1358 * @param stmt Statement to execute before returning in case of a failed
1359 * assertion.
1360 * @param rcRet What is to be presented to return.
1361 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1362 */
[71606]1363#define ASSERT_GUEST_RC_STMT_RETURN(rc, stmt, rcRet) ASSERT_GUEST_MSG_RC_STMT_RETURN(rc, ("%Rra\n", (rc)), stmt, rcRet)
[37354]1364
[71606]1365/** @def ASSERT_GUEST_RC_RETURN_VOID
[3111]1366 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
1367 *
1368 * @param rc iprt status code.
[21646]1369 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[3111]1370 */
[71606]1371#define ASSERT_GUEST_RC_RETURN_VOID(rc) ASSERT_GUEST_MSG_RC_RETURN_VOID(rc, ("%Rra\n", (rc)))
[3111]1372
[71606]1373/** @def ASSERT_GUEST_RC_STMT_RETURN_VOID
[32671]1374 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), and
1375 * execute the given statement/return if it isn't.
1376 *
1377 * @param rc iprt status code.
1378 * @param stmt Statement to execute before returning on failure.
1379 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1380 */
[71606]1381#define ASSERT_GUEST_RC_STMT_RETURN_VOID(rc, stmt) ASSERT_GUEST_MSG_RC_STMT_RETURN_VOID(rc, ("%Rra\n", (rc)), stmt)
[32671]1382
[71608]1383/** @def ASSERT_GUEST_RC_BREAK
[1]1384 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1385 *
1386 * @param rc iprt status code.
[21646]1387 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1388 */
[71606]1389#define ASSERT_GUEST_RC_BREAK(rc) ASSERT_GUEST_MSG_RC_BREAK(rc, ("%Rra\n", (rc)))
[1]1390
[71606]1391/** @def ASSERT_GUEST_RC_STMT_BREAK
[6076]1392 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
1393 *
1394 * @param rc iprt status code.
[8588]1395 * @param stmt Statement to execute before break in case of a failed assertion.
[21646]1396 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6076]1397 */
[71606]1398#define ASSERT_GUEST_RC_STMT_BREAK(rc, stmt) ASSERT_GUEST_MSG_RC_STMT_BREAK(rc, ("%Rra\n", (rc)), stmt)
[6076]1399
[71606]1400/** @def ASSERT_GUEST_MSG_RC
[1]1401 * Asserts a iprt status code successful.
1402 *
1403 * It prints a custom message and hits a breakpoint on FAILURE.
1404 *
1405 * @param rc iprt status code.
1406 * @param msg printf argument list (in parenthesis).
[21646]1407 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1408 */
[71606]1409#define ASSERT_GUEST_MSG_RC(rc, msg) \
1410 do { ASSERT_GUEST_MSG(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
[1]1411
[71608]1412/** @def ASSERT_GUEST_MSG_RC_STMT
[60070]1413 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and
1414 * execute @a stmt if it isn't.
[60065]1415 *
1416 * @param rc iprt status code.
1417 * @param msg printf argument list (in parenthesis).
1418 * @param stmt Statement to execute before returning in case of a failed
1419 * assertion.
1420 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1421 */
[71606]1422#define ASSERT_GUEST_MSG_RC_STMT(rc, msg, stmt) \
1423 do { ASSERT_GUEST_MSG_STMT(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
[60065]1424
[71606]1425/** @def ASSERT_GUEST_MSG_RC_RETURN
[60070]1426 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
1427 * @a rcRet if it isn't.
[1]1428 *
1429 * @param rc iprt status code.
1430 * @param msg printf argument list (in parenthesis).
1431 * @param rcRet What is to be presented to return.
[21646]1432 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1433 */
[71606]1434#define ASSERT_GUEST_MSG_RC_RETURN(rc, msg, rcRet) \
1435 do { ASSERT_GUEST_MSG_RETURN(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
[1]1436
[71606]1437/** @def ASSERT_GUEST_MSG_RC_STMT_RETURN
[60070]1438 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1439 * @a stmt and return @a rcRet if it isn't.
[37354]1440 *
1441 * @param rc iprt status code.
1442 * @param msg printf argument list (in parenthesis).
1443 * @param stmt Statement to execute before returning in case of a failed
1444 * assertion.
1445 * @param rcRet What is to be presented to return.
1446 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1447 */
[71606]1448#define ASSERT_GUEST_MSG_RC_STMT_RETURN(rc, msg, stmt, rcRet) \
1449 do { ASSERT_GUEST_MSG_STMT_RETURN(RT_SUCCESS_NP(rc), msg, stmt, rcRet); NOREF(rc); } while (0)
[37354]1450
[71606]1451/** @def ASSERT_GUEST_MSG_RC_RETURN_VOID
[60070]1452 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
1453 * void if it isn't.
[3111]1454 *
1455 * @param rc iprt status code.
1456 * @param msg printf argument list (in parenthesis).
[21646]1457 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[3111]1458 */
[71606]1459#define ASSERT_GUEST_MSG_RC_RETURN_VOID(rc, msg) \
1460 do { ASSERT_GUEST_MSG_RETURN_VOID(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
[3111]1461
[71606]1462/** @def ASSERT_GUEST_MSG_RC_STMT_RETURN_VOID
[60070]1463 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1464 * @a stmt and return void if it isn't.
[32671]1465 *
1466 * @param rc iprt status code.
1467 * @param msg printf argument list (in parenthesis).
1468 * @param stmt Statement to execute before break in case of a failed assertion.
1469 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
1470 */
[71606]1471#define ASSERT_GUEST_MSG_RC_STMT_RETURN_VOID(rc, msg, stmt) \
1472 do { ASSERT_GUEST_MSG_STMT_RETURN_VOID(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
[32671]1473
[71606]1474/** @def ASSERT_GUEST_MSG_RC_BREAK
[60070]1475 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break
1476 * if it isn't.
[1]1477 *
1478 * @param rc iprt status code.
1479 * @param msg printf argument list (in parenthesis).
[21646]1480 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1481 */
[71606]1482#define ASSERT_GUEST_MSG_RC_BREAK(rc, msg) \
1483 if (1) { ASSERT_GUEST_MSG_BREAK(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
[1]1484
[71606]1485/** @def ASSERT_GUEST_MSG_RC_STMT_BREAK
[60070]1486 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1487 * @a stmt and break if it isn't.
[6076]1488 *
1489 * @param rc iprt status code.
1490 * @param msg printf argument list (in parenthesis).
[8589]1491 * @param stmt Statement to execute before break in case of a failed assertion.
[21646]1492 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6076]1493 */
[71606]1494#define ASSERT_GUEST_MSG_RC_STMT_BREAK(rc, msg, stmt) \
1495 if (1) { ASSERT_GUEST_MSG_STMT_BREAK(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
[6076]1496
[71606]1497/** @def ASSERT_GUEST_RC_SUCCESS
[1]1498 * Asserts an iprt status code equals VINF_SUCCESS.
1499 *
1500 * On failure it will print info about the rc and hit a breakpoint.
1501 *
1502 * @param rc iprt status code.
[21646]1503 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1504 */
[71606]1505#define ASSERT_GUEST_RC_SUCCESS(rc) do { ASSERT_GUEST_MSG((rc) == VINF_SUCCESS, ("%Rra\n", (rc))); NOREF(rc); } while (0)
[1]1506
[71606]1507/** @def ASSERT_GUEST_RC_SUCCESS_RETURN
[1]1508 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1509 *
1510 * @param rc iprt status code.
1511 * @param rcRet What is to be presented to return.
[21646]1512 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1513 */
[71606]1514#define ASSERT_GUEST_RC_SUCCESS_RETURN(rc, rcRet) ASSERT_GUEST_MSG_RETURN((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
[1]1515
[71606]1516/** @def ASSERT_GUEST_RC_SUCCESS_RETURN_VOID
[3111]1517 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
1518 *
1519 * @param rc iprt status code.
[21646]1520 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[3111]1521 */
[71606]1522#define ASSERT_GUEST_RC_SUCCESS_RETURN_VOID(rc) ASSERT_GUEST_MSG_RETURN_VOID((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
[3111]1523
[71606]1524/** @def ASSERT_GUEST_RC_SUCCESS_BREAK
[1]1525 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1526 *
1527 * @param rc iprt status code.
[21646]1528 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1529 */
[71606]1530#define ASSERT_GUEST_RC_SUCCESS_BREAK(rc) ASSERT_GUEST_MSG_BREAK((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
[1]1531
[71608]1532/** @def ASSERT_GUEST_RC_SUCCESS_STMT_BREAK
[6076]1533 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
1534 *
1535 * @param rc iprt status code.
[8590]1536 * @param stmt Statement to execute before break in case of a failed assertion.
[21646]1537 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6076]1538 */
[71606]1539#define ASSERT_GUEST_RC_SUCCESS_STMT_BREAK(rc, stmt) ASSERT_GUEST_MSG_STMT_BREAK((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
[1]1540
[71606]1541/** @def ASSERT_GUEST_GCPHYS32
1542 * Asserts that the high dword of a physical address is zero
1543 *
1544 * @param GCPhys The address (RTGCPHYS).
1545 */
1546#define ASSERT_GUEST_GCPHYS32(GCPhys) ASSERT_GUEST_MSG(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
[6076]1547
[71606]1548
1549/** @def ASSERT_GUEST_RC
[6814]1550 * Asserts a iprt status code successful.
1551 *
[71606]1552 * On failure it will print info about the rc and hit a breakpoint.
1553 *
[6814]1554 * @param rc iprt status code.
[71606]1555 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6814]1556 */
[71606]1557#define ASSERT_GUEST_LOGREL_RC(rc) ASSERT_GUEST_LOGREL_MSG_RC(rc, ("%Rra\n", (rc)))
[6814]1558
[71606]1559/** @def ASSERT_GUEST_LOGREL_RC_STMT
1560 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and execute
1561 * @a stmt if it isn't.
[6814]1562 *
1563 * @param rc iprt status code.
[33520]1564 * @param stmt Statement to execute before returning in case of a failed
1565 * assertion.
[71606]1566 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[33520]1567 */
[71606]1568#define ASSERT_GUEST_LOGREL_RC_STMT(rc, stmt) ASSERT_GUEST_LOGREL_MSG_RC_STMT(rc, ("%Rra\n", (rc)), stmt)
[33520]1569
[71606]1570/** @def ASSERT_GUEST_LOGREL_RC_RETURN
1571 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
[6814]1572 *
1573 * @param rc iprt status code.
1574 * @param rcRet What is to be presented to return.
[71606]1575 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6814]1576 */
[71606]1577#define ASSERT_GUEST_LOGREL_RC_RETURN(rc, rcRet) ASSERT_GUEST_LOGREL_MSG_RC_RETURN(rc, ("%Rra\n", (rc)), rcRet)
[6814]1578
[71606]1579/** @def ASSERT_GUEST_LOGREL_RC_STMT_RETURN
1580 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1581 * @a stmt and returns @a rcRet if it isn't.
[33520]1582 *
1583 * @param rc iprt status code.
[37354]1584 * @param stmt Statement to execute before returning in case of a failed
1585 * assertion.
[33520]1586 * @param rcRet What is to be presented to return.
[71606]1587 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[33520]1588 */
[71606]1589#define ASSERT_GUEST_LOGREL_RC_STMT_RETURN(rc, stmt, rcRet) ASSERT_GUEST_LOGREL_MSG_RC_STMT_RETURN(rc, ("%Rra\n", (rc)), stmt, rcRet)
[33520]1590
[71606]1591/** @def ASSERT_GUEST_LOGREL_RC_RETURN_VOID
1592 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
[6814]1593 *
1594 * @param rc iprt status code.
[71606]1595 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6814]1596 */
[71606]1597#define ASSERT_GUEST_LOGREL_RC_RETURN_VOID(rc) ASSERT_GUEST_LOGREL_MSG_RC_RETURN_VOID(rc, ("%Rra\n", (rc)))
[6814]1598
[71606]1599/** @def ASSERT_GUEST_LOGREL_RC_STMT_RETURN_VOID
1600 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), and
1601 * execute the given statement/return if it isn't.
[6814]1602 *
1603 * @param rc iprt status code.
[71606]1604 * @param stmt Statement to execute before returning on failure.
1605 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6814]1606 */
[71606]1607#define ASSERT_GUEST_LOGREL_RC_STMT_RETURN_VOID(rc, stmt) ASSERT_GUEST_LOGREL_MSG_RC_STMT_RETURN_VOID(rc, ("%Rra\n", (rc)), stmt)
[6814]1608
[71608]1609/** @def ASSERT_GUEST_LOGREL_RC_BREAK
[71606]1610 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
[6814]1611 *
1612 * @param rc iprt status code.
[71606]1613 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6814]1614 */
[71606]1615#define ASSERT_GUEST_LOGREL_RC_BREAK(rc) ASSERT_GUEST_LOGREL_MSG_RC_BREAK(rc, ("%Rra\n", (rc)))
[6814]1616
[71606]1617/** @def ASSERT_GUEST_LOGREL_RC_STMT_BREAK
1618 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
[6814]1619 *
1620 * @param rc iprt status code.
1621 * @param stmt Statement to execute before break in case of a failed assertion.
[71606]1622 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6814]1623 */
[71606]1624#define ASSERT_GUEST_LOGREL_RC_STMT_BREAK(rc, stmt) ASSERT_GUEST_LOGREL_MSG_RC_STMT_BREAK(rc, ("%Rra\n", (rc)), stmt)
[6814]1625
[71606]1626/** @def ASSERT_GUEST_LOGREL_MSG_RC
[1]1627 * Asserts a iprt status code successful.
1628 *
[71606]1629 * It prints a custom message and hits a breakpoint on FAILURE.
[1]1630 *
1631 * @param rc iprt status code.
[71606]1632 * @param msg printf argument list (in parenthesis).
1633 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1634 */
[71606]1635#define ASSERT_GUEST_LOGREL_MSG_RC(rc, msg) \
1636 do { ASSERT_GUEST_LOGREL_MSG(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
[1]1637
[71608]1638/** @def ASSERT_GUEST_LOGREL_MSG_RC_STMT
[71606]1639 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and
1640 * execute @a stmt if it isn't.
[3111]1641 *
1642 * @param rc iprt status code.
[71606]1643 * @param msg printf argument list (in parenthesis).
1644 * @param stmt Statement to execute before returning in case of a failed
1645 * assertion.
1646 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[3111]1647 */
[71606]1648#define ASSERT_GUEST_LOGREL_MSG_RC_STMT(rc, msg, stmt) \
1649 do { ASSERT_GUEST_LOGREL_MSG_STMT(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
[3111]1650
[71606]1651/** @def ASSERT_GUEST_LOGREL_MSG_RC_RETURN
1652 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
1653 * @a rcRet if it isn't.
[1]1654 *
1655 * @param rc iprt status code.
[71606]1656 * @param msg printf argument list (in parenthesis).
1657 * @param rcRet What is to be presented to return.
1658 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1659 */
[71606]1660#define ASSERT_GUEST_LOGREL_MSG_RC_RETURN(rc, msg, rcRet) \
1661 do { ASSERT_GUEST_LOGREL_MSG_RETURN(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
[1]1662
[71606]1663/** @def ASSERT_GUEST_LOGREL_MSG_RC_STMT_RETURN
1664 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1665 * @a stmt and return @a rcRet if it isn't.
[6076]1666 *
1667 * @param rc iprt status code.
[1]1668 * @param msg printf argument list (in parenthesis).
[71606]1669 * @param stmt Statement to execute before returning in case of a failed
1670 * assertion.
1671 * @param rcRet What is to be presented to return.
1672 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1673 */
[71606]1674#define ASSERT_GUEST_LOGREL_MSG_RC_STMT_RETURN(rc, msg, stmt, rcRet) \
1675 do { ASSERT_GUEST_LOGREL_MSG_STMT_RETURN(RT_SUCCESS_NP(rc), msg, stmt, rcRet); NOREF(rc); } while (0)
[1]1676
[71606]1677/** @def ASSERT_GUEST_LOGREL_MSG_RC_RETURN_VOID
1678 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return
1679 * void if it isn't.
[1]1680 *
1681 * @param rc iprt status code.
1682 * @param msg printf argument list (in parenthesis).
[71606]1683 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1684 */
[71606]1685#define ASSERT_GUEST_LOGREL_MSG_RC_RETURN_VOID(rc, msg) \
1686 do { ASSERT_GUEST_LOGREL_MSG_RETURN_VOID(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
[1]1687
[71606]1688/** @def ASSERT_GUEST_LOGREL_MSG_RC_STMT_RETURN_VOID
1689 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1690 * @a stmt and return void if it isn't.
[3111]1691 *
1692 * @param rc iprt status code.
1693 * @param msg printf argument list (in parenthesis).
[71606]1694 * @param stmt Statement to execute before break in case of a failed assertion.
1695 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[3111]1696 */
[71606]1697#define ASSERT_GUEST_LOGREL_MSG_RC_STMT_RETURN_VOID(rc, msg, stmt) \
1698 do { ASSERT_GUEST_LOGREL_MSG_STMT_RETURN_VOID(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } while (0)
[3111]1699
[71606]1700/** @def ASSERT_GUEST_LOGREL_MSG_RC_BREAK
1701 * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break
1702 * if it isn't.
[1]1703 *
1704 * @param rc iprt status code.
1705 * @param msg printf argument list (in parenthesis).
[71606]1706 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1707 */
[71606]1708#define ASSERT_GUEST_LOGREL_MSG_RC_BREAK(rc, msg) \
1709 if (1) { ASSERT_GUEST_LOGREL_MSG_BREAK(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
[1]1710
[71606]1711/** @def ASSERT_GUEST_LOGREL_MSG_RC_STMT_BREAK
1712 * Asserts a iprt status code successful, bitch (RT_STRICT mode only), execute
1713 * @a stmt and break if it isn't.
[6076]1714 *
1715 * @param rc iprt status code.
1716 * @param msg printf argument list (in parenthesis).
[8592]1717 * @param stmt Statement to execute before break in case of a failed assertion.
[71606]1718 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6076]1719 */
[71606]1720#define ASSERT_GUEST_LOGREL_MSG_RC_STMT_BREAK(rc, msg, stmt) \
1721 if (1) { ASSERT_GUEST_LOGREL_MSG_STMT_BREAK(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
[6076]1722
[71606]1723/** @def ASSERT_GUEST_LOGREL_RC_SUCCESS
1724 * Asserts an iprt status code equals VINF_SUCCESS.
[1]1725 *
[71606]1726 * On failure it will print info about the rc and hit a breakpoint.
[1]1727 *
1728 * @param rc iprt status code.
[71606]1729 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1730 */
[71606]1731#define ASSERT_GUEST_LOGREL_RC_SUCCESS(rc) do { ASSERT_GUEST_LOGREL_MSG((rc) == VINF_SUCCESS, ("%Rra\n", (rc))); NOREF(rc); } while (0)
[1]1732
[71606]1733/** @def ASSERT_GUEST_LOGREL_RC_SUCCESS_RETURN
1734 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
[1]1735 *
1736 * @param rc iprt status code.
1737 * @param rcRet What is to be presented to return.
[71606]1738 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1739 */
[71606]1740#define ASSERT_GUEST_LOGREL_RC_SUCCESS_RETURN(rc, rcRet) ASSERT_GUEST_LOGREL_MSG_RETURN((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
[1]1741
[71606]1742/** @def ASSERT_GUEST_LOGREL_RC_SUCCESS_RETURN_VOID
1743 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
[3111]1744 *
1745 * @param rc iprt status code.
[71606]1746 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[3111]1747 */
[71606]1748#define ASSERT_GUEST_LOGREL_RC_SUCCESS_RETURN_VOID(rc) ASSERT_GUEST_LOGREL_MSG_RETURN_VOID((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
[3111]1749
[71606]1750/** @def ASSERT_GUEST_LOGREL_RC_SUCCESS_BREAK
1751 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
[1]1752 *
1753 * @param rc iprt status code.
[71606]1754 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[1]1755 */
[71606]1756#define ASSERT_GUEST_LOGREL_RC_SUCCESS_BREAK(rc) ASSERT_GUEST_LOGREL_MSG_BREAK((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
[1]1757
[71608]1758/** @def ASSERT_GUEST_LOGREL_RC_SUCCESS_STMT_BREAK
[71606]1759 * Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
[6076]1760 *
1761 * @param rc iprt status code.
[8593]1762 * @param stmt Statement to execute before break in case of a failed assertion.
[71606]1763 * @remark rc is referenced multiple times. In release mode is NOREF()'ed.
[6076]1764 */
[71606]1765#define ASSERT_GUEST_LOGREL_RC_SUCCESS_STMT_BREAK(rc, stmt) ASSERT_GUEST_LOGREL_MSG_STMT_BREAK((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), stmt)
[1]1766
[71606]1767/** @def ASSERT_GUEST_LOGREL_GCPHYS32
[7620]1768 * Asserts that the high dword of a physical address is zero
1769 *
[8563]1770 * @param GCPhys The address (RTGCPHYS).
[7620]1771 */
[71606]1772#define ASSERT_GUEST_LOGREL_GCPHYS32(GCPhys) ASSERT_GUEST_LOGREL_MSG(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
[6076]1773
[13931]1774
[71606]1775/** @} */
[16542]1776
[63050]1777
[13306]1778/** @} */
[1]1779
[76585]1780#endif /* !VBOX_INCLUDED_AssertGuest_h */
[1]1781
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