VirtualBox

Changeset 8402 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Apr 26, 2008 5:13:38 AM (17 years ago)
Author:
vboxsync
Message:

Added %Rhrc, %Rhrf and %Rhra for formatting COM/XPCOM status codes. Added RTErrCOMGet() for looking up these status codes. Note that we're not yet generating the XPCOM database, only the win32/64 one.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r8400 r8402  
    257257        VBox/RTAssertDoBreakpoint-vbox.cpp \
    258258        VBox/log-vbox.cpp
     259ifneq ($(BUILD_TARGET),win)
     260RuntimeR3_SOURCES += \
     261        common/err/errmsgxpcom.cpp
     262endif
    259263
    260264RuntimeR3_SOURCES.win = \
  • trunk/src/VBox/Runtime/common/err/errmsgxpcom.cpp

    r8400 r8402  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Status code messages.
     3 * IPRT - Status code messages for XPCOM.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232*   Header Files                                                               *
    3333*******************************************************************************/
    34 #include <windows.h>
     34//#include <some xpcom header.h>
    3535
    3636#include <iprt/err.h>
     
    3838#include <iprt/string.h>
    3939#include <iprt/err.h>
    40 #include <VBox/err.h>
    4140
    4241
     
    4746 * The data is generated by a sed script.
    4847 */
    49 static const RTWINERRMSG  g_aStatusMsgs[] =
     48static const RTCOMERRMSG  g_aStatusMsgs[] =
    5049{
    51 #include "errmsgcomdata.h"
     50//#include "errmsgxpcomdata.h"
    5251    { NULL, NULL, 0 }
    5352};
     
    5857 */
    5958static char                 g_aszUnknownStr[4][64];
    60 static RTWINERRMSG          g_aUnknownMsgs[4] =
     59static RTCOMERRMSG          g_aUnknownMsgs[4] =
    6160{
    6261    { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 },
     
    7069
    7170
    72 /**
    73  * Get the message corresponding to a given status code.
    74  *
    75  * @returns Pointer to read-only message description.
    76  * @param   rc      The status code.
    77  */
    78 RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc)
     71RTDECL(PCRTCOMERRMSG) RTErrCOMGet(uint32_t rc)
    7972{
    8073    unsigned i;
    81     for (i = 0; i < ELEMENTS(g_aStatusMsgs); i++)
    82     {
     74    for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs); i++)
    8375        if (g_aStatusMsgs[i].iCode == rc)
    84         {
    8576            return &g_aStatusMsgs[i];
    86         }
    87     }
    8877
    8978    /*
    9079     * Need to use the temporary stuff.
    9180     */
    92     int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % ELEMENTS(g_aUnknownMsgs));
     81    int32_t iMsg = (ASMAtomicIncU32(&g_iUnknownMsgs) - 1) % RT_ELEMENTS(g_aUnknownMsgs);
    9382    RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X\n", rc);
    9483    return &g_aUnknownMsgs[iMsg];
    9584}
     85
  • trunk/src/VBox/Runtime/common/string/strformatrt.cpp

    r8245 r8402  
    117117 *                            error code define + full description.
    118118 *
     119 *      - \%Rhrc            - Takes a COM/XPCOM status code as argument. Will insert the status
     120 *                            code define corresponding to the Windows error code.
     121 *      - \%Rhrf            - Takes a COM/XPCOM status code as argument. Will insert the
     122 *                            full description of the specified status code.
     123 *      - \%Rhra            - Takes a COM/XPCOM error code as argument. Will insert the
     124 *                            error code define + full description.
     125 *
    119126 * On other platforms, \%Rw? simply prints the argument in a form of 0xXXXXXXXX.
    120  *
    121  * @todo (r=dmik) Add a cross-platform \%Rcomr? that will fall back to \%Rw? on
    122  * Win32 platforms and will interpret XPCOM result codes on all other.
    123127 *
    124128 *
     
    486490
    487491            /*
    488              * hex dumping.
     492             * hex dumping and COM/XPCOM.
    489493             */
    490494            case 'h':
     
    567571                    }
    568572
     573
     574#ifdef IN_RING3
     575                    /*
     576                     * XPCOM / COM status code: %Rhrc, %Rhrf, %Rhra
     577                     * ASSUMES: If Windows Then COM else XPCOM.
     578                     */
     579                    case 'r':
     580                    {
     581
     582                        char ch = *(*ppszFormat)++;
     583                        uint32_t hrc = va_arg(*pArgs, uint32_t);
     584                        PCRTCOMERRMSG pMsg = RTErrCOMGet(hrc);
     585                        switch (ch)
     586                        {
     587                            case 'c':
     588                                return pfnOutput(pvArgOutput, pMsg->pszDefine, strlen(pMsg->pszDefine));
     589                            case 'f':
     590                                return pfnOutput(pvArgOutput, pMsg->pszMsgFull,strlen(pMsg->pszMsgFull));
     591                            case 'a':
     592                                return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s (0x%08X) - %s", pMsg->pszDefine, hrc, pMsg->pszMsgFull);
     593                            default:
     594                                AssertMsgFailed(("Invalid status code format type '%.10s'!\n", pszFormatOrg));
     595                                return 0;
     596                        }
     597                        break;
     598                    }
     599#endif /* IN_RING3 */
     600
    569601                    default:
    570602                        AssertMsgFailed(("Invalid status code format type '%.10s'!\n", ch, pszFormatOrg));
     
    622654                long rc = va_arg(*pArgs, long);
    623655                char ch = *(*ppszFormat)++;
    624 #if defined(RT_OS_WINDOWS)
     656# if defined(RT_OS_WINDOWS)
    625657                PCRTWINERRMSG pMsg = RTErrWinGet(rc);
    626 #endif
     658# endif
    627659                switch (ch)
    628660                {
    629 #if defined(RT_OS_WINDOWS)
     661# if defined(RT_OS_WINDOWS)
    630662                    case 'c':
    631663                        return pfnOutput(pvArgOutput, pMsg->pszDefine, strlen(pMsg->pszDefine));
     
    634666                    case 'a':
    635667                        return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s (0x%08X) - %s", pMsg->pszDefine, rc, pMsg->pszMsgFull);
    636 #else
     668# else
    637669                    case 'c':
    638670                    case 'f':
    639671                    case 'a':
    640672                        return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "0x%08X", rc);
    641 #endif
     673# endif
    642674                    default:
    643675                        AssertMsgFailed(("Invalid status code format type '%.10s'!\n", pszFormatOrg));
  • trunk/src/VBox/Runtime/win/errmsgwin.cpp

    r8245 r8402  
    3838#include <iprt/string.h>
    3939#include <iprt/err.h>
    40 #include <VBox/err.h>
    4140
    4241
     
    7978{
    8079    unsigned i;
    81     for (i = 0; i < ELEMENTS(g_aStatusMsgs); i++)
    82     {
     80    for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs); i++)
    8381        if (g_aStatusMsgs[i].iCode == rc)
    84         {
    8582            return &g_aStatusMsgs[i];
    86         }
    87     }
    8883
    8984    /*
    9085     * Need to use the temporary stuff.
    9186     */
    92     int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % ELEMENTS(g_aUnknownMsgs));
     87    int32_t iMsg = (ASMAtomicIncU32(&g_iUnknownMsgs) - 1) % RT_ELEMENTS(g_aUnknownMsgs);
    9388    RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X\n", rc);
    9489    return &g_aUnknownMsgs[iMsg];
    9590}
     91
     92
     93RTDECL(PCRTCOMERRMSG) RTErrCOMGet(uint32_t rc)
     94{
     95    return RTErrWinGet((long)rc);
     96}
     97
Note: See TracChangeset for help on using the changeset viewer.

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