|
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
|
|
From: Nicholas N. <nj...@cs...> - 2006-10-15 11:08:23
|
On Sun, 15 Oct 2006 sv...@va... wrote: > Modified: trunk/include/pub_tool_options.h > =================================================================== > --- 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); > > -/* 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); > > +/* 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 ); Hmm, there isn't any reason why a tool should call err_missing_prog or err_config_error... I think those two should stay in m_main.c. I see the similarity between the three functions, perhaps that should be factored out into another function. Nick |
|
From: Julian S. <js...@ac...> - 2006-10-15 11:59:14
|
> > +/* 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 ); > > Hmm, there isn't any reason why a tool should call err_missing_prog or > err_config_error... I think those two should stay in m_main.c. I see the > similarity between the three functions, perhaps that should be factored out > into another function. Hmm, that's a good point. Hadn't noticed that before. Alternatively err_missing_prog and err_config_error could be moved from the tool .h to the core .h -- what say you to that? J |
|
From: Nicholas N. <nj...@cs...> - 2006-10-15 22:34:05
|
On Sun, 15 Oct 2006, Julian Seward wrote: >> Hmm, there isn't any reason why a tool should call err_missing_prog or >> err_config_error... I think those two should stay in m_main.c. I see the >> similarity between the three functions, perhaps that should be factored out >> into another function. > > Hmm, that's a good point. Hadn't noticed that before. Alternatively > err_missing_prog and err_config_error could be moved from the tool .h > to the core .h -- what say you to that? That's better because it's not tool-visible. But they're still not used outside of m_main.c, so there's no need to make them visible outside that module. Nick |
|
From: Julian S. <js...@ac...> - 2006-10-19 13:43:59
|
On Sunday 15 October 2006 23:33, Nicholas Nethercote wrote: > On Sun, 15 Oct 2006, Julian Seward wrote: > >> Hmm, there isn't any reason why a tool should call err_missing_prog or > >> err_config_error... I think those two should stay in m_main.c. I see > >> the similarity between the three functions, perhaps that should be > >> factored out into another function. > > > > Hmm, that's a good point. Hadn't noticed that before. Alternatively > > err_missing_prog and err_config_error could be moved from the tool .h > > to the core .h -- what say you to that? > > That's better because it's not tool-visible. But they're still not used > outside of m_main.c, so there's no need to make them visible outside that > module. I just looked into this again. Turns out that now, err_missing_prog and err_config_error are referred to by the newly created m_initimg. So the best I can do is move them to the core .h file. [Really the right answer is to create m_initimg/initimg-common.c and put them in there, since they're _only_ referred to from the two .c files in m_initimg, but that's a bit overkill right now.] J |