Skip to content

Commit 46b5433

Browse files
author
florian
committed
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent f3bf562 commit 46b5433

File tree

11 files changed

+31
-15
lines changed

11 files changed

+31
-15
lines changed

Makefile.all.am

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ AM_CFLAGS_BASE = \
105105
-Wpointer-arith \
106106
-Wstrict-prototypes \
107107
-Wmissing-declarations \
108-
@FLAG_W_NO_FORMAT_ZERO_LENGTH@ \
109108
@FLAG_W_NO_TAUTOLOGICAL_COMPARE@ \
110109
-fno-strict-aliasing \
111110
-fno-builtin

NEWS

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

cachegrind/cg_arch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static void parse_cache_opt ( cache_t* cache, const HChar* opt,
105105
return;
106106

107107
bad:
108-
VG_(fmsg_bad_option)(opt, "");
108+
VG_(fmsg_bad_option)(opt, "Bad argument '%s'\n", optval);
109109

110110
overflow:
111111
VG_(fmsg_bad_option)(opt,

callgrind/main.c

-1
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,6 @@ void clg_print_stats(void)
18601860
CLG_(stat).bb_retranslations);
18611861
VG_(message)(Vg_DebugMsg, "Distinct instrs: %d\n",
18621862
CLG_(stat).distinct_instrs);
1863-
VG_(message)(Vg_DebugMsg, "");
18641863

18651864
VG_(message)(Vg_DebugMsg, "LRU Contxt Misses: %d\n",
18661865
CLG_(stat).cxt_lru_misses);

coregrind/m_gdbserver/remote-utils.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void remote_open (const HChar *name)
395395
o = VG_(open) (shared_mem, VKI_O_CREAT|VKI_O_RDWR, 0600);
396396
if (sr_isError (o)) {
397397
sr_perror(o, "cannot create shared_mem file %s\n", shared_mem);
398-
fatal("");
398+
fatal("Cannot recover from previous error. Good-bye.");
399399
} else {
400400
shared_mem_fd = sr_Res(o);
401401
}
@@ -412,7 +412,7 @@ void remote_open (const HChar *name)
412412
if (sr_isError(res)) {
413413
sr_perror(res, "error VG_(am_shared_mmap_file_float_valgrind) %s\n",
414414
shared_mem);
415-
fatal("");
415+
fatal("Cannot recover from previous error. Good-bye.");
416416
}
417417
addr_shared = sr_Res (res);
418418
}

coregrind/m_libcprint.c

+8
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,14 @@ void VG_(fmsg_bad_option) ( const HChar* opt, const HChar* format, ... )
636636
VG_(exit)(1);
637637
}
638638

639+
void VG_(fmsg_unknown_option) ( const HChar* opt)
640+
{
641+
revert_to_stderr();
642+
VG_(message) (Vg_FailMsg, "Unknown option: %s\n", opt);
643+
VG_(message) (Vg_FailMsg, "Use --help for more information or consult the user manual.\n");
644+
VG_(exit)(1);
645+
}
646+
639647
UInt VG_(umsg) ( const HChar* format, ... )
640648
{
641649
UInt count;

coregrind/m_main.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
624624
else if (VG_(strcmp)(tmp_str, "no") == 0)
625625
VG_(clo_fair_sched) = disable_fair_sched;
626626
else
627-
VG_(fmsg_bad_option)(arg, "");
628-
627+
VG_(fmsg_bad_option)(arg,
628+
"Bad argument, should be 'yes', 'try' or 'no'\n");
629629
}
630630
else if VG_BOOL_CLO(arg, "--trace-sched", VG_(clo_trace_sched)) {}
631631
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,
845845

846846
else if ( ! VG_(needs).command_line_options
847847
|| ! VG_TDICT_CALL(tool_process_cmd_line_option, arg) ) {
848-
VG_(fmsg_bad_option)(arg, "");
848+
VG_(fmsg_unknown_option)(arg);
849849
}
850850
}
851851

@@ -961,7 +961,8 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
961961
chaos. No big deal; dump_error is a flag for debugging V
962962
itself. */
963963
if (VG_(clo_dump_error) > 0) {
964-
VG_(fmsg_bad_option)("--xml=yes together with --dump-error", "");
964+
VG_(fmsg_bad_option)("--xml=yes",
965+
"Cannot be used together with --dump-error");
965966
}
966967

967968
/* Disable error limits (this might be a bad idea!) */

coregrind/pub_core_libcprint.h

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ extern void VG_(err_missing_prog) ( void );
6666
__attribute__((noreturn))
6767
extern void VG_(err_config_error) ( const HChar* format, ... );
6868

69+
/* Called by main_process_cmd_line_options to indicate an unrecognised
70+
command line option. */
71+
__attribute__((noreturn))
72+
extern void VG_(fmsg_unknown_option) ( const HChar *opt );
73+
6974
#endif // __PUB_CORE_LIBCPRINT_H
7075

7176
/*--------------------------------------------------------------------*/

include/pub_tool_options.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
Long n = VG_(strtoll10)( val, &s ); \
106106
(qq_var) = n; \
107107
/* Check for non-numeralness, or overflow. */ \
108-
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, ""); \
108+
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, \
109+
"Invalid integer value '%s'\n", val); \
109110
True; \
110111
}) \
111112
)
@@ -123,7 +124,8 @@
123124
/* for all the other macros in this file. */ \
124125
/* Check for non-numeralness, or overflow. */ \
125126
/* Nb: it will overflow if qq_var is unsigned and qq_val is negative! */ \
126-
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, ""); \
127+
if ('\0' != s[0] || (qq_var) != n) VG_(fmsg_bad_option)(qq_arg, \
128+
"Invalid integer value '%s'\n", val); \
127129
/* Check bounds. */ \
128130
if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \
129131
VG_(fmsg_bad_option)(qq_arg, \
@@ -153,7 +155,8 @@
153155
double n = VG_(strtod)( val, &s ); \
154156
(qq_var) = n; \
155157
/* Check for non-numeralness */ \
156-
if ('\0' != s[0]) VG_(fmsg_bad_option)(qq_arg, ""); \
158+
if ('\0' != s[0]) VG_(fmsg_bad_option)(qq_arg, \
159+
"Invalid floating point value '%s'\n",val); \
157160
True; \
158161
}) \
159162
)

massif/ms_main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2447,8 +2447,8 @@ static void ms_post_clo_init(void)
24472447
// Check options.
24482448
if (clo_pages_as_heap) {
24492449
if (clo_stacks) {
2450-
VG_(fmsg_bad_option)(
2451-
"--pages-as-heap=yes together with --stacks=yes", "");
2450+
VG_(fmsg_bad_option)("--pages-as-heap=yes",
2451+
"Cannot be used together with --stacks=yes");
24522452
}
24532453
}
24542454
if (!clo_heap) {

none/tests/cmdline4.stderr.exp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
valgrind: Bad option: --bad-bad-option
1+
valgrind: Unknown option: --bad-bad-option
22
valgrind: Use --help for more information or consult the user manual.

0 commit comments

Comments
 (0)