]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix BZ 334802. Patch by Mark Wielaard with a few mods to make it apply.
authorFlorian Krohm <florian@eich-krohm.de>
Sat, 29 Nov 2014 14:41:32 +0000 (14:41 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sat, 29 Nov 2014 14:41:32 +0000 (14:41 +0000)
r14794 is related as well.
Also: remove -Wno-format-zero-length from compile options.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14795

Makefile.all.am
NEWS
cachegrind/cg_arch.c
callgrind/main.c
coregrind/m_gdbserver/remote-utils.c
coregrind/m_libcprint.c
coregrind/m_main.c
coregrind/pub_core_libcprint.h
include/pub_tool_options.h
massif/ms_main.c
none/tests/cmdline4.stderr.exp

index 68f8fe57e02d1a7ee7f05b8173a8b78db565a978..6257a20b70ac71a47fe0fc5daa77d18c8a64d84f 100644 (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
diff --git a/NEWS b/NEWS
index fc4b73b4d1a6555596f4feebc72aff30680ac587..4841de464b20300383ee1b5ea924baabd7650661 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 2afda87c4a3f2d1fd16192976544e06b27649cb4..265044e2362b3ea2835d555cd87881beec173329 100644 (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,
index 158f02185f8d6e6f094bf0f5a79eda29a00a02f0..740213123b814923ff0b595ae27f295e63d0c2a8 100644 (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);
index 56c8617fbdd487c39330de6f31c39e7f04f05cb6..1cdb49179bd356dcd2c6f56e7a4b156af0425987 100644 (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);
       }
index 13258568b5f00769d28564af58b90c7747dcb487..3617c039a8785f43cf80e660ed916482ba7855f2 100644 (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;
index 2a0b2a67785a75afbeb10b5c8dbcf74bb4aa3c15..2b2ac79b506bd996824862d46209f20370587d9f 100644 (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!) */
index c9adb0b24fe3611f33aebe7ddbd6fe458b483776..aedd915bb7cba9a3f52d5ec4f9ad051adf8048da 100644 (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
 
 /*--------------------------------------------------------------------*/
index cb34639b8d3c14b382a622a4f07d66ff6634c4bf..c9f8559855422c44bd7646924749ee1bc7c9c249 100644 (file)
       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; \
      }) \
     )
       /* 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, \
       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; \
      }) \
     )
index 7d11631d3b012e50e01a39c6ecd2c7d6dc14cc5c..450379dd156d1beda6d9451c58239865a49dafd7 100644 (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) {
index f9b9ba65855aefffa37e6365eac78da467013d7b..879e12a28cb4487d6587528b9aa5986b1ae84844 100644 (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.