diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index 24abb9e0e..bbda85589 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -201,6 +201,7 @@ static void usage_NORETURN ( Bool debug_help )
" 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";
const HChar usage2[] =
@@ -426,6 +427,10 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
const HChar* log_fsname_unexpanded = NULL;
const HChar* 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;
@@ -520,6 +525,9 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
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));
@@ -788,6 +796,9 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
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 --git a/coregrind/m_options.c b/coregrind/m_options.c
index 07086216b..f2061c904 100644
--- a/coregrind/m_options.c
+++ b/coregrind/m_options.c
@@ -119,7 +119,7 @@ Bool VG_(clo_wait_for_gdb) = False;
VgSmc VG_(clo_smc_check) = Vg_SmcStack;
const HChar* VG_(clo_kernel_variant) = NULL;
Bool VG_(clo_dsymutil) = False;
-
+Bool VG_(clo_sigill_diag) = True;
/*====================================================================*/
/*=== File expansion ===*/
diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c
index ef41c64c4..ce019a5e6 100644
--- a/coregrind/m_scheduler/scheduler.c
+++ b/coregrind/m_scheduler/scheduler.c
@@ -1439,9 +1439,10 @@ VgSchedReturnCode VG_(scheduler) ( ThreadId tid )
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." );
@@ -1454,6 +1455,7 @@ VgSchedReturnCode VG_(scheduler) ( ThreadId tid )
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 --git a/coregrind/m_translate.c b/coregrind/m_translate.c
index 26e6376e3..99a9b8190 100644
--- a/coregrind/m_translate.c
+++ b/coregrind/m_translate.c
@@ -1530,6 +1530,7 @@ Bool VG_(translate) ( ThreadId tid,
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 --git a/coregrind/pub_core_options.h b/coregrind/pub_core_options.h
index 87c67107e..76af826b0 100644
--- a/coregrind/pub_core_options.h
+++ b/coregrind/pub_core_options.h
@@ -278,6 +278,11 @@ extern Bool VG_(clo_dsymutil);
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 --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml
index c39a9f1d1..7b8a77f81 100644
--- a/docs/xml/manual-core.xml
+++ b/docs/xml/manual-core.xml
@@ -1037,6 +1037,26 @@ that can report errors, e.g. Memcheck, but not Cachegrind.
+
+
+
+
+
+ Enable/disable printing of illegal instruction diagnostics.
+ Enabled by default, but defaults to disabled when
+ is given. The default can always be explicitly
+ overridden by giving this option.
+
+ 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.
+
+
+
diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp
index 3938d868c..9eb70d1ac 100644
--- a/none/tests/cmdline1.stdout.exp
+++ b/none/tests/cmdline1.stdout.exp
@@ -90,6 +90,7 @@ usage: valgrind [options] prog-and-args
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 --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp
index 533984fdd..efc4bc7eb 100644
--- a/none/tests/cmdline2.stdout.exp
+++ b/none/tests/cmdline2.stdout.exp
@@ -90,6 +90,7 @@ usage: valgrind [options] prog-and-args
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)