public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: systemtap@sourceware.org
Cc: "Frank Ch. Eigler" <fche@redhat.com>,
	Josh Stone <jistone@redhat.com>,
	       Jonathan Lebon <jlebon@redhat.com>,
	       Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	       Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PATCH v2 1/3] stap: add --save-uprobes
Date: Mon, 11 Aug 2014 13:25:00 -0000	[thread overview]
Message-ID: <1407763523-30556-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1407763523-30556-1-git-send-email-stefanha@redhat.com>

The stap -m <name> option saves the script module.  For scripts that
rely on uprobes it may also be necessary to get the uprobes module (if
it was built by stap).

The new stap --save-uprobes option saves uprobes/uprobes.ko into the
current directory.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 buildrun.cxx |  4 +++-
 cmdline.cxx  |  1 +
 cmdline.h    |  1 +
 main.cxx     |  8 ++++++++
 session.cxx  | 10 ++++++++++
 session.h    |  2 ++
 6 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/buildrun.cxx b/buildrun.cxx
index 6f9b78b..9339b49 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -601,8 +601,10 @@ make_uprobes (systemtap_session& s)
     clog << _("uprobes rebuild exit code: ") << rc << endl;
   if (rc)
     s.set_try_server ();
-  else
+  else {
     s.uprobes_path = dir + "/uprobes.ko";
+    s.built_uprobes = true;
+  }
   return rc;
 }
 
diff --git a/cmdline.cxx b/cmdline.cxx
index 090659d..d50ca1a 100644
--- a/cmdline.cxx
+++ b/cmdline.cxx
@@ -61,5 +61,6 @@ struct option stap_long_options[] = {
   { "benchmark-sdt-threads",       required_argument, NULL, LONG_OPT_BENCHMARK_SDT_THREADS },
   { "color",                       optional_argument, NULL, LONG_OPT_COLOR_ERRS },
   { "colour",                      optional_argument, NULL, LONG_OPT_COLOR_ERRS },
+  { "save-uprobes",                no_argument,       NULL, LONG_OPT_SAVE_UPROBES },
   { NULL, 0, NULL, 0 }
 };
diff --git a/cmdline.h b/cmdline.h
index fa19d65..297096f 100644
--- a/cmdline.h
+++ b/cmdline.h
@@ -59,6 +59,7 @@ enum {
   LONG_OPT_BENCHMARK_SDT_LOOPS,
   LONG_OPT_BENCHMARK_SDT_THREADS,
   LONG_OPT_COLOR_ERRS,
+  LONG_OPT_SAVE_UPROBES,
 };
 
 // NB: when adding new options, consider very carefully whether they
diff --git a/main.cxx b/main.cxx
index 5150a30..d8b1d98 100644
--- a/main.cxx
+++ b/main.cxx
@@ -994,6 +994,14 @@ passes_0_4 (systemtap_session &s)
 	  string module_dest_path = s.module_filename();
 	  copy_file(module_src_path, module_dest_path, s.verbose > 1);
 	}
+
+      // Copy uprobes module to the current directory.
+      if (s.save_uprobes && s.built_uprobes && !pending_interrupts)
+        {
+          rc = create_dir("uprobes");
+          if (! rc)
+            copy_file(s.uprobes_path, "uprobes/uprobes.ko", s.verbose > 1);
+        }
     }
 
   PROBE1(stap, pass4__end, &s);
diff --git a/session.cxx b/session.cxx
index 56198ef..201ae6c 100644
--- a/session.cxx
+++ b/session.cxx
@@ -134,6 +134,7 @@ systemtap_session::systemtap_session ():
   output_file = ""; // -o FILE
   tmpdir_opt_set = false;
   save_module = false;
+  save_uprobes = false;
   modname_given = false;
   keep_tmpdir = false;
   cmd = "";
@@ -145,6 +146,7 @@ systemtap_session::systemtap_session ():
   need_uprobes = false;
   need_unwind = false;
   need_symbols = false;
+  built_uprobes = false;
   uprobes_path = "";
   load_only = false;
   skip_badvars = false;
@@ -315,6 +317,7 @@ systemtap_session::systemtap_session (const systemtap_session& other,
   output_file = other.output_file; // XXX how should multiple remotes work?
   tmpdir_opt_set = false;
   save_module = other.save_module;
+  save_uprobes = other.save_uprobes;
   modname_given = other.modname_given;
   keep_tmpdir = other.keep_tmpdir;
   cmd = other.cmd;
@@ -326,6 +329,7 @@ systemtap_session::systemtap_session (const systemtap_session& other,
   need_uprobes = false;
   need_unwind = false;
   need_symbols = false;
+  built_uprobes = false;
   uprobes_path = "";
   load_only = other.load_only;
   skip_badvars = other.skip_badvars;
@@ -637,6 +641,8 @@ systemtap_session::usage (int exitcode)
     "              relative to the sysroot.\n"
     "   --suppress-time-limits\n"
     "              disable -DSTP_OVERLOAD, -DMAXACTION, and -DMAXTRYACTION limits\n"
+    "   --save-uprobes\n"
+    "              save uprobes.ko to current directory if it is built from source\n"
     , compatible.c_str()) << endl
   ;
 
@@ -1390,6 +1396,10 @@ systemtap_session::parse_cmdline (int argc, char * const argv [])
                     strcmp(getenv("TERM") ?: "notdumb", "dumb"));
           break;
 
+        case LONG_OPT_SAVE_UPROBES:
+          save_uprobes = true;
+          break;
+
 	case '?':
 	  // Invalid/unrecognized option given or argument required, but
 	  // not given. In both cases getopt_long() will have printed the
diff --git a/session.h b/session.h
index e95a26d..70f7909 100644
--- a/session.h
+++ b/session.h
@@ -197,6 +197,7 @@ public:
   unsigned verbose;
   bool timing;
   bool save_module;
+  bool save_uprobes;
   bool modname_given;
   bool keep_tmpdir;
   bool guru_mode;
@@ -210,6 +211,7 @@ public:
   bool need_uprobes;
   bool need_unwind;
   bool need_symbols;
+  bool built_uprobes;
   std::string uprobes_path;
   std::string uprobes_hash;
   bool load_only; // flight recorder mode
-- 
1.9.3

  parent reply	other threads:[~2014-08-11 13:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11 13:25 [PATCH v2 0/3] initscript: add support for uprobes scripts Stefan Hajnoczi
2014-08-11 13:25 ` [PATCH v2 2/3] initscript: copy uprobes.ko to cache directory Stefan Hajnoczi
2014-08-11 13:25 ` Stefan Hajnoczi [this message]
2014-08-11 13:25 ` [PATCH v2 3/3] initscript: allow scripts to load uprobes Stefan Hajnoczi
2014-09-01 12:15 ` [PATCH v2 0/3] initscript: add support for uprobes scripts Stefan Hajnoczi
2014-09-02 15:03   ` Jonathan Lebon
2014-09-03 12:46     ` Stefan Hajnoczi
2014-09-03 23:01       ` Jonathan Lebon
2014-09-03 23:22         ` Josh Stone
2014-09-03 23:44           ` [PATCH] Remove systemtap_session::built_uprobes Josh Stone
2014-09-04 11:13             ` Stefan Hajnoczi
2014-09-04 15:20             ` Jonathan Lebon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407763523-30556-2-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=fche@redhat.com \
    --cc=jistone@redhat.com \
    --cc=jlebon@redhat.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).