]> sourceware.org Git - systemtap.git/commitdiff
monitor mode: deconflict with private global mangling
authorFrank Ch. Eigler <fche@redhat.com>
Sun, 20 Mar 2016 22:22:01 +0000 (18:22 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Sun, 20 Mar 2016 22:25:40 +0000 (18:25 -0400)
The synthesized probe body for monitor mode control needs to refer to
globals that may be declared private inside a tapset, in order to
clear them.  It needs to pierce the mangling-based name-hiding, so
that when the synthetic fragment is symbol-resolved, it will find the
mangled private globals to manipulate.  This is implemented by an
optional mode-flag in the symresolution_info class to suppress
global-mangling.

The test script was:

   stap --monitor -p4 -e 'probe nd_syscall.* {}' -v

elaborate.cxx
elaborate.h

index df45f2264e578fe55c058b4113baf38922504a2d..6492c52c5c84ef00fe28744691d9b9b13ca9cca2 100644 (file)
@@ -2199,7 +2199,7 @@ static void monitor_mode_write(systemtap_session& s)
   dp->join_group (s);
 
   // Repopulate symbol info
-  symresolution_info sym (s);
+  symresolution_info sym (s, /* omniscient-unmangled */ true);
   sym.current_function = 0;
   sym.current_probe = dp;
   dp->body->visit (&sym);
@@ -2349,8 +2349,8 @@ semantic_pass (systemtap_session& s)
 // semantic processing: symbol resolution
 
 
-symresolution_info::symresolution_info (systemtap_session& s):
-  session (s), current_function (0), current_probe (0)
+symresolution_info::symresolution_info (systemtap_session& s, bool omniscient_unmangled):
+  session (s), unmangled_p(omniscient_unmangled), current_function (0), current_probe (0)
 {
 }
 
@@ -2631,8 +2631,16 @@ symresolution_info::find_var (interned_string name, int arity, const token* tok)
        }
 
   // search processed globals
-  string gname = "__global_" + string(name);
-  string pname = "__private_" + detox_path(tok->location.file->name) + string(name);
+  string gname, pname;
+  if (unmangled_p)
+    {
+      gname = pname = string(name);
+    }
+  else
+    {
+      gname = "__global_" + string(name);
+      pname = "__private_" + detox_path(tok->location.file->name) + string(name);
+    }
   for (unsigned i=0; i<session.globals.size(); i++)
   {
     if ((session.globals[i]->name == name && startswith(name, "__global_")) ||
index 07cc16ce9891d7c73dcc1e35a6bc7b8d7a1914fb..f01b6d709e5ad54eb1d40d45b96346566de0fefd 100644 (file)
@@ -47,11 +47,11 @@ struct symresolution_info: public traversing_visitor
 {
 protected:
   systemtap_session& session;
-
+  bool unmangled_p;
 public:
   functiondecl* current_function;
   derived_probe* current_probe;
-  symresolution_info (systemtap_session& s);
+  symresolution_info (systemtap_session& s, bool omniscient_unmangled = false);
 
   vardecl* find_var (interned_string name, int arity, const token *tok);
   std::vector<functiondecl*> find_functions (const std::string& name, unsigned arity, const token *tok);
This page took 0.038737 seconds and 5 git commands to generate.