From 87103d2b32ea873721f727aaac1434e52660b713 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 20 Mar 2016 18:22:01 -0400 Subject: [PATCH] monitor mode: deconflict with private global mangling 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 | 18 +++++++++++++----- elaborate.h | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/elaborate.cxx b/elaborate.cxx index df45f2264..6492c52c5 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -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; iname == name && startswith(name, "__global_")) || diff --git a/elaborate.h b/elaborate.h index 07cc16ce9..f01b6d709 100644 --- a/elaborate.h +++ b/elaborate.h @@ -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 find_functions (const std::string& name, unsigned arity, const token *tok); -- 2.43.5