diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | elaborate.cxx | 46 | ||||
-rw-r--r-- | session.h | 4 | ||||
-rw-r--r-- | testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | testsuite/systemtap.base/warnings.exp | 2 | ||||
-rw-r--r-- | testsuite/systemtap.base/warnings.stp | 12 |
6 files changed, 67 insertions, 11 deletions
@@ -1,3 +1,10 @@ +2008-06-13 Stan Cox <scox@redhat.com> + + * elaborate.cxx (print_warning): Add optional_str parameter. + (semantic_pass_opt2): List variable alternatives for probes and + functions. + * session.h (print_warning): Add optional_str parameter. + 2008-06-13 Josh Stone <joshua.i.stone@intel.com> * translate.cxx: Jump out directly after setting last_error, rather @@ -23,7 +30,7 @@ * elaborate.cxx (print_warning): Only output WARNING, don't put it in the message_str and seen_warnings. - * session.h (print_waring): Reindent. + * session.h (print_warning): Reindent. 2008-06-11 Frank Ch. Eigler <fche@elastic.org> diff --git a/elaborate.cxx b/elaborate.cxx index e9746cdd..efdf2e96 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1229,13 +1229,13 @@ systemtap_session::print_error (const semantic_error& e) } void -systemtap_session::print_warning (const string& message_str) +systemtap_session::print_warning (const string& message_str, string optional_str = "") { // Duplicate elimination if (seen_warnings.find (message_str) == seen_warnings.end()) { seen_warnings.insert (message_str); - clog << "WARNING: " << message_str << endl; + clog << "WARNING: " << message_str << optional_str << endl; } } @@ -1612,7 +1612,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) // Now in vut.read/written, we have a mixture of all locals, globals - for (unsigned i=0; i<s.probes.size(); i++) + for (unsigned i=0; i<s.probes.size(); i++) for (unsigned j=0; j<s.probes[i]->locals.size(); /* see below */) { vardecl* l = s.probes[i]->locals[j]; @@ -1638,11 +1638,27 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) { if (vut.written.find (l) == vut.written.end()) if (! s.suppress_warnings) - s.print_warning ("read-only local variable " + stringify(*l->tok)); - + { + stringstream o; + vector<vardecl*>::iterator it; + for ( it = s.probes[i]->locals.begin() ; + it != s.probes[i]->locals.end(); it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + for ( it = s.globals.begin() ; + it != s.globals.end() ; it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + + s.print_warning ("read-only local variable " + + stringify(*l->tok), + " (alternatives: " + o.str () + ")"); + } + j++; } } + for (unsigned i=0; i<s.functions.size(); i++) for (unsigned j=0; j<s.functions[i]->locals.size(); /* see below */) { @@ -1667,9 +1683,27 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) } else { + stringstream o; + vector<vardecl*>::iterator it; + for ( it = s.functions[i]->formal_args.begin() ; + it != s.functions[i]->formal_args.end(); it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + for ( it = s.functions[i]->locals.begin() ; + it != s.functions[i]->locals.end(); it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + for ( it = s.globals.begin() ; + it != s.globals.end() ; it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + if (vut.written.find (l) == vut.written.end()) if (! s.suppress_warnings) - s.print_warning ("read-only local variable " + stringify(*l->tok)); + s.print_warning ("read-only local variable " + + stringify(*l->tok), + " (alternatives:" + o.str () + ")"); + j++; } } @@ -1,5 +1,5 @@ // -*- C++ -*- -// Copyright (C) 2005-2007 Red Hat Inc. +// Copyright (C) 2005-2008 Red Hat Inc. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General @@ -167,7 +167,7 @@ struct systemtap_session unsigned num_errors () { return seen_errors.size(); } // void print_error (const parse_error& e); void print_error (const semantic_error& e); - void print_warning (const std::string& w); + void print_warning (const std::string& w, std::string o); // reNB: new POD members likely need to be explicitly cleared in the ctor. }; diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 518dc4f1..fd5a4c8f 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-06-16 Stan Cox <scox@redhat.com> + + * systemtap.base/warnings.stp: Added PR 6611 warning tests. + * systemtap.base/warnings.exp: Reset warning count. + 2008-06-13 Frank Ch. Eigler <fche@elastic.org> * lib/stap_run.exp: Remove module/cache warning boilerplate. diff --git a/testsuite/systemtap.base/warnings.exp b/testsuite/systemtap.base/warnings.exp index 99e70847..3e37553f 100644 --- a/testsuite/systemtap.base/warnings.exp +++ b/testsuite/systemtap.base/warnings.exp @@ -9,7 +9,7 @@ expect { eof { } } wait -if {$ok == 12} { +if {$ok == 16} { pass $test } else { fail "$test ($ok)" diff --git a/testsuite/systemtap.base/warnings.stp b/testsuite/systemtap.base/warnings.stp index a2ac5afc..314e45f7 100644 --- a/testsuite/systemtap.base/warnings.stp +++ b/testsuite/systemtap.base/warnings.stp @@ -1,4 +1,4 @@ -# PR 1119, 6538 +# PR 1119 global elide_me1 function elide_me2 () {} @@ -6,3 +6,13 @@ function foo:long () { elide_me3 = 1 } function bar() { print(elide+me1) ; ; ; } probe never { elide_me4 = 1; (elide_me5+5); print (foo()) } probe never { print(elide+me1) bar () } + +# PR 6611 + +probe probea = kernel.statement("bio_init@fs/bio.c:135") + { printf("%d", funca(2)); elide_me6="foo" } +probe probea { printf("%d", funcb(2,3)); printf("%s",var) } + +function funcb(a:long, b:long) {return a + b} +function funca(a:long) {a=b; elide_me7=1; return a} + |