]> sourceware.org Git - systemtap.git/commitdiff
Add passable -J<BYTEMAN_INSTALL_OPTIONS> to stap
authorLukas Berk <lberk@redhat.com>
Sat, 27 Apr 2013 19:13:57 +0000 (15:13 -0400)
committerLukas Berk <lberk@redhat.com>
Wed, 1 May 2013 15:13:36 +0000 (11:13 -0400)
This will allow systemtap to pass options to bminstall.  This can include
an option such as -Jorg.jboss.byteman.compile.to.bytecode which will then
be passed as -Dorg.jboss.byteman.compile.to.bytecode and directly compile
the byteman rule to bytecode, allowing for faster rule execution

*cmdline.h: add the J case
*java/stapbm: add the new (optional) parameter to be passed
*session.cxx: add the new -J case statement
*session.h: compilation variable
*tapset-method.cxx: append the passed command

cmdline.h
java/stapbm
session.cxx
session.h
tapset-method.cxx

index 7750128507031d197a8fe0a0453f2f90a3eeda3e..85d7c2117a59b10c7989bc156b26ca799e43ffbb 100644 (file)
--- a/cmdline.h
+++ b/cmdline.h
@@ -59,7 +59,7 @@ enum {
 
 // NB: when adding new options, consider very carefully whether they
 // should be restricted from stap clients (after --client-options)!
-#define STAP_SHORT_OPTIONS "hVvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:WG:"
+#define STAP_SHORT_OPTIONS "hVvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:J:WG:"
 
 #define OWE5 "tter"
 #define OWE1 "uild-"
index 6507309ff286fc36181b8ac8d64ced63edde977d..01b7d92e9d28e0ade9e6b288eb8414536803cc53 100755 (executable)
@@ -8,6 +8,7 @@
 # $6 - method
 # $7 - number of args
 # $8 - entry/exit/line
+# $9 - options to pass to bminstall
 
 #We need to both record, and check that this pid is the first
 #This is to avoid recurssion in probing java processes
@@ -61,7 +62,7 @@ function install_byteman()
     then
        touch $4/java/$JAVA_FILE
        touch $4/java/`hostname`-install
-       exec bminstall.sh $2 &
+       exec bminstall.sh $5 $2 &
        pid=$!
        wait $pid
        rm $4/java/`hostname`-install 2>&1 1>/dev/null
@@ -110,7 +111,7 @@ function run_byteman()
        install)
            if [[ ! -f "$4/java/$JAVA_FILE" && ! -f "$4/java/`hostname`-install" ]]
            then
-               install_byteman $1 $2 $3 $4
+               install_byteman $1 $2 $3 $4 $5
            fi
            submit_byteman $1 $2 $3 $4
            ;;
@@ -190,4 +191,4 @@ function print_stap_helper
 mkdir -p $2/java
 check_running $2 $3 $5 $6
 write_rule $1 $2 $3 $4 $5 $6 $7 $8
-run_byteman $1 $3 $4 $2
+run_byteman $1 $3 $4 $2 $9
index 8a00177d275f1c6b2364874af94656b6a4c9606f..e6963d34700a6845f8f8e2e57406b44edae864e7 100644 (file)
@@ -162,6 +162,10 @@ systemtap_session::systemtap_session ():
   update_release_sysroot = false;
   suppress_time_limits = false;
 
+#ifdef HAVE_JAVA_HELPER
+  compile_byteman_rule = false;
+#endif /* HAVE_JAVA_HELPER */
+
   // PR12443: put compiled-in / -I paths in front, to be preferred during 
   // tapset duplicate-file elimination
   const char* s_p = getenv ("SYSTEMTAP_TAPSET");
@@ -352,6 +356,12 @@ systemtap_session::systemtap_session (const systemtap_session& other,
   c_macros = other.c_macros;
   args = other.args;
   kbuildflags = other.kbuildflags;
+
+#ifdef HAVE_JAVA_HELPER
+  compile_byteman_rule = other.compile_byteman_rule;
+  bminstallflags = other.bminstallflags;
+#endif /* HAVE_JAVA_HELPER */
+
   globalopts = other.globalopts;
   modinfos = other.modinfos;
 
@@ -534,6 +544,9 @@ systemtap_session::usage (int exitcode)
 #ifdef HAVE_LIBSQLITE3
     "   -q         generate information on tapset coverage\n"
 #endif /* HAVE_LIBSQLITE3 */
+#ifdef HAVE_JAVA_HELPER
+    "   -J         request byteman pass such options to the JVM during bminstall\n"
+#endif /* HAVE_JAVA_HELPER */
     "   --runtime=MODE\n"
     "              set the pass-5 runtime mode, instead of kernel\n"
 #ifdef HAVE_DYNINST
@@ -885,6 +898,15 @@ systemtap_session::parse_cmdline (int argc, char * const argv [])
           kbuildflags.push_back (string (optarg));
          break;
 
+       case 'J':
+#ifdef HAVE_JAVA_HELPER
+         bminstallflags.push_back(string("-D") + (string (optarg)) );
+         break;
+#else
+         cerr << _("You may only specify -J options when configured with --with-jdk") << endl;
+         return 1;
+#endif /* HAVE_JAVA_HELPER */
+
        case LONG_OPT_VERSION:
          version ();
          throw exit_exception (EXIT_SUCCESS);
index dd29db9c94a740c682b4adbc271ea0666495f915..40b176a0a361acd6cedf2e8d2a636459332d3cd4 100644 (file)
--- a/session.h
+++ b/session.h
@@ -200,6 +200,10 @@ public:
   int download_dbinfo;
   bool suppress_handler_errors;
   bool suppress_time_limits;
+#ifdef HAVE_JAVA_HELPER
+  bool compile_byteman_rule;
+  std::vector<std::string> bminstallflags; // -J var=val
+#endif
 
   enum { kernel_runtime, dyninst_runtime } runtime_mode;
   bool runtime_usermode_p() const { return runtime_mode == dyninst_runtime; }
index 9420359feedd517547d857315237344d7cee225f..477c4cf2de5059e6fc1ea10b3b96979710c3bd66 100644 (file)
@@ -321,6 +321,7 @@ java_builder::build (systemtap_session & sess,
      $6 - method
      $7 - number of args
      $8 - entry/exit/line
+     $9 - options to pass to bminstall
   */
 
   char arg_count[3];
@@ -361,6 +362,13 @@ java_builder::build (systemtap_session & sess,
     stapbm_string.append("exit");
   else if(!has_return && has_line_number)
     stapbm_string.append(method_line_val);
+  if(!sess.bminstallflags.empty())
+    {
+      stapbm_string.append(" ");
+      for (vector<string>::iterator it = sess.bminstallflags.begin() ; it != sess.bminstallflags.end(); ++it)
+       stapbm_string.append(*it + " ");
+    }
+
   block *bb = new block;
   bb->tok = base->body->tok;
   functioncall *fc = new functioncall;
This page took 0.040412 seconds and 5 git commands to generate.