This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH v2 1/3] stap: add --save-uprobes
- From: Stefan Hajnoczi <stefanha at redhat dot com>
- To: systemtap at sourceware dot org
- Cc: "Frank Ch. Eigler" <fche at redhat dot com>, Josh Stone <jistone at redhat dot com>, Jonathan Lebon <jlebon at redhat dot com>, Masami Hiramatsu <masami dot hiramatsu dot pt at hitachi dot com>, Stefan Hajnoczi <stefanha at redhat dot com>
- Date: Mon, 11 Aug 2014 14:25:21 +0100
- Subject: [PATCH v2 1/3] stap: add --save-uprobes
- Authentication-results: sourceware.org; auth=none
- References: <1407763523-30556-1-git-send-email-stefanha at redhat dot 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