assert-r0drv-freebsd.c revision 5b281ba489ca18f0380d7efc7a5108b606cce449
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync/* $Id$ */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync/** @file
00fa3bc989ffe84474e828c8b90b24284dcfdf0cvboxsync * IPRT - Assertion Workers, Ring-0 Drivers, FreeBSD.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync/*
00fa3bc989ffe84474e828c8b90b24284dcfdf0cvboxsync * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync *
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * Permission is hereby granted, free of charge, to any person
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * obtaining a copy of this software and associated documentation
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * files (the "Software"), to deal in the Software without
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * restriction, including without limitation the rights to use,
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * copy, modify, merge, publish, distribute, sublicense, and/or sell
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * copies of the Software, and to permit persons to whom the
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * Software is furnished to do so, subject to the following
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * conditions:
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync *
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * The above copyright notice and this permission notice shall be
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * included in all copies or substantial portions of the Software.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync *
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0c437bb10c61b229407a7517efde04dfe3b1e4a1vboxsync * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
0c437bb10c61b229407a7517efde04dfe3b1e4a1vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync * OTHER DEALINGS IN THE SOFTWARE.
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync */
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync/*******************************************************************************
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync* Header Files *
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync*******************************************************************************/
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#include "the-freebsd-kernel.h"
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#include <iprt/assert.h>
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#include <iprt/log.h>
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#include <iprt/string.h>
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#include <iprt/stdarg.h>
652d85a9390f54d4c6eca560340bf67ac1f85c9dvboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsyncRTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync{
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync#ifdef IN_GUEST_R0
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync RTLogBackdoorPrintf("\n!!Assertion Failed!!\n"
87e4d5b892065b2de7ba56d4bd471f51022398cfvboxsync "Expression: %s\n"
87e4d5b892065b2de7ba56d4bd471f51022398cfvboxsync "Location : %s(%d) %s\n",
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync pszExpr, pszFile, uLine, pszFunction);
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#endif
ec21c063515d0931111f0c1f8d6f4bc8e7a6c882vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync printf("\r\n!!Assertion Failed!!\r\n"
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync "Expression: %s\r\n"
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync "Location : %s(%d) %s\r\n",
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync pszExpr, pszFile, uLine, pszFunction);
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync}
addc480d0d7650db6323467bbdab6c21836a2928vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsyncRTDECL(void) AssertMsg2(const char *pszFormat, ...)
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync{
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync va_list va;
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync char szMsg[256];
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#ifdef IN_GUEST_R0
1999ae03c34840fa4d712fd2e020120b2cb7182avboxsync va_start(va, pszFormat);
9347f1987dfb760943aba5a9ef094c6066901be3vboxsync RTLogBackdoorPrintfV(pszFormat, va);
1999ae03c34840fa4d712fd2e020120b2cb7182avboxsync va_end(va);
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync#endif
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync va_start(va, pszFormat);
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va);
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync szMsg[sizeof(szMsg) - 1] = '\0';
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync va_end(va);
faa31dfcb46e5e2fb9c2bf224d113a0ca136ddecvboxsync printf("%s", szMsg);
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync}
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync
760446f710619a9daa6cedc7f0601f49e4ea3442vboxsync