Changeset 16530 in vbox
- Timestamp:
- Feb 5, 2009 4:08:49 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42461
- Location:
- trunk
- Files:
-
- 17 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/assert.h
r13856 r16530 137 137 if (!SUCCEEDED (rc)) { throw rc; } else do {} while (0) 138 138 139 /*140 * A section of helpful macros for error output141 */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 instance158 */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 value185 * (COM result code) indicates a failure. If so, prints the failed186 * 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 on203 * 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 on210 * 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 return217 * value (COM result code) indicates a failure. If so, prints the failed218 * function/line/file, the description of the result code and attempts to219 * query the extended error information on the current thread (using220 * 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 on237 * 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 on244 * failure.245 */246 #if defined(__GNUC__)247 #define CHECK_ERROR_BREAK(iface, method) \248 ({ CHECK_ERROR (iface, method); if (FAILED (rc)) break; })249 #else250 #define CHECK_ERROR_BREAK(iface, method) \251 if (1) { CHECK_ERROR (iface, method); if (FAILED (rc)) break; } else do {} while (0)252 #endif253 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 pointer262 * 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| statement275 * 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| statement282 * 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, prints290 * 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 the303 * 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 the310 * expression to assert is false.311 */312 #define ASSERT_BREAK(expr) \313 if (1) { ASSERT (expr); if (!(expr)) break; } else do {} while (0)314 315 139 316 140 #endif -
trunk/include/VBox/com/errorprint_legacy.h
r16526 r16530 1 1 /** @file 2 2 * 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. 4 7 */ 5 8 6 9 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.10 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 8 11 * 9 12 * This file is part of VirtualBox Open Source Edition (OSE), as … … 29 32 */ 30 33 31 #ifndef ___VBox_com_ assert_h32 #define ___VBox_com_ assert_h34 #ifndef ___VBox_com_errorprint_legacy_h 35 #define ___VBox_com_errorprint_legacy_h 33 36 34 37 #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 code41 */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 expression47 * if the result code is failed.48 *49 * @param rc COM result code50 * @param ret the expression to return51 */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 code57 * if it is failed.58 *59 * @param rc COM result code60 * @param ret the expression to return61 */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 code69 * @param ret the expression to return70 */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 and76 * breaks if the result code is failed.77 *78 * @param rc COM result code79 * @param eval the expression to evaluate80 */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 and86 * throws it if the result code is failed.87 *88 * @param rc COM result code89 * @param eval the expression to throw90 */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 is96 * failed.97 *98 * @param rc COM result code99 */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 is105 * failed.106 *107 * @param rc COM result code108 */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 code117 */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 code126 */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 code135 */136 #define CheckComRCThrowRC(rc) \137 if (!SUCCEEDED (rc)) { throw rc; } else do {} while (0)138 38 139 39 /* -
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r16152 r16530 25 25 #include <VBox/com/Guid.h> 26 26 #include <VBox/com/ErrorInfo.h> 27 #include <VBox/com/errorprint2.h> 27 28 #include <VBox/com/EventQueue.h> 28 29 … … 617 618 618 619 rc = com::Initialize(); 619 if (FAILED (rc)) 620 if (FAILED(rc)) 621 { 622 RTPrintf("ERROR: failed to initialize COM!\n"); 620 623 return rc; 624 } 621 625 622 626 do 623 627 { 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)) 630 642 { 631 643 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"); 636 648 } 637 649 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); 647 651 break; 648 652 } -
trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp
r14831 r16530 25 25 #include <VBox/com/Guid.h> 26 26 #include <VBox/com/ErrorInfo.h> 27 #include <VBox/com/errorprint_legacy.h> 27 28 #include <VBox/com/EventQueue.h> 28 29 -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r16052 r16530 33 33 #include <VBox/com/Guid.h> 34 34 #include <VBox/com/ErrorInfo.h> 35 #include <VBox/com/errorprint2.h> 35 36 36 37 #include <VBox/com/VirtualBox.h> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r16509 r16530 30 30 #include <VBox/com/array.h> 31 31 #include <VBox/com/ErrorInfo.h> 32 #include <VBox/com/errorprint2.h> 32 33 #include <VBox/com/EventQueue.h> 33 34 … … 997 998 CHECK_ERROR_RET(progress, COMGETTER(ErrorInfo)(errorInfo.asOutParam()), 1); 998 999 ErrorInfo info (errorInfo); 999 PRINT_ERROR_INFO(info);1000 GluePrintErrorInfo(info); 1000 1001 } 1001 1002 else … … 2678 2679 { 2679 2680 Bstr formatVersion; 2680 CHECK_RC_BREAK (virtualBox-> 2681 COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam())); 2681 CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam())); 2682 2682 2683 2683 bool isGlobalConverted = false; … … 2688 2688 2689 2689 com::SafeIfaceArray <IMachine> machines; 2690 CHECK_RC_BREAK (virtualBox-> 2691 COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines))); 2690 CHECK_ERROR_BREAK(virtualBox, COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines))); 2692 2691 2693 2692 for (size_t i = 0; i < machines.size(); ++ i) 2694 2693 { 2695 2694 BOOL accessible; 2696 CHECK_RC_BREAK (machines [i]-> 2697 COMGETTER(Accessible) (&accessible)); 2695 CHECK_ERROR_BREAK(machines[i], COMGETTER(Accessible) (&accessible)); 2698 2696 if (!accessible) 2699 2697 continue; 2700 2698 2701 CHECK_RC_BREAK (machines [i]-> 2702 COMGETTER(SettingsFileVersion) (version.asOutParam())); 2699 CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFileVersion) (version.asOutParam())); 2703 2700 2704 2701 if (version != formatVersion) … … 2706 2703 cvtMachines.push_back (machines [i]); 2707 2704 Bstr filePath; 2708 CHECK_RC_BREAK (machines [i]-> 2709 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 2705 CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFilePath) (filePath.asOutParam())); 2710 2706 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 2711 2707 version.raw())); … … 2713 2709 } 2714 2710 2715 CHECK_RC_BREAK (rc);2716 2717 CHECK_RC_BREAK (virtualBox-> 2718 2711 if (FAILED(rc)) 2712 break; 2713 2714 CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFileVersion) (version.asOutParam())); 2719 2715 if (version != formatVersion) 2720 2716 { 2721 2717 isGlobalConverted = true; 2722 CHECK_RC_BREAK (virtualBox-> 2723 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 2718 CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFilePath) (filePath.asOutParam())); 2724 2719 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 2725 2720 version.raw())); … … 2773 2768 { 2774 2769 Guid id; 2775 CHECK_ RC_BREAK ((*m)->COMGETTER(Id) (id.asOutParam()));2770 CHECK_ERROR_BREAK((*m), COMGETTER(Id) (id.asOutParam())); 2776 2771 2777 2772 /* open a session for the VM */ … … 2779 2774 2780 2775 ComPtr <IMachine> sm; 2781 CHECK_ RC_BREAK (session->COMGETTER(Machine) (sm.asOutParam()));2776 CHECK_ERROR_BREAK(session, COMGETTER(Machine) (sm.asOutParam())); 2782 2777 2783 2778 Bstr bakFileName; … … 2789 2784 session->Close(); 2790 2785 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; 2795 2792 2796 2793 if (isGlobalConverted) … … 2803 2800 } 2804 2801 2805 CHECK_RC_BREAK (rc); 2802 if (FAILED(rc)) 2803 break; 2806 2804 } 2807 2805 } … … 2897 2895 HRESULT rc = 0; 2898 2896 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 } 2900 2903 2901 2904 /* … … 2924 2927 } 2925 2928 2926 ComPtr 2927 ComPtr 2928 2929 rc = virtualBox.createLocalObject 2929 ComPtr<IVirtualBox> virtualBox; 2930 ComPtr<ISession> session; 2931 2932 rc = virtualBox.createLocalObject(CLSID_VirtualBox); 2930 2933 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 { 2935 2944 com::ErrorInfo info; 2936 2945 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 } 2939 2950 else 2940 PRINT_ERROR_INFO(info);2951 GluePrintErrorInfo(info); 2941 2952 break; 2942 2953 } 2943 2944 CHECK_RC_BREAK (session.createInprocObject (CLSID_Session));2945 2954 2946 2955 /* create the event queue -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r16150 r16530 28 28 #include <VBox/com/array.h> 29 29 #include <VBox/com/ErrorInfo.h> 30 #include <VBox/com/errorprint2.h> 30 31 #include <VBox/com/VirtualBox.h> 31 32 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
r16104 r16530 35 35 #include <VBox/com/array.h> 36 36 #include <VBox/com/ErrorInfo.h> 37 #include <VBox/com/errorprint2.h> 38 37 39 #include <VBox/com/VirtualBox.h> 38 40 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
r16517 r16530 31 31 #include <VBox/com/array.h> 32 32 #include <VBox/com/ErrorInfo.h> 33 #include <VBox/com/errorprint2.h> 33 34 #include <VBox/com/EventQueue.h> 34 35 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r16509 r16530 30 30 #include <VBox/com/array.h> 31 31 #include <VBox/com/ErrorInfo.h> 32 #include <VBox/com/errorprint2.h> 32 33 33 34 #include <VBox/com/VirtualBox.h> … … 159 160 RTPrintf ("Access error details:\n"); 160 161 ErrorInfo ei (accessError); 161 PRINT_ERROR_INFO(ei);162 GluePrintErrorInfo(ei); 162 163 RTPrintf ("\n"); 163 164 } … … 989 990 { 990 991 com::ErrorInfo info (display); 991 PRINT_ERROR_INFO(info);992 GluePrintErrorInfo(info); 992 993 return rc; 993 994 } … … 998 999 { 999 1000 com::ErrorInfo info (display); 1000 PRINT_ERROR_INFO(info);1001 GluePrintErrorInfo(info); 1001 1002 return rc; 1002 1003 } … … 1007 1008 { 1008 1009 com::ErrorInfo info (display); 1009 PRINT_ERROR_INFO(info);1010 GluePrintErrorInfo(info); 1010 1011 return rc; 1011 1012 } … … 1107 1108 ULONG index = 0; 1108 1109 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; 1111 1113 1112 1114 if (!fMore) … … 1119 1121 { 1120 1122 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; 1123 1126 1124 1127 /* Query info. */ … … 1184 1187 } 1185 1188 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; 1188 1192 1189 1193 index ++; … … 1205 1209 1206 1210 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; 1209 1214 1210 1215 if (!more) … … 1217 1222 { 1218 1223 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; 1221 1227 1222 1228 /* Query info. */ … … 1287 1293 RTPrintf("\n"); 1288 1294 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; 1291 1298 1292 1299 index ++; … … 1307 1314 1308 1315 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; 1311 1319 1312 1320 if (!more) … … 1319 1327 { 1320 1328 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; 1323 1332 1324 1333 /* Query info. */ … … 1389 1398 RTPrintf("\n"); 1390 1399 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; 1393 1403 1394 1404 index ++; … … 1841 1851 { 1842 1852 RTPrintf("[!] FAILED calling console->getGuest at line %d!\n", __LINE__); 1843 PRINT_RC_MESSAGE(rc);1853 GluePrintRCMessage(rc); 1844 1854 } 1845 1855 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r16052 r16530 30 30 #include <VBox/com/array.h> 31 31 #include <VBox/com/ErrorInfo.h> 32 #include <VBox/com/errorprint2.h> 32 33 33 34 #include <VBox/com/VirtualBox.h> … … 143 144 { 144 145 ComPtr<IGuestOSType> guestOS; 145 CHECK_ RC_BREAK(enumerator->GetNext(guestOS.asOutParam()));146 CHECK_ERROR_BREAK(enumerator, GetNext(guestOS.asOutParam())); 146 147 Bstr guestId; 147 148 guestOS->COMGETTER(Id)(guestId.asOutParam()); … … 168 169 { 169 170 ComPtr<IHostDVDDrive> dvdDrive; 170 CHECK_ RC_BREAK(enumerator->GetNext(dvdDrive.asOutParam()));171 CHECK_ERROR_BREAK(enumerator, GetNext(dvdDrive.asOutParam())); 171 172 Bstr name; 172 173 dvdDrive->COMGETTER(Name)(name.asOutParam()); … … 190 191 { 191 192 ComPtr<IHostFloppyDrive> floppyDrive; 192 CHECK_ RC_BREAK(enumerator->GetNext(floppyDrive.asOutParam()));193 CHECK_ERROR_BREAK(enumerator, GetNext(floppyDrive.asOutParam())); 193 194 Bstr name; 194 195 floppyDrive->COMGETTER(Name)(name.asOutParam()); … … 484 485 485 486 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; 488 490 489 491 if (!fMore) … … 495 497 { 496 498 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; 499 502 500 503 /* Query info. */ … … 556 559 RTPrintf("Current State: %s\n\n", pszState); 557 560 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; 560 564 } 561 565 } … … 576 580 ULONG index = 0; 577 581 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; 580 585 581 586 if (!more) … … 587 592 { 588 593 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; 591 597 592 598 /* Query info. */ … … 630 636 RTPrintf("Serial Number: %lS\n\n", bstr.raw()); 631 637 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; 634 641 635 642 index ++; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMetrics.cpp
r16052 r16530 28 28 #include <VBox/com/array.h> 29 29 #include <VBox/com/ErrorInfo.h> 30 #include <VBox/com/errorprint2.h> 30 31 #include <VBox/com/VirtualBox.h> 31 32 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r16509 r16530 26 26 #include <VBox/com/com.h> 27 27 #include <VBox/com/ErrorInfo.h> 28 #include <VBox/com/errorprint2.h> 28 29 #include <VBox/com/EventQueue.h> 29 30 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r16151 r16530 30 30 #include <VBox/com/array.h> 31 31 #include <VBox/com/ErrorInfo.h> 32 #include <VBox/com/errorprint2.h> 33 32 34 #include <VBox/com/EventQueue.h> 33 35 #include <VBox/com/VirtualBox.h> … … 813 815 { 814 816 Bstr formatVersion; 815 CHECK_RC_BREAK (virtualBox-> 816 COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam())); 817 CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam())); 817 818 818 819 bool isGlobalConverted = false; … … 823 824 824 825 com::SafeIfaceArray <IMachine> machines; 825 CHECK_RC_BREAK (virtualBox-> 826 COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines))); 826 CHECK_ERROR_BREAK(virtualBox, COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines))); 827 827 828 828 for (size_t i = 0; i < machines.size(); ++ i) 829 829 { 830 830 BOOL accessible; 831 CHECK_RC_BREAK (machines [i]-> 832 COMGETTER(Accessible) (&accessible)); 831 CHECK_ERROR_BREAK(machines[i], COMGETTER(Accessible) (&accessible)); 833 832 if (!accessible) 834 833 continue; 835 834 836 CHECK_RC_BREAK (machines [i]-> 837 COMGETTER(SettingsFileVersion) (version.asOutParam())); 835 CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFileVersion) (version.asOutParam())); 838 836 839 837 if (version != formatVersion) … … 841 839 cvtMachines.push_back (machines [i]); 842 840 Bstr filePath; 843 CHECK_RC_BREAK (machines [i]-> 844 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 841 CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFilePath) (filePath.asOutParam())); 845 842 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 846 843 version.raw())); … … 848 845 } 849 846 850 CHECK_RC_BREAK (rc);851 852 CHECK_RC_BREAK (virtualBox-> 853 847 if (FAILED(rc)) 848 break; 849 850 CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFileVersion) (version.asOutParam())); 854 851 if (version != formatVersion) 855 852 { 856 853 isGlobalConverted = true; 857 CHECK_RC_BREAK (virtualBox-> 858 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 854 CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFilePath) (filePath.asOutParam())); 859 855 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 860 856 version.raw())); … … 908 904 { 909 905 Guid id; 910 CHECK_ RC_BREAK ((*m)->COMGETTER(Id) (id.asOutParam()));906 CHECK_ERROR_BREAK((*m), COMGETTER(Id) (id.asOutParam())); 911 907 912 908 /* open a session for the VM */ … … 914 910 915 911 ComPtr <IMachine> sm; 916 CHECK_ RC_BREAK (session->COMGETTER(Machine) (sm.asOutParam()));912 CHECK_ERROR_BREAK(session, COMGETTER(Machine) (sm.asOutParam())); 917 913 918 914 Bstr bakFileName; … … 924 920 session->Close(); 925 921 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; 930 928 931 929 if (isGlobalConverted) … … 938 936 } 939 937 940 CHECK_RC_BREAK (rc); 938 if (FAILED(rc)) 939 break; 941 940 } 942 941 } -
trunk/src/VBox/Main/Makefile.kmk
r16406 r16530 587 587 glue/EventQueue.cpp \ 588 588 glue/ErrorInfo.cpp \ 589 glue/errorprint2.cpp \ 589 590 glue/SupportErrorInfo.cpp \ 590 591 glue/VirtualBoxErrorInfo.cpp -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r16507 r16530 28 28 #include <VBox/com/Guid.h> 29 29 #include <VBox/com/ErrorInfo.h> 30 #include <VBox/com/errorprint_legacy.h> 30 31 #include <VBox/com/EventQueue.h> 31 32 -
trunk/src/VBox/Main/webservice/vboxweb.cpp
r16301 r16530 26 26 #include <VBox/com/Guid.h> 27 27 #include <VBox/com/ErrorInfo.h> 28 #include <VBox/com/errorprint2.h> 28 29 #include <VBox/com/EventQueue.h> 29 30 #include <VBox/com/VirtualBox.h> … … 345 346 346 347 // 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 { 359 370 com::ErrorInfo info; 360 371 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 } 362 376 else 363 PRINT_ERROR_INFO(info);364 exit(rc);377 com::GluePrintErrorInfo(info); 378 return rc; 365 379 } 366 380 … … 862 876 // (and of which IWebsessionManager::getSessionObject returns a managed object reference) 863 877 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 } 865 883 866 884 _pISession = new ManagedObjectRef(*this, g_pcszISession, session); -
trunk/src/VBox/Main/webservice/websrv-cpp.xsl
r16122 r16530 66 66 #include <VBox/com/Guid.h> 67 67 #include <VBox/com/ErrorInfo.h> 68 #include <VBox/com/errorprint2.h> 68 69 #include <VBox/com/EventQueue.h> 69 70 #include <VBox/com/VirtualBox.h> … … 1011 1012 <xsl:value-of select="concat('ComPtr<', $collectiontype, 'Enumerator> ', $enumerator, ';')" /> 1012 1013 <xsl:call-template name="emitNewlineIndent8" /> 1013 <xsl:value-of select="concat('CHECK_ RC_BREAK( comcall_', $callerprefix, $name, '->Enumerate(', $enumerator, '.asOutParam()) );')" />1014 <xsl:value-of select="concat('CHECK_ERROR_BREAK( comcall_', $callerprefix, $name, ', Enumerate(', $enumerator, '.asOutParam()) );')" /> 1014 1015 <xsl:call-template name="emitNewlineIndent8" /> 1015 1016 <xsl:value-of select="concat('BOOL comcall_', $callerprefix, $name, '_hasmore = FALSE;')" /> … … 1017 1018 <xsl:value-of select="'do {'" /> 1018 1019 <xsl:call-template name="emitNewlineIndent8" /> 1019 <xsl:value-of select="concat(' CHECK_ RC_BREAK( ', $enumerator, '->HasMore(&comcall_', $callerprefix, $name, '_hasmore) );')" />1020 <xsl:value-of select="concat(' CHECK_ERROR_BREAK( ', $enumerator, ', HasMore(&comcall_', $callerprefix, $name, '_hasmore) );')" /> 1020 1021 <xsl:call-template name="emitNewlineIndent8" /> 1021 1022 <xsl:value-of select="concat(' if (!comcall_', $callerprefix, $name, '_hasmore) break;')" /> … … 1023 1024 <xsl:value-of select="concat(' ComPtr<', $collectiontype, '> arrayitem;')" /> 1024 1025 <xsl:call-template name="emitNewlineIndent8" /> 1025 <xsl:value-of select="concat(' CHECK_ RC_BREAK( ', $enumerator, '->GetNext(arrayitem.asOutParam()) );')" />1026 <xsl:value-of select="concat(' CHECK_ERROR_BREAK( ', $enumerator, ', GetNext(arrayitem.asOutParam()) );')" /> 1026 1027 <xsl:call-template name="emitNewlineIndent8" /> 1027 1028 <xsl:value-of select="concat(' // collection of "', $collectiontype, '", target interface wsmap: "', $targetwsmap, '"')" />
Note:
See TracChangeset
for help on using the changeset viewer.