Make diagnostics for SIGILL more controllable (Valgrind part).

Fixes #309425.  (Mark Wielaard, mjw@redhat.com)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13164
This commit is contained in:
Julian Seward 2012-12-06 18:08:54 +00:00
parent 5ed1bb6a2f
commit f192a5574d
8 changed files with 45 additions and 4 deletions

View File

@ -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) {
/* [] */

View File

@ -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 ===*/

View File

@ -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

View File

@ -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;

View File

@ -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
/*--------------------------------------------------------------------*/

View File

@ -1037,6 +1037,26 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para>
</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>

View File

@ -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)

View File

@ -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)