VirtualBox

Ignore:
Timestamp:
Jun 4, 2012 2:07:38 PM (12 years ago)
Author:
vboxsync
Message:

DBGC: Implemented the functions by(addr), dwo(addr), not(value/addr), poi(addr), qwo(addr), and wo(addr). (untested)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp

    r41562 r41565  
    42124212
    42134213
     4214/**
     4215 * @callback_method_impl{Reads a unsigned 8-bit value.}
     4216 */
     4217static DECLCALLBACK(int) dbgcFuncReadU8(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs,
     4218                                        PDBGCVAR pResult)
     4219{
     4220    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4221    AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
     4222    AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
     4223
     4224    uint8_t b;
     4225    int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &b, sizeof(b), &paArgs[0], NULL);
     4226    if (RT_FAILURE(rc))
     4227        return rc;
     4228    DBGCVAR_INIT_NUMBER(pResult, b);
     4229
     4230    NOREF(pFunc);
     4231    return VINF_SUCCESS;
     4232}
     4233
     4234
     4235/**
     4236 * @callback_method_impl{Reads a unsigned 16-bit value.}
     4237 */
     4238static DECLCALLBACK(int) dbgcFuncReadU16(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs,
     4239                                         PDBGCVAR pResult)
     4240{
     4241    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4242    AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
     4243    AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
     4244
     4245    uint16_t u16;
     4246    int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &u16, sizeof(u16), &paArgs[0], NULL);
     4247    if (RT_FAILURE(rc))
     4248        return rc;
     4249    DBGCVAR_INIT_NUMBER(pResult, u16);
     4250
     4251    NOREF(pFunc);
     4252    return VINF_SUCCESS;
     4253}
     4254
     4255
     4256/**
     4257 * @callback_method_impl{Reads a unsigned 32-bit value.}
     4258 */
     4259static DECLCALLBACK(int) dbgcFuncReadU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs,
     4260                                         PDBGCVAR pResult)
     4261{
     4262    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4263    AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
     4264    AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
     4265
     4266    uint32_t u32;
     4267    int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &u32, sizeof(u32), &paArgs[0], NULL);
     4268    if (RT_FAILURE(rc))
     4269        return rc;
     4270    DBGCVAR_INIT_NUMBER(pResult, u32);
     4271
     4272    NOREF(pFunc);
     4273    return VINF_SUCCESS;
     4274}
     4275
     4276
     4277/**
     4278 * @callback_method_impl{Reads a unsigned 64-bit value.}
     4279 */
     4280static DECLCALLBACK(int) dbgcFuncReadU64(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs,
     4281                                         PDBGCVAR pResult)
     4282{
     4283    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4284    AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
     4285    AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
     4286
     4287    uint64_t u64;
     4288    int rc = DBGCCmdHlpMemRead(pCmdHlp, pVM, &u64, sizeof(u64), &paArgs[0], NULL);
     4289    if (RT_FAILURE(rc))
     4290        return rc;
     4291    DBGCVAR_INIT_NUMBER(pResult, u64);
     4292
     4293    NOREF(pFunc);
     4294    return VINF_SUCCESS;
     4295}
     4296
     4297
     4298/**
     4299 * @callback_method_impl{Reads a unsigned pointer-sized value.}
     4300 */
     4301static DECLCALLBACK(int) dbgcFuncReadPtr(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs,
     4302                                         PDBGCVAR pResult)
     4303{
     4304    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4305    AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
     4306    AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
     4307
     4308    CPUMMODE enmMode = DBGCCmdHlpGetCpuMode(pCmdHlp);
     4309    if (enmMode == CPUMMODE_LONG)
     4310        return dbgcFuncReadU64(pFunc, pCmdHlp, pVM, paArgs, cArgs, pResult);
     4311    return dbgcFuncReadU32(pFunc, pCmdHlp, pVM, paArgs, cArgs, pResult);
     4312}
     4313
    42144314
    42154315/**
     
    42204320{
    42214321    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4322
    42224323    uint16_t uHi;
    42234324    switch (paArgs[0].enmType)
     
    42324333            AssertFailedReturn(VERR_DBGC_PARSE_BUG);
    42334334    }
    4234 
    42354335    DBGCVAR_INIT_NUMBER(pResult, uHi);
     4336    DBGCVAR_SET_RANGE(pResult, paArgs[0].enmRangeType, paArgs[0].u64Range);
     4337
    42364338    NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM);
    42374339    return VINF_SUCCESS;
     
    42464348{
    42474349    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4350
    42484351    uint16_t uLow;
    42494352    switch (paArgs[0].enmType)
     
    42584361            AssertFailedReturn(VERR_DBGC_PARSE_BUG);
    42594362    }
    4260 
    42614363    DBGCVAR_INIT_NUMBER(pResult, uLow);
     4364    DBGCVAR_SET_RANGE(pResult, paArgs[0].enmRangeType, paArgs[0].u64Range);
     4365
    42624366    NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM);
    42634367    return VINF_SUCCESS;
    42644368}
    42654369
     4370
     4371/**
     4372 * @callback_method_impl{The low(value) function implementation.}
     4373 */
     4374static DECLCALLBACK(int) dbgcFuncNot(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs,
     4375                                     PDBGCVAR pResult)
     4376{
     4377    AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
     4378    NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM);
     4379    return DBGCCmdHlpEval(pCmdHlp, pResult, "!(%Dv)", &paArgs[0]);
     4380}
     4381
     4382
     4383/** Generic pointer argument wo/ range. */
     4384static const DBGCVARDESC    g_aArgPointerWoRange[] =
     4385{
     4386    /* cTimesMin,   cTimesMax,  enmCategory,            fFlags,                         pszName,        pszDescription */
     4387    {  1,           1,    DBGCVAR_CAT_POINTER_NO_RANGE, 0,                              "value",        "Address or number." },
     4388};
    42664389
    42674390/** Generic pointer or number argument. */
     
    42794402const DBGCFUNC g_aFuncsCodeView[] =
    42804403{
     4404    { "by",     1, 1,   &g_aArgPointerWoRange[0],   RT_ELEMENTS(g_aArgPointerWoRange),  0, dbgcFuncReadU8,  "address", "Reads a byte at the given address." },
     4405    { "dwo",    1, 1,   &g_aArgPointerWoRange[0],   RT_ELEMENTS(g_aArgPointerWoRange),  0, dbgcFuncReadU32, "address", "Reads a 32-bit value at the given address." },
    42814406    { "hi",     1, 1,   &g_aArgPointerNumber[0],    RT_ELEMENTS(g_aArgPointerNumber),   0, dbgcFuncHi,      "value", "Returns the high 16-bit bits of a value." },
    42824407    { "low",    1, 1,   &g_aArgPointerNumber[0],    RT_ELEMENTS(g_aArgPointerNumber),   0, dbgcFuncLow,     "value", "Returns the low 16-bit bits of a value." },
     4408    { "not",    1, 1,   &g_aArgPointerNumber[0],    RT_ELEMENTS(g_aArgPointerNumber),   0, dbgcFuncNot,     "address", "Boolean NOT." },
     4409    { "poi",    1, 1,   &g_aArgPointerWoRange[0],   RT_ELEMENTS(g_aArgPointerWoRange),  0, dbgcFuncReadPtr, "address", "Reads a pointer sized (CS) value at the given address." },
     4410    { "qwo",    1, 1,   &g_aArgPointerWoRange[0],   RT_ELEMENTS(g_aArgPointerWoRange),  0, dbgcFuncReadU64, "address", "Reads a 32-bit value at the given address." },
     4411    { "wo",     1, 1,   &g_aArgPointerWoRange[0],   RT_ELEMENTS(g_aArgPointerWoRange),  0, dbgcFuncReadU16, "address", "Reads a 16-bit value at the given address." },
    42834412};
    42844413
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