VirtualBox

Ignore:
Timestamp:
Dec 21, 2009 11:06:08 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56209
Message:

iprt/assert.h: Added RTAssertMsg2Add[Weak][V] for dumping the lock deadlock chain and stacks. Added the missing internal/assert.h file to the linux and freebsd kernel source trees.

Location:
trunk/src/VBox/Runtime/common/misc
Files:
1 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/RTAssertMsg2Add.cpp

    r25534 r25536  
    11/* $Id$ */
    22/** @file
    3  * IPRT - RTAssertMsg2.
     3 * IPRT - RTAssertMsg2Add.
    44 */
    55
    66/*
    7  * Copyright (C) 2008 Sun Microsystems, Inc.
     7 * Copyright (C) 2008-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3939
    4040
    41 RTDECL(void) RTAssertMsg2(const char *pszFormat, ...)
     41RTDECL(void) RTAssertMsg2Add(const char *pszFormat, ...)
    4242{
    4343    va_list va;
    4444    va_start(va, pszFormat);
    45     RTAssertMsg2V(pszFormat, va);
     45    RTAssertMsg2AddV(pszFormat, va);
    4646    va_end(va);
    4747}
    48 RT_EXPORT_SYMBOL(RTAssertMsg2);
     48RT_EXPORT_SYMBOL(RTAssertMsg2Add);
    4949
  • trunk/src/VBox/Runtime/common/misc/RTAssertMsg2AddWeak.cpp

    r25534 r25536  
    11/* $Id$ */
    22/** @file
    3  * IPRT - RTAssertMsg2Weak.
     3 * IPRT - RTAssertMsg2AddWeak.
    44 */
    55
     
    3939
    4040
    41 RTDECL(void) RTAssertMsg2Weak(const char *pszFormat, ...)
     41RTDECL(void) RTAssertMsg2AddWeak(const char *pszFormat, ...)
    4242{
    4343    va_list va;
    4444    va_start(va, pszFormat);
    45     RTAssertMsg2WeakV(pszFormat, va);
     45    RTAssertMsg2AddWeakV(pszFormat, va);
    4646    va_end(va);
    4747}
    48 RT_EXPORT_SYMBOL(RTAssertMsg2Weak);
     48RT_EXPORT_SYMBOL(RTAssertMsg2AddWeak);
    4949
  • trunk/src/VBox/Runtime/common/misc/RTAssertMsg2AddWeakV.cpp

    r25534 r25536  
    11/* $Id$ */
    22/** @file
    3  * IPRT - RTAssertMsg2WeakV.
     3 * IPRT - RTAssertMsg2AddWeakV.
    44 */
    55
     
    3737
    3838
    39 RTDECL(void) RTAssertMsg2WeakV(const char *pszFormat, va_list va)
     39RTDECL(void) RTAssertMsg2AddWeakV(const char *pszFormat, va_list va)
    4040{
    41     RTAssertMsg2V(pszFormat, va);
     41    RTAssertMsg2AddV(pszFormat, va);
    4242}
    43 RT_EXPORT_SYMBOL(RTAssertMsg2WeakV);
     43RT_EXPORT_SYMBOL(RTAssertMsg2AddWeakV);
    4444
  • trunk/src/VBox/Runtime/common/misc/assert.cpp

    r25528 r25536  
    5353RT_EXPORT_SYMBOL(g_szRTAssertMsg1);
    5454/** The last assert message, 2nd part. */
    55 RTDATADECL(char)                    g_szRTAssertMsg2[2048];
     55RTDATADECL(char)                    g_szRTAssertMsg2[4096];
    5656RT_EXPORT_SYMBOL(g_szRTAssertMsg2);
     57/** The length of the g_szRTAssertMsg2 content.
     58 * @remarks Race.  */
     59static uint32_t volatile            g_cchRTAssertMsg2;
    5760/** The last assert message, expression. */
    5861RTDATADECL(const char * volatile)   g_pszRTAssertExpr;
     
    188191
    189192
    190 RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va)
     193/**
     194 * Worker for RTAssertMsg2V and RTAssertMsg2AddV
     195 *
     196 * @param   fInitial            True if it's RTAssertMsg2V, otherwise false.
     197 * @param   pszFormat           The message format string.
     198 * @param   va                  The format arguments.
     199 */
     200static void rtAssertMsg2Worker(bool fInitial, const char *pszFormat, va_list va)
    191201{
    192202    va_list vaCopy;
     203    size_t  cch;
    193204
    194205    /*
    195206     * The global first.
    196207     */
    197     va_copy(vaCopy, va);
    198     RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, vaCopy);
    199     va_end(vaCopy);
     208    if (fInitial)
     209    {
     210        va_copy(vaCopy, va);
     211        cch = RTStrPrintfV(g_szRTAssertMsg2, sizeof(g_szRTAssertMsg2), pszFormat, vaCopy);
     212        ASMAtomicWriteU32(&g_cchRTAssertMsg2, (uint32_t)cch);
     213        va_end(vaCopy);
     214    }
     215    else
     216    {
     217        cch = ASMAtomicReadU32(&g_cchRTAssertMsg2);
     218        if (cch < sizeof(g_szRTAssertMsg2) - 4)
     219        {
     220            va_copy(vaCopy, va);
     221            cch += RTStrPrintfV(&g_szRTAssertMsg2[cch], sizeof(g_szRTAssertMsg2) - cch, pszFormat, vaCopy);
     222            ASMAtomicWriteU32(&g_cchRTAssertMsg2, (uint32_t)cch);
     223            va_end(vaCopy);
     224        }
     225    }
    200226
    201227    /*
     
    211237# endif
    212238        /** @todo fully integrate this with the logger... play safe a bit for now.  */
    213         rtR0AssertNativeMsg2V(pszFormat, va);
     239        rtR0AssertNativeMsg2V(fInitial, pszFormat, va);
    214240
    215241#else  /* !IN_RING0 */
     
    255281
    256282}
     283
     284
     285RTDECL(void) RTAssertMsg2V(const char *pszFormat, va_list va)
     286{
     287    rtAssertMsg2Worker(true /*fInitial*/, pszFormat, va);
     288}
    257289RT_EXPORT_SYMBOL(RTAssertMsg2V);
    258290
     291
     292RTDECL(void) RTAssertMsg2AddV(const char *pszFormat, va_list va)
     293{
     294    rtAssertMsg2Worker(false /*fInitial*/, pszFormat, va);
     295}
     296RT_EXPORT_SYMBOL(RTAssertMsg2AddV);
     297
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette