|
From: <sv...@va...> - 2012-12-06 18:09:06
|
sewardj 2012-12-06 18:08:54 +0000 (Thu, 06 Dec 2012)
New Revision: 13164
Log:
Make diagnostics for SIGILL more controllable (Valgrind part).
Fixes #309425. (Mark Wielaard, mj...@re...)
Modified files:
trunk/coregrind/m_main.c
trunk/coregrind/m_options.c
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/m_translate.c
trunk/coregrind/pub_core_options.h
trunk/docs/xml/manual-core.xml
trunk/none/tests/cmdline1.stdout.exp
trunk/none/tests/cmdline2.stdout.exp
Modified: trunk/none/tests/cmdline1.stdout.exp (+1 -0)
===================================================================
--- trunk/none/tests/cmdline1.stdout.exp 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/none/tests/cmdline1.stdout.exp 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -90,6 +90,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)
Modified: trunk/coregrind/m_translate.c (+1 -0)
===================================================================
--- trunk/coregrind/m_translate.c 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/coregrind/m_translate.c 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -1530,6 +1530,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;
Modified: trunk/docs/xml/manual-core.xml (+20 -0)
===================================================================
--- trunk/docs/xml/manual-core.xml 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/docs/xml/manual-core.xml 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -1037,6 +1037,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>
Modified: trunk/none/tests/cmdline2.stdout.exp (+1 -0)
===================================================================
--- trunk/none/tests/cmdline2.stdout.exp 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/none/tests/cmdline2.stdout.exp 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -90,6 +90,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)
Modified: trunk/coregrind/pub_core_options.h (+5 -0)
===================================================================
--- trunk/coregrind/pub_core_options.h 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/coregrind/pub_core_options.h 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -278,6 +278,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
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_options.c (+1 -1)
===================================================================
--- trunk/coregrind/m_options.c 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/coregrind/m_options.c 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -119,8 +119,8 @@
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 ===*/
/*====================================================================*/
Modified: trunk/coregrind/m_scheduler/scheduler.c (+5 -3)
===================================================================
--- trunk/coregrind/m_scheduler/scheduler.c 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/coregrind/m_scheduler/scheduler.c 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -1439,9 +1439,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." );
@@ -1454,6 +1455,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
Modified: trunk/coregrind/m_main.c (+11 -0)
===================================================================
--- trunk/coregrind/m_main.c 2012-12-06 17:54:33 +00:00 (rev 13163)
+++ trunk/coregrind/m_main.c 2012-12-06 18:08:54 +00:00 (rev 13164)
@@ -201,6 +201,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";
const HChar usage2[] =
@@ -426,6 +427,10 @@
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 @@
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 @@
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) {
/* [] */
|