VirtualBox

Changeset 91520 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 1, 2021 2:49:17 PM (3 years ago)
Author:
vboxsync
Message:

VMM/vmR3TrySetState: Attempt at improving the error reporting. bugref:10111

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r90794 r91520  
    33193319         * Complain about it.
    33203320         */
     3321        const char * const pszStateCur = VMR3GetStateName(enmStateCur);
    33213322        if (cTransitions == 1)
    33223323        {
    3323             LogRel(("%s: %s -> %s failed, because the VM state is actually %s\n",
    3324                     pszWho, VMR3GetStateName(enmStateOld), VMR3GetStateName(enmStateNew), VMR3GetStateName(enmStateCur)));
    3325             VMSetError(pVM, VERR_VM_INVALID_VM_STATE, RT_SRC_POS,
    3326                        N_("%s failed because the VM state is %s instead of %s"),
    3327                        pszWho, VMR3GetStateName(enmStateCur), VMR3GetStateName(enmStateOld));
     3324            LogRel(("%s: %s -> %s failed, because the VM state is actually %s!\n",
     3325                    pszWho, VMR3GetStateName(enmStateOld), VMR3GetStateName(enmStateNew), pszStateCur));
     3326            VMSetError(pVM, VERR_VM_INVALID_VM_STATE, RT_SRC_POS, N_("%s failed because the VM state is %s instead of %s"),
     3327                       pszWho, pszStateCur, VMR3GetStateName(enmStateOld));
    33283328            AssertMsgFailed(("%s: %s -> %s failed, because the VM state is actually %s\n",
    3329                              pszWho, VMR3GetStateName(enmStateOld), VMR3GetStateName(enmStateNew), VMR3GetStateName(enmStateCur)));
     3329                             pszWho, VMR3GetStateName(enmStateOld), VMR3GetStateName(enmStateNew), pszStateCur));
    33303330        }
    33313331        else
    33323332        {
     3333            char   szTransitions[4096];
     3334            size_t cchTransitions = 0;
     3335            szTransitions[0] = '\0';
    33333336            va_end(va);
    33343337            va_start(va, cTransitions);
    3335             LogRel(("%s:\n", pszWho));
    33363338            for (unsigned i = 0; i < cTransitions; i++)
    33373339            {
    33383340                enmStateNew = (VMSTATE)va_arg(va, /*VMSTATE*/int);
    33393341                enmStateOld = (VMSTATE)va_arg(va, /*VMSTATE*/int);
    3340                 LogRel(("%s%s -> %s",
    3341                         i ? ", " : " ", VMR3GetStateName(enmStateOld), VMR3GetStateName(enmStateNew)));
     3342                const char * const pszStateNew = VMR3GetStateName(enmStateNew);
     3343                const char * const pszStateOld = VMR3GetStateName(enmStateOld);
     3344                LogRel(("%s%s -> %s", i ? ", " : " ", pszStateOld, pszStateNew));
     3345                cchTransitions += RTStrPrintf(&szTransitions[cchTransitions], sizeof(szTransitions) - cchTransitions,
     3346                                              "%s%s -> %s", i ? ", " : " ", pszStateOld, pszStateNew);
    33423347            }
    3343             LogRel((" failed, because the VM state is actually %s\n", VMR3GetStateName(enmStateCur)));
     3348            Assert(cchTransitions < sizeof(szTransitions) - 64);
     3349
     3350            LogRel(("%s: %s failed, because the VM state is actually %s!\n", pszWho, szTransitions, pszStateCur));
    33443351            VMSetError(pVM, VERR_VM_INVALID_VM_STATE, RT_SRC_POS,
    3345                        N_("%s failed because the current VM state, %s, was not found in the state transition table (old state %s)"),
    3346                        pszWho, VMR3GetStateName(enmStateCur), VMR3GetStateName(enmStateOld));
    3347             AssertMsgFailed(("%s - state=%s, see release log for full details. Check the cTransitions passed us.\n",
    3348                              pszWho, VMR3GetStateName(enmStateCur)));
     3352                       N_("%s failed because the current VM state, %s, was not found in the state transition table (%s)"),
     3353                       pszWho, pszStateCur, szTransitions);
     3354            AssertMsgFailed(("%s - state=%s, transitions: %s. Check the cTransitions passed us.\n",
     3355                             pszWho, pszStateCur, szTransitions));
    33493356        }
    33503357    }
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