diff options
author | Stan Cox <scox@redhat.com> | 2008-06-11 09:39:53 -0400 |
---|---|---|
committer | Stan Cox <scox@redhat.com> | 2008-06-11 09:39:53 -0400 |
commit | ab54fa853735acfe90a0e125216bbb400e12ee1c (patch) | |
tree | b1c84717229a12c3825c3f431a30f80bb0cca0cf | |
parent | ba53ea9f51453154bca13c57988a17e009e80476 (diff) | |
download | systemtap-steved-ab54fa853735acfe90a0e125216bbb400e12ee1c.tar.gz systemtap-steved-ab54fa853735acfe90a0e125216bbb400e12ee1c.tar.xz systemtap-steved-ab54fa853735acfe90a0e125216bbb400e12ee1c.zip |
Eliminate duplicate warnings.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | elaborate.cxx | 34 | ||||
-rw-r--r-- | session.h | 2 | ||||
-rw-r--r-- | testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/warnings.exp | 2 |
5 files changed, 35 insertions, 12 deletions
@@ -1,3 +1,8 @@ +2008-06-10 Stan Cox <scox@redhat.com> + + * elaborate.cxx (print_warning): New. + * elaborate.cxx (semantic_pass_opt1): Use it. + 2008-06-11 Tim Moore <timoore@redhat.com> * dwarf_wrappers.h (dwfl_assert): Add overload with boolean value diff --git a/elaborate.cxx b/elaborate.cxx index 2f246e2c..dd01eaae 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1228,6 +1228,18 @@ systemtap_session::print_error (const semantic_error& e) print_error (* e.chain); } +void +systemtap_session::print_warning (string message_str) +{ + message_str.insert(0, "WARNING: "); + // Duplicate elimination + if (seen_errors.find (message_str) == seen_errors.end()) + { + seen_errors.insert (message_str); + clog << message_str << endl; + } +} + // ------------------------------------------------------------------------ // semantic processing: symbol resolution @@ -1558,7 +1570,7 @@ void semantic_pass_opt1 (systemtap_session& s, bool& relaxed_p) { if (s.functions[i]->tok->location.file == s.user_file->name && // !tapset ! s.suppress_warnings) - clog << "WARNING: eliding unused function " << *s.functions[i]->tok << endl; + s.print_warning ("eliding unused function " + stringify(*s.functions[i]->tok)); else if (s.verbose>2) clog << "Eliding unused function " << s.functions[i]->name << endl; @@ -1611,7 +1623,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) { if (l->tok->location.file == s.user_file->name && // !tapset ! s.suppress_warnings) - clog << "WARNING: eliding unused variable " << *l->tok << endl; + s.print_warning ("eliding unused variable " + stringify(*l->tok)); else if (s.verbose>2) clog << "Eliding unused local variable " << l->name << " in " << s.probes[i]->name << endl; @@ -1627,7 +1639,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) { if (vut.written.find (l) == vut.written.end()) if (! s.suppress_warnings) - clog << "WARNING: read-only local variable " << *l->tok << endl; + s.print_warning ("read-only local variable " + stringify(*l->tok)); j++; } @@ -1641,7 +1653,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) { if (l->tok->location.file == s.user_file->name && // !tapset ! s.suppress_warnings) - clog << "WARNING: eliding unused variable " << *l->tok << endl; + s.print_warning ("eliding unused variable " + stringify(*l->tok)); else if (s.verbose>2) clog << "Eliding unused local variable " << l->name << " in function " << s.functions[i]->name @@ -1658,7 +1670,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) { if (vut.written.find (l) == vut.written.end()) if (! s.suppress_warnings) - clog << "WARNING: read-only local variable " << *l->tok << endl; + s.print_warning ("read-only local variable " + stringify(*l->tok)); j++; } } @@ -1670,7 +1682,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) { if (l->tok->location.file == s.user_file->name && // !tapset ! s.suppress_warnings) - clog << "WARNING: eliding unused variable " << *l->tok << endl; + s.print_warning ("eliding unused variable " + stringify(*l->tok)); else if (s.verbose>2) clog << "Eliding unused global variable " << l->name << endl; @@ -1686,7 +1698,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) if (vut.written.find (l) == vut.written.end() && ! l->init) // no initializer if (! s.suppress_warnings) - clog << "WARNING: read-only global variable " << *l->tok << endl; + s.print_warning ("read-only global variable " + stringify(*l->tok)); i++; } } @@ -2084,8 +2096,8 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p) if (p->body == 0) { if (! s.suppress_warnings) - clog << "WARNING: side-effect-free probe '" << p->name << "' " - << *p->tok << endl; + s.print_warning ("side-effect-free probe '" + p->name + "' " + + stringify(*p->tok)); p->body = new null_statement(); p->body->tok = p->tok; @@ -2109,8 +2121,8 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p) if (fn->body == 0) { if (! s.suppress_warnings) - clog << "WARNING: side-effect-free function '" << fn->name << "' " - << *fn->tok << endl; + s.print_warning ("side-effect-free function '" + fn->name + "' " + + stringify(*fn->tok)); fn->body = new null_statement(); fn->body->tok = fn->tok; @@ -163,9 +163,11 @@ struct systemtap_session Dwarf_Addr sym_stext; std::set<std::string> seen_errors; + std::set<std::string> seen_warnings; unsigned num_errors () { return seen_errors.size(); } // void print_error (const parse_error& e); void print_error (const semantic_error& e); + void print_warning (std::string w); // reNB: new POD members likely need to be explicitly cleared in the ctor. }; diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 48f6fbcb..58f9baff 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-06-10 Stan Cox <scox@redhat.com> + + * systemtap.base/warnings.exp: Adjust for duplicate warning elimination. + 2008-06-10 Frank Ch. Eigler <fche@elastic.org> PR 6470. diff --git a/testsuite/systemtap.base/warnings.exp b/testsuite/systemtap.base/warnings.exp index 6cff723d..072b52fb 100644 --- a/testsuite/systemtap.base/warnings.exp +++ b/testsuite/systemtap.base/warnings.exp @@ -9,7 +9,7 @@ expect { eof { } } wait -if {$ok == 22} { +if {$ok == 11} { pass $test } else { fail "$test ($ok)" |