Changeset 41714 in vbox
- Timestamp:
- Jun 14, 2012 4:12:57 PM (12 years ago)
- Location:
- trunk/src/VBox/Disassembler
- Files:
-
- 2 edited
-
DisasmTest.cpp (modified) (1 diff)
-
DisasmTestA.asm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Disassembler/DisasmTest.cpp
r41690 r41714 20 20 *******************************************************************************/ 21 21 #include <VBox/dis.h> 22 #include <iprt/test.h> 23 #include <iprt/asm.h> 24 #include <iprt/string.h> 22 25 #include <VBox/err.h> 23 #include <stdio.h>24 #include <iprt/string.h>25 #include <iprt/asm.h>26 26 27 DECLASM(int) TestProc(); 27 28 DECLASM(int) TestProc32(void); 29 char TestProc32_End; 28 30 #ifndef RT_OS_OS2 29 DECLASM(int) TestProc64(); 31 DECLASM(int) TestProc64(void); 32 char TestProc64_End; 30 33 #endif 31 34 //uint8_t aCode16[] = { 0x66, 0x67, 0x89, 0x07 }; 32 35 36 static void testDisas(uint8_t const *pabInstrs, size_t cbInstrs, DISCPUMODE enmDisCpuMode) 37 { 38 for (size_t off = 0; off < cbInstrs; off++) 39 { 40 uint32_t const cErrBefore = RTTestIErrorCount(); 41 uint32_t cb = 1; 42 DISCPUSTATE Cpu; 43 char szOutput[256] = {0}; 44 int rc = DISInstrToStr(&pabInstrs[off], enmDisCpuMode, &Cpu, &cb, szOutput, sizeof(szOutput)); 45 46 47 RTTESTI_CHECK_RC(rc, VINF_SUCCESS); 48 RTTESTI_CHECK(cb == Cpu.opsize); 49 RTTESTI_CHECK(cb > 0); 50 RTTESTI_CHECK(cb <= 16); 51 if (cErrBefore != RTTestIErrorCount()) 52 RTTestIFailureDetails("rc=%Rrc, off=%#x (%u) cbInstr=%u enmDisCpuMode=%d", 53 rc, off, Cpu.opsize, enmDisCpuMode); 54 RTTestIPrintf(RTTESTLVL_ALWAYS, "%s", szOutput); 55 off += cb; 56 } 57 58 } 59 60 33 61 int main(int argc, char **argv) 34 62 { 35 printf("VBox Disassembler Test\n"); 36 if (argc != 1) 37 { 38 //printf("DisasmBlock on printf:\n"); 39 //DisasmBlock((uint8_t *)printf, 256); 40 } 41 else 42 { 43 uint8_t const *pbInstr = (uint8_t const *)(uintptr_t)TestProc; 63 RTTEST hTest; 64 RTEXITCODE rcExit = RTTestInitAndCreate("tstDisasm", &hTest); 65 if (rcExit) 66 return rcExit; 67 RTTestBanner(hTest); 44 68 45 for (int i=0;i<50;i++)46 {47 unsigned cb;48 DISCPUSTATE cpu;49 char szOutput[256];50 69 51 if (RT_SUCCESS(DISInstrToStr(pbInstr, DISCPUMODE_32BIT, &cpu, &cb, szOutput, sizeof(szOutput)))) 52 { 53 printf("%s", szOutput); 54 } 55 else 56 { 57 printf("DISOne failed!\n"); 58 return 1; 59 } 60 pbInstr += cb; 61 } 70 testDisas((uint8_t const *)(uintptr_t)TestProc32, (uintptr_t)&TestProc32_End - (uintptr_t)TestProc32, DISCPUMODE_32BIT); 71 #ifndef RT_OS_OS2 72 testDisas((uint8_t const *)(uintptr_t)TestProc64, (uintptr_t)&TestProc64_End - (uintptr_t)TestProc64, DISCPUMODE_64BIT); 73 #endif 62 74 63 #ifndef RT_OS_OS2 64 printf("\n64 bits disassembly\n"); 65 pbInstr = (uint8_t const *)(uintptr_t)TestProc64; 66 67 ////__debugbreak(); 68 for (int i=0;i<50;i++) 69 { 70 unsigned cb; 71 DISCPUSTATE cpu; 72 char szOutput[256]; 73 74 if (RT_SUCCESS(DISInstrToStr(pbInstr, DISCPUMODE_64BIT, &cpu, &cb, szOutput, sizeof(szOutput)))) 75 printf("%s", szOutput); 76 else 77 { 78 printf("DISOne failed!\n"); 79 return 1; 80 } 81 pbInstr += cb; 82 } 83 #endif 84 } 85 return 0; 75 return RTTestSummaryAndDestroy(hTest); 86 76 } 87 77 -
trunk/src/VBox/Disassembler/DisasmTestA.asm
r37955 r41714 30 30 31 31 align 16 32 BEGINPROC TestProc 32 BEGINPROC TestProc32 33 33 xor eax, eax 34 34 mov al, 4 … … 82 82 pause 83 83 84 ENDPROC TestProc 84 ENDPROC TestProc32 85 85 86 86 %ifndef RT_OS_OS2
Note:
See TracChangeset
for help on using the changeset viewer.

