Index: trunk/src/VBox/Runtime/common/misc/RTAssertMsg1Weak.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/RTAssertMsg1Weak.cpp	(revision 25525)
+++ trunk/src/VBox/Runtime/common/misc/RTAssertMsg1Weak.cpp	(revision 25528)
@@ -39,8 +39,8 @@
 
 
-RTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
+RTDECL(void) RTAssertMsg1Weak(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
 {
     RTAssertMsg1(pszExpr, uLine, pszFile, pszFunction);
 }
-RT_EXPORT_SYMBOL(AssertMsg1);
+RT_EXPORT_SYMBOL(RTAssertMsg1Weak);
 
Index: trunk/src/VBox/Runtime/common/misc/RTAssertMsg2Weak.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/RTAssertMsg2Weak.cpp	(revision 25525)
+++ trunk/src/VBox/Runtime/common/misc/RTAssertMsg2Weak.cpp	(revision 25528)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2008 Sun Microsystems, Inc.
+ * Copyright (C) 2008-2009 Sun Microsystems, Inc.
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -39,11 +39,11 @@
 
 
-RTDECL(void) AssertMsg2(const char *pszFormat, ...)
+RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...)
 {
     va_list va;
     va_start(va, pszFormat);
-    RTAssertMsg2V(pszFormat, va);
+    RTAssertMsg2WeakV(pszFormat, va);
     va_end(va);
 }
-RT_EXPORT_SYMBOL(AssertMsg2);
+RT_EXPORT_SYMBOL(RTAssertMsg2Weak);
 
Index: trunk/src/VBox/Runtime/common/misc/RTAssertMsg2WeakV.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/RTAssertMsg2WeakV.cpp	(revision 25528)
+++ trunk/src/VBox/Runtime/common/misc/RTAssertMsg2WeakV.cpp	(revision 25528)
@@ -0,0 +1,44 @@
+/* $Id$ */
+/** @file
+ * IPRT - RTAssertMsg2WeakV.
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <iprt/assert.h>
+#include "internal/iprt.h"
+
+
+RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat, va_list va)
+{
+    RTAssertMsg2V(pszFormat, va);
+}
+RT_EXPORT_SYMBOL(RTAssertMsg2WeakV);
+
Index: trunk/src/VBox/Runtime/common/misc/assert.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/assert.cpp	(revision 25525)
+++ trunk/src/VBox/Runtime/common/misc/assert.cpp	(revision 25528)
@@ -1,9 +1,9 @@
 /* $Id$ */
 /** @file
- * IPRT - Assertion Workers.
+ * IPRT - Assertions, common code.
  */
 
 /*
- * Copyright (C) 2006-2007 Sun Microsystems, Inc.
+ * Copyright (C) 2006-2009 Sun Microsystems, Inc.
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -43,4 +43,5 @@
 # include <stdio.h>
 #endif
+#include "internal/assert.h"
 
 
@@ -48,8 +49,28 @@
 *   Global Variables                                                           *
 *******************************************************************************/
+/** The last assert message, 1st part. */
+RTDATADECL(char)                    g_szRTAssertMsg1[1024];
+RT_EXPORT_SYMBOL(g_szRTAssertMsg1);
+/** The last assert message, 2nd part. */
+RTDATADECL(char)                    g_szRTAssertMsg2[2048];
+RT_EXPORT_SYMBOL(g_szRTAssertMsg2);
+/** The last assert message, expression. */
+RTDATADECL(const char * volatile)   g_pszRTAssertExpr;
+RT_EXPORT_SYMBOL(g_pszRTAssertExpr);
+/** The last assert message, function name. */
+RTDATADECL(const char *  volatile)  g_pszRTAssertFunction;
+RT_EXPORT_SYMBOL(g_pszRTAssertFunction);
+/** The last assert message, file name. */
+RTDATADECL(const char * volatile)   g_pszRTAssertFile;
+RT_EXPORT_SYMBOL(g_pszRTAssertFile);
+/** The last assert message, line number. */
+RTDATADECL(uint32_t volatile)       g_u32RTAssertLine;
+RT_EXPORT_SYMBOL(g_u32RTAssertLine);
+
+
 /** Set if assertions are quiet. */
-static bool volatile g_fQuiet = false;
+static bool volatile                g_fQuiet = false;
 /** Set if assertions may panic. */
-static bool volatile g_fMayPanic = true;
+static bool volatile                g_fMayPanic = true;
 
 
@@ -58,4 +79,5 @@
     return ASMAtomicXchgBool(&g_fQuiet, fQuiet);
 }
+RT_EXPORT_SYMBOL(RTAssertSetQuiet);
 
 
@@ -64,4 +86,5 @@
     return ASMAtomicUoReadBool(&g_fQuiet);
 }
+RT_EXPORT_SYMBOL(RTAssertAreQuiet);
 
 
@@ -70,4 +93,5 @@
     return ASMAtomicXchgBool(&g_fMayPanic, fMayPanic);
 }
+RT_EXPORT_SYMBOL(RTAssertSetMayPanic);
 
 
@@ -76,37 +100,44 @@
     return ASMAtomicUoReadBool(&g_fMayPanic);
 }
-
-
-#ifdef IN_RING0
-
-/* OS specific.  */
-
-#else /* !IN_RING0 */
-
-
-/** The last assert message, 1st part. */
-RTDATADECL(char) g_szRTAssertMsg1[1024];
-/** The last assert message, 2nd part. */
-RTDATADECL(char) g_szRTAssertMsg2[2048];
-
-/**
- * The 1st part of an assert message.
- *
- * @param   pszExpr     Expression. Can be NULL.
- * @param   uLine       Location line number.
- * @param   pszFile     Location file name.
- * @param   pszFunction Location function name.
- * @remark  This API exists in HC Ring-3 and GC.
- */
-RTDECL(void)    AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
-{
+RT_EXPORT_SYMBOL(RTAssertMayPanic);
+
+
+RTDECL(void) RTAssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
+{
+    /*
+     * Fill in the globals.
+     */
+    ASMAtomicUoWritePtr((void * volatile *)&g_pszRTAssertExpr, (void *)pszExpr);
+    ASMAtomicUoWritePtr((void * volatile *)&g_pszRTAssertFile, (void *)pszFile);
+    ASMAtomicUoWritePtr((void * volatile *)&g_pszRTAssertFunction, (void *)pszFunction);
+    ASMAtomicUoWriteU32(&g_u32RTAssertLine, uLine);
+    RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1),
+                "\n!!Assertion Failed!!\n"
+                "Expression: %s\n"
+                "Location  : %s(%d) %s\n",
+                pszExpr, pszFile, uLine, pszFunction);
+
+    /*
+     * If not quiet, make noise.
+     */
     if (!RTAssertAreQuiet())
     {
-#if !defined(IN_RING3) && !defined(LOG_NO_COM)
+#ifdef IN_RING0
+# ifdef IN_GUEST_R0
+        RTLogBackdoorPrintf("\n!!Assertion Failed!!\n"
+                            "Expression: %s\n"
+                            "Location  : %s(%d) %s\n",
+                            pszExpr, pszFile, uLine, pszFunction);
+# endif
+        /** @todo fully integrate this with the logger... play safe a bit for now.  */
+        rtR0AssertNativeMsg1(pszExpr, uLine, pszFile, pszFunction);
+
+#else  /* !IN_RING0 */
+# if !defined(IN_RING3) && !defined(LOG_NO_COM)
         RTLogComPrintf("\n!!Assertion Failed!!\n"
                        "Expression: %s\n"
                        "Location  : %s(%d) %s\n",
                        pszExpr, pszFile, uLine, pszFunction);
-#endif
+# endif
 
         PRTLOGGER pLog = RTLogRelDefaultInstance();
@@ -117,12 +148,12 @@
                            "Location  : %s(%d) %s\n",
                            pszExpr, pszFile, uLine, pszFunction);
-#ifndef IN_RC /* flushing is done automatically in RC */
+# ifndef IN_RC /* flushing is done automatically in RC */
             RTLogFlush(pLog);
-#endif
-        }
-
-#ifndef LOG_ENABLED
+# endif
+        }
+
+# ifndef LOG_ENABLED
         if (!pLog)
-#endif
+# endif
         {
             pLog = RTLogDefaultInstance();
@@ -133,11 +164,11 @@
                             "Location  : %s(%d) %s\n",
                             pszExpr, pszFile, uLine, pszFunction);
-#ifndef IN_RC /* flushing is done automatically in RC */
+# ifndef IN_RC /* flushing is done automatically in RC */
                 RTLogFlush(pLog);
-#endif
+# endif
             }
         }
 
-#ifdef IN_RING3
+# ifdef IN_RING3
         /* print to stderr, helps user and gdb debugging. */
         fprintf(stderr,
@@ -150,72 +181,78 @@
                 VALID_PTR(pszFunction) ? pszFunction : "");
         fflush(stderr);
-#endif
+# endif
+#endif /* !IN_RING0 */
     }
-
-    RTStrPrintf(g_szRTAssertMsg1, sizeof(g_szRTAssertMsg1),
-                "\n!!Assertion Failed!!\n"
-                "Expression: %s\n"
-                "Location  : %s(%d) %s\n",
-                pszExpr, pszFile, uLine, pszFunction);
-}
-
-
-/**
- * The 2nd (optional) part of an assert message.
- *
- * @param   pszFormat   Printf like format string.
- * @param   ...         Arguments to that string.
- * @remark  This API exists in HC Ring-3 and GC.
- */
-RTDECL(void)    AssertMsg2(const char *pszFormat, ...)
-{
-    va_list args;
-
+}
+RT_EXPORT_SYMBOL(RTAssertMsg1);
+
+
+RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va)
+{
+    va_list vaCopy;
+
+    /*
+     * The global first.
+     */
+    va_copy(vaCopy, va);
+    RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, vaCopy);
+    va_end(vaCopy);
+
+    /*
+     * If not quiet, make some noise.
+     */
     if (!RTAssertAreQuiet())
     {
-#if !defined(IN_RING3) && !defined(LOG_NO_COM)
-        va_start(args, pszFormat);
-        RTLogComPrintfV(pszFormat, args);
-        va_end(args);
-#endif
+#ifdef IN_RING0
+# ifdef IN_GUEST_R0
+        va_copy(vaCopy, va);
+        RTLogBackdoorPrintfV(pszFormat, vaCopy);
+        va_end(vaCopy);
+# endif
+        /** @todo fully integrate this with the logger... play safe a bit for now.  */
+        rtR0AssertNativeMsg2V(pszFormat, va);
+
+#else  /* !IN_RING0 */
+# if !defined(IN_RING3) && !defined(LOG_NO_COM)
+        va_copy(vaCopy, va);
+        RTLogComPrintfV(pszFormat, vaCopy);
+        va_end(vaCopy);
+# endif
 
         PRTLOGGER pLog = RTLogRelDefaultInstance();
         if (pLog)
         {
-            va_start(args, pszFormat);
-            RTLogRelPrintfV(pszFormat, args);
-            va_end(args);
-#ifndef IN_RC /* flushing is done automatically in RC */
+            va_copy(vaCopy, va);
+            RTLogRelPrintfV(pszFormat, vaCopy);
+            va_end(vaCopy);
+# ifndef IN_RC /* flushing is done automatically in RC */
+            RTLogFlush(pLog);
+# endif
+        }
+
+        pLog = RTLogDefaultInstance();
+        if (pLog)
+        {
+            va_copy(vaCopy, va);
+            RTLogPrintfV(pszFormat, vaCopy);
+            va_end(vaCopy);
+# ifndef IN_RC /* flushing is done automatically in RC */
             RTLogFlush(pLog);
 #endif
         }
 
-        pLog = RTLogDefaultInstance();
-        if (pLog)
-        {
-            va_start(args, pszFormat);
-            RTLogPrintfV(pszFormat, args);
-            va_end(args);
-#ifndef IN_RC /* flushing is done automatically in RC */
-            RTLogFlush(pLog);
-#endif
-        }
-
-#ifdef IN_RING3
+# ifdef IN_RING3
         /* print to stderr, helps user and gdb debugging. */
         char szMsg[1024];
-        va_start(args, pszFormat);
-        RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, args);
-        va_end(args);
+        va_copy(vaCopy, va);
+        RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, vaCopy);
+        va_end(vaCopy);
         fprintf(stderr, "%s", szMsg);
         fflush(stderr);
-#endif
+# endif
+#endif /* !IN_RING0 */
     }
 
-    va_start(args, pszFormat);
-    RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, args);
-    va_end(args);
-}
-
-#endif /* !IN_RING0 */
-
+}
+RT_EXPORT_SYMBOL(RTAssertMsg2V);
+
Index: trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 25525)
+++ trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 25528)
@@ -819,5 +819,5 @@
                                                  PRTTHREADINT pCur, PCRTLOCKVALIDATORSRCPOS pSrcPos)
 {
-    AssertMsg1(pCur == pThread ? "!!Deadlock detected!!" : "!!Deadlock exists!!", pSrcPos->uLine, pSrcPos->pszFile, pSrcPos->pszFunction);
+    RTAssertMsg1Weak(pCur == pThread ? "!!Deadlock detected!!" : "!!Deadlock exists!!", pSrcPos->uLine, pSrcPos->pszFile, pSrcPos->pszFunction);
 
     /*
@@ -832,8 +832,8 @@
          * Print info on pCur. Determin next while doing so.
          */
-        AssertMsg2(" #%u: %RTthrd/%RTnthrd %s: %s(%u) %RTptr\n",
-                   iEntry, pCur, pCur->Core.Key, pCur->szName,
-                   pCur->LockValidator.SrcPos.pszFile, pCur->LockValidator.SrcPos.uLine,
-                   pCur->LockValidator.SrcPos.pszFunction, pCur->LockValidator.SrcPos.uId);
+        RTAssertMsg2Weak(" #%u: %RTthrd/%RTnthrd %s: %s(%u) %RTptr\n",
+                         iEntry, pCur, pCur->Core.Key, pCur->szName,
+                         pCur->LockValidator.SrcPos.pszFile, pCur->LockValidator.SrcPos.uLine,
+                         pCur->LockValidator.SrcPos.pszFunction, pCur->LockValidator.SrcPos.uId);
         PRTTHREADINT  pNext       = NULL;
         RTTHREADSTATE enmCurState = rtThreadGetState(pCur);
@@ -853,6 +853,6 @@
                 if (enmCurState2 != enmCurState)
                 {
-                    AssertMsg2(" Impossible!!! enmState=%s -> %s (%d)\n",
-                               RTThreadStateName(enmCurState), RTThreadStateName(enmCurState2), enmCurState2);
+                    RTAssertMsg2Weak(" Impossible!!! enmState=%s -> %s (%d)\n",
+                                     RTThreadStateName(enmCurState), RTThreadStateName(enmCurState2), enmCurState2);
                     break;
                 }
@@ -860,20 +860,20 @@
                     && pCurRec->u32Magic == RTLOCKVALIDATORREC_MAGIC)
                 {
-                    AssertMsg2("     Waiting on %s %p [%s]: Entered %s(%u) %s %p\n",
-                               RTThreadStateName(enmCurState), pCurRec->hLock, pCurRec->pszName,
-                               pCurRec->SrcPos.pszFile, pCurRec->SrcPos.uLine, pCurRec->SrcPos.pszFunction, pCurRec->SrcPos.uId);
+                    RTAssertMsg2Weak("     Waiting on %s %p [%s]: Entered %s(%u) %s %p\n",
+                                     RTThreadStateName(enmCurState), pCurRec->hLock, pCurRec->pszName,
+                                     pCurRec->SrcPos.pszFile, pCurRec->SrcPos.uLine, pCurRec->SrcPos.pszFunction, pCurRec->SrcPos.uId);
                     pNext = pCurRec->hThread;
                 }
                 else if (VALID_PTR(pCurRec))
-                    AssertMsg2("     Waiting on %s pCurRec=%p: invalid magic number: %#x\n",
-                               RTThreadStateName(enmCurState), pCurRec, pCurRec->u32Magic);
+                    RTAssertMsg2Weak("     Waiting on %s pCurRec=%p: invalid magic number: %#x\n",
+                                     RTThreadStateName(enmCurState), pCurRec, pCurRec->u32Magic);
                 else
-                    AssertMsg2("     Waiting on %s pCurRec=%p: invalid pointer\n",
-                               RTThreadStateName(enmCurState), pCurRec);
+                    RTAssertMsg2Weak("     Waiting on %s pCurRec=%p: invalid pointer\n",
+                                     RTThreadStateName(enmCurState), pCurRec);
                 break;
             }
 
             default:
-                AssertMsg2(" Impossible!!! enmState=%s (%d)\n", RTThreadStateName(enmCurState), enmCurState);
+                RTAssertMsg2Weak(" Impossible!!! enmState=%s (%d)\n", RTThreadStateName(enmCurState), enmCurState);
                 break;
         }
@@ -887,5 +887,5 @@
             if (apSeenThreads[i] == pCur)
             {
-                AssertMsg2(" Cycle!\n");
+                RTAssertMsg2Weak(" Cycle!\n");
                 pNext = NULL;
                 break;
Index: trunk/src/VBox/Runtime/common/misc/thread.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/thread.cpp	(revision 25525)
+++ trunk/src/VBox/Runtime/common/misc/thread.cpp	(revision 25528)
@@ -192,5 +192,5 @@
     g_ThreadSpinlock = NIL_RTSPINLOCK;
     if (g_ThreadTree != NULL)
-        AssertMsg2("WARNING: g_ThreadTree=%p\n", g_ThreadTree);
+        RTAssertMsg2Weak("WARNING: g_ThreadTree=%p\n", g_ThreadTree);
 #endif
 }
