]> sourceware.org Git - systemtap.git/commitdiff
simplify derived_probe::script_location()
authorJonathan Lebon <jlebon@redhat.com>
Tue, 13 May 2014 20:18:43 +0000 (16:18 -0400)
committerJonathan Lebon <jlebon@redhat.com>
Tue, 27 May 2014 14:14:00 +0000 (10:14 -0400)
Rather than relying on yucky heuristics, we go the explicit way. The
script_location() function now relies on the new probe_point member
'well_formed', which is true if the probe point represents the 'final'
script-level expression, after wildcard expansion.

Since only each individual probe builder knows what constitutes a
well-formed probe point, it will be up to those to set the 'well_formed'
flag as needed. If the probe point that we want to list is also the
final one, which is the case for many simpler probe points, then no
further work is needed. The following patches modify the appropriate
builders to do just this.

elaborate.cxx
staptree.cxx
staptree.h

index d8801129b6ba2c103ac0c3c41febd452907834a9..80232f43186a6953e7e9bb42912b5681919dfeff 100644 (file)
@@ -155,27 +155,14 @@ probe_point*
 derived_probe::script_location () const
 {
   // This feeds function::pn() in the tapset, which is documented as the
-  // script-level probe point expression, *after wildcard expansion*.  If
-  // it were not for wildcard stuff, we'd just return the last item in the
-  // derivation chain.  But alas ... we need to search for the last one
-  // that doesn't have a * in the textual representation.  Heuristics, eww.
+  // script-level probe point expression, *after wildcard expansion*.
   vector<probe_point*> chain;
   collect_derivation_pp_chain (chain);
 
-  // NB: we actually start looking from the second-to-last item, so the user's
-  // direct input is not considered.  Input like 'kernel.function("init_once")'
-  // will thus be listed with the resolved @file:line too, disambiguating the
-  // distinct functions by this name, and matching our historical behavior.
-  for (int i=chain.size()-2; i>=0; i--)
-    {
-      probe_point pp_copy (* chain [i]);
-      // drop any ?/! denotations that would confuse a glob-char search
-      pp_copy.optional = false;
-      pp_copy.sufficient = false;
-      string pp_printed = lex_cast(pp_copy);
-      if (! contains_glob_chars(pp_printed))
-        return chain[i];
-    }
+  // Go backwards until we hit the first well-formed probe point
+  for (int i=chain.size()-1; i>=0; i--)
+    if (chain[i]->well_formed)
+      return chain[i];
 
   // If that didn't work, just fallback to -something-.
   return sole_location();
index 4985b3658c771c33b9dba6b4e494bafaf11f2dbc..ed327617d633f88245c6f7a22e28c061c4b3aecb 100644 (file)
@@ -95,20 +95,22 @@ symboldecl::~symboldecl ()
 
 probe_point::probe_point (std::vector<component*> const & comps):
   components(comps), optional (false), sufficient (false),
-  from_glob (false), condition (0)
+  from_glob (false), well_formed (false), condition (0)
 {
 }
 
 // NB: shallow-copy of compoonents & condition!
 probe_point::probe_point (const probe_point& pp):
   components(pp.components), optional (pp.optional), sufficient (pp.sufficient),
-  from_glob (pp.from_glob), condition (pp.condition)
+  from_glob (pp.from_glob), well_formed (pp.well_formed),
+  condition (pp.condition)
 {
 }
 
 
 probe_point::probe_point ():
-  optional (false), sufficient (false), from_glob (false), condition (0)
+  optional (false), sufficient (false), from_glob (false),
+  well_formed (false), condition (0)
 {
 }
 
index 7433b4126bf4cacd0143af60e9402ab396e49c96..a7f34691eb6c25d229675052fe05f65fb6acc82a 100644 (file)
@@ -747,6 +747,7 @@ struct probe_point
   bool optional;
   bool sufficient;
   bool from_glob;
+  bool well_formed; // used in derived_probe::script_location()
   expression* condition;
   void print (std::ostream& o, bool print_extras=true) const;
   probe_point ();
This page took 0.042816 seconds and 5 git commands to generate.