Index: trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp
===================================================================
--- trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp	(revision 8933)
+++ trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp	(revision 8934)
@@ -43,4 +43,6 @@
     uint8_t        *pbInstr;            /**< The current instruction (pointer). */
     uint32_t        cbInstr;            /**< The size of the current instruction. */
+    bool            fInvalid;           /**< Whether the instruction is invalid/illegal or not. */
+    bool            fRaw;               /**< Whether invalid instructions are printed as byte defintions or not. */
     int             rc;                 /**< Set if we hit EOF. */
     size_t          cbLeft;             /**< The number of bytes left. (read) */
@@ -191,7 +193,9 @@
  * @param   enmStyle    The assembly output style.
  * @param   fListing    Whether to print in a listing like mode.
+ * @param   fRaw        Whether to output byte definitions for invalid sequences.
+ * @param   fAllInvalid Whether all instructions are expected to be invalid.
  */
 static int MyDisasmBlock(const char *argv0, DISCPUMODE enmCpuMode, uint64_t uAddress, uint8_t *pbFile, size_t cbFile,
-                         ASMSTYLE enmStyle, bool fListing)
+                         ASMSTYLE enmStyle, bool fListing, bool fRaw, bool fAllInvalid)
 {
     /*
@@ -204,4 +208,6 @@
     State.pbInstr = pbFile;
     State.cbInstr = 0;
+    State.fInvalid = false;
+    State.fRaw = fRaw;
     State.rc = VINF_SUCCESS;
     State.cbLeft = cbFile;
@@ -245,5 +251,14 @@
         if (RT_SUCCESS(rc))
         {
-            pfnFormatter(&State);
+            State.fInvalid = State.Cpu.pCurInstr->opcode == OP_INVALID
+                          || State.Cpu.pCurInstr->opcode == OP_ILLUD2;
+            if (!State.fInvalid || !fAllInvalid)
+                pfnFormatter(&State);
+            else
+            {
+                RTPrintf("%s: error at %#RX64: unexpected valid instruction\n", argv0, State.uAddress);
+                pfnFormatter(&State);
+                rcRet = VERR_GENERAL_FAILURE;
+            }
         }
         else
@@ -257,5 +272,6 @@
             {
                 RTPrintf("%s: error at %#RX64: %Rrc cbInstr=%d!\n", argv0, State.uAddress, rc, State.cbInstr);
-                rcRet = rc;
+                if (rcRet == VINF_SUCCESS)
+                    rcRet = rc;
                 break;
             }
@@ -291,8 +307,12 @@
 "  --cpumode|-c <16|32|64>\n"
 "    The cpu mode. Default: 32\n"
+"  --all-invalid|-i\n"
+"    When specified all instructions are expected to be invalid.\n"
 "  --listing|-l, --no-listing|-L\n"
 "    Enables or disables listing mode. Default: --no-listing\n"
 "  --offset|-o <offset>\n"
 "    The file offset at which to start disassembling. Default: 0\n"
+"  --raw|-r, --no-raw|-R\n"
+"    Whether to employ byte defines for unknown bits. Default: --no-raw\n"
 "  --style|-s <default|yasm|masm>\n"
 "    The assembly output style. Default: default\n"
@@ -310,4 +330,6 @@
     ASMSTYLE enmStyle = kAsmStyle_Default;
     bool fListing = true;
+    bool fRaw = false;
+    bool fAllInvalid = false;
     DISCPUMODE enmCpuMode = CPUMODE_32BIT;
     RTFOFF off = 0;
@@ -323,7 +345,10 @@
         { "--help",         'h', 0 },
         { "--bytes",        'b', RTGETOPT_REQ_INT64 },
+        { "--all-invalid",  'i', 0, },
         { "--listing",      'l', 0 },
         { "--no-listing",   'L', 0 },
         { "--offset",       'o', RTGETOPT_REQ_INT64 },
+        { "--raw",          'r', 0 },
+        { "--no-raw",       'R', 0 },
         { "--style",        's', RTGETOPT_REQ_STRING },
     };
@@ -361,4 +386,8 @@
                 return Usage(argv[0]);
 
+            case 'i':
+                fAllInvalid = true;
+                break;
+
             case 'l':
                 fListing = true;
@@ -371,4 +400,12 @@
             case 'o':
                 off = ValueUnion.i;
+                break;
+
+            case 'r':
+                fRaw = true;
+                break;
+
+            case 'R':
+                fRaw = false;
                 break;
 
@@ -420,5 +457,5 @@
          * Disassemble it.
          */
-        rc = MyDisasmBlock(argv[0], enmCpuMode, uAddress, (uint8_t *)pvFile, cbFile, enmStyle, fListing);
+        rc = MyDisasmBlock(argv[0], enmCpuMode, uAddress, (uint8_t *)pvFile, cbFile, enmStyle, fListing, fRaw, fAllInvalid);
         if (RT_FAILURE(rc))
             break;
