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
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;
systemtap_session::~systemtap_session ()
{
#ifdef HAVE_HELPER
- java_detach();
+ if(java_pid != 0)
+ java_detach();
#endif //HAVE_HELPER
remove_tmp_dir();
delete_map(subsessions);
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
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) {}
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 ('(');
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 (), ',');
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;
}
//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
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
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);
void
register_standard_tapsets(systemtap_session & s)
{
- register_tapset_java(s);
register_tapset_been(s);
register_tapset_itrace(s);
register_tapset_mark(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());
//perf event based probe
register_tapset_perf(s);
-
+ register_tapset_java(s);
}