VirtualBox

Ignore:
Timestamp:
May 20, 2008 12:52:26 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
31001
Message:

Wrote up the makefile bits or the dissassembler test 'framework' and hacked together a yasmification of the DIS output sufficient to make the current tests work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp

    r8935 r8937  
    7272static void MyDisasYasmFormatter(PMYDISSTATE pState)
    7373{
    74     RTPrintf("yasm not implemented: %s", pState->szLine);
     74    /* a very quick hack. */
     75    char szTmp[256];
     76    strcpy(szTmp, RTStrStripL(strchr(pState->szLine, ':') + 1));
     77
     78    char *psz = strrchr(szTmp, '[');
     79    *psz = '\0';
     80    RTStrStripR(szTmp);
     81
     82    psz = strstr(szTmp, " ptr ");
     83    if (psz)
     84        memset(psz, ' ', 5);
     85
     86    char *pszEnd = strchr(szTmp, '\0');
     87    while (pszEnd - &szTmp[0] < 71)
     88        *pszEnd++ = ' ';
     89    *pszEnd = '\0';
     90
     91    RTPrintf("    %s ; %s", szTmp, pState->szLine);
    7592}
    7693
     
    223240
    224241        case kAsmStyle_yasm:
     242            RTPrintf("    BITS %d\n", enmCpuMode == CPUMODE_16BIT ? 16 : enmCpuMode == CPUMODE_32BIT ? 32 : 64);
    225243            pfnFormatter = MyDisasYasmFormatter;
    226244            break;
     
    257275            else
    258276            {
    259                 RTPrintf("%s: error at %#RX64: unexpected valid instruction\n", argv0, State.uAddress);
     277                RTPrintf("%s: error at %#RX64: unexpected valid instruction (op=%d)\n", argv0, State.uAddress, State.Cpu.pCurInstr->opcode);
    260278                pfnFormatter(&State);
    261279                rcRet = VERR_GENERAL_FAILURE;
     
    325343{
    326344    RTR3Init();
     345    const char * const argv0 = RTPathFilename(argv[0]);
    327346
    328347    /* options */
     
    378397                else
    379398                {
    380                     RTStrmPrintf(g_pStdErr, "%s: Invalid CPU mode value %RU32\n", argv[0], ValueUnion.u32);
     399                    RTStrmPrintf(g_pStdErr, "%s: Invalid CPU mode value %RU32\n", argv0, ValueUnion.u32);
    381400                    return 1;
    382401                }
     
    384403
    385404            case 'h':
    386                 return Usage(argv[0]);
     405                return Usage(argv0);
    387406
    388407            case 'i':
     
    418437                {
    419438                    enmStyle = kAsmStyle_masm;
    420                     RTStrmPrintf(g_pStdErr, "%s: masm style isn't implemented yet\n", argv[0]);
     439                    RTStrmPrintf(g_pStdErr, "%s: masm style isn't implemented yet\n", argv0);
    421440                    return 1;
    422441                }
    423442                else
    424443                {
    425                     RTStrmPrintf(g_pStdErr, "%s: unknown assembly style: %s\n", argv[0], ValueUnion.psz);
     444                    RTStrmPrintf(g_pStdErr, "%s: unknown assembly style: %s\n", argv0, ValueUnion.psz);
    426445                    return 1;
    427446                }
     
    429448
    430449            default:
    431                 RTStrmPrintf(g_pStdErr, "%s: syntax error: %Rrc\n", argv[0], ch);
     450                RTStrmPrintf(g_pStdErr, "%s: syntax error: %Rrc\n", argv0, ch);
    432451                return 1;
    433452        }
    434453    }
    435454    if (iArg >= argc)
    436         return Usage(argv[0]);
     455        return Usage(argv0);
    437456
    438457    /*
     
    450469        if (RT_FAILURE(rc))
    451470        {
    452             RTStrmPrintf(g_pStdErr, "%s: %s: %Rrc\n", argv[0], argv[iArg], rc);
     471            RTStrmPrintf(g_pStdErr, "%s: %s: %Rrc\n", argv0, argv[iArg], rc);
    453472            break;
    454473        }
     
    457476         * Disassemble it.
    458477         */
    459         rc = MyDisasmBlock(argv[0], enmCpuMode, uAddress, (uint8_t *)pvFile, cbFile, enmStyle, fListing, fRaw, fAllInvalid);
     478        rc = MyDisasmBlock(argv0, enmCpuMode, uAddress, (uint8_t *)pvFile, cbFile, enmStyle, fListing, fRaw, fAllInvalid);
    460479        if (RT_FAILURE(rc))
    461480            break;
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