VirtualBox

Changeset 16530 in vbox


Ignore:
Timestamp:
Feb 5, 2009 4:08:49 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
42461
Message:

Main: rework error macros everywhere; make error messages much more readable (esp. with VBoxManage); use shared function to actually print message; reduces size of VBoxManage debug build from 3.4 to 2.3 MB

Location:
trunk
Files:
17 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/assert.h

    r13856 r16530  
    137137    if (!SUCCEEDED (rc)) { throw rc; } else do {} while (0)
    138138
    139 /*
    140  * A section of helpful macros for error output
    141  */
    142 
    143 /**
    144  *  Prints a line describing the given COM result code.
    145  *  Used by command line tools or for debugging.
    146  */
    147 #define PRINT_RC_MESSAGE(rc) \
    148     do { \
    149         RTPrintf ("[!] Primary RC  = %Rhra\n", rc); \
    150         Log (("[!] Primary RC  = %Rhra\n", rc)); \
    151     } while (0)
    152 
    153 /**
    154  *  Prints the extended error information.
    155  *  Used by command line tools or for debugging.
    156  *
    157  *  @param info com::ErrorInfo instance
    158  */
    159 #define PRINT_ERROR_INFO(info) \
    160     do { \
    161         RTPrintf ("[!] Full error info present: %RTbool, basic error info present: %RTbool\n", \
    162                   info.isFullAvailable(), info.isBasicAvailable()); \
    163         Log (("[!] Full error info present: %RTbool, basic error info present: %RTbool\n", \
    164               info.isFullAvailable(), info.isBasicAvailable())); \
    165         if (info.isFullAvailable() || info.isBasicAvailable()) { \
    166             RTPrintf ("[!] Result Code = %Rhra\n", info.getResultCode()); \
    167             RTPrintf ("[!] Text        = %ls\n", info.getText().raw()); \
    168             RTPrintf ("[!] Component   = %ls, Interface: %ls, {%RTuuid}\n", \
    169                       info.getComponent().raw(), info.getInterfaceName().raw(), \
    170                       info.getInterfaceID().raw()); \
    171             RTPrintf ("[!] Callee      = %ls, {%RTuuid}\n", \
    172                       info.getCalleeName().raw(), info.getCalleeIID().raw()); \
    173             Log (("[!] Result Code = %Rhra\n", info.getResultCode())); \
    174             Log (("[!] Text        = %ls\n", info.getText().raw())); \
    175             Log (("[!] Component   = %ls, Interface: %ls, {%RTuuid}\n", \
    176                   info.getComponent().raw(), info.getInterfaceName().raw(), \
    177                   info.getInterfaceID().raw())); \
    178             Log (("[!] Callee      = %ls, {%RTuuid}\n", \
    179                   info.getCalleeName().raw(), info.getCalleeIID().raw())); \
    180         } \
    181     } while (0)
    182 
    183 /**
    184  *  Calls the given interface method and then checks if the return value
    185  *  (COM result code) indicates a failure. If so, prints the failed
    186  *  function/line/file and the description of the result code.
    187  *
    188  *  Used by command line tools or for debugging and assumes the |HRESULT rc|
    189  *  variable is accessible for assigning in the current scope.
    190  */
    191 #define CHECK_RC(method) \
    192     do { \
    193         rc = method; \
    194         if (FAILED (rc)) { \
    195             RTPrintf ("[!] FAILED calling " #method " at line %d!\n", __LINE__); \
    196             Log (("[!] FAILED calling " #method " at line %d!\n", __LINE__)); \
    197             PRINT_RC_MESSAGE(rc); \
    198         } \
    199     } while (0)
    200 
    201 /**
    202  *  Does the same as CHECK_RC(), but executes the |return rc| statement on
    203  *  failure.
    204  */
    205 #define CHECK_RC_RET(method) \
    206     do { CHECK_RC (method); if (FAILED (rc)) return rc; } while (0)
    207 
    208 /**
    209  *  Does the same as CHECK_RC(), but executes the |break| statement on
    210  *  failure.
    211  */
    212 #define CHECK_RC_BREAK(method) \
    213     if (1) { CHECK_RC (method); if (FAILED (rc)) break; } else do {} while (0)
    214 
    215 /**
    216  *  Calls the given method of the given interface and then checks if the return
    217  *  value (COM result code) indicates a failure. If so, prints the failed
    218  *  function/line/file, the description of the result code and attempts to
    219  *  query the extended error information on the current thread (using
    220  *  com::ErrorInfo) if the interface reports that it supports error information.
    221  *
    222  *  Used by command line tools or for debugging and assumes the |HRESULT rc|
    223  *  variable is accessible for assigning in the current scope.
    224  */
    225 #define CHECK_ERROR(iface, method) \
    226     do \
    227     { \
    228         CHECK_RC(iface->method); \
    229         if (FAILED(rc)) { \
    230             com::ErrorInfo info (iface); \
    231             PRINT_ERROR_INFO (info); \
    232         } \
    233     } while (0)
    234 
    235 /**
    236  *  Does the same as CHECK_ERROR(), but executes the |return ret| statement on
    237  *  failure.
    238  */
    239 #define CHECK_ERROR_RET(iface, method, ret) \
    240     do { CHECK_ERROR (iface, method); if (FAILED (rc)) return (ret); } while (0)
    241 
    242 /**
    243  *  Does the same as CHECK_ERROR(), but executes the |break| statement on
    244  *  failure.
    245  */
    246 #if defined(__GNUC__)
    247  #define CHECK_ERROR_BREAK(iface, method) \
    248     ({ CHECK_ERROR (iface, method); if (FAILED (rc)) break; })
    249 #else
    250  #define CHECK_ERROR_BREAK(iface, method) \
    251     if (1) { CHECK_ERROR (iface, method); if (FAILED (rc)) break; } else do {} while (0)
    252 #endif
    253 
    254 #define CHECK_ERROR_NOCALL() \
    255     do { \
    256         com::ErrorInfo info; \
    257         PRINT_ERROR_INFO (info); \
    258     } while (0)
    259 
    260 /**
    261  *  Does the same as CHECK_ERROR(), but doesn't need the interface pointer
    262  *  because doesn't do a check whether the interface supports error info or not.
    263  */
    264 #define CHECK_ERROR_NI(method) \
    265     do { \
    266         CHECK_RC (method); \
    267         if (FAILED (rc)) { \
    268             com::ErrorInfo info; \
    269             PRINT_ERROR_INFO (info); \
    270         } \
    271     } while (0)
    272 
    273 /**
    274  *  Does the same as CHECK_ERROR_NI(), but executes the |return rc| statement
    275  *  on failure.
    276  */
    277 #define CHECK_ERROR_NI_RET(method) \
    278     do { CHECK_ERROR_NI (method); if (FAILED (rc)) return rc; } while (0)
    279 
    280 /**
    281  *  Does the same as CHECK_ERROR_NI(), but executes the |break| statement
    282  *  on failure.
    283  */
    284 #define CHECK_ERROR_NI_BREAK(method) \
    285     if (1) { CHECK_ERROR_NI (method); if (FAILED (rc)) break; } else do {} while (0)
    286 
    287 
    288 /**
    289  *  Asserts the given expression is true. When the expression is false, prints
    290  *  a line containing the failed function/line/file; otherwise does nothing.
    291  */
    292 #define ASSERT(expr) \
    293     do { \
    294         if (!(expr)) \
    295         { \
    296             RTPrintf ("[!] ASSERTION FAILED at line %d: %s\n", __LINE__, #expr); \
    297             Log (("[!] ASSERTION FAILED at line %d: %s\n", __LINE__, #expr)); \
    298         } \
    299     } while (0)
    300 
    301 /**
    302  *  Does the same as ASSERT(), but executes the |return ret| statement if the
    303  *  expression to assert is false.
    304  */
    305 #define ASSERT_RET(expr, ret) \
    306     do { ASSERT (expr); if (!(expr)) return (ret); } while (0)
    307 
    308 /**
    309  *  Does the same as ASSERT(), but executes the |break| statement if the
    310  *  expression to assert is false.
    311  */
    312 #define ASSERT_BREAK(expr) \
    313     if (1) { ASSERT (expr); if (!(expr)) break; } else do {} while (0)
    314 
    315139
    316140#endif
  • trunk/include/VBox/com/errorprint_legacy.h

    r16526 r16530  
    11/** @file
    22 * MS COM / XPCOM Abstraction Layer:
    3  * Assertion macros for COM/XPCOM
     3 * Legacy error printing macros for COM/XPCOM (used with testcases).
     4 *
     5 * NOTE: to lighten the load on the compilers, please use the shared
     6 * functions in errorprint2.h for new code.
    47 */
    58
    69/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     10 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
    811 *
    912 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2932 */
    3033
    31 #ifndef ___VBox_com_assert_h
    32 #define ___VBox_com_assert_h
     34#ifndef ___VBox_com_errorprint_legacy_h
     35#define ___VBox_com_errorprint_legacy_h
    3336
    3437#include <iprt/assert.h>
    35 
    36 /**
    37  *  Asserts that the COM result code is succeeded in strict builds.
    38  *  In non-strict builds the result code will be NOREF'ed to kill compiler warnings.
    39  *
    40  *  @param rc   COM result code
    41  */
    42 #define AssertComRC(rc)      \
    43     do { AssertMsg (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc)); NOREF (rc); } while (0)
    44 
    45 /**
    46  *  A special version of AssertComRC that returns the given expression
    47  *  if the result code is failed.
    48  *
    49  *  @param rc   COM result code
    50  *  @param ret  the expression to return
    51  */
    52 #define AssertComRCReturn(rc, ret)      \
    53     AssertMsgReturn (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc), ret)
    54 
    55 /**
    56  *  A special version of AssertComRC that returns the given result code
    57  *  if it is failed.
    58  *
    59  *  @param rc   COM result code
    60  *  @param ret  the expression to return
    61  */
    62 #define AssertComRCReturnRC(rc)         \
    63     AssertMsgReturn (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc), rc)
    64 
    65 /**
    66  *  A special version of AssertComRC that returns if the result code is failed.
    67  *
    68  *  @param rc   COM result code
    69  *  @param ret  the expression to return
    70  */
    71 #define AssertComRCReturnVoid(rc)      \
    72     AssertMsgReturnVoid (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc))
    73 
    74 /**
    75  *  A special version of AssertComRC that evaluates the given expression and
    76  *  breaks if the result code is failed.
    77  *
    78  *  @param rc   COM result code
    79  *  @param eval the expression to evaluate
    80  */
    81 #define AssertComRCBreak(rc, eval)      \
    82     if (!SUCCEEDED (rc)) { AssertComRC (rc); eval; break; } else do {} while (0)
    83 
    84 /**
    85  *  A special version of AssertComRC that evaluates the given expression and
    86  *  throws it if the result code is failed.
    87  *
    88  *  @param rc   COM result code
    89  *  @param eval the expression to throw
    90  */
    91 #define AssertComRCThrow(rc, eval)      \
    92     if (!SUCCEEDED (rc)) { AssertComRC (rc); throw (eval); } else do {} while (0)
    93 
    94 /**
    95  *  A special version of AssertComRC that just breaks if the result code is
    96  *  failed.
    97  *
    98  *  @param rc   COM result code
    99  */
    100 #define AssertComRCBreakRC(rc)          \
    101     if (!SUCCEEDED (rc)) { AssertComRC (rc); break; } else do {} while (0)
    102 
    103 /**
    104  *  A special version of AssertComRC that just throws @a rc if the result code is
    105  *  failed.
    106  *
    107  *  @param rc   COM result code
    108  */
    109 #define AssertComRCThrowRC(rc)          \
    110     if (!SUCCEEDED (rc)) { AssertComRC (rc); throw rc; } else do {} while (0)
    111 
    112 /**
    113  *  Checks whether the given COM result code is successful.
    114  *  If not, executes the return statement with this result code.
    115  *
    116  *  @param rc   COM result code
    117  */
    118 #define CheckComRCReturnRC(rc)      \
    119     if (!SUCCEEDED (rc)) { return (rc); } else do {} while (0)
    120 
    121 /**
    122  *  Checks whether the given COM result code is successful.
    123  *  If not, executes the break statement.
    124  *
    125  *  @param rc   COM result code
    126  */
    127 #define CheckComRCBreakRC(rc)      \
    128     if (!SUCCEEDED (rc)) { break; } else do {} while (0)
    129 
    130 /**
    131  *  Checks whether the given COM result code is successful.
    132  *  If not, throws the given COM result.
    133  *
    134  *  @param rc   COM result code
    135  */
    136 #define CheckComRCThrowRC(rc)      \
    137     if (!SUCCEEDED (rc)) { throw rc; } else do {} while (0)
    13838
    13939/*
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r16152 r16530  
    2525#include <VBox/com/Guid.h>
    2626#include <VBox/com/ErrorInfo.h>
     27#include <VBox/com/errorprint2.h>
    2728#include <VBox/com/EventQueue.h>
    2829
     
    617618
    618619    rc = com::Initialize();
    619     if (FAILED (rc))
     620    if (FAILED(rc))
     621    {
     622        RTPrintf("ERROR: failed to initialize COM!\n");
    620623        return rc;
     624    }
    621625
    622626    do
    623627    {
    624         ComPtr <IVirtualBox> virtualBox;
    625         ComPtr <ISession> session;
    626 
    627         /* create VirtualBox object */
    628         rc = virtualBox.createLocalObject (CLSID_VirtualBox);
    629         if (FAILED (rc))
     628        ComPtr<IVirtualBox> virtualBox;
     629        ComPtr<ISession> session;
     630
     631        rc = virtualBox.createLocalObject(CLSID_VirtualBox);
     632        if (FAILED(rc))
     633            RTPrintf("ERROR: failed to create the VirtualBox object!\n");
     634        else
     635        {
     636            rc = session.createInprocObject(CLSID_Session);
     637            if (FAILED(rc))
     638                RTPrintf("ERROR: failed to create a session object!\n");
     639        }
     640
     641        if (FAILED(rc))
    630642        {
    631643            com::ErrorInfo info;
    632             if (info.isFullAvailable())
    633             {
    634                 RTPrintf("Failed to create VirtualBox object! Error info: '%lS' (component %lS).\n",
    635                          info.getText().raw(), info.getComponent().raw());
     644            if (!info.isFullAvailable() && !info.isBasicAvailable())
     645            {
     646                com::GluePrintRCMessage(rc);
     647                RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n");
    636648            }
    637649            else
    638                 RTPrintf("Failed to create VirtualBox object! No error information available (rc = 0x%x).\n", rc);
    639             break;
    640         }
    641 
    642         /* create Session object */
    643         rc = session.createInprocObject (CLSID_Session);
    644         if (FAILED (rc))
    645         {
    646             LogError ("Cannot create Session object!", rc);
     650                GluePrintErrorInfo(info);
    647651            break;
    648652        }
  • trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp

    r14831 r16530  
    2525#include <VBox/com/Guid.h>
    2626#include <VBox/com/ErrorInfo.h>
     27#include <VBox/com/errorprint_legacy.h>
    2728#include <VBox/com/EventQueue.h>
    2829
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r16052 r16530  
    3333#include <VBox/com/Guid.h>
    3434#include <VBox/com/ErrorInfo.h>
     35#include <VBox/com/errorprint2.h>
    3536
    3637#include <VBox/com/VirtualBox.h>
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r16509 r16530  
    3030#include <VBox/com/array.h>
    3131#include <VBox/com/ErrorInfo.h>
     32#include <VBox/com/errorprint2.h>
    3233#include <VBox/com/EventQueue.h>
    3334
     
    997998            CHECK_ERROR_RET(progress, COMGETTER(ErrorInfo)(errorInfo.asOutParam()), 1);
    998999            ErrorInfo info (errorInfo);
    999             PRINT_ERROR_INFO(info);
     1000            GluePrintErrorInfo(info);
    10001001        }
    10011002        else
     
    26782679    {
    26792680        Bstr formatVersion;
    2680         CHECK_RC_BREAK (virtualBox->
    2681                         COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam()));
     2681        CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam()));
    26822682
    26832683        bool isGlobalConverted = false;
     
    26882688
    26892689        com::SafeIfaceArray <IMachine> machines;
    2690         CHECK_RC_BREAK (virtualBox->
    2691                         COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines)));
     2690        CHECK_ERROR_BREAK(virtualBox, COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines)));
    26922691
    26932692        for (size_t i = 0; i < machines.size(); ++ i)
    26942693        {
    26952694            BOOL accessible;
    2696             CHECK_RC_BREAK (machines [i]->
    2697                             COMGETTER(Accessible) (&accessible));
     2695            CHECK_ERROR_BREAK(machines[i], COMGETTER(Accessible) (&accessible));
    26982696            if (!accessible)
    26992697                continue;
    27002698
    2701             CHECK_RC_BREAK (machines [i]->
    2702                             COMGETTER(SettingsFileVersion) (version.asOutParam()));
     2699            CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFileVersion) (version.asOutParam()));
    27032700
    27042701            if (version != formatVersion)
     
    27062703                cvtMachines.push_back (machines [i]);
    27072704                Bstr filePath;
    2708                 CHECK_RC_BREAK (machines [i]->
    2709                                 COMGETTER(SettingsFilePath) (filePath.asOutParam()));
     2705                CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFilePath) (filePath.asOutParam()));
    27102706                fileList.push_back (Utf8StrFmt ("%ls  (%ls)", filePath.raw(),
    27112707                                                version.raw()));
     
    27132709        }
    27142710
    2715         CHECK_RC_BREAK (rc);
    2716 
    2717         CHECK_RC_BREAK (virtualBox->
    2718                         COMGETTER(SettingsFileVersion) (version.asOutParam()));
     2711        if (FAILED(rc))
     2712            break;
     2713
     2714        CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFileVersion) (version.asOutParam()));
    27192715        if (version != formatVersion)
    27202716        {
    27212717            isGlobalConverted = true;
    2722             CHECK_RC_BREAK (virtualBox->
    2723                             COMGETTER(SettingsFilePath) (filePath.asOutParam()));
     2718            CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFilePath) (filePath.asOutParam()));
    27242719            fileList.push_back (Utf8StrFmt ("%ls  (%ls)", filePath.raw(),
    27252720                                            version.raw()));
     
    27732768            {
    27742769                Guid id;
    2775                 CHECK_RC_BREAK ((*m)->COMGETTER(Id) (id.asOutParam()));
     2770                CHECK_ERROR_BREAK((*m), COMGETTER(Id) (id.asOutParam()));
    27762771
    27772772                /* open a session for the VM */
     
    27792774
    27802775                ComPtr <IMachine> sm;
    2781                 CHECK_RC_BREAK (session->COMGETTER(Machine) (sm.asOutParam()));
     2776                CHECK_ERROR_BREAK(session, COMGETTER(Machine) (sm.asOutParam()));
    27822777
    27832778                Bstr bakFileName;
     
    27892784                session->Close();
    27902785
    2791                 CHECK_RC_BREAK (rc);
    2792             }
    2793 
    2794             CHECK_RC_BREAK (rc);
     2786                if (FAILED(rc))
     2787                    break;
     2788            }
     2789
     2790            if (FAILED(rc))
     2791                break;
    27952792
    27962793            if (isGlobalConverted)
     
    28032800            }
    28042801
    2805             CHECK_RC_BREAK (rc);
     2802            if (FAILED(rc))
     2803                break;
    28062804        }
    28072805    }
     
    28972895    HRESULT rc = 0;
    28982896
    2899     CHECK_RC_RET (com::Initialize());
     2897    rc = com::Initialize();
     2898    if (FAILED(rc))
     2899    {
     2900        RTPrintf("ERROR: failed to initialize COM!\n");
     2901        return rc;
     2902    }
    29002903
    29012904    /*
     
    29242927    }
    29252928
    2926     ComPtr <IVirtualBox> virtualBox;
    2927     ComPtr <ISession> session;
    2928 
    2929     rc = virtualBox.createLocalObject (CLSID_VirtualBox);
     2929    ComPtr<IVirtualBox> virtualBox;
     2930    ComPtr<ISession> session;
     2931
     2932    rc = virtualBox.createLocalObject(CLSID_VirtualBox);
    29302933    if (FAILED(rc))
    2931     {
    2932         RTPrintf ("[!] Failed to create the VirtualBox object!\n");
    2933         PRINT_RC_MESSAGE (rc);
    2934 
     2934        RTPrintf("ERROR: failed to create the VirtualBox object!\n");
     2935    else
     2936    {
     2937        rc = session.createInprocObject(CLSID_Session);
     2938        if (FAILED(rc))
     2939            RTPrintf("ERROR: failed to create a session object!\n");
     2940    }
     2941
     2942    if (FAILED(rc))
     2943    {
    29352944        com::ErrorInfo info;
    29362945        if (!info.isFullAvailable() && !info.isBasicAvailable())
    2937             RTPrintf ("[!] Most likely, the VirtualBox COM server is not running "
    2938                       "or failed to start.\n");
     2946        {
     2947            com::GluePrintRCMessage(rc);
     2948            RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n");
     2949        }
    29392950        else
    2940             PRINT_ERROR_INFO (info);
     2951            GluePrintErrorInfo(info);
    29412952        break;
    29422953    }
    2943 
    2944     CHECK_RC_BREAK (session.createInprocObject (CLSID_Session));
    29452954
    29462955    /* create the event queue
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r16150 r16530  
    2828#include <VBox/com/array.h>
    2929#include <VBox/com/ErrorInfo.h>
     30#include <VBox/com/errorprint2.h>
    3031#include <VBox/com/VirtualBox.h>
    3132
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp

    r16104 r16530  
    3535#include <VBox/com/array.h>
    3636#include <VBox/com/ErrorInfo.h>
     37#include <VBox/com/errorprint2.h>
     38
    3739#include <VBox/com/VirtualBox.h>
    3840
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp

    r16517 r16530  
    3131#include <VBox/com/array.h>
    3232#include <VBox/com/ErrorInfo.h>
     33#include <VBox/com/errorprint2.h>
    3334#include <VBox/com/EventQueue.h>
    3435
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r16509 r16530  
    3030#include <VBox/com/array.h>
    3131#include <VBox/com/ErrorInfo.h>
     32#include <VBox/com/errorprint2.h>
    3233
    3334#include <VBox/com/VirtualBox.h>
     
    159160            RTPrintf ("Access error details:\n");
    160161            ErrorInfo ei (accessError);
    161             PRINT_ERROR_INFO (ei);
     162            GluePrintErrorInfo(ei);
    162163            RTPrintf ("\n");
    163164        }
     
    989990            {
    990991                com::ErrorInfo info (display);
    991                 PRINT_ERROR_INFO (info);
     992                GluePrintErrorInfo(info);
    992993                return rc;
    993994            }
     
    998999            {
    9991000                com::ErrorInfo info (display);
    1000                 PRINT_ERROR_INFO (info);
     1001                GluePrintErrorInfo(info);
    10011002                return rc;
    10021003            }
     
    10071008            {
    10081009                com::ErrorInfo info (display);
    1009                 PRINT_ERROR_INFO (info);
     1010                GluePrintErrorInfo(info);
    10101011                return rc;
    10111012            }
     
    11071108        ULONG index = 0;
    11081109        BOOL fMore = FALSE;
    1109         rc = Enum->HasMore (&fMore);
    1110         ASSERT_RET (SUCCEEDED (rc), rc);
     1110        ASSERT(SUCCEEDED(rc = Enum->HasMore (&fMore)));
     1111        if (FAILED(rc))
     1112            return rc;
    11111113
    11121114        if (!fMore)
     
    11191121        {
    11201122            ComPtr<IUSBDeviceFilter> DevPtr;
    1121             rc = Enum->GetNext(DevPtr.asOutParam());
    1122             ASSERT_RET (SUCCEEDED (rc), rc);
     1123            ASSERT(SUCCEEDED(rc = Enum->GetNext(DevPtr.asOutParam())));
     1124            if (FAILED(rc))
     1125                return rc;
    11231126
    11241127            /* Query info. */
     
    11841187            }
    11851188
    1186             rc = Enum->HasMore (&fMore);
    1187             ASSERT_RET (SUCCEEDED (rc), rc);
     1189            ASSERT(SUCCEEDED(rc = Enum->HasMore (&fMore)));
     1190            if (FAILED(rc))
     1191                return rc;
    11881192
    11891193            index ++;
     
    12051209
    12061210                BOOL more = FALSE;
    1207                 rc = en->HasMore (&more);
    1208                 ASSERT_RET (SUCCEEDED (rc), rc);
     1211                ASSERT(SUCCEEDED(rc = en->HasMore(&more)));
     1212                if (FAILED(rc))
     1213                    return rc;
    12091214
    12101215                if (!more)
     
    12171222                {
    12181223                    ComPtr <IHostUSBDevice> dev;
    1219                     rc = en->GetNext (dev.asOutParam());
    1220                     ASSERT_RET (SUCCEEDED (rc), rc);
     1224                    ASSERT(SUCCEEDED(rc = en->GetNext (dev.asOutParam())));
     1225                    if (FAILED(rc))
     1226                        return rc;
    12211227
    12221228                    /* Query info. */
     
    12871293                        RTPrintf("\n");
    12881294
    1289                     rc = en->HasMore (&more);
    1290                     ASSERT_RET (SUCCEEDED (rc), rc);
     1295                    ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
     1296                    if (FAILED(rc))
     1297                        return rc;
    12911298
    12921299                    index ++;
     
    13071314
    13081315                BOOL more = FALSE;
    1309                 rc = en->HasMore (&more);
    1310                 ASSERT_RET (SUCCEEDED (rc), rc);
     1316                ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
     1317                if (FAILED(rc))
     1318                    return rc;
    13111319
    13121320                if (!more)
     
    13191327                {
    13201328                    ComPtr <IUSBDevice> dev;
    1321                     rc = en->GetNext (dev.asOutParam());
    1322                     ASSERT_RET (SUCCEEDED (rc), rc);
     1329                    ASSERT(SUCCEEDED(rc = en->GetNext (dev.asOutParam())));
     1330                    if (FAILED(rc))
     1331                        return rc;
    13231332
    13241333                    /* Query info. */
     
    13891398                        RTPrintf("\n");
    13901399
    1391                     rc = en->HasMore (&more);
    1392                     ASSERT_RET (SUCCEEDED (rc), rc);
     1400                    ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
     1401                    if (FAILED(rc))
     1402                        return rc;
    13931403
    13941404                    index ++;
     
    18411851            {
    18421852                RTPrintf("[!] FAILED calling console->getGuest at line %d!\n", __LINE__);
    1843                 PRINT_RC_MESSAGE(rc);
     1853                GluePrintRCMessage(rc);
    18441854            }
    18451855        }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r16052 r16530  
    3030#include <VBox/com/array.h>
    3131#include <VBox/com/ErrorInfo.h>
     32#include <VBox/com/errorprint2.h>
    3233
    3334#include <VBox/com/VirtualBox.h>
     
    143144            {
    144145                ComPtr<IGuestOSType> guestOS;
    145                 CHECK_RC_BREAK(enumerator->GetNext(guestOS.asOutParam()));
     146                CHECK_ERROR_BREAK(enumerator, GetNext(guestOS.asOutParam()));
    146147                Bstr guestId;
    147148                guestOS->COMGETTER(Id)(guestId.asOutParam());
     
    168169            {
    169170                ComPtr<IHostDVDDrive> dvdDrive;
    170                 CHECK_RC_BREAK(enumerator->GetNext(dvdDrive.asOutParam()));
     171                CHECK_ERROR_BREAK(enumerator, GetNext(dvdDrive.asOutParam()));
    171172                Bstr name;
    172173                dvdDrive->COMGETTER(Name)(name.asOutParam());
     
    190191            {
    191192                ComPtr<IHostFloppyDrive> floppyDrive;
    192                 CHECK_RC_BREAK(enumerator->GetNext(floppyDrive.asOutParam()));
     193                CHECK_ERROR_BREAK(enumerator, GetNext(floppyDrive.asOutParam()));
    193194                Bstr name;
    194195                floppyDrive->COMGETTER(Name)(name.asOutParam());
     
    484485
    485486        BOOL fMore = FALSE;
    486         rc = EnumPtr->HasMore (&fMore);
    487         ASSERT_RET (SUCCEEDED (rc), 1);
     487        ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
     488        if (FAILED(rc))
     489            return rc;
    488490
    489491        if (!fMore)
     
    495497        {
    496498            ComPtr <IHostUSBDevice> dev;
    497             rc = EnumPtr->GetNext (dev.asOutParam());
    498             ASSERT_RET (SUCCEEDED (rc), 1);
     499            ASSERT(SUCCEEDED(rc = EnumPtr->GetNext (dev.asOutParam())));
     500            if (FAILED(rc))
     501                return rc;
    499502
    500503            /* Query info. */
     
    556559            RTPrintf("Current State:      %s\n\n", pszState);
    557560
    558             rc = EnumPtr->HasMore (&fMore);
    559             ASSERT_RET (SUCCEEDED (rc), rc);
     561            ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
     562            if (FAILED(rc))
     563                return rc;
    560564        }
    561565    }
     
    576580        ULONG index = 0;
    577581        BOOL more = FALSE;
    578         rc = en->HasMore (&more);
    579         ASSERT_RET (SUCCEEDED (rc), 1);
     582        ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
     583        if (FAILED(rc))
     584            return rc;
    580585
    581586        if (!more)
     
    587592        {
    588593            ComPtr<IHostUSBDeviceFilter> flt;
    589             rc = en->GetNext (flt.asOutParam());
    590             ASSERT_RET (SUCCEEDED (rc), 1);
     594            ASSERT(SUCCEEDED(rc = en->GetNext (flt.asOutParam())));
     595            if (FAILED(rc))
     596                return rc;
    591597
    592598            /* Query info. */
     
    630636            RTPrintf("Serial Number:    %lS\n\n", bstr.raw());
    631637
    632             rc = en->HasMore (&more);
    633             ASSERT_RET (SUCCEEDED (rc), 1);
     638            ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
     639            if (FAILED(rc))
     640                return rc;
    634641
    635642            index ++;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMetrics.cpp

    r16052 r16530  
    2828#include <VBox/com/array.h>
    2929#include <VBox/com/ErrorInfo.h>
     30#include <VBox/com/errorprint2.h>
    3031#include <VBox/com/VirtualBox.h>
    3132
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r16509 r16530  
    2626#include <VBox/com/com.h>
    2727#include <VBox/com/ErrorInfo.h>
     28#include <VBox/com/errorprint2.h>
    2829#include <VBox/com/EventQueue.h>
    2930
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r16151 r16530  
    3030#include <VBox/com/array.h>
    3131#include <VBox/com/ErrorInfo.h>
     32#include <VBox/com/errorprint2.h>
     33
    3234#include <VBox/com/EventQueue.h>
    3335#include <VBox/com/VirtualBox.h>
     
    813815    {
    814816        Bstr formatVersion;
    815         CHECK_RC_BREAK (virtualBox->
    816                         COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam()));
     817        CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam()));
    817818
    818819        bool isGlobalConverted = false;
     
    823824
    824825        com::SafeIfaceArray <IMachine> machines;
    825         CHECK_RC_BREAK (virtualBox->
    826                         COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines)));
     826        CHECK_ERROR_BREAK(virtualBox, COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines)));
    827827
    828828        for (size_t i = 0; i < machines.size(); ++ i)
    829829        {
    830830            BOOL accessible;
    831             CHECK_RC_BREAK (machines [i]->
    832                             COMGETTER(Accessible) (&accessible));
     831            CHECK_ERROR_BREAK(machines[i], COMGETTER(Accessible) (&accessible));
    833832            if (!accessible)
    834833                continue;
    835834
    836             CHECK_RC_BREAK (machines [i]->
    837                             COMGETTER(SettingsFileVersion) (version.asOutParam()));
     835            CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFileVersion) (version.asOutParam()));
    838836
    839837            if (version != formatVersion)
     
    841839                cvtMachines.push_back (machines [i]);
    842840                Bstr filePath;
    843                 CHECK_RC_BREAK (machines [i]->
    844                                 COMGETTER(SettingsFilePath) (filePath.asOutParam()));
     841                CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFilePath) (filePath.asOutParam()));
    845842                fileList.push_back (Utf8StrFmt ("%ls  (%ls)", filePath.raw(),
    846843                                                version.raw()));
     
    848845        }
    849846
    850         CHECK_RC_BREAK (rc);
    851 
    852         CHECK_RC_BREAK (virtualBox->
    853                         COMGETTER(SettingsFileVersion) (version.asOutParam()));
     847        if (FAILED(rc))
     848            break;
     849
     850        CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFileVersion) (version.asOutParam()));
    854851        if (version != formatVersion)
    855852        {
    856853            isGlobalConverted = true;
    857             CHECK_RC_BREAK (virtualBox->
    858                             COMGETTER(SettingsFilePath) (filePath.asOutParam()));
     854            CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFilePath) (filePath.asOutParam()));
    859855            fileList.push_back (Utf8StrFmt ("%ls  (%ls)", filePath.raw(),
    860856                                            version.raw()));
     
    908904            {
    909905                Guid id;
    910                 CHECK_RC_BREAK ((*m)->COMGETTER(Id) (id.asOutParam()));
     906                CHECK_ERROR_BREAK((*m), COMGETTER(Id) (id.asOutParam()));
    911907
    912908                /* open a session for the VM */
     
    914910
    915911                ComPtr <IMachine> sm;
    916                 CHECK_RC_BREAK (session->COMGETTER(Machine) (sm.asOutParam()));
     912                CHECK_ERROR_BREAK(session, COMGETTER(Machine) (sm.asOutParam()));
    917913
    918914                Bstr bakFileName;
     
    924920                session->Close();
    925921
    926                 CHECK_RC_BREAK (rc);
    927             }
    928 
    929             CHECK_RC_BREAK (rc);
     922                if (FAILED(rc))
     923                    break;
     924            }
     925
     926            if (FAILED(rc))
     927                break;
    930928
    931929            if (isGlobalConverted)
     
    938936            }
    939937
    940             CHECK_RC_BREAK (rc);
     938            if (FAILED(rc))
     939                break;
    941940        }
    942941    }
  • trunk/src/VBox/Main/Makefile.kmk

    r16406 r16530  
    587587        glue/EventQueue.cpp \
    588588        glue/ErrorInfo.cpp \
     589        glue/errorprint2.cpp \
    589590        glue/SupportErrorInfo.cpp \
    590591        glue/VirtualBoxErrorInfo.cpp
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r16507 r16530  
    2828#include <VBox/com/Guid.h>
    2929#include <VBox/com/ErrorInfo.h>
     30#include <VBox/com/errorprint_legacy.h>
    3031#include <VBox/com/EventQueue.h>
    3132
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r16301 r16530  
    2626#include <VBox/com/Guid.h>
    2727#include <VBox/com/ErrorInfo.h>
     28#include <VBox/com/errorprint2.h>
    2829#include <VBox/com/EventQueue.h>
    2930#include <VBox/com/VirtualBox.h>
     
    345346
    346347    // intialize COM/XPCOM
    347 //     ComPtr<ISession> session;
    348     if ((rc = com::Initialize()))
    349         RTStrmPrintf(g_pStdErr, "[!] Failed to initialize COM!\n");
    350     else if ((rc = g_pVirtualBox.createLocalObject(CLSID_VirtualBox)))
    351         RTStrmPrintf(g_pStdErr, "[!] Failed to create the local VirtualBox object!\n");
    352 //     else if ((rc = session.createInprocObject(CLSID_Session)))
    353 //         RTStrmPrintf(g_pStdErr, "[!] Failed to create the inproc VirtualBox object!\n");
    354 
    355     if (rc)
    356     {
    357         PRINT_RC_MESSAGE(rc);
    358 
     348    rc = com::Initialize();
     349    if (FAILED(rc))
     350    {
     351        RTPrintf("ERROR: failed to initialize COM!\n");
     352        return rc;
     353    }
     354
     355    ComPtr<IVirtualBox> virtualBox;
     356    ComPtr<ISession> session;
     357
     358    rc = virtualBox.createLocalObject(CLSID_VirtualBox);
     359    if (FAILED(rc))
     360        RTPrintf("ERROR: failed to create the VirtualBox object!\n");
     361    else
     362    {
     363        rc = session.createInprocObject(CLSID_Session);
     364        if (FAILED(rc))
     365            RTPrintf("ERROR: failed to create a session object!\n");
     366    }
     367
     368    if (FAILED(rc))
     369    {
    359370        com::ErrorInfo info;
    360371        if (!info.isFullAvailable() && !info.isBasicAvailable())
    361             RTStrmPrintf(g_pStdErr, "[!] Most likely, the VirtualBox COM server is not running or failed to start.\n");
     372        {
     373            com::GluePrintRCMessage(rc);
     374            RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n");
     375        }
    362376        else
    363             PRINT_ERROR_INFO(info);
    364         exit(rc);
     377            com::GluePrintErrorInfo(info);
     378        return rc;
    365379    }
    366380
     
    862876            // (and of which IWebsessionManager::getSessionObject returns a managed object reference)
    863877            ComPtr<ISession> session;
    864             CHECK_RC_BREAK(session.createInprocObject(CLSID_Session));
     878            if (FAILED(rc = session.createInprocObject(CLSID_Session)))
     879            {
     880                WEBDEBUG(("ERROR: cannot create session object!"));
     881                break;
     882            }
    865883
    866884            _pISession = new ManagedObjectRef(*this, g_pcszISession, session);
  • trunk/src/VBox/Main/webservice/websrv-cpp.xsl

    r16122 r16530  
    6666#include <VBox/com/Guid.h>
    6767#include <VBox/com/ErrorInfo.h>
     68#include <VBox/com/errorprint2.h>
    6869#include <VBox/com/EventQueue.h>
    6970#include <VBox/com/VirtualBox.h>
     
    10111012      <xsl:value-of select="concat('ComPtr&lt;', $collectiontype, 'Enumerator&gt; ', $enumerator, ';')" />
    10121013      <xsl:call-template name="emitNewlineIndent8" />
    1013       <xsl:value-of select="concat('CHECK_RC_BREAK( comcall_', $callerprefix, $name, '-&gt;Enumerate(', $enumerator, '.asOutParam()) );')" />
     1014      <xsl:value-of select="concat('CHECK_ERROR_BREAK( comcall_', $callerprefix, $name, ', Enumerate(', $enumerator, '.asOutParam()) );')" />
    10141015      <xsl:call-template name="emitNewlineIndent8" />
    10151016      <xsl:value-of select="concat('BOOL comcall_', $callerprefix, $name, '_hasmore = FALSE;')" />
     
    10171018      <xsl:value-of select="'do {'" />
    10181019      <xsl:call-template name="emitNewlineIndent8" />
    1019       <xsl:value-of select="concat('    CHECK_RC_BREAK( ', $enumerator, '-&gt;HasMore(&amp;comcall_', $callerprefix, $name, '_hasmore) );')" />
     1020      <xsl:value-of select="concat('    CHECK_ERROR_BREAK( ', $enumerator, ', HasMore(&amp;comcall_', $callerprefix, $name, '_hasmore) );')" />
    10201021      <xsl:call-template name="emitNewlineIndent8" />
    10211022      <xsl:value-of select="concat('    if (!comcall_', $callerprefix, $name, '_hasmore) break;')" />
     
    10231024      <xsl:value-of select="concat('    ComPtr&lt;', $collectiontype, '&gt; arrayitem;')" />
    10241025      <xsl:call-template name="emitNewlineIndent8" />
    1025       <xsl:value-of select="concat('    CHECK_RC_BREAK( ', $enumerator, '-&gt;GetNext(arrayitem.asOutParam()) );')" />
     1026      <xsl:value-of select="concat('    CHECK_ERROR_BREAK( ', $enumerator, ', GetNext(arrayitem.asOutParam()) );')" />
    10261027      <xsl:call-template name="emitNewlineIndent8" />
    10271028      <xsl:value-of select="concat('    // collection of &quot;', $collectiontype, '&quot;, target interface wsmap: &quot;', $targetwsmap, '&quot;')" />
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