Changeset 56567 in vbox for trunk/src/VBox
- Timestamp:
- Jun 20, 2015 5:15:56 PM (10 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineDebuggerImpl.h
r55885 r56567 138 138 /** Function pointer. */ 139 139 typedef FNLOGGETSTR *PFNLOGGETSTR; 140 HRESULT i_logStringProps(PRTLOGGER pLogger, PFNLOGGETSTR pfnLogGetStr, const char *pszLogGetStr, Utf8Str aSettings);140 HRESULT i_logStringProps(PRTLOGGER pLogger, PFNLOGGETSTR pfnLogGetStr, const char *pszLogGetStr, Utf8Str *pstrSettings); 141 141 142 142 Console * const mParent; -
trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp
r55996 r56567 455 455 456 456 HRESULT MachineDebugger::i_logStringProps(PRTLOGGER pLogger, PFNLOGGETSTR pfnLogGetStr, 457 const char *pszLogGetStr, Utf8Str astrSettings) 458 { 459 BSTR *a_pbstrSettings = new BSTR; 460 astrSettings.cloneTo(a_pbstrSettings); 461 457 const char *pszLogGetStr, Utf8Str *pstrSettings) 458 { 462 459 /* Make sure the VM is powered up. */ 463 460 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 470 467 if (!pLogger) 471 468 { 472 Bstr bstrEmpty; 473 bstrEmpty.cloneTo(a_pbstrSettings); 469 *pstrSettings = ""; 474 470 return S_OK; 475 471 } … … 481 477 char *pszBuf = (char *)RTMemTmpAlloc(cbBuf); 482 478 AssertReturn(pszBuf, E_OUTOFMEMORY); 483 484 int rc = pfnLogGetStr(pLogger, pszBuf, cbBuf); 485 if (RT_SUCCESS(rc)) 486 { 487 try 488 { 489 Bstr bstrRet(pszBuf); 490 bstrRet.detachTo(a_pbstrSettings); 491 hrc = S_OK; 492 } 493 catch (std::bad_alloc) 494 { 495 hrc = E_OUTOFMEMORY; 496 } 497 RTMemTmpFree(pszBuf); 498 return hrc; 499 } 500 RTMemTmpFree(pszBuf); 501 AssertReturn(rc == VERR_BUFFER_OVERFLOW, setError(VBOX_E_IPRT_ERROR, tr("%s returned %Rrc"), pszLogGetStr, rc)); 479 int vrc = pstrSettings->reserveNoThrow(cbBuf); 480 if (RT_SUCCESS(vrc)) 481 { 482 vrc = pfnLogGetStr(pLogger, pstrSettings->mutableRaw(), cbBuf); 483 if (RT_SUCCESS(vrc)) 484 { 485 pstrSettings->jolt(); 486 return S_OK; 487 } 488 *pstrSettings = ""; 489 AssertReturn(vrc == VERR_BUFFER_OVERFLOW, setError(VBOX_E_IPRT_ERROR, tr("%s returned %Rrc"), pszLogGetStr, vrc)); 490 } 491 else 492 return E_OUTOFMEMORY; 502 493 503 494 /* try again with a bigger buffer. */ … … 509 500 HRESULT MachineDebugger::getLogDbgFlags(com::Utf8Str &aLogDbgFlags) 510 501 { 511 HRESULT hrc = i_logStringProps(RTLogGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", aLogDbgFlags); 512 513 return hrc; 502 return i_logStringProps(RTLogGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", &aLogDbgFlags); 514 503 } 515 504 516 505 HRESULT MachineDebugger::getLogDbgGroups(com::Utf8Str &aLogDbgGroups) 517 506 { 518 HRESULT hrc = i_logStringProps(RTLogGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", aLogDbgGroups); 519 520 return hrc; 507 return i_logStringProps(RTLogGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", &aLogDbgGroups); 521 508 } 522 509 523 510 HRESULT MachineDebugger::getLogDbgDestinations(com::Utf8Str &aLogDbgDestinations) 524 511 { 525 HRESULT hrc = i_logStringProps(RTLogGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", aLogDbgDestinations); 526 return hrc; 512 return i_logStringProps(RTLogGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", &aLogDbgDestinations); 527 513 } 528 514 529 515 HRESULT MachineDebugger::getLogRelFlags(com::Utf8Str &aLogRelFlags) 530 516 { 531 HRESULT hrc = i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", aLogRelFlags); 532 return hrc; 517 return i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", &aLogRelFlags); 533 518 } 534 519 535 520 HRESULT MachineDebugger::getLogRelGroups(com::Utf8Str &aLogRelGroups) 536 521 { 537 HRESULT hrc = i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", aLogRelGroups); 538 return hrc; 522 return i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", &aLogRelGroups); 539 523 } 540 524 541 525 HRESULT MachineDebugger::getLogRelDestinations(com::Utf8Str &aLogRelDestinations) 542 526 { 543 HRESULT hrc = i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", aLogRelDestinations); 544 return hrc; 527 return i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", &aLogRelDestinations); 545 528 } 546 529
Note:
See TracChangeset
for help on using the changeset viewer.