]> sourceware.org Git - systemtap.git/commitdiff
Uninstall the specific byteman rule we generated
authorLukas Berk <lberk@redhat.com>
Mon, 18 Mar 2013 23:11:29 +0000 (19:11 -0400)
committerLukas Berk <lberk@redhat.com>
Wed, 1 May 2013 15:11:26 +0000 (11:11 -0400)
*session.cxx: add systemtap_session member variables and use
      stap_system to launch bmsubmit.sh uninstall command
*session.h: added member variable declarations
*tapset-method.cx: use member variables so we know which rule to uninstall
*tapsets.cxx: reorder which tapsets to register so normal process probes
      are registered first

session.cxx
session.h
tapset-method.cxx
tapsets.cxx

index 232fc299756e1b4ba77a70884ca147d398df0a08..1242644bcb5357f417f1772aff7a57f2c7602e0b 100644 (file)
@@ -161,11 +161,13 @@ systemtap_session::systemtap_session ():
   sysroot = "";
   update_release_sysroot = false;
   suppress_time_limits = false;
+  java_pid = 0;
 
 #ifdef HAVE_HELPER
-  java_pid = 0;
   bminstall_path = "";
   bmsubmit_path = "";
+  byteman_script_path = "";
+  byteman_log = "";
 #endif //HAVE_HELPER
 
   // PR12443: put compiled-in / -I paths in front, to be preferred during 
@@ -340,11 +342,13 @@ systemtap_session::systemtap_session (const systemtap_session& other,
   update_release_sysroot = other.update_release_sysroot;
   sysenv = other.sysenv;
   suppress_time_limits = other.suppress_time_limits;
+  java_pid = other.java_pid;
 
 #ifdef HAVE_HELPER
-  java_pid = 0;
-  bminstall_path = "";
-  bmsubmit_path = "";
+  bminstall_path = other.bminstall_path;
+  bmsubmit_path = other.bmsubmit_path;
+  byteman_script_path = other.byteman_script_path;
+  byteman_log = other.byteman_log;
 #endif //HAVE_HELPER
 
   include_path = other.include_path;
@@ -382,7 +386,8 @@ systemtap_session::systemtap_session (const systemtap_session& other,
 systemtap_session::~systemtap_session ()
 {
 #ifdef HAVE_HELPER
-  java_detach();
+  if(java_pid != 0)
+    java_detach();
 #endif //HAVE_HELPER
   remove_tmp_dir();
   delete_map(subsessions);
@@ -2007,20 +2012,15 @@ translator_output* systemtap_session::op_create_auxiliary()
 void
 systemtap_session::java_detach()
 {
-  int bmsubmit = 0;
-  const char* option = " -u ";
-  bmsubmit_path = (find_executable("bmsubmit.sh")).c_str();
-  pid_t remove_pid = fork();
-  if (remove_pid == 0)
-    {
-      execl (bmsubmit_path, " ", option, (char*)NULL);
-      _exit (EXIT_FAILURE);
-    }
-  else if (remove_pid < 0) //failed
-    bmsubmit = -1;
-  else
-    if (waitpid (remove_pid, &bmsubmit, 0) != remove_pid)
-      bmsubmit = -1;
+  vector<string> bmcommand;
+  bmcommand.push_back(bmsubmit_path);
+  bmcommand.push_back(byteman_log);
+  bmcommand.push_back(" -u");
+  bmcommand.push_back(byteman_script_path);
+  (void) stap_system(verbose, bmcommand);
+  if (verbose>1)
+    clog << _F("Removed byteman rule: \"%s\"", byteman_script_path.c_str()) << endl;
+
 }
 #endif
 
index e7e5a984368ace01ed427a70b0e1b9fe5b793c1c..a5a2fb57cf97907df45237e25b2aee94cbf90a3c 100644 (file)
--- a/session.h
+++ b/session.h
@@ -200,13 +200,12 @@ public:
   int download_dbinfo;
   bool suppress_handler_errors;
   bool suppress_time_limits;
-
-#ifdef HAVE_HELPER
   int java_pid;
-  const char* bminstall_path;
-  const char* bmsubmit_path;
   void java_detach();
-#endif //HAVE_HELPER
+  std::string bminstall_path;
+  std::string bmsubmit_path;
+  std::string byteman_script_path;
+  std::string byteman_log;
 
   enum { kernel_runtime, dyninst_runtime } runtime_mode;
   bool runtime_usermode_p() const { return runtime_mode == dyninst_runtime; }
index e4b6ce658d4fa141af04fa5211809ea9c1b99fad..35b62c174c21fbc8fac6c08cb34220a868c4cb86 100644 (file)
@@ -44,6 +44,7 @@ private:
   typedef pair<java_cache_const_iterator_t, java_cache_const_iterator_t>
     java_cache_const_iterator_pair_t;
   java_cache_t java_cache;
+  //  string helper_path;
 
 public:
   java_builder (): cache_initialized (false) {}
@@ -76,7 +77,7 @@ java_builder::build (systemtap_session & sess,
                     literal_map_t const & parameters,
                     vector <derived_probe *> & finished_results)
 {
-
+  //  helper_path = HAVE_HELPER;
   string method_str_val;
   bool has_method_str = get_param (parameters, TOK_METHOD, method_str_val);
   int short_method_pos = method_str_val.find ('(');
@@ -92,8 +93,7 @@ java_builder::build (systemtap_session & sess,
   string short_method_str = method_str_val.substr (0, short_method_pos);
   string class_str_val; // fully qualified class string
   bool has_class_str = get_param (parameters, TOK_CLASS, class_str_val);
-  int java_pid;
-  bool has_pid_int = get_number_param (parameters, TOK_JAVA, java_pid);
+  bool has_pid_int = get_number_param (parameters, TOK_JAVA, sess.java_pid);
   //need to count the number of parameters, exit if more than 10
   int method_params_counter = 1;
   int method_params_count = count (method_str_val.begin (), method_str_val.end (), ',');
@@ -110,24 +110,23 @@ java_builder::build (systemtap_session & sess,
   assert (has_class_str);
   (void) has_class_str;
 
-  string byteman_script_path;
   if (! cache_initialized)
     {
 
       cache_initialized = true;
-      byteman_script_path = sess.tmpdir + "/stap-byteman.btm";
+      sess.byteman_script_path = sess.tmpdir + "/stap-byteman.btm";
       if (sess.verbose > 3)
        {
-         clog << "byteman script path: " << byteman_script_path
+         clog << "byteman script path: " << sess.byteman_script_path
               << endl;
        }
       ofstream byteman_script;
-      byteman_script.open (byteman_script_path.c_str (), ifstream::out);
+      byteman_script.open (sess.byteman_script_path.c_str(), ifstream::out);
       if (! byteman_script)
        {
          if (sess.verbose > 3)
            //TRANSLATORS: Specific path cannot be opened
-           clog << byteman_script_path << _(" cannot be opened: ")
+           clog << sess.byteman_script_path << _(" cannot be opened: ")
                 << strerror (errno) << endl;
          return;
        }
@@ -176,22 +175,23 @@ java_builder::build (systemtap_session & sess,
 
   //this could be done using itoa
   string arg = static_cast <ostringstream*> ( & (ostringstream ()
-                                             << java_pid) )->str ();
+                                             << sess.java_pid) )->str ();
 
   const char* java_pid_str = arg.c_str ();
-  sess.bminstall_path = (find_executable ("bminstall.sh")).c_str ();
+  sess.bminstall_path = (find_executable ("bminstall.sh"));
+  const char* tmp2 = sess.bminstall_path.c_str();
 
   if (sess.verbose > 3)
     clog << "Reported bminstall.sh path: " << sess.bminstall_path << endl;
   // XXX check both scripts here, exit if not available
   const char* space = " ";
-
   int bminstall; //bminstall command status
   int bmsubmit; //bmsubmit command status
   pid_t install_pid = fork ();
   if (install_pid == 0)
     {
-      execl (sess.bminstall_path, space, java_pid_str, (char*)NULL);
+      //      execl (sess.bminstall_path.c_str(), space, java_pid_str, (char*)NULL);
+      execl (tmp2, space, java_pid_str, (char*)NULL);
       _exit (EXIT_FAILURE);
     }
   else if (install_pid < 0) //failure
@@ -201,17 +201,17 @@ java_builder::build (systemtap_session & sess,
       bminstall = -1;
 
   const char* bmsubmit_option = " -l";
-  const char* bmsubmit_script = byteman_script_path.c_str ();
-  sess.bmsubmit_path = (find_executable ("bmsubmit.sh")).c_str ();
-  string _redirect = " -o " + sess.tmpdir + "/byteman.log";
-  const char* redirect = _redirect.c_str();
+  sess.bmsubmit_path = (find_executable ("bmsubmit.sh"));
+  const char* _bmsubmit_path = sess.bmsubmit_path.c_str();
+  sess.byteman_log = " -o " + sess.tmpdir + "/byteman.log";
+  //  const char* bmlog = sess.byteman_log.c_str();
   if (sess.verbose > 3)
     clog << "Reported bmsubmit.sh path: " << sess.bmsubmit_path << endl;
 
   pid_t submit_pid = fork ();
   if (submit_pid == 0)
     {
-      execl (sess.bmsubmit_path, bmsubmit_option, redirect, bmsubmit_script, (char*)NULL);
+      execl (_bmsubmit_path, bmsubmit_option, sess.byteman_log.c_str(), sess.byteman_script_path.c_str(), (char*)NULL);
       _exit (EXIT_FAILURE);
     }
   else if (submit_pid < 0) //failure
@@ -229,7 +229,7 @@ java_builder::build (systemtap_session & sess,
   probe_point* new_loc = new probe_point (*loc);
   vector<probe_point::component*> java_marker;
   java_marker.push_back( new probe_point::component 
-                        (TOK_PROCESS, new literal_string (HAVE_HELPER)));
+                        (TOK_PROCESS, new literal_string ("/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/lib/amd64/libHelperSDT.so")));
   java_marker.push_back( new probe_point::component 
                         (TOK_MARK, new literal_string ("*")));
   probe_point * derived_loc = new probe_point (*new_loc);
index 94be7455a61ec7ecf6d26d5b69022a1cc88cd1ed..aa3bb95069025f516c6627920bf0ee7030ef155d 100644 (file)
@@ -10010,7 +10010,6 @@ tracepoint_builder::build(systemtap_session& s,
 void
 register_standard_tapsets(systemtap_session & s)
 {
-  register_tapset_java(s);
   register_tapset_been(s);
   register_tapset_itrace(s);
   register_tapset_mark(s);
@@ -10032,18 +10031,6 @@ register_standard_tapsets(systemtap_session & s)
     ->bind_privilege(pr_all)
     ->bind(new uprobe_builder ());
 
-  // java per-method probes
-  /*  s.pattern_root->bind_num(TOK_PROCESS)
-    ->bind_str(TOK_CLASS)->bind_str(TOK_METHOD)
-    ->bind(new java_builder ());*/
-
-  /* second java case where we have 
-     process("PID").method("class.method")
-  */
-  /*  s.pattern_root->bind_num(TOK_PROCESS)
-    ->bind_str(TOK_CLASSMETHOD)
-    ->bind(new java_builder ());*/
-
   // kernel tracepoint probes
   s.pattern_root->bind(TOK_KERNEL)->bind_str(TOK_TRACE)
     ->bind(new tracepoint_builder());
@@ -10088,7 +10075,7 @@ register_standard_tapsets(systemtap_session & s)
 
   //perf event based probe
   register_tapset_perf(s);
-
+  register_tapset_java(s);
 }
 
 
This page took 0.045327 seconds and 5 git commands to generate.