From 57a56e00067b4546bb0da15fb00653ee0341f5af Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 25 Feb 2010 21:14:52 -0500 Subject: PR11075: -W option to turn warnings into errors * session.h * NEWS: Discuss it. * main.cxx: Parse it. * session.h (num_errors): Provide it. * semok/fortyeight.stp, semok/thirtyseven.stp: Test it. --- NEWS | 4 ++++ main.cxx | 8 +++++++- session.h | 3 ++- testsuite/semko/fortyeight.stp | 6 ++++++ testsuite/semok/thirtyseven.stp | 6 ++++++ 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100755 testsuite/semko/fortyeight.stp create mode 100755 testsuite/semok/thirtyseven.stp diff --git a/NEWS b/NEWS index 85619f8e..d9f70676 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ * What's new +- A new command line flag '-W' forces systemtap to abort translation of + a script if any warnings are produced. It is similar to gcc's -Werror. + (If '-w' is also supplied to suppress warnings, it wins.) + - A new predicate @defined is available for testing whether a particular $variable/expression is resolvable at translate time: probe foo { if (@defined($bar)) log ("$bar is available here") } diff --git a/main.cxx b/main.cxx index 7073f7d3..c7be3bc1 100644 --- a/main.cxx +++ b/main.cxx @@ -93,6 +93,7 @@ usage (systemtap_session& s, int exitcode) << " -k keep temporary directory" << endl << " -u unoptimized translation" << (s.unoptimized ? " [set]" : "") << endl << " -w suppress warnings" << (s.suppress_warnings ? " [set]" : "") << endl + << " -W turn warnings into errors" << (s.panic_warnings ? " [set]" : "") << endl << " -g guru mode" << (s.guru_mode ? " [set]" : "") << endl << " -P prologue-searching for function probes" << (s.prologue_searching ? " [set]" : "") << endl @@ -504,6 +505,7 @@ main (int argc, char * const argv []) s.bulk_mode = false; s.unoptimized = false; s.suppress_warnings = false; + s.panic_warnings = false; s.listing_mode = false; s.listing_mode_vars = false; @@ -640,7 +642,7 @@ main (int argc, char * const argv []) { "help", 0, &long_opt, LONG_OPT_HELP }, { NULL, 0, NULL, 0 } }; - int grc = getopt_long (argc, argv, "hVvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:", + int grc = getopt_long (argc, argv, "hVvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:W", long_options, NULL); if (grc < 0) break; @@ -663,6 +665,10 @@ main (int argc, char * const argv []) s.suppress_warnings = true; break; + case 'W': + s.panic_warnings = true; + break; + case 'p': s.last_pass = (int)strtoul(optarg, &num_endptr, 10); if (*num_endptr != '\0' || s.last_pass < 1 || s.last_pass > 5) diff --git a/session.h b/session.h index d43b1f21..18d811e7 100644 --- a/session.h +++ b/session.h @@ -110,6 +110,7 @@ struct systemtap_session bool bulk_mode; bool unoptimized; bool suppress_warnings; + bool panic_warnings; int buffer_size; unsigned perfmon; bool symtab; /* true: emit symbol table at translation time; false: let staprun do it. */ @@ -214,7 +215,7 @@ struct systemtap_session std::set seen_errors; std::set seen_warnings; - unsigned num_errors () { return seen_errors.size(); } + unsigned num_errors () { return seen_errors.size() + (panic_warnings ? seen_warnings.size() : 0); } std::set rpms_to_install; diff --git a/testsuite/semko/fortyeight.stp b/testsuite/semko/fortyeight.stp new file mode 100755 index 00000000..34bcad01 --- /dev/null +++ b/testsuite/semko/fortyeight.stp @@ -0,0 +1,6 @@ +#! stap -Wp2 + +# PR 11075 + +global foo # evokes warning +probe begin { exit() } diff --git a/testsuite/semok/thirtyseven.stp b/testsuite/semok/thirtyseven.stp new file mode 100755 index 00000000..fb378359 --- /dev/null +++ b/testsuite/semok/thirtyseven.stp @@ -0,0 +1,6 @@ +#! stap -wWp2 + +# PR 11075 + +global foo # evokes warning +probe begin { exit() } -- cgit