VirtualBox

Changeset 8937 in vbox for trunk


Ignore:
Timestamp:
May 20, 2008 12:52:26 AM (17 years ago)
Author:
vboxsync
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.

Location:
trunk/src/VBox/Disassembler
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/Makefile.kmk

    r8933 r8937  
    11# $Id$
    22## @file
    3 # Makefile for the VBox Disassembler.
     3# Sub-Makefile for the VBox Disassembler.
    44#
    55
     
    2020#
    2121
    22 DEPTH = ../../..
    23 include $(KBUILD_PATH)/header.kmk
     22DEPTH ?= ../../..
     23SUB_DEPTH = .
     24include $(KBUILD_PATH)/subheader.kmk
     25
     26# include the sub-makefile first.
     27ifdef VBOX_WITH_TESTCASES
     28 include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
     29endif
    2430
    2531
    26 PROGRAMS                = tstDisasmCore tstDisasm tstDisasm-2
    27 LIBRARIES               = DisasmR3 DisasmCoreR3 DisasmGC DisasmR0
    28 
     32LIBRARIES              += DisasmR3
    2933DisasmR3_TEMPLATE       = VBOXR3
     34DisasmR3_DEFS           = IN_DIS_R3
    3035ifeq ($(KBUILD_TARGET),win)
    3136DisasmR3_CXXFLAGS      += -EHa
    32 else
    33  ifneq ($(KBUILD_TARGET),l4)
     37else ifneq ($(KBUILD_TARGET),l4)
    3438DisasmR3_CXXFLAGS      += -fexceptions
    35  endif
    3639endif
    37 DisasmR3_SOURCES        = Disasm.cpp DisasmCore.cpp DisasmReg.cpp DisasmTables.cpp DisasmTablesX64.cpp
    38 DisasmR3_DEFS           = IN_DIS_R3
     40DisasmR3_SOURCES        = \
     41        Disasm.cpp \
     42        DisasmCore.cpp \
     43        DisasmReg.cpp \
     44        DisasmTables.cpp \
     45        DisasmTablesX64.cpp
    3946
     47LIBRARIES              += DisasmCoreR3
    4048DisasmCoreR3_TEMPLATE   = VBOXR3
    41 DisasmCoreR3_SOURCES    = DisasmCore.cpp DisasmReg.cpp DisasmTables.cpp DisasmTablesX64.cpp
    4249DisasmCoreR3_DEFS       = IN_DIS_R3 DIS_CORE_ONLY
     50DisasmCoreR3_SOURCES    = \
     51        DisasmCore.cpp \
     52        DisasmReg.cpp \
     53        DisasmTables.cpp \
     54        DisasmTablesX64.cpp
    4355
     56LIBRARIES              += DisasmGC
    4457DisasmGC_TEMPLATE       = VBOXGC
    45 DisasmGC_SOURCES        = DisasmCore.cpp DisasmReg.cpp DisasmTables.cpp DisasmTablesX64.cpp
    4658DisasmGC_DEFS           = IN_DIS_GC IN_RT_GC DIS_CORE_ONLY
     59DisasmGC_SOURCES        = \
     60        DisasmCore.cpp \
     61        DisasmReg.cpp \
     62        DisasmTables.cpp \
     63        DisasmTablesX64.cpp
    4764
     65LIBRARIES              += DisasmR0
    4866DisasmR0_TEMPLATE       = VBOXR0
    49 DisasmR0_SOURCES        = DisasmCore.cpp DisasmReg.cpp DisasmTables.cpp DisasmTablesX64.cpp
    5067DisasmR0_DEFS           = IN_DIS_R0 IN_RT_R0 DIS_CORE_ONLY
    51 
    52 tstDisasm_TEMPLATE      = VBOXR3TSTEXE
    53 tstDisasm_SOURCES       = DisasmTest.cpp DisasmTestA.asm
    54 tstDisasm_DEFS          = IN_DIS_R3
    55 tstDisasm_LIBS          = \
    56         $(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
    57         $(LIB_RUNTIME)
    58 
    59 tstDisasmCore_TEMPLATE  = VBOXR3TSTEXE
    60 tstDisasmCore_SOURCES   = DisasmTestCore.cpp
    61 tstDisasmCore_DEFS      = IN_DIS_R3 DIS_CORE_ONLY
    62 tstDisasmCore_LIBS      = \
    63         $(PATH_LIB)/DisasmCoreR3$(VBOX_SUFF_LIB) \
    64         $(LIB_RUNTIME)
    65 
    66 tstDisasm-2_TEMPLATE    = VBOXR3TSTEXE
    67 tstDisasm-2_SOURCES     = testcase/tstDisasm-2.cpp
    68 tstDisasm-2_DEFS        = IN_DIS_R3
    69 tstDisasm-2_LIBS        = \
    70         $(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
    71         $(LIB_RUNTIME)
     68DisasmR0_SOURCES        = \
     69        DisasmCore.cpp \
     70        DisasmReg.cpp \
     71        DisasmTables.cpp \
     72        DisasmTablesX64.cpp
    7273
    7374
    74 include $(KBUILD_PATH)/footer.kmk
     75ifdef VBOX_WITH_TESTCASES
     76 # testcase that hasn't been moved yet.
     77 PROGRAMS              += tstDisasm
     78 tstDisasm_TEMPLATE     = VBOXR3TSTEXE
     79 tstDisasm_DEFS         = IN_DIS_R3
     80 tstDisasm_SOURCES      = DisasmTest.cpp DisasmTestA.asm
     81 tstDisasm_LIBS         = \
     82        $(PATH_LIB)/DisasmR3$(VBOX_SUFF_LIB) \
     83        $(LIB_RUNTIME)
    7584
     85 PROGRAMS              += tstDisasmCore
     86 tstDisasmCore_TEMPLATE = VBOXR3TSTEXE
     87 tstDisasmCore_DEFS     = IN_DIS_R3 DIS_CORE_ONLY
     88 tstDisasmCore_SOURCES  = DisasmTestCore.cpp
     89 tstDisasmCore_LIBS     = \
     90        $(PATH_LIB)/DisasmCoreR3$(VBOX_SUFF_LIB) \
     91        $(LIB_RUNTIME)
     92endif # VBOX_WITH_TESTCASES
     93
     94
     95include $(KBUILD_PATH)/subfooter.kmk
     96
  • trunk/src/VBox/Disassembler/testcase/tstAsmLock-1.asm

    r8935 r8937  
    33; Disassembly testcase - Valid lock sequences and related instructions.
    44;
    5 ; The intention is to check in a binary and the disassembler output.
    6 ; Both will be recreated and verified during testing.
     5; This is a build test, that means it will be assembled, disassembled,
     6; then the disassembly output will be assembled and the new binary will
     7; compared with the original.
    78;
    89
     
    2324;
    2425
    25     BITS 32
     26    BITS TEST_BITS
    2627
    2728    ; ADC
  • trunk/src/VBox/Disassembler/testcase/tstAsmLock-2.asm

    r8935 r8937  
    2323;
    2424
    25     BITS 32
     25    BITS TEST_BITS
    2626
    2727    ; ADC
  • trunk/src/VBox/Disassembler/testcase/tstAsmLock-3.asm

    r8935 r8937  
    2323;
    2424
    25     BITS 32
     25    BITS TEST_BITS
    2626
    2727    lock mov ebp, esp
     
    3939    lock mov [ebx], dl
    4040    lock ret
     41%if TEST_BITS != 64
    4142    lock pop  ebp
    4243    lock push esp
     44%else
     45    lock pop  rbp
     46    lock push rsp
     47%endif
    4348
  • 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.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette