};
+struct statement_counter: public update_visitor
+{
+ bool empty;
+ const token* first_tok;
+
+ statement_counter () {}
+
+ void visit_block (block *b)
+ {
+ if (b->statements.size() > 0)
+ {
+ empty = false;
+ first_tok = b->statements[0]->tok;
+ }
+ else
+ empty = true;
+ };
+};
+
+
void
perf_builder::build(systemtap_session & sess,
probe * base,
for (it=sess.perf_counters.begin(); it != sess.perf_counters.end(); it++)
if ((*it).first == var)
throw semantic_error(_("duplicate counter name"));
+
+ struct statement_counter sc;
+ base->body->visit(&sc);
+ if (! sc.empty)
+ sess.print_warning(_("Statements in perf counter probe will never be reached."), sc.first_tok);
+
+ if_statement *ifs = new if_statement ();
+ ifs->tok = base->tok;
+ ifs->thenblock = new next_statement ();
+ ifs->thenblock->tok = base->tok;
+ ifs->elseblock = NULL;
+ ifs->condition = new literal_number(0);
+ base->body = new block (ifs, base->body);
}
if (sess.verbose > 1)