|
From: <sv...@va...> - 2006-10-15 01:25:20
|
Author: sewardj
Date: 2006-10-15 02:25:13 +0100 (Sun, 15 Oct 2006)
New Revision: 6233
Log:
Move functions which deal with bad command line options from m_main
into m_options.
Modified:
trunk/cachegrind/cg_main.c
trunk/callgrind/sim.c
trunk/coregrind/m_options.c
trunk/coregrind/m_replacemalloc/replacemalloc_core.c
trunk/include/pub_tool_options.h
trunk/massif/ms_main.c
Modified: trunk/cachegrind/cg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/cachegrind/cg_main.c 2006-10-15 00:07:24 UTC (rev 6232)
+++ trunk/cachegrind/cg_main.c 2006-10-15 01:25:13 UTC (rev 6233)
@@ -1288,7 +1288,7 @@
return;
=20
bad:
- VG_(bad_option)(opt);
+ VG_(err_bad_option)(opt);
}
=20
static Bool cg_process_cmd_line_option(Char* arg)
Modified: trunk/callgrind/sim.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/callgrind/sim.c 2006-10-15 00:07:24 UTC (rev 6232)
+++ trunk/callgrind/sim.c 2006-10-15 01:25:13 UTC (rev 6233)
@@ -1637,7 +1637,7 @@
return;
=20
bad:
- VG_(bad_option)(orig_opt);
+ VG_(err_bad_option)(orig_opt);
}
=20
/* Check for command line option for cache configuration.
Modified: trunk/coregrind/m_options.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_options.c 2006-10-15 00:07:24 UTC (rev 6232)
+++ trunk/coregrind/m_options.c 2006-10-15 01:25:13 UTC (rev 6233)
@@ -31,6 +31,8 @@
=20
#include "pub_core_basics.h"
#include "pub_core_options.h"
+#include "pub_core_libcassert.h"
+#include "pub_core_libcprint.h"
=20
// See pub_{core,tool}_options.h for explanations of all these.
=20
@@ -79,6 +81,41 @@
HChar* VG_(clo_kernel_variant) =3D NULL;
=20
=20
+/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
+/*=3D=3D=3D Command line errors =
=3D=3D=3D*/
+/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
+
+static void revert_to_stderr ( void )
+{
+ vg_assert( !VG_(logging_to_socket) );
+ VG_(clo_log_fd) =3D 2; /* stderr */
+}
+
+void VG_(err_bad_option) ( Char* opt )
+{
+ revert_to_stderr();
+ VG_(printf)("valgrind: Bad option '%s'; aborting.\n", opt);
+ VG_(printf)("valgrind: Use --help for more information.\n");
+ VG_(exit)(1);
+}
+
+void VG_(err_missing_prog) ( void )
+{
+ revert_to_stderr();
+ VG_(printf)("valgrind: no program specified\n");
+ VG_(printf)("valgrind: Use --help for more information.\n");
+ VG_(exit)(1);
+}
+
+void VG_(err_config_error) ( Char* msg )
+{
+ revert_to_stderr();
+ VG_(printf)("valgrind: Startup or configuration error:\n %s\n", msg=
);
+ VG_(printf)("valgrind: Unable to start up properly. Giving up.\n");
+ VG_(exit)(1);
+}
+
+
/*--------------------------------------------------------------------*/
/*--- end m_options.c ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_replacemalloc/replacemalloc_core.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_replacemalloc/replacemalloc_core.c 2006-10-15 00:07=
:24 UTC (rev 6232)
+++ trunk/coregrind/m_replacemalloc/replacemalloc_core.c 2006-10-15 01:25=
:13 UTC (rev 6233)
@@ -63,7 +63,7 @@
VG_(message)(Vg_UserMsg,=20
"Invalid --alignment=3D setting. "
"Should be a power of 2, >=3D %d, <=3D 4096.", VG_MIN_MALLOC=
_SZB);
- VG_(bad_option)("--alignment");
+ VG_(err_bad_option)("--alignment");
}
}
=20
Modified: trunk/include/pub_tool_options.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/pub_tool_options.h 2006-10-15 00:07:24 UTC (rev 6232)
+++ trunk/include/pub_tool_options.h 2006-10-15 01:25:13 UTC (rev 6233)
@@ -75,15 +75,24 @@
XML output, in between <usercomment> tags. */
extern HChar* VG_(clo_xml_user_comment);
=20
-/* Call this if a recognised option was bad for some reason.
- Note: don't use it just because an option was unrecognised -- return =
'False'
- from VG_(tdict).tool_process_cmd_line_option) to indicate that. */
-extern void VG_(bad_option) ( Char* opt );
-
/* Vex iropt control. Tool-visible so tools can make Vex optimise
less aggressively if that is needed (callgrind needs this). */
extern VexControl VG_(clo_vex_control);
=20
+/* Call this if a recognised option was bad for some reason. Note:
+ don't use it just because an option was unrecognised -- return
+ 'False' from VG_(tdict).tool_process_cmd_line_option) to indicate
+ that. This function prints an error message, then shuts down the
+ entire system. */
+extern void VG_(err_bad_option) ( Char* opt );
+
+/* Similarly - complain that the executable is missing, then stop. */
+extern void VG_(err_missing_prog) ( void );
+
+/* Similarly - complain about some config error. */
+extern void VG_(err_config_error) ( Char* msg );
+
+
#endif // __PUB_TOOL_OPTIONS_H
=20
/*--------------------------------------------------------------------*/
Modified: trunk/massif/ms_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/massif/ms_main.c 2006-10-15 00:07:24 UTC (rev 6232)
+++ trunk/massif/ms_main.c 2006-10-15 01:25:13 UTC (rev 6233)
@@ -298,7 +298,7 @@
n_alloc_fns++;
if (n_alloc_fns >=3D MAX_ALLOC_FNS) {
VG_(printf)("Too many alloc functions specified, sorry");
- VG_(bad_option)(arg);
+ VG_(err_bad_option)(arg);
}
}
=20
|