Blob Blame History Raw
diff -ur valgrind-3.8.1.orig/coregrind/m_main.c valgrind-3.8.1/coregrind/m_main.c
--- valgrind-3.8.1.orig/coregrind/m_main.c	2012-11-04 21:57:03.722415879 +0100
+++ valgrind-3.8.1/coregrind/m_main.c	2012-11-04 21:57:37.250896792 +0100
@@ -198,6 +198,7 @@
 "              To use a non-libc malloc library that is\n"
 "                  in the main exe:  --soname-synonyms=somalloc=NONE\n"
 "                  in libxyzzy.so:   --soname-synonyms=somalloc=libxyzzy.so\n"
+"    --sigill-diagnostics=yes|no  warn about illegal instructions? [yes]\n"
 "\n";
 
    Char* usage2 = 
@@ -422,6 +423,10 @@
    Char* log_fsname_unexpanded = NULL;
    Char* xml_fsname_unexpanded = NULL;
 
+   /* Whether the user has explicitly provided --sigill-diagnostics.
+      If not explicitly given depends on general verbosity setting. */
+   Bool sigill_diag_set = False;
+
    /* Log to stderr by default, but usage message goes to stdout.  XML
       output is initially disabled. */
    tmp_log_fd = 2; 
@@ -516,6 +521,9 @@
                VG_STREQ(arg, "--quiet"))
          VG_(clo_verbosity)--;
 
+      else if VG_BOOL_CLO(arg, "--sigill-diagnostics", VG_(clo_sigill_diag))
+         sigill_diag_set = True;
+
       else if VG_BOOL_CLO(arg, "--stats",          VG_(clo_stats)) {}
       else if VG_BOOL_CLO(arg, "--xml",            VG_(clo_xml))
          VG_(debugLog_setXml)(VG_(clo_xml));
@@ -777,6 +785,9 @@
    if (VG_(clo_verbosity) < 0)
       VG_(clo_verbosity) = 0;
 
