Fix BZ 334802. Patch by Mark Wielaard with a few mods to make it apply.

r14794 is related as well.
Also: remove -Wno-format-zero-length from compile options.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14795
This commit is contained in:
Florian Krohm 2014-11-29 14:41:32 +00:00
parent 2ad0d731f9
commit 69d42e3d4b
11 changed files with 31 additions and 15 deletions

View File

@ -105,7 +105,6 @@ AM_CFLAGS_BASE = \
-Wpointer-arith \
-Wstrict-prototypes \
-Wmissing-declarations \
@FLAG_W_NO_FORMAT_ZERO_LENGTH@ \
@FLAG_W_NO_TAUTOLOGICAL_COMPARE@ \
-fno-strict-aliasing \
-fno-builtin

1
NEWS
View File

@ -41,6 +41,7 @@ where XXXXXX is the bug number as listed below.
269360 s390x: Fix addressing mode selection for compare-and-swap
333051 mmap of huge pages fails due to incorrect alignment
== 339163
334802 valgrind does not always explain why a given option is bad
335440 arm64: ld1 (single structure) is not implemented
335713 arm64: unhanded instruction: prfm (immediate)
338731 ppc: Fix testuite build for toolchains not supporting -maltivec

View File

@ -105,7 +105,7 @@ static void parse_cache_opt ( cache_t* cache, const HChar* opt,
return;
bad:
VG_(fmsg_bad_option)(opt, "");
VG_(fmsg_bad_option)(opt, "Bad argument '%s'\n", optval);
overflow:
VG_(fmsg_bad_option)(opt,

View File

@ -1860,7 +1860,6 @@ void clg_print_stats(void)
CLG_(stat).bb_retranslations);
VG_(message)(Vg_DebugMsg, "Distinct instrs: %d\n",
CLG_(stat).distinct_instrs);
VG_(message)(Vg_DebugMsg, "");
VG_(message)(Vg_DebugMsg, "LRU Contxt Misses: %d\n",
CLG_(stat).cxt_lru_misses);

View File

@ -395,7 +395,7 @@ void remote_open (const HChar *name)
o = VG_(open) (shared_mem, VKI_O_CREAT|VKI_O_RDWR, 0600);
if (sr_isError (o)) {
sr_perror(o, "cannot create shared_mem file %s\n", shared_mem);
fatal("");
fatal("Cannot recover from previous error. Good-bye.");
} else {
shared_mem_fd = sr_Res(o);
}
@ -412,7 +412,7 @@ void remote_open (const HChar *name)
if (sr_isError(res)) {
sr_perror(res, "error VG_(am_shared_mmap_file_float_valgrind) %s\n",
shared_mem);
fatal("");
fatal("Cannot recover from previous error. Good-bye.");
}
addr_shared = sr_Res (res);
}

View File

@ -636,6 +636,14 @@ void VG_(fmsg_bad_option) ( const HChar* opt, const HChar* format, ... )
VG_(exit)(1);
}
void VG_(fmsg_unknown_option) ( const HChar* opt)
{
revert_to_stderr();
VG_(message) (Vg_FailMsg, "Unknown option: %s\n", opt);
VG_(message) (Vg_FailMsg, "Use --help for more information or consult the user manual.\n");
VG_(exit)(1);
}
UInt VG_(umsg) ( const HChar* format, ... )
{
UInt count;

View File

@ -624,8 +624,8 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
else if (VG_(strcmp)(tmp_str, "no") == 0)
VG_(clo_fair_sched) = disable_fair_sched;
else
VG_(fmsg_bad_option)(arg, "");
VG_(fmsg_bad_option)(arg,
"Bad argument, should be 'yes', 'try' or 'no'\n");
}
else if VG_BOOL_CLO(arg, "--trace-sched", VG_(clo_trace_sched)) {}
else if VG_BOOL_CLO(arg, "--trace-signals", VG_(clo_trace_signals)) {}
@ -845,7 +845,7 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
else if ( ! VG_(needs).command_line_options
|| ! VG_TDICT_CALL(tool_process_cmd_line_option, arg) ) {
VG_(fmsg_bad_option)(arg, "");
VG_(fmsg_unknown_option)(arg);
}
}
@ -961,7 +961,8 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
chaos. No big deal; dump_error is a flag for debugging V
itself. */
if (VG_(clo_dump_error) > 0) {
VG_(fmsg_bad_option)("--xml=yes together with --dump-error", "");
VG_(fmsg_bad_option)("--xml=yes",
"Cannot be used together with --dump-error");
}
/* Disable error limits (this might be a bad idea!) */

View File

@ -66,6 +66,11 @@ extern void VG_(err_missing_prog) ( void );
__attribute__((noreturn))
extern void VG_(err_config_error) ( const HChar* format, ... );
/* Called by main_process_cmd_line_options to indicate an unrecognised
command line option. */
__attribute__((noreturn))
extern void VG_(fmsg_unknown_option) ( const HChar *opt );
#endif // __PUB_CORE_LIBCPRINT_H
/*--------------------------------------------------------------------*/

View File

@ -105,7 +105,8 @@
Long n = VG_(strtoll10)( val, &s ); \
(qq_var) = n; \
/* Check for non-numeralness, or overflow. */ \
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, ""); \
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, \
"Invalid integer value '%s'\n", val); \
True; \
}) \
)
@ -123,7 +124,8 @@
/* for all the other macros in this file. */ \
/* Check for non-numeralness, or overflow. */ \
/* Nb: it will overflow if qq_var is unsigned and qq_val is negative! */ \
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, ""); \
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, \
"Invalid integer value '%s'\n", val); \
/* Check bounds. */ \
if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \
VG_(fmsg_bad_option)(qq_arg, \
@ -153,7 +155,8 @@
double n = VG_(strtod)( val, &s ); \
(qq_var) = n; \
/* Check for non-numeralness */ \
if ('\0' != s[0]) VG_(fmsg_bad_option)(qq_arg, ""); \
if ('\0' != s[0]) VG_(fmsg_bad_option)(qq_arg, \
"Invalid floating point value '%s'\n",val); \
True; \
}) \
)

View File

@ -2447,8 +2447,8 @@ static void ms_post_clo_init(void)
// Check options.
if (clo_pages_as_heap) {
if (clo_stacks) {
VG_(fmsg_bad_option)(
"--pages-as-heap=yes together with --stacks=yes", "");
VG_(fmsg_bad_option)("--pages-as-heap=yes",
"Cannot be used together with --stacks=yes");
}
}
if (!clo_heap) {

View File

@ -1,2 +1,2 @@
valgrind: Bad option: --bad-bad-option
valgrind: Unknown option: --bad-bad-option
valgrind: Use --help for more information or consult the user manual.