]> sourceware.org Git - systemtap.git/commitdiff
Only install rules once per java process
authorLukas Berk <lberk@redhat.com>
Thu, 4 Apr 2013 15:24:51 +0000 (11:24 -0400)
committerLukas Berk <lberk@redhat.com>
Wed, 1 May 2013 15:11:27 +0000 (11:11 -0400)
*session.cxx: re-enable the check before executing java_detach
*tapset-method.cxx: only bminstall.sh the process if its not already been recorded
    and check to see if we've installed any java procs already

session.cxx
tapset-method.cxx

index 05c167fdc2244a1e6c6d5c91a0e77ed700ce7e5b..0abc540cd45bd15f80765da2b41934949e6ef14f 100644 (file)
@@ -388,7 +388,7 @@ systemtap_session::~systemtap_session ()
 {
 #ifdef HAVE_HELPER
 
-  //  if(!java_pid.empty() || !java_proc_class.empty())
+  if(java_pid.size() != 0 || java_proc_class.size() != 0)
     java_detach();
 #endif //HAVE_HELPER
   remove_tmp_dir();
index a060b560664013fd813cc6e0ce8a317b1edc5781..80d8756803b5be70a523333478e62a0c3da353aa 100644 (file)
@@ -116,35 +116,6 @@ java_builder::build (systemtap_session & sess,
   bool has_pid_int = get_number_param (parameters, TOK_JAVA, _java_pid);
   bool has_pid_str = get_param (parameters, TOK_JAVA, _java_proc_class);
 
-  if (has_pid_int)
-    {
-      for (it = sess.java_pid.begin(); it != sess.java_pid.end(); ++it)
-       {
-         if(*it == _java_pid) //if we work our way though it all and still doesn't 
-           {
-             break;                    // match then we push back on the vector
-           }
-         else if ((*it != _java_pid) && ++it == sess.java_pid.end())
-           {
-             sess.java_pid.push_back(_java_pid);
-           }
-       }
-
-    }
-  else
-    {
-      for (is = sess.java_proc_class.begin(); is != sess.java_proc_class.end(); ++is)
-       {
-         if(*is == _java_proc_class)
-           {
-             break;
-           }
-         else if ((*is != _java_proc_class) && (++is == sess.java_proc_class.end()))
-           {
-             sess.java_proc_class.push_back(_java_proc_class);
-           }
-       }
-    }
   //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 (), ',');
@@ -246,20 +217,82 @@ java_builder::build (systemtap_session & sess,
     clog << "Reported bminstall.sh path: " << sess.bminstall_path << endl;
   // XXX check both scripts here, exit if not available
 
-  vector<string> bminstall_cmd;
-  bminstall_cmd.push_back(sess.bminstall_path);
-  if(!has_pid_str)
-    bminstall_cmd.push_back(java_pid_str);
+  if (has_pid_int)
+    {
+      for (it = sess.java_pid.begin(); it != sess.java_pid.end(); ++it)
+       {
+         if(*it == _java_pid) //if we work our way though it all and still doesn't 
+             break;           //match then we push back on the vector
+         else if ((*it != _java_pid) && ++it == sess.java_pid.end())
+           {
+             cout << "this was hit java_pid" << endl;
+             sess.java_pid.push_back(_java_pid);
+             vector<string> bminstall_cmd;
+             bminstall_cmd.push_back(sess.bminstall_path);
+             bminstall_cmd.push_back(java_pid_str);
+             int ret = stap_system(sess.verbose, bminstall_cmd);
+             if (sess.verbose > 2)
+               {
+                 if (ret)
+                   clog << _F("WARNING: stap_system for bminstall.sh returned error: %d", ret) << endl;
+                 else
+                   clog << _F("stap_system for bminstall.sh returned: %d", ret) << endl;
+               }
+           }
+       }
+      if (sess.java_pid.size() == 0)
+       {
+         sess.java_pid.push_back(_java_pid);
+         vector<string> bminstall_cmd;
+         bminstall_cmd.push_back(sess.bminstall_path);
+         bminstall_cmd.push_back(java_pid_str);
+         int ret = stap_system(sess.verbose, bminstall_cmd);
+         if (sess.verbose > 2)
+           {
+             if (ret)
+               clog << _F("WARNING: stap_system for bminstall.sh returned error: %d", ret) << endl;
+             else
+               clog << _F("stap_system for bminstall.sh returned: %d", ret) << endl;
+           }
+       }
+    }
   else
-    bminstall_cmd.push_back(_java_proc_class);
-  //need to properly check this
-  int ret = stap_system(sess.verbose, bminstall_cmd);
-  if (sess.verbose > 2)
     {
-      if (ret)
-       clog << _F("WARNING: stap_system for bminstall.sh returned error: %d", ret) << endl;
-      else
-       clog << _F("stap_system for bminstall.sh returned: %d", ret) << endl;
+      for (is = sess.java_proc_class.begin(); is != sess.java_proc_class.end(); ++is)
+       {
+         if(*is == _java_proc_class)
+             break;
+         else if ((*is != _java_proc_class) && (++is == sess.java_proc_class.end()))
+           {
+             sess.java_proc_class.push_back(_java_proc_class);
+             vector<string> bminstall_cmd;
+             bminstall_cmd.push_back(sess.bminstall_path);
+             bminstall_cmd.push_back(_java_proc_class);
+             int ret = stap_system(sess.verbose, bminstall_cmd);
+             if (sess.verbose > 2)
+               {
+                 if (ret)
+                   clog << _F("WARNING: stap_system for bminstall.sh returned error: %d", ret) << endl;
+                 else
+                   clog << _F("stap_system for bminstall.sh returned: %d", ret) << endl;
+               }
+           }
+       }
+      if (sess.java_proc_class.size() == 0)
+       {
+         sess.java_proc_class.push_back(_java_proc_class);
+         vector<string> bminstall_cmd;
+         bminstall_cmd.push_back(sess.bminstall_path);
+         bminstall_cmd.push_back(_java_proc_class);
+         int ret = stap_system(sess.verbose, bminstall_cmd);
+         if (sess.verbose > 2)
+           {
+             if (ret)
+               clog << _F("WARNING: stap_system for bminstall.sh returned error: %d", ret) << endl;
+             else
+               clog << _F("stap_system for bminstall.sh returned: %d", ret) << endl;
+           }
+       }
     }
   vector<string> bmsubmit_cmd;
   sess.bmsubmit_path = (find_executable ("bmsubmit.sh"));
@@ -271,8 +304,6 @@ java_builder::build (systemtap_session & sess,
 
   if(has_pid_int)
     bmsubmit_cmd.push_back(sess.byteman_script_path.back());
-  else
-    bmsubmit_cmd.push_back(sess.byteman_script_path.back());
   (void) stap_system(sess.verbose, bmsubmit_cmd);
   if (sess.verbose > 3)
     clog << _("Reported bmsubmit.sh path: ") << sess.bmsubmit_path << endl;
@@ -311,7 +342,6 @@ java_builder::build (systemtap_session & sess,
       mc->tok = b->tok;
       mc->name = "$name";
 
-
       functioncall *mcus = new functioncall;
       mcus->function = "user_string";
       mcus->type = pe_string;
This page took 0.03758 seconds and 5 git commands to generate.