+   if (!sigill_diag_set)
+      VG_(clo_sigill_diag) = (VG_(clo_verbosity) > 0);
+
    if (VG_(clo_trace_notbelow) == -1) {
      if (VG_(clo_trace_notabove) == -1) {
        /* [] */
diff -ur valgrind-3.8.1.orig/coregrind/m_options.c valgrind-3.8.1/coregrind/m_options.c
--- valgrind-3.8.1.orig/coregrind/m_options.c	2012-11-04 21:57:03.709415680 +0100
+++ valgrind-3.8.1/coregrind/m_options.c	2012-11-04 21:57:37.251896807 +0100
@@ -118,7 +118,7 @@
 VgSmc  VG_(clo_smc_check)      = Vg_SmcStack;
 HChar* VG_(clo_kernel_variant) = NULL;
 Bool   VG_(clo_dsymutil)       = False;
-
+Bool   VG_(clo_sigill_diag)    = True;
 
 /*====================================================================*/
 /*=== File expansion                                               ===*/
diff -ur valgrind-3.8.1.orig/coregrind/m_scheduler/scheduler.c valgrind-3.8.1/coregrind/m_scheduler/scheduler.c
--- valgrind-3.8.1.orig/coregrind/m_scheduler/scheduler.c	2012-11-04 21:57:03.720415849 +0100
+++ valgrind-3.8.1/coregrind/m_scheduler/scheduler.c	2012-11-04 21:57:37.252896823 +0100
@@ -1427,9 +1427,10 @@
       case VEX_TRC_JMP_NODECODE: {
          Addr addr = VG_(get_IP)(tid);
 
-         VG_(umsg)(
-            "valgrind: Unrecognised instruction at address %#lx.\n", addr);
-         VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
+         if (VG_(clo_sigill_diag)) {
+            VG_(umsg)(
+               "valgrind: Unrecognised instruction at address %#lx.\n", addr);
+            VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
 #define M(a) VG_(umsg)(a "\n");
    M("Your program just tried to execute an instruction that Valgrind" );
    M("did not recognise.  There are two possible reasons for this."    );
@@ -1442,6 +1443,7 @@
    M("Either way, Valgrind will now raise a SIGILL signal which will"  );
    M("probably kill your program."                                     );
 #undef M
+         }
 
 #if defined(VGA_s390x)
          /* Now that the complaint is out we need to adjust the guest_IA. The
diff -ur valgrind-3.8.1.orig/coregrind/m_translate.c valgrind-3.8.1/coregrind/m_translate.c
--- valgrind-3.8.1.orig/coregrind/m_translate.c	2012-11-04 21:57:03.721415864 +0100
+++ valgrind-3.8.1/coregrind/m_translate.c	2012-11-04 21:57:37.261896960 +0100
@@ -1524,6 +1524,7 @@
    vta.needs_self_check  = needs_self_check;
    vta.preamble_function = preamble_fn;
    vta.traceflags        = verbosity;
+   vta.sigill_diag       = VG_(clo_sigill_diag);
    vta.addProfInc        = VG_(clo_profile_flags) > 0
                            && kind != T_NoRedir;
 
diff -ur valgrind-3.8.1.orig/coregrind/pub_core_options.h valgrind-3.8.1/coregrind/pub_core_options.h
--- valgrind-3.8.1.orig/coregrind/pub_core_options.h	2012-11-04 21:57:03.704415605 +0100
+++ valgrind-3.8.1/coregrind/pub_core_options.h	2012-11-04 21:57:37.300897526 +0100
@@ -275,6 +275,11 @@
 extern Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name,
                                               HChar** child_argv );
 
+/* Whether illegal instructions should be reported/diagnosed.
+   Can be explicitly set through --sigill-diagnostics otherwise
+   depends on verbosity (False if -q). */
+extern Bool VG_(clo_sigill_diag);
+
 #endif   // __PUB_CORE_OPTIONS_H
 
 /*--------------------------------------------------------------------*/
diff -ur valgrind-3.8.1.orig/docs/xml/manual-core.xml valgrind-3.8.1/docs/xml/manual-core.xml
--- valgrind-3.8.1.orig/docs/xml/manual-core.xml	2012-11-04 21:57:03.689415507 +0100
+++ valgrind-3.8.1/docs/xml/manual-core.xml	2012-11-04 21:57:37.302897560 +0100
@@ -1036,6 +1036,26 @@
     </listitem>
   </varlistentry>
 
+  <varlistentry id="opt.sigill-diagnostics" xreflabel="--sigill-diagnostics">
+    <term>
+      <option><![CDATA[--sigill-diagnostics=<yes|no> [default: yes] ]]></option>
+    </term>
+    <listitem>
+      <para>Enable/disable printing of illegal instruction diagnostics.
+      Enabled by default, but defaults to disabled when
+      <option>--quiet</option> is given. The default can always be explicitly
+      overridden by giving this option.</para>
+
+      <para>When enabled a warning message will be printed with some
+      diagnostics whenever some instruction is encountered that valgrind
+      cannot decode or translate before the program is given a SIGILL signal.
+      Often an illegal instruction indicates a bug in the program or missing
+      support for the particular instruction in Valgrind. But some programs
+      do deliberately try to execute an instruction that might be missing
+      and trap the SIGILL signal to detect processor features.</para>
+    </listitem>
+  </varlistentry>
+
   <varlistentry id="opt.stack-traces" xreflabel="--show-below-main">
     <term>
       <option><![CDATA[--show-below-main=<yes|no> [default: no] ]]></option>
diff -ur valgrind-3.8.1.orig/none/tests/cmdline1.stdout.exp valgrind-3.8.1/none/tests/cmdline1.stdout.exp
--- valgrind-3.8.1.orig/none/tests/cmdline1.stdout.exp	2012-11-04 21:57:03.844417741 +0100
+++ valgrind-3.8.1/none/tests/cmdline1.stdout.exp	2012-11-04 21:57:37.385898730 +0100
@@ -87,6 +87,7 @@
               To use a non-libc malloc library that is
                   in the main exe:  --soname-synonyms=somalloc=NONE
                   in libxyzzy.so:   --soname-synonyms=somalloc=libxyzzy.so
+    --sigill-diagnostics=yes|no  warn about illegal instructions? [yes]
 
   user options for Nulgrind:
     (none)
diff -ur valgrind-3.8.1.orig/none/tests/cmdline2.stdout.exp valgrind-3.8.1/none/tests/cmdline2.stdout.exp
--- valgrind-3.8.1.orig/none/tests/cmdline2.stdout.exp	2012-11-04 21:57:03.811417238 +0100
+++ valgrind-3.8.1/none/tests/cmdline2.stdout.exp	2012-11-04 21:57:37.386898745 +0100
@@ -87,6 +87,7 @@
               To use a non-libc malloc library that is
                   in the main exe:  --soname-synonyms=somalloc=NONE
                   in libxyzzy.so:   --soname-synonyms=somalloc=libxyzzy.so
+    --sigill-diagnostics=yes|no  warn about illegal instructions? [yes]
 
   user options for Nulgrind:
     (none)
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_amd64_defs.h valgrind-3.8.1/VEX/priv/guest_amd64_defs.h
--- valgrind-3.8.1.orig/VEX/priv/guest_amd64_defs.h	2012-11-04 21:57:03.782416795 +0100
+++ valgrind-3.8.1/VEX/priv/guest_amd64_defs.h	2012-11-04 21:57:36.328883370 +0100
@@ -56,7 +56,8 @@
                            VexArch      guest_arch,
                            VexArchInfo* archinfo,
                            VexAbiInfo*  abiinfo,
-                           Bool         host_bigendian );
+                           Bool         host_bigendian,
+                           Bool         sigill_diag );
 
 /* Used by the optimiser to specialise calls to helpers. */
 extern
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_amd64_toIR.c valgrind-3.8.1/VEX/priv/guest_amd64_toIR.c
--- valgrind-3.8.1.orig/VEX/priv/guest_amd64_toIR.c	2012-11-04 21:57:03.784416825 +0100
+++ valgrind-3.8.1/VEX/priv/guest_amd64_toIR.c	2012-11-04 21:57:36.465885366 +0100
@@ -30426,7 +30426,8 @@
              void*        callback_opaque,
              Long         delta64,
              VexArchInfo* archinfo,
-             VexAbiInfo*  vbi
+             VexAbiInfo*  vbi,
+             Bool         sigill_diag
           )
 {
    IRTemp    t1, t2, t3, t4, t5, t6;
@@ -30956,29 +30957,31 @@
      //default:
   decode_failure:
    /* All decode failures end up here. */
-   vex_printf("vex amd64->IR: unhandled instruction bytes: "
-              "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
-              (Int)getUChar(delta_start+0),
-              (Int)getUChar(delta_start+1),
-              (Int)getUChar(delta_start+2),
-              (Int)getUChar(delta_start+3),
-              (Int)getUChar(delta_start+4),
-              (Int)getUChar(delta_start+5),
-              (Int)getUChar(delta_start+6),
-              (Int)getUChar(delta_start+7) );
-   vex_printf("vex amd64->IR:   REX=%d REX.W=%d REX.R=%d REX.X=%d REX.B=%d\n",
-              haveREX(pfx) ? 1 : 0, getRexW(pfx), getRexR(pfx),
-              getRexX(pfx), getRexB(pfx));
-   vex_printf("vex amd64->IR:   VEX=%d VEX.L=%d VEX.nVVVV=0x%x ESC=%s\n",
-              haveVEX(pfx) ? 1 : 0, getVexL(pfx),
-              getVexNvvvv(pfx),
-              esc==ESC_NONE ? "NONE" :
-                esc==ESC_0F ? "0F" :
-                esc==ESC_0F38 ? "0F38" :
-                esc==ESC_0F3A ? "0F3A" : "???");
-   vex_printf("vex amd64->IR:   PFX.66=%d PFX.F2=%d PFX.F3=%d\n",
-              have66(pfx) ? 1 : 0, haveF2(pfx) ? 1 : 0,
-              haveF3(pfx) ? 1 : 0);
+   if (sigill_diag) {
+      vex_printf("vex amd64->IR: unhandled instruction bytes: "
+                 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+                 (Int)getUChar(delta_start+0),
+                 (Int)getUChar(delta_start+1),
+                 (Int)getUChar(delta_start+2),
+                 (Int)getUChar(delta_start+3),
+                 (Int)getUChar(delta_start+4),
+                 (Int)getUChar(delta_start+5),
+                 (Int)getUChar(delta_start+6),
+                 (Int)getUChar(delta_start+7) );
+      vex_printf("vex amd64->IR:   REX=%d REX.W=%d REX.R=%d REX.X=%d REX.B=%d\n",
+                 haveREX(pfx) ? 1 : 0, getRexW(pfx), getRexR(pfx),
+                 getRexX(pfx), getRexB(pfx));
+      vex_printf("vex amd64->IR:   VEX=%d VEX.L=%d VEX.nVVVV=0x%x ESC=%s\n",
+                 haveVEX(pfx) ? 1 : 0, getVexL(pfx),
+                 getVexNvvvv(pfx),
+                 esc==ESC_NONE ? "NONE" :
+                   esc==ESC_0F ? "0F" :
+                   esc==ESC_0F38 ? "0F38" :
+                   esc==ESC_0F3A ? "0F3A" : "???");
+      vex_printf("vex amd64->IR:   PFX.66=%d PFX.F2=%d PFX.F3=%d\n",
+                 have66(pfx) ? 1 : 0, haveF2(pfx) ? 1 : 0,
+                 haveF3(pfx) ? 1 : 0);
+   }
 
    /* Tell the dispatcher that this insn cannot be decoded, and so has
       not been executed, and (is currently) the next to be executed.
@@ -31041,7 +31044,8 @@
                            VexArch      guest_arch,
                            VexArchInfo* archinfo,
                            VexAbiInfo*  abiinfo,
-                           Bool         host_bigendian_IN )
+                           Bool         host_bigendian_IN,
+                           Bool         sigill_diag_IN )
 {
    Int       i, x1, x2;
    Bool      expect_CAS, has_CAS;
@@ -31064,7 +31068,7 @@
    dres = disInstr_AMD64_WRK ( &expect_CAS, resteerOkFn,
                                resteerCisOk,
                                callback_opaque,
-                               delta, archinfo, abiinfo );
+                               delta, archinfo, abiinfo, sigill_diag_IN );
    x2 = irsb_IN->stmts_used;
    vassert(x2 >= x1);
 
@@ -31097,7 +31101,7 @@
       dres = disInstr_AMD64_WRK ( &expect_CAS, resteerOkFn,
                                   resteerCisOk,
                                   callback_opaque,
-                                  delta, archinfo, abiinfo );
+                                  delta, archinfo, abiinfo, sigill_diag_IN );
       for (i = x1; i < x2; i++) {
          vex_printf("\t\t");
          ppIRStmt(irsb_IN->stmts[i]);
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_arm_defs.h valgrind-3.8.1/VEX/priv/guest_arm_defs.h
--- valgrind-3.8.1.orig/VEX/priv/guest_arm_defs.h	2012-11-04 21:57:03.790416917 +0100
+++ valgrind-3.8.1/VEX/priv/guest_arm_defs.h	2012-11-04 21:57:36.588887153 +0100
@@ -50,7 +50,8 @@
                          VexArch      guest_arch,
                          VexArchInfo* archinfo,
                          VexAbiInfo*  abiinfo,
-                         Bool         host_bigendian );
+                         Bool         host_bigendian,
+                         Bool         sigill_diag );
 
 /* Used by the optimiser to specialise calls to helpers. */
 extern
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_arm_toIR.c valgrind-3.8.1/VEX/priv/guest_arm_toIR.c
--- valgrind-3.8.1.orig/VEX/priv/guest_arm_toIR.c	2012-11-04 21:57:03.787416871 +0100
+++ valgrind-3.8.1/VEX/priv/guest_arm_toIR.c	2012-11-04 21:57:36.812890419 +0100
@@ -12564,7 +12564,8 @@
              void*        callback_opaque,
              UChar*       guest_instr,
              VexArchInfo* archinfo,
-             VexAbiInfo*  abiinfo
+             VexAbiInfo*  abiinfo,
+             Bool         sigill_diag
           )
 {
    // A macro to fish bits out of 'insn'.
@@ -14643,15 +14644,17 @@
 
   decode_failure:
    /* All decode failures end up here. */
-   vex_printf("disInstr(arm): unhandled instruction: "
-              "0x%x\n", insn);
-   vex_printf("                 cond=%d(0x%x) 27:20=%u(0x%02x) "
-                                "4:4=%d "
-                                "3:0=%u(0x%x)\n",
-              (Int)INSN_COND, (UInt)INSN_COND,
-              (Int)INSN(27,20), (UInt)INSN(27,20),
-              (Int)INSN(4,4),
-              (Int)INSN(3,0), (UInt)INSN(3,0) );
+   if (sigill_diag) {
+      vex_printf("disInstr(arm): unhandled instruction: "
+                 "0x%x\n", insn);
+      vex_printf("                 cond=%d(0x%x) 27:20=%u(0x%02x) "
+                                   "4:4=%d "
+                                   "3:0=%u(0x%x)\n",
+                 (Int)INSN_COND, (UInt)INSN_COND,
+                 (Int)INSN(27,20), (UInt)INSN(27,20),
+                 (Int)INSN(4,4),
+                 (Int)INSN(3,0), (UInt)INSN(3,0) );
+   }
 
    /* Tell the dispatcher that this insn cannot be decoded, and so has
       not been executed, and (is currently) the next to be executed.
@@ -14760,7 +14763,8 @@
              void*        callback_opaque,
              UChar*       guest_instr,
              VexArchInfo* archinfo,
-             VexAbiInfo*  abiinfo
+             VexAbiInfo*  abiinfo,
+             Bool         sigill_diag
           )
 {
    /* A macro to fish bits out of insn0.  There's also INSN1, to fish
@@ -18746,8 +18750,9 @@
 
   decode_failure:
    /* All decode failures end up here. */
-   vex_printf("disInstr(thumb): unhandled instruction: "
-              "0x%04x 0x%04x\n", (UInt)insn0, (UInt)insn1);
+   if (sigill_diag)
+      vex_printf("disInstr(thumb): unhandled instruction: "
+                 "0x%04x 0x%04x\n", (UInt)insn0, (UInt)insn1);
 
    /* Back up ITSTATE to the initial value for this instruction.
       If we don't do that, any subsequent restart of the instruction
@@ -18892,7 +18897,8 @@
                          VexArch      guest_arch,
                          VexArchInfo* archinfo,
                          VexAbiInfo*  abiinfo,
-                         Bool         host_bigendian_IN )
+                         Bool         host_bigendian_IN,
+                         Bool         sigill_diag_IN )
 {
    DisResult dres;
    Bool isThumb = (Bool)(guest_IP_ENCODED & 1);
@@ -18914,12 +18920,12 @@
       dres = disInstr_THUMB_WRK ( resteerOkFn,
                                   resteerCisOk, callback_opaque,
                                   &guest_code_IN[delta_ENCODED - 1],
-                                  archinfo, abiinfo );
+                                  archinfo, abiinfo, sigill_diag_IN );
    } else {
       dres = disInstr_ARM_WRK ( resteerOkFn,
                                 resteerCisOk, callback_opaque,
                                 &guest_code_IN[delta_ENCODED],
-                                archinfo, abiinfo );
+                                archinfo, abiinfo, sigill_diag_IN );
    }
 
    return dres;
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_generic_bb_to_IR.c valgrind-3.8.1/VEX/priv/guest_generic_bb_to_IR.c
--- valgrind-3.8.1.orig/VEX/priv/guest_generic_bb_to_IR.c	2012-11-04 21:57:03.790416917 +0100
+++ valgrind-3.8.1/VEX/priv/guest_generic_bb_to_IR.c	2012-11-04 21:57:36.918891974 +0100
@@ -187,6 +187,7 @@
          /*IN*/ Addr64           guest_IP_bbstart,
          /*IN*/ Bool             (*chase_into_ok)(void*,Addr64),
          /*IN*/ Bool             host_bigendian,
+         /*IN*/ Bool             sigill_diag,
          /*IN*/ VexArch          arch_guest,
          /*IN*/ VexArchInfo*     archinfo_guest,
          /*IN*/ VexAbiInfo*      abiinfo_both,
@@ -361,7 +362,8 @@
                             arch_guest,
                             archinfo_guest,
                             abiinfo_both,
-                            host_bigendian );
+                            host_bigendian,
+                            sigill_diag );
 
       /* stay sane ... */
       vassert(dres.whatNext == Dis_StopHere
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_generic_bb_to_IR.h valgrind-3.8.1/VEX/priv/guest_generic_bb_to_IR.h
--- valgrind-3.8.1.orig/VEX/priv/guest_generic_bb_to_IR.h	2012-11-04 21:57:03.790416917 +0100
+++ valgrind-3.8.1/VEX/priv/guest_generic_bb_to_IR.h	2012-11-04 21:57:36.970892726 +0100
@@ -150,7 +150,10 @@
       /*IN*/  VexAbiInfo*  abiinfo,
 
       /* Is the host bigendian? */
-      /*IN*/  Bool         host_bigendian
+      /*IN*/  Bool         host_bigendian,
+
+      /* Should diagnostics be printed for illegal instructions? */
+      /*IN*/  Bool         sigill_diag
 
    );
 
@@ -171,6 +174,7 @@
          /*IN*/ Addr64           guest_IP_bbstart,
          /*IN*/ Bool             (*chase_into_ok)(void*,Addr64),
          /*IN*/ Bool             host_bigendian,
+         /*IN*/ Bool             sigill_diag,
          /*IN*/ VexArch          arch_guest,
          /*IN*/ VexArchInfo*     archinfo_guest,
          /*IN*/ VexAbiInfo*      abiinfo_both,
Only in valgrind-3.8.1/VEX/priv: guest_generic_bb_to_IR.h.orig
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_mips_defs.h valgrind-3.8.1/VEX/priv/guest_mips_defs.h
--- valgrind-3.8.1.orig/VEX/priv/guest_mips_defs.h	2012-11-04 21:57:03.790416917 +0100
+++ valgrind-3.8.1/VEX/priv/guest_mips_defs.h	2012-11-04 21:57:36.984892934 +0100
@@ -49,7 +49,8 @@
                                  VexArch      guest_arch,
                                  VexArchInfo* archinfo,
                                  VexAbiInfo*  abiinfo,
-                                 Bool         host_bigendian );
+                                 Bool         host_bigendian,
+                                 Bool         sigill_diag );
 
 /* Used by the optimiser to specialise calls to helpers. */
 extern IRExpr *guest_mips32_spechelper(HChar * function_name, IRExpr ** args,
Only in valgrind-3.8.1/VEX/priv: guest_mips_defs.h.orig
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_mips_toIR.c valgrind-3.8.1/VEX/priv/guest_mips_toIR.c
--- valgrind-3.8.1.orig/VEX/priv/guest_mips_toIR.c	2012-11-04 21:57:03.785416840 +0100
+++ valgrind-3.8.1/VEX/priv/guest_mips_toIR.c	2012-11-04 21:57:36.986892956 +0100
@@ -1195,7 +1195,8 @@
                                      void*        callback_opaque,
                                      Long         delta64,
                                      VexArchInfo* archinfo,
-                                     VexAbiInfo*  abiinfo )
+                                     VexAbiInfo*  abiinfo,
+                                     Bool         sigill_diag )
 {
    IRTemp t0, t1, t2, t3, t4, t5, t6, t7, t8;
    UInt opcode, cins, rs, rt, rd, sa, ft, fs, fd, fmt, tf, nd, function,
@@ -3399,12 +3400,13 @@
 
  decode_failure:
       /* All decode failures end up here. */
-      DIP("vex mips->IR: unhandled instruction bytes: "
-          "0x%x 0x%x 0x%x 0x%x\n",
-          (Int) getIByte(delta_start + 0),
-          (Int) getIByte(delta_start + 1),
-          (Int) getIByte(delta_start + 2),
-          (Int) getIByte(delta_start + 3));
+      if (sigill_diag)
+         vex_printf("vex mips->IR: unhandled instruction bytes: "
+                    "0x%x 0x%x 0x%x 0x%x\n",
+                    (Int) getIByte(delta_start + 0),
+                    (Int) getIByte(delta_start + 1),
+                    (Int) getIByte(delta_start + 2),
+                    (Int) getIByte(delta_start + 3));
 
       /* Tell the dispatcher that this insn cannot be decoded, and so has
          not been executed, and (is currently) the next to be executed.
@@ -3494,7 +3496,8 @@
               VexArch      guest_arch,
               VexArchInfo* archinfo,
               VexAbiInfo*  abiinfo,
-              Bool         host_bigendian_IN)
+              Bool         host_bigendian_IN,
+              Bool         sigill_diag_IN)
 {
    DisResult dres;
 
@@ -3510,7 +3513,7 @@
    guest_PC_bbstart = (Addr32) toUInt(guest_IP - delta);
 
    dres = disInstr_MIPS_WRK(resteerOkFn, resteerCisOk, callback_opaque,
-                            delta, archinfo, abiinfo);
+                            delta, archinfo, abiinfo, sigill_diag_IN);
 
    return dres;
 }
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_ppc_defs.h valgrind-3.8.1/VEX/priv/guest_ppc_defs.h
--- valgrind-3.8.1.orig/VEX/priv/guest_ppc_defs.h	2012-11-04 21:57:03.782416795 +0100
+++ valgrind-3.8.1/VEX/priv/guest_ppc_defs.h	2012-11-04 21:57:37.030893654 +0100
@@ -57,7 +57,8 @@
                          VexArch      guest_arch,
                          VexArchInfo* archinfo,
                          VexAbiInfo*  abiinfo,
-                         Bool         host_bigendian );
+                         Bool         host_bigendian,
+                         Bool         sigill_diag );
 
 /* Used by the optimiser to specialise calls to helpers. */
 extern
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_ppc_toIR.c valgrind-3.8.1/VEX/priv/guest_ppc_toIR.c
--- valgrind-3.8.1.orig/VEX/priv/guest_ppc_toIR.c	2012-11-04 21:57:03.784416825 +0100
+++ valgrind-3.8.1/VEX/priv/guest_ppc_toIR.c	2012-11-04 21:57:37.034893677 +0100
@@ -16475,7 +16475,8 @@
              void*        callback_opaque,
              Long         delta64,
              VexArchInfo* archinfo,
-             VexAbiInfo*  abiinfo
+             VexAbiInfo*  abiinfo,
+             Bool         sigill_diag
           )
 {
    UChar     opc1;
@@ -17688,10 +17689,12 @@
    decode_failure:
    /* All decode failures end up here. */
    opc2 = (theInstr) & 0x7FF;
-   vex_printf("disInstr(ppc): unhandled instruction: "
-              "0x%x\n", theInstr);
-   vex_printf("                 primary %d(0x%x), secondary %u(0x%x)\n", 
-              opc1, opc1, opc2, opc2);
+   if (sigill_diag) {
+      vex_printf("disInstr(ppc): unhandled instruction: "
+                 "0x%x\n", theInstr);
+      vex_printf("                 primary %d(0x%x), secondary %u(0x%x)\n", 
+                 opc1, opc1, opc2, opc2);
+   }
 
    /* Tell the dispatcher that this insn cannot be decoded, and so has
       not been executed, and (is currently) the next to be executed.
@@ -17752,7 +17755,8 @@
                          VexArch      guest_arch,
                          VexArchInfo* archinfo,
                          VexAbiInfo*  abiinfo,
-                         Bool         host_bigendian_IN )
+                         Bool         host_bigendian_IN,
+                         Bool         sigill_diag_IN )
 {
    IRType     ty;
    DisResult  dres;
@@ -17788,7 +17792,7 @@
    guest_CIA_bbstart    = mkSzAddr(ty, guest_IP - delta);
 
    dres = disInstr_PPC_WRK ( resteerOkFn, resteerCisOk, callback_opaque,
-                             delta, archinfo, abiinfo );
+                             delta, archinfo, abiinfo, sigill_diag_IN );
 
    return dres;
 }
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_s390_defs.h valgrind-3.8.1/VEX/priv/guest_s390_defs.h
--- valgrind-3.8.1.orig/VEX/priv/guest_s390_defs.h	2012-11-04 21:57:03.782416795 +0100
+++ valgrind-3.8.1/VEX/priv/guest_s390_defs.h	2012-11-04 21:57:37.098894575 +0100
@@ -52,7 +52,8 @@
                           VexArch      guest_arch,
                           VexArchInfo* archinfo,
                           VexAbiInfo*  abiinfo,
-                          Bool         host_bigendian );
+                          Bool         host_bigendian,
+                          Bool         sigill_diag );
 
 /* Used by the optimiser to specialise calls to helpers. */
 IRExpr* guest_s390x_spechelper ( HChar   *function_name,
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_s390_toIR.c valgrind-3.8.1/VEX/priv/guest_s390_toIR.c
--- valgrind-3.8.1.orig/VEX/priv/guest_s390_toIR.c	2012-11-04 21:57:03.789416902 +0100
+++ valgrind-3.8.1/VEX/priv/guest_s390_toIR.c	2012-11-04 21:57:37.102894640 +0100
@@ -73,6 +73,9 @@
 static Bool (*resteer_fn)(void *, Addr64);
 static void *resteer_data;
 
+/* Whether to print diagnostics for illegal instructions. */
+static Bool sigill_diag;
+
 /* The last seen execute target instruction */
 ULong last_execute_target;
 
@@ -14143,34 +14146,36 @@
    if (status == S390_DECODE_OK) return insn_length;  /* OK */
 
    /* Decoding failed somehow */
-   vex_printf("vex s390->IR: ");
-   switch (status) {
-   case S390_DECODE_UNKNOWN_INSN:
-      vex_printf("unknown insn: ");
-      break;
+   if (sigill_diag) {
+      vex_printf("vex s390->IR: ");
+      switch (status) {
+      case S390_DECODE_UNKNOWN_INSN:
+         vex_printf("unknown insn: ");
+         break;
 
-   case S390_DECODE_UNIMPLEMENTED_INSN:
-      vex_printf("unimplemented insn: ");
-      break;
+      case S390_DECODE_UNIMPLEMENTED_INSN:
+         vex_printf("unimplemented insn: ");
+         break;
 
-   case S390_DECODE_UNKNOWN_SPECIAL_INSN:
-      vex_printf("unimplemented special insn: ");
-      break;
+      case S390_DECODE_UNKNOWN_SPECIAL_INSN:
+         vex_printf("unimplemented special insn: ");
+         break;
 
-   default:
-   case S390_DECODE_ERROR:
-      vex_printf("decoding error: ");
-      break;
-   }
+      default:
+      case S390_DECODE_ERROR:
+         vex_printf("decoding error: ");
+         break;
+      }
 
-   vex_printf("%02x%02x", bytes[0], bytes[1]);
-   if (insn_length > 2) {
-      vex_printf(" %02x%02x", bytes[2], bytes[3]);
-   }
-   if (insn_length > 4) {
-      vex_printf(" %02x%02x", bytes[4], bytes[5]);
+      vex_printf("%02x%02x", bytes[0], bytes[1]);
+      if (insn_length > 2) {
+         vex_printf(" %02x%02x", bytes[2], bytes[3]);
+      }
+      if (insn_length > 4) {
+         vex_printf(" %02x%02x", bytes[4], bytes[5]);
+      }
+      vex_printf("\n");
    }
-   vex_printf("\n");
 
    return 0;  /* Failed */
 }
@@ -14261,7 +14266,8 @@
               VexArch      guest_arch,
               VexArchInfo *archinfo,
               VexAbiInfo  *abiinfo,
-              Bool         host_bigendian)
+              Bool         host_bigendian,
+              Bool         sigill_diag_IN)
 {
    vassert(guest_arch == VexArchS390X);
 
@@ -14273,6 +14279,7 @@
    irsb = irsb_IN;
    resteer_fn = resteerOkFn;
    resteer_data = callback_opaque;
+   sigill_diag = sigill_diag_IN;
 
    return disInstr_S390_WRK(guest_code + delta);
 }
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_x86_defs.h valgrind-3.8.1/VEX/priv/guest_x86_defs.h
--- valgrind-3.8.1.orig/VEX/priv/guest_x86_defs.h	2012-11-04 21:57:03.782416795 +0100
+++ valgrind-3.8.1/VEX/priv/guest_x86_defs.h	2012-11-04 21:57:37.169895603 +0100
@@ -56,7 +56,8 @@
                          VexArch      guest_arch,
                          VexArchInfo* archinfo,
                          VexAbiInfo*  abiinfo,
-                         Bool         host_bigendian );
+                         Bool         host_bigendian,
+                         Bool         sigill_diag );
 
 /* Used by the optimiser to specialise calls to helpers. */
 extern
diff -ur valgrind-3.8.1.orig/VEX/priv/guest_x86_toIR.c valgrind-3.8.1/VEX/priv/guest_x86_toIR.c
--- valgrind-3.8.1.orig/VEX/priv/guest_x86_toIR.c	2012-11-04 21:57:03.790416917 +0100
+++ valgrind-3.8.1/VEX/priv/guest_x86_toIR.c	2012-11-04 21:57:37.176895720 +0100
@@ -7927,7 +7927,8 @@
              void*        callback_opaque,
              Long         delta64,
              VexArchInfo* archinfo,
-             VexAbiInfo*  vbi
+             VexAbiInfo*  vbi,
+             Bool         sigill_diag
           )
 {
    IRType    ty;
@@ -15157,12 +15158,14 @@
   default:
   decode_failure:
    /* All decode failures end up here. */
-   vex_printf("vex x86->IR: unhandled instruction bytes: "
-              "0x%x 0x%x 0x%x 0x%x\n",
-              (Int)getIByte(delta_start+0),
-              (Int)getIByte(delta_start+1),
-              (Int)getIByte(delta_start+2),
-              (Int)getIByte(delta_start+3) );
+   if (sigill_diag) {
+      vex_printf("vex x86->IR: unhandled instruction bytes: "
+                 "0x%x 0x%x 0x%x 0x%x\n",
+                 (Int)getIByte(delta_start+0),
+                 (Int)getIByte(delta_start+1),
+                 (Int)getIByte(delta_start+2),
+                 (Int)getIByte(delta_start+3) );
+   }
 
    /* Tell the dispatcher that this insn cannot be decoded, and so has
       not been executed, and (is currently) the next to be executed.
@@ -15225,7 +15228,8 @@
                          VexArch      guest_arch,
                          VexArchInfo* archinfo,
                          VexAbiInfo*  abiinfo,
-                         Bool         host_bigendian_IN )
+                         Bool         host_bigendian_IN,
+                         Bool         sigill_diag_IN )
 {
    Int       i, x1, x2;
    Bool      expect_CAS, has_CAS;
@@ -15244,7 +15248,7 @@
    dres = disInstr_X86_WRK ( &expect_CAS, resteerOkFn,
                              resteerCisOk,
                              callback_opaque,
-                             delta, archinfo, abiinfo );
+                             delta, archinfo, abiinfo, sigill_diag_IN );
    x2 = irsb_IN->stmts_used;
    vassert(x2 >= x1);
 
@@ -15264,7 +15268,7 @@
       dres = disInstr_X86_WRK ( &expect_CAS, resteerOkFn,
                                 resteerCisOk,
                                 callback_opaque,
-                                delta, archinfo, abiinfo );
+                                delta, archinfo, abiinfo, sigill_diag_IN );
       for (i = x1; i < x2; i++) {
          vex_printf("\t\t");
          ppIRStmt(irsb_IN->stmts[i]);
Only in valgrind-3.8.1/VEX/priv: guest_x86_toIR.c.orig
diff -ur valgrind-3.8.1.orig/VEX/priv/main_main.c valgrind-3.8.1/VEX/priv/main_main.c
--- valgrind-3.8.1.orig/VEX/priv/main_main.c	2012-11-04 21:57:03.784416825 +0100
+++ valgrind-3.8.1/VEX/priv/main_main.c	2012-11-04 21:57:37.247896750 +0100
@@ -605,6 +605,7 @@
                      vta->guest_bytes_addr,
                      vta->chase_into_ok,
                      host_is_bigendian,
+                     vta->sigill_diag,
                      vta->arch_guest,
                      &vta->archinfo_guest,
                      &vta->abiinfo_both,
diff -ur valgrind-3.8.1.orig/VEX/pub/libvex.h valgrind-3.8.1/VEX/pub/libvex.h
--- valgrind-3.8.1.orig/VEX/pub/libvex.h	2012-11-04 21:57:03.781416780 +0100
+++ valgrind-3.8.1/VEX/pub/libvex.h	2012-11-04 21:57:37.248896764 +0100
@@ -622,6 +622,9 @@
       /* IN: debug: trace vex activity at various points */
       Int     traceflags;
 
+      /* IN: debug: print diagnostics when an illegal instr is detected */
+      Bool    sigill_diag;
+
       /* IN: profiling: add a 64 bit profiler counter increment to the
          translation? */
       Bool    addProfInc;