assert.cpp revision 6bd27257a4f996c855391902114c7ac459e929ed
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/* $Id$ */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** @file
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * IPRT - Assertions, common code.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2006-2009 Oracle Corporation
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * available from http://www.virtualbox.org. This file is free software;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * General Public License (GPL) as published by the Free Software
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * The contents of this file may alternatively be used under the terms
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * of the Common Development and Distribution License Version 1.0
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * VirtualBox OSE distribution, in which case the provisions of the
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * CDDL are applicable instead of those of the GPL.
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync *
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync * You may elect to license modified versions of this file under the
a55af63ead2dcca370bfc0dfe49771d9dcc61b93vboxsync * terms and conditions of either the GPL or the CDDL or both.
e0778e583cb4a0bdc9bcc48f5957e00a01108388vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
a55af63ead2dcca370bfc0dfe49771d9dcc61b93vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/*******************************************************************************
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync* Header Files *
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync*******************************************************************************/
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#include <iprt/assert.h>
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#include "internal/iprt.h"
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#include <iprt/asm.h>
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#include <iprt/log.h>
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#include <iprt/string.h>
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#include <iprt/stdarg.h>
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#ifdef IN_RING3
57958eb1223628d507daf47ed31ea25c4e8c6da9vboxsync# include <stdio.h>
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync#endif
22d7a125fcbe8650770ac700108b6f27ca1f0dfdvboxsync#include "internal/assert.h"
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync/*******************************************************************************
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync* Global Variables *
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync*******************************************************************************/
b0ad0bbadf3a5b5258acda1bfe16f0ad8bee5ff0vboxsync/** The last assert message, 1st part. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDATADECL(char) g_szRTAssertMsg1[1024];
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(g_szRTAssertMsg1);
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync/** The last assert message, 2nd part. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDATADECL(char) g_szRTAssertMsg2[4096];
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(g_szRTAssertMsg2);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The length of the g_szRTAssertMsg2 content.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * @remarks Race. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncstatic uint32_t volatile g_cchRTAssertMsg2;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The last assert message, expression. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDATADECL(const char * volatile) g_pszRTAssertExpr;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(g_pszRTAssertExpr);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The last assert message, function name. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDATADECL(const char * volatile) g_pszRTAssertFunction;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(g_pszRTAssertFunction);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The last assert message, file name. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDATADECL(const char * volatile) g_pszRTAssertFile;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(g_pszRTAssertFile);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** The last assert message, line number. */
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsyncRTDATADECL(uint32_t volatile) g_u32RTAssertLine;
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsyncRT_EXPORT_SYMBOL(g_u32RTAssertLine);
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync/** Set if assertions are quiet. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncstatic bool volatile g_fQuiet = false;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync/** Set if assertions may panic. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncstatic bool volatile g_fMayPanic = true;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(bool) RTAssertSetQuiet(bool fQuiet)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync{
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync return ASMAtomicXchgBool(&g_fQuiet, fQuiet);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync}
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(RTAssertSetQuiet);
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsyncRTDECL(bool) RTAssertAreQuiet(void)
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync{
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync return ASMAtomicUoReadBool(&g_fQuiet);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync}
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(RTAssertAreQuiet);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(bool) RTAssertSetMayPanic(bool fMayPanic)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync{
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync return ASMAtomicXchgBool(&g_fMayPanic, fMayPanic);
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync}
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(RTAssertSetMayPanic);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
a2d9f81753c129b5e3bbe3769627dcd25a3724bdvboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(bool) RTAssertMayPanic(void)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync{
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync return ASMAtomicUoReadBool(&g_fMayPanic);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync}
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(RTAssertMayPanic);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(void) RTAssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync{
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /*
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * Fill in the globals.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync ASMAtomicUoWritePtr(&g_pszRTAssertExpr, pszExpr);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync ASMAtomicUoWritePtr(&g_pszRTAssertFile, pszFile);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync ASMAtomicUoWritePtr(&g_pszRTAssertFunction, pszFunction);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync ASMAtomicUoWriteU32(&g_u32RTAssertLine, uLine);
7bf07b1592dfaab1a4fb6d497fd0ff1302fb7585vboxsync RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1),
3dd53c06fd54914761cf550503f02fce1ed5a815vboxsync "\n!!Assertion Failed!!\n"
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync "Expression: %s\n"
ffb14f6b8aefea7399c4bf70faab4c9fc26e6cd5vboxsync "Location : %s(%d) %s\n",
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync pszExpr, pszFile, uLine, pszFunction);
ffb14f6b8aefea7399c4bf70faab4c9fc26e6cd5vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /*
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * If not quiet, make noise.
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync if (!RTAssertAreQuiet())
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync {
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#ifdef IN_RING0
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync# ifdef IN_GUEST_R0
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync RTLogBackdoorPrintf("\n!!Assertion Failed!!\n"
83e0da18877bbce83f52a975d9102fbbdb9727a8vboxsync "Expression: %s\n"
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync "Location : %s(%d) %s\n",
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync pszExpr, pszFile, uLine, pszFunction);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# endif
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /** @todo fully integrate this with the logger... play safe a bit for now. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync rtR0AssertNativeMsg1(pszExpr, uLine, pszFile, pszFunction);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#else /* !IN_RING0 */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# if !defined(IN_RING3) && !defined(LOG_NO_COM)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync RTLogComPrintf("\n!!Assertion Failed!!\n"
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync "Expression: %s\n"
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync "Location : %s(%d) %s\n",
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync pszExpr, pszFile, uLine, pszFunction);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# endif
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync PRTLOGGER pLog = RTLogRelDefaultInstance();
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync if (pLog)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync {
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync RTLogRelPrintf("\n!!Assertion Failed!!\n"
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync "Expression: %s\n"
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync "Location : %s(%d) %s\n",
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync pszExpr, pszFile, uLine, pszFunction);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync# ifndef IN_RC /* flushing is done automatically in RC */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync RTLogFlush(pLog);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# endif
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync }
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# ifndef LOG_ENABLED
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync if (!pLog)
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync# endif
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync {
9133c0526e3c7cebf5b3bf9bee5addfd7f298fe0vboxsync pLog = RTLogDefaultInstance();
b304856b23107864c9c594a80cebca6006623f31vboxsync if (pLog)
9133c0526e3c7cebf5b3bf9bee5addfd7f298fe0vboxsync {
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync RTLogPrintf("\n!!Assertion Failed!!\n"
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync "Expression: %s\n"
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync "Location : %s(%d) %s\n",
dbabc9de5bf52ce5eb77cf82b038e9a6166c5a04vboxsync pszExpr, pszFile, uLine, pszFunction);
4cf22805d13f50eef86e917f2c7106fe5198a2d8vboxsync# ifndef IN_RC /* flushing is done automatically in RC */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync RTLogFlush(pLog);
c33fc49611f2444dade533488bf431e29eb88bcdvboxsync# endif
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync }
505b794841d6f18d9917bc4ecaedb0a2782623f8vboxsync }
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync# ifdef IN_RING3
db0ecde8f28fdb4525bc6d94056166c70b02ebb8vboxsync /* print to stderr, helps user and gdb debugging. */
505b794841d6f18d9917bc4ecaedb0a2782623f8vboxsync fprintf(stderr,
9dfcf62b7a5a289684d46ee55f6042d49509daecvboxsync "\n!!Assertion Failed!!\n"
e2760cdc84c692bc46cfaf5018d313db2f122acavboxsync "Expression: %s\n"
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync "Location : %s(%d) %s\n",
b5e852fe286f938722f7d8eb6ab96cced98237e4vboxsync VALID_PTR(pszExpr) ? pszExpr : "<none>",
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync VALID_PTR(pszFile) ? pszFile : "<none>",
b5e852fe286f938722f7d8eb6ab96cced98237e4vboxsync uLine,
49e54e2ffe0c10864d06e9d1ebe24a8eb1327a6bvboxsync VALID_PTR(pszFunction) ? pszFunction : "");
3a0bc95d0adf57baefd303e94b8f1b7b31a8f080vboxsync fflush(stderr);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync# endif
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync#endif /* !IN_RING0 */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync }
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync}
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsyncRT_EXPORT_SYMBOL(RTAssertMsg1);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync/**
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync * Worker for RTAssertMsg2V and RTAssertMsg2AddV
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync *
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync * @param fInitial True if it's RTAssertMsg2V, otherwise false.
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync * @param pszFormat The message format string.
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync * @param va The format arguments.
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync */
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsyncstatic void rtAssertMsg2Worker(bool fInitial, const char *pszFormat, va_list va)
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync{
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync va_list vaCopy;
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync size_t cch;
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync /*
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync * The global first.
9bb98d54790a98dad0ad6d9bdc5d319b6fdf0bffvboxsync */
9bb98d54790a98dad0ad6d9bdc5d319b6fdf0bffvboxsync if (fInitial)
9bb98d54790a98dad0ad6d9bdc5d319b6fdf0bffvboxsync {
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync va_copy(vaCopy, va);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync cch = RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, vaCopy);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync ASMAtomicWriteU32(&g_cchRTAssertMsg2, (uint32_t)cch);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync va_end(vaCopy);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync }
f62342e2cc901a67e27fa69c0e712ee35e9c4c68vboxsync else
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync {
629e8f58c569e4c51a98284c41754fd9f0b973f8vboxsync cch = ASMAtomicReadU32(&g_cchRTAssertMsg2);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync if (cch < sizeof(g_szRTAssertMsg2) - 4)
7c1f498692cd2393f8ba68cb62be482495106f93vboxsync {
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync va_copy(vaCopy, va);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync cch += RTStrPrintfV(&g_szRTAssertMsg2[cch], sizeof(g_szRTAssertMsg2) - cch, pszFormat, vaCopy);
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync ASMAtomicWriteU32(&g_cchRTAssertMsg2, (uint32_t)cch);
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync va_end(vaCopy);
8c58249d7f93d82395aa6c8b31526443892bc375vboxsync }
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync }
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync /*
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync * If not quiet, make some noise.
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync */
b5e852fe286f938722f7d8eb6ab96cced98237e4vboxsync if (!RTAssertAreQuiet())
8cfd6e2b7edd6c0d95653de8e7e237a3ccae99bevboxsync {
8cfd6e2b7edd6c0d95653de8e7e237a3ccae99bevboxsync#ifdef IN_RING0
8cfd6e2b7edd6c0d95653de8e7e237a3ccae99bevboxsync# ifdef IN_GUEST_R0
8cfd6e2b7edd6c0d95653de8e7e237a3ccae99bevboxsync va_copy(vaCopy, va);
8cfd6e2b7edd6c0d95653de8e7e237a3ccae99bevboxsync RTLogBackdoorPrintfV(pszFormat, vaCopy);
8cfd6e2b7edd6c0d95653de8e7e237a3ccae99bevboxsync va_end(vaCopy);
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync# endif
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync /** @todo fully integrate this with the logger... play safe a bit for now. */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync rtR0AssertNativeMsg2V(fInitial, pszFormat, va);
19cb1f8699e352d590c4946caee33863a5157241vboxsync
19cb1f8699e352d590c4946caee33863a5157241vboxsync#else /* !IN_RING0 */
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync# if !defined(IN_RING3) && !defined(LOG_NO_COM)
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync va_copy(vaCopy, va);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync RTLogComPrintfV(pszFormat, vaCopy);
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync va_end(vaCopy);
801238b286a80a5dd67ba56a1f26c0bc98a2a1eavboxsync# endif
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync
9133c0526e3c7cebf5b3bf9bee5addfd7f298fe0vboxsync PRTLOGGER pLog = RTLogRelDefaultInstance();
14f3b3761dd547223728deb999e4ea962fc83280vboxsync if (pLog)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync {
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync va_copy(vaCopy, va);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync RTLogRelPrintfV(pszFormat, vaCopy);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync va_end(vaCopy);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# ifndef IN_RC /* flushing is done automatically in RC */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync RTLogFlush(pLog);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# endif
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync }
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync pLog = RTLogDefaultInstance();
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync if (pLog)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync {
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync va_copy(vaCopy, va);
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync RTLogPrintfV(pszFormat, vaCopy);
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync va_end(vaCopy);
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync# ifndef IN_RC /* flushing is done automatically in RC */
5704a317c3b6bdf4b59f6a6ebe45d443296b1995vboxsync RTLogFlush(pLog);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync#endif
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync }
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync# ifdef IN_RING3
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync /* print to stderr, helps user and gdb debugging. */
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync char szMsg[sizeof(g_szRTAssertMsg2)];
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync va_copy(vaCopy, va);
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, vaCopy);
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync va_end(vaCopy);
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync fprintf(stderr, "%s", szMsg);
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync fflush(stderr);
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync# endif
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync#endif /* !IN_RING0 */
a0644dbbd30adb9bd2937110d6f016e56c4cc52bvboxsync }
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync}
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsyncRTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va)
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync{
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync rtAssertMsg2Worker(true /*fInitial*/, pszFormat, va);
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync}
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(RTAssertMsg2V);
229a63857c5fd2e441a62206eacce4156d0b2a26vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRTDECL(void) RTAssertMsg2AddV(const char *pszFormat, va_list va)
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync{
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync rtAssertMsg2Worker(false /*fInitial*/, pszFormat, va);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync}
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsyncRT_EXPORT_SYMBOL(RTAssertMsg2AddV);
2711c80499bbd95e3da4a6cd2dffd9f81a5dce98vboxsync
d40a840eecf0146eee47c14edaef7ace1ddfb5a6vboxsync