]> sourceware.org Git - systemtap.git/commitdiff
Simplify the '?' removal for STP_TIMING
authorJosh Stone <jistone@redhat.com>
Fri, 24 Sep 2010 22:16:36 +0000 (15:16 -0700)
committerJosh Stone <jistone@redhat.com>
Tue, 28 Sep 2010 23:00:06 +0000 (16:00 -0700)
Add a new flag to probe_point::print() so the extra details can be
avoided.  This skips '?', '!', and any conditionals as well.

* staptree.cxx (probe_point::print): Make the extras optional.
  (probe_point::str): Pass along the choice of extras.
* translate.cxx (c_unparser::emit_module_exit): Let the print routine
  skip the extra flags, rather than trying to strip them out manually.

staptree.cxx
staptree.h
translate.cxx

index 37416e3dfa8cec37b57b25782f34e5998ab64a89..367396ba827b18b4a62a3852f09d831acf4dcea1 100644 (file)
@@ -1120,7 +1120,7 @@ probe::collect_derivation_chain (std::vector<probe*> &probes_list)
 }
 
 
-void probe_point::print (ostream& o) const
+void probe_point::print (ostream& o, bool print_extras) const
 {
   for (unsigned i=0; i<components.size(); i++)
     {
@@ -1130,6 +1130,8 @@ void probe_point::print (ostream& o) const
       if (c->arg)
         o << "(" << *c->arg << ")";
     }
+  if (!print_extras)
+    return;
   if (sufficient)
     o << "!";
   else if (optional) // sufficient implies optional
@@ -1138,10 +1140,10 @@ void probe_point::print (ostream& o) const
     o<< " if (" << *condition << ")";
 }
 
-string probe_point::str ()
+string probe_point::str (bool print_extras) const
 {
   ostringstream o;
-  print(o);
+  print(o, print_extras);
   return o.str();
 }
 
index 647aa0e8d3115595f1f966228b50151a5390ff28..2edbec73890d258005904938a5fa15cc4eed2e3e 100644 (file)
@@ -680,11 +680,11 @@ struct probe_point
   bool optional;
   bool sufficient;
   expression* condition;
-  void print (std::ostream& o) const;
+  void print (std::ostream& o, bool print_extras=true) const;
   probe_point ();
   probe_point(const probe_point& pp);
   probe_point(std::vector<component*> const & comps);
-  std::string str();
+  std::string str(bool print_extras=true) const;
 };
 
 std::ostream& operator << (std::ostream& o, const probe_point& k);
index 73cfa6eb3d975f92bccf57ff909cb9f9be5c204a..9ce3e2b844b6671dd9dfde13a1faa85ada8e15b3 100644 (file)
@@ -1445,14 +1445,9 @@ c_unparser::emit_module_exit ()
     for (unsigned i=0; i<session->probes.size(); i++)
       {
         vector<probe*> reference_point;
-        const probe* p = session->probes[i];
+        const derived_probe* p = session->probes[i];
         const string &nm = p->name;
-        string::iterator it;
-        string call = session->probes[i]->sole_location()->str();
-        it = call.end()-1;
-        if(*it=='?')
-          call.erase(it);
-        //checking and erasing any trailing '?'
+        string call = p->sole_location()->str(false); // no ?,!,etc
         session->probes[i]->collect_derivation_chain(reference_point);
         // NB: check for null stat object
         o->newline() << "if (likely (time_" << nm << ")) {";
@@ -1470,19 +1465,14 @@ c_unparser::emit_module_exit ()
         o->newline() << "_stp_printf (\"%s, (%s), hits: %lld, cycles: %lldmin/%lldavg/%lldmax,\",";
         o->newline() << "probe_point, decl_location, (long long) stats->count, "
                      << "(long long) stats->min, (long long) avg, (long long) stats->max);";
-        for(unsigned int j=0; j<reference_point.size()-1; ++j)
+        for(unsigned int j=1; j<reference_point.size(); ++j)
           {
-            string::iterator it1;
-            string call_derivation = reference_point[j+1]->locations[0]->str();
-            it1 = call_derivation.end()-1;
-            if(*it1=='?')
-              call_derivation.erase(it1);
-            //checking for ? again
-            o->newline() << "_stp_printf(\" from: \");";
-            o->newline() << "_stp_printf(";
-            o->line() << lex_cast_qstring(call_derivation) << ");";
+            const probe_point *pp = reference_point[j]->locations[0];
+            o->newline() << "_stp_printf(\" from: %s\", "
+                         << lex_cast_qstring(pp->str(false)) // no ?,!,etc
+                         << ");";
           }
-        o->newline() << "_stp_printf(\" \\n\");";
+        o->newline() << "_stp_printf(\"\\n\");";
         o->newline(-1) << "}";
         o->newline() << "_stp_stat_del (time_" << nm << ");";
         o->newline(-1) << "}";
This page took 0.043664 seconds and 5 git commands to generate.