]> sourceware.org Git - systemtap.git/commitdiff
Eliminate duplicate warnings.
authorStan Cox <scox@redhat.com>
Wed, 11 Jun 2008 13:39:53 +0000 (09:39 -0400)
committerStan Cox <scox@redhat.com>
Wed, 11 Jun 2008 13:39:53 +0000 (09:39 -0400)
ChangeLog
elaborate.cxx
session.h
testsuite/ChangeLog
testsuite/systemtap.base/warnings.exp

index cf3ef28993ac47699efd521b927073c76723fb79..2904bbee7d2f1d5fcd46d21096c17f97c2f939f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 2f246e2ced6d75b0c83dd3fae1ee3376dca7fa77..dd01eaae02c869d6cee2e29d4774da27384abef7 100644 (file)
@@ -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;
index 646b915414b87e7c7802b6a7c560eddfc9de1afb..fc2ca2a96cbe0917cc9e49fe2f0ebb272e7745e6 100644 (file)
--- a/session.h
+++ b/session.h
@@ -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.
 };
index 48f6fbcbe4cc7f4e644614392f2fc4d36ee39f5f..58f9baff19228088571162e7da7122ccdb07aaed 100644 (file)
@@ -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.
index 6cff723dac0966eb3dadce674102953ddd4218ac..072b52fb84c04290368b32e902cbf2bc949a6358 100644 (file)
@@ -9,7 +9,7 @@ expect {
     eof { }
 }
 wait
-if {$ok == 22} {
+if {$ok == 11} {
     pass $test
 } else {
     fail "$test ($ok)"
This page took 0.048678 seconds and 5 git commands to generate.