]> sourceware.org Git - systemtap.git/blobdiff - tapset-perfmon.cxx
perf.counter probe warnings.
[systemtap.git] / tapset-perfmon.cxx
index 9862d7538802ff6b5815faec7daa990406d078bb..e25bb1e4f50c5bb66ffc91a6b0960c8a8321fb6d 100644 (file)
@@ -297,6 +297,26 @@ struct perf_builder: public derived_probe_builder
 };
 
 
+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,
@@ -347,6 +367,19 @@ perf_builder::build(systemtap_session & sess,
       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)
This page took 0.024078 seconds and 5 git commands to generate.