1 | /* $Id: assert-r0drv-darwin.cpp 3760 2007-07-22 10:18:54Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * innotek Portable Runtime - Assertion Workers, Ring-0 Drivers, Darwin.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /*******************************************************************************
|
---|
24 | * Header Files *
|
---|
25 | *******************************************************************************/
|
---|
26 | #include "the-darwin-kernel.h"
|
---|
27 |
|
---|
28 | #include <iprt/assert.h>
|
---|
29 | #include <iprt/log.h>
|
---|
30 | #include <iprt/string.h>
|
---|
31 | #include <iprt/stdarg.h>
|
---|
32 |
|
---|
33 | /*******************************************************************************
|
---|
34 | * Global Variables *
|
---|
35 | *******************************************************************************/
|
---|
36 | /** The last assert message, 1st part. */
|
---|
37 | RTDATADECL(char) g_szRTAssertMsg1[1024];
|
---|
38 | /** The last assert message, 2nd part. */
|
---|
39 | RTDATADECL(char) g_szRTAssertMsg2[2048];
|
---|
40 |
|
---|
41 |
|
---|
42 | RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
|
---|
43 | {
|
---|
44 | #ifdef IN_GUEST_R0
|
---|
45 | RTLogBackdoorPrintf("\n!!Assertion Failed!!\n"
|
---|
46 | "Expression: %s\n"
|
---|
47 | "Location : %s(%d) %s\n",
|
---|
48 | pszExpr, pszFile, uLine, pszFunction);
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | printf("\r\n!!Assertion Failed!!\r\n"
|
---|
52 | "Expression: %s\r\n"
|
---|
53 | "Location : %s(%d) %s\r\n",
|
---|
54 | pszExpr, pszFile, uLine, pszFunction);
|
---|
55 |
|
---|
56 | RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1),
|
---|
57 | "\n!!Assertion Failed!!\n"
|
---|
58 | "Expression: %s\n"
|
---|
59 | "Location : %s(%d) %s\n",
|
---|
60 | pszExpr, pszFile, uLine, pszFunction);
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | RTDECL(void) AssertMsg2(const char *pszFormat, ...)
|
---|
65 | {
|
---|
66 | va_list va;
|
---|
67 | char szMsg[256];
|
---|
68 |
|
---|
69 | #ifdef IN_GUEST_R0
|
---|
70 | va_start(va, pszFormat);
|
---|
71 | RTLogBackdoorPrintfV(pszFormat, va);
|
---|
72 | va_end(va);
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | va_start(va, pszFormat);
|
---|
76 | RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va);
|
---|
77 | szMsg[sizeof(szMsg) - 1] = '\0';
|
---|
78 | va_end(va);
|
---|
79 | printf("%s", szMsg);
|
---|
80 |
|
---|
81 | va_start(va, pszFormat);
|
---|
82 | RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, va);
|
---|
83 | va_end(va);
|
---|
84 |
|
---|
85 | panic("%s%s", g_szRTAssertMsg1, g_szRTAssertMsg2);
|
---|
86 | }
|
---|
87 |
|
---|