This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] duplicate warning elimination


This patch for SW6469 adds and uses a print_warnings method to eliminate
duplicate warnings.


--- a/ChangeLog
+++ b/ChangeLog
@@ -0,0 +1,5 @@
+2008-06-10  Stan Cox  <scox@redhat.com>
+
+	* elaborate.cxx (print_warning): New.
+	* elaborate.cxx (semantic_pass_opt1): Use it.
+

--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1230,0 +1231,12 @@ systemtap_session::print_error (const semantic_error& e)
+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;
+    }
+}
+
@@ -1561 +1573 @@ void semantic_pass_opt1 (systemtap_session& s, bool& relaxed_p)
-            clog << "WARNING: eliding unused function " << *s.functions[i]->tok << endl;
+	    s.print_warning ("eliding unused function " + stringify(*s.functions[i]->tok));
@@ -1614 +1626 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p)
-              clog << "WARNING: eliding unused variable " << *l->tok << endl;
+	      s.print_warning ("eliding unused variable " + stringify(*l->tok));
@@ -1630 +1642 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p)
-                clog << "WARNING: read-only local variable " << *l->tok << endl;
+		s.print_warning ("read-only local variable " + stringify(*l->tok));
@@ -1644 +1656 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p)
-              clog << "WARNING: eliding unused variable " << *l->tok << endl;
+              s.print_warning ("eliding unused variable " + stringify(*l->tok));
@@ -1661 +1673 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p)
-                clog << "WARNING: read-only local variable " << *l->tok << endl;
+                s.print_warning ("read-only local variable " + stringify(*l->tok));
@@ -1673 +1685 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p)
-            clog << "WARNING: eliding unused variable " << *l->tok << endl;
+            s.print_warning ("eliding unused variable " + stringify(*l->tok));
@@ -1689 +1701 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p)
-              clog << "WARNING: read-only global variable " << *l->tok << endl;
+              s.print_warning ("read-only global variable " + stringify(*l->tok));
@@ -2087,2 +2099,2 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p)
-            clog << "WARNING: side-effect-free probe '" << p->name << "' " 
-                 << *p->tok << endl;
+            s.print_warning ("side-effect-free probe '" + p->name + "' " 
+			     + stringify(*p->tok));
@@ -2112,2 +2124,2 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p)
-            clog << "WARNING: side-effect-free function '" << fn->name << "' "
-                 << *fn->tok << endl;
+            s.print_warning ("side-effect-free function '" + fn->name + "' "
+			     + stringify(*fn->tok));

--- a/session.h
+++ b/session.h
@@ -165,0 +166 @@ struct systemtap_session
+  std::set<std::string> seen_warnings;
@@ -168,0 +170 @@ struct systemtap_session
+    void print_warning (std::string w);

--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -0,0 +1,4 @@
+2008-06-10  Stan Cox  <scox@redhat.com>
+
+	* systemtap.base/warnings.exp: Adjust for duplicate warning elimination.
+

--- a/testsuite/systemtap.base/warnings.exp
+++ b/testsuite/systemtap.base/warnings.exp
@@ -12 +12 @@ wait
-if {$ok == 22} {
+if {$ok == 11} {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]