assert-r0drv-nt.cpp revision fe1394d91c571fee8cccf07cda953d4313cc35df
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync/* $Id$ */
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync/** @file
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * IPRT - Assertion Workers, Ring-0 Drivers, NT.
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync */
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync/*
5654aa8329bbe2838fa5733f28c1a0461c9e6453vboxsync * Copyright (C) 2006-2008 Sun Microsystems, Inc.
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync *
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * available from http://www.virtualbox.org. This file is free software;
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync *
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * The contents of this file may alternatively be used under the terms
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * of the Common Development and Distribution License Version 1.0
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync * VirtualBox OSE distribution, in which case the provisions of the
f84cd77241a1c4b9106a92280611c659243e10d1vboxsync * CDDL are applicable instead of those of the GPL.
2508d15edddcae0b79002fae3fe103d6c4836810vboxsync *
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * You may elect to license modified versions of this file under the
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * terms and conditions of either the GPL or the CDDL or both.
2508d15edddcae0b79002fae3fe103d6c4836810vboxsync *
0c437bb10c61b229407a7517efde04dfe3b1e4a1vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
0c437bb10c61b229407a7517efde04dfe3b1e4a1vboxsync * additional information or have any questions.
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync */
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync/*******************************************************************************
209c11e4b5dbb310116c99a42d773163928e002bvboxsync* Header Files *
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync*******************************************************************************/
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync#include "the-nt-kernel.h"
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync#include <iprt/assert.h>
7c9a5eca233baf6ede345ace077a00bd0b7af1efvboxsync#include <iprt/log.h>
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync#include <iprt/string.h>
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync#include <iprt/stdarg.h>
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync/*******************************************************************************
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync* Global Variables *
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync*******************************************************************************/
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync/** The last assert message, 1st part. */
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsyncRTDATADECL(char) g_szRTAssertMsg1[1024];
611910c4ba57eb6db5c0d508ca7b923efd654aecvboxsync/** The last assert message, 2nd part. */
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsyncRTDATADECL(char) g_szRTAssertMsg2[2048];
134a71c1528b56afe4db843ab63ec5a5b849535bvboxsync
289060a0c3cb1d509f2cb01fca060796212376f6vboxsync
289060a0c3cb1d509f2cb01fca060796212376f6vboxsyncRTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
289060a0c3cb1d509f2cb01fca060796212376f6vboxsync{
289060a0c3cb1d509f2cb01fca060796212376f6vboxsync#ifdef IN_GUEST_R0
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync RTLogBackdoorPrintf("\n!!Assertion Failed!!\n"
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync "Expression: %s\n"
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync "Location : %s(%d) %s\n",
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync pszExpr, pszFile, uLine, pszFunction);
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync#endif
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync DbgPrint("\n!!Assertion Failed!!\n"
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync "Expression: %s\n"
4bfa7b58e362a1bca0628643c352c137900bf01avboxsync "Location : %s(%d) %s\n",
df25990f935e7fd32acd9be9a156aff8d10facf2vboxsync pszExpr, pszFile, uLine, pszFunction);
6420f75ffc86ab6494eb5e95418f0c95e71e8068vboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1),
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync "\n!!Assertion Failed!!\n"
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync "Expression: %s\n"
faf968cea88f2ab4bcc3325b17bc8b095a8e3642vboxsync "Location : %s(%d) %s\n",
3609dfc9f2733f4dc836c6a6bb3745398f280fcevboxsync pszExpr, pszFile, uLine, pszFunction);
c7a00ac75c7941df2afb62e6fd7ffdf1795e6c76vboxsync}
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsyncRTDECL(void) AssertMsg2(const char *pszFormat, ...)
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync{
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync va_list va;
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync char szMsg[256];
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync# ifdef IN_GUEST_R0
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync va_start(va, pszFormat);
ff78b877ed7acd25e2d384570a938441455d6a95vboxsync RTLogBackdoorPrintfV(pszFormat, va);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync va_end(va);
683371bbf37760161d1b8454ce978acf89bbb04fvboxsync# endif
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync va_start(va, pszFormat);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va);
f94f82d66536c7332c347dd9a3a9f0f8c79247f4vboxsync szMsg[sizeof(szMsg) - 1] = '\0';
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync va_end(va);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync DbgPrint("%s", szMsg);
43dff6077acb4176145b18bdb862eb73620182d2vboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync va_start(va, pszFormat);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, va);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync va_end(va);
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync}
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync
436b5c616e019c5e62053657c52d3ab5562ecbbfvboxsync