summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2008-04-18 13:52:25 -0500
committerDavid Smith <dsmith@redhat.com>2008-04-18 13:52:25 -0500
commit159cb10989a9d6c1d28fc5d1fa5506a75046a9f7 (patch)
tree4c4c325a0153001b4862537f0d4fa2fcff5ea8bd
parent29cb9b42bd28a22ab926ed1a577267e4c54d935a (diff)
downloadsystemtap-steved-159cb10989a9d6c1d28fc5d1fa5506a75046a9f7.tar.gz
systemtap-steved-159cb10989a9d6c1d28fc5d1fa5506a75046a9f7.tar.xz
systemtap-steved-159cb10989a9d6c1d28fc5d1fa5506a75046a9f7.zip
Added utrace exec probes.
2008-04-18 David Smith <dsmith@redhat.com> * tapsets.cxx (struct utrace_builder): Added exec probes. (utrace_derived_probe_group::emit_probe_decl): Ditto. (utrace_derived_probe_group::emit_module_decls): Ditto. (register_standard_tapsets): Ditto. * stapprobes.5.in: Added information about exec probes. * NEWS: Added information about utrace probes. 2008-04-18 David Smith <dsmith@redhat.com> * systemtap.base/utrace_p4.exp: Added exec probe test.
-rw-r--r--ChangeLog7
-rw-r--r--NEWS12
-rw-r--r--stapprobes.5.in6
-rw-r--r--tapsets.cxx62
-rw-r--r--testsuite/ChangeLog2
-rw-r--r--testsuite/systemtap.base/utrace_p4.exp9
6 files changed, 82 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index d1f79ce3..8ba4c334 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-04-18 David Smith <dsmith@redhat.com>
+ * tapsets.cxx (struct utrace_builder): Added exec probes.
+ (utrace_derived_probe_group::emit_probe_decl): Ditto.
+ (utrace_derived_probe_group::emit_module_decls): Ditto.
+ (register_standard_tapsets): Ditto.
+ * stapprobes.5.in: Added information about exec probes.
+ * NEWS: Added information about utrace probes.
+
* stapprobes.5.in: Added information about utrace probes.
2008-04-17 Josh Stone <joshua.i.stone@intel.com>
diff --git a/NEWS b/NEWS
index 00cfb70c..03fb7117 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,18 @@
vm.pagefault
vm.write_shared
+- More user-space probe types are added:
+
+ probe process(PID).clone { }
+ probe process("PATH").clone { }
+ probe process(PID).exec { }
+ probe process("PATH").exec { }
+ probe process(PID).death { }
+ probe process("PATH").death { }
+ probe process(PID).syscall { }
+ probe process("PATH").syscall { }
+ probe process(PID).syscall.return { }
+ probe process("PATH").syscall.return { }
* What's new in version 0.6
diff --git a/stapprobes.5.in b/stapprobes.5.in
index fdba10be..3633fd39 100644
--- a/stapprobes.5.in
+++ b/stapprobes.5.in
@@ -311,6 +311,8 @@ Additional user-space probing is available in the following forms:
.SAMPLE
process(PID).clone
process("PATH").clone
+process(PID).exec
+process("PATH").exec
process(PID).death
process("PATH").death
process(PID).syscall
@@ -324,6 +326,10 @@ A
probe gets called when a thread described by PID or PATH creates a new
thread.
A
+.B .exec
+probe gets called when a thread described by PID or PATH returns from
+.IR exec() .
+A
.B .death
probe gets called when a thread described by PID or PATH dies.
A
diff --git a/tapsets.cxx b/tapsets.cxx
index c4cfaa25..35d25172 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -4531,6 +4531,8 @@ struct utrace_builder: public derived_probe_builder
}
else if (has_null_param (parameters, "clone"))
flags = UDPF_CLONE;
+ else if (has_null_param (parameters, "exec"))
+ flags = UDPF_EXEC;
// If we have a path, we need to validate it.
if (has_path)
@@ -4616,11 +4618,15 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s,
switch (p->flags)
{
case UDPF_CLONE:
- // Notice we're not setting up a .ops/.report_clone handler
- // here. Instead, we'll just call the probe directly when we
- // get notified the clone happened.
+ s.op->line() << " .ops={ .report_clone=stap_utrace_probe_clone },";
s.op->line() << " .flags=(UTRACE_EVENT(CLONE)),";
break;
+ case UDPF_EXEC:
+ // Notice we're not setting up a .ops/.report_exec handler here.
+ // Instead, we'll just call the probe directly when we get
+ // notified the exec happened.
+ s.op->line() << " .flags=(UTRACE_EVENT(EXEC)),";
+ break;
case UDPF_DEATH:
// Notice we're not setting up a .ops/.report_death handler
// here. Instead, we'll just call the probe directly when we
@@ -4662,9 +4668,27 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline() << "int engine_attached;";
s.op->newline(-1) << "};";
- // Output handler function for CLONE and DEATH events
- if (flags_seen[UDPF_CLONE] || flags_seen[UDPF_DEATH])
- {
+ // Output handler function for CLONE events
+ if (flags_seen[UDPF_CLONE])
+ {
+ s.op->newline() << "static u32 stap_utrace_probe_clone(struct utrace_attached_engine *engine, struct task_struct *parent, unsigned long clone_flags, struct task_struct *child) {";
+ s.op->indent(1);
+ s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;";
+
+ common_probe_entryfn_prologue (s.op, "STAP_SESSION_RUNNING");
+ s.op->newline() << "c->probe_point = p->pp;";
+
+ // call probe function
+ s.op->newline() << "(*p->ph) (c);";
+ common_probe_entryfn_epilogue (s.op);
+
+ s.op->newline() << "return UTRACE_ACTION_RESUME;";
+ s.op->newline(-1) << "}";
+ }
+
+ // Output handler function for EXEC and DEATH events
+ if (flags_seen[UDPF_EXEC] || flags_seen[UDPF_DEATH])
+ {
s.op->newline() << "static void stap_utrace_probe_handler(struct task_struct *tsk, struct stap_utrace_probe *p) {";
s.op->indent(1);
@@ -4677,7 +4701,7 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline() << "return;";
s.op->newline(-1) << "}";
- }
+ }
// Output handler function for SYSCALL_ENTRY and SYSCALL_EXIT events
if (flags_seen[UDPF_SYSCALL_ENTRY] || flags_seen[UDPF_SYSCALL_EXIT])
@@ -4712,23 +4736,23 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline() << "switch (p->flags) {";
s.op->indent(1);
- // For the register/clone case, we can't install a utrace engine,
- // since we're already in a clone event. So, we just call the probe
+ // When registering an exec probe, we can't install a utrace engine,
+ // since we're already in a exec event. So, we just call the probe
// directly. Note that for existing threads, this won't really work
// since our state isn't STAP_SESSION_RUNNING yet. But that's OK,
- // since this isn't really a 'clone' event - it is a notification
+ // since this isn't really a 'exec' event - it is a notification
// that task_finder found an interesting process.
- if (flags_seen[UDPF_CLONE])
+ if (flags_seen[UDPF_EXEC])
{
- s.op->newline() << "case UTRACE_EVENT(CLONE):";
+ s.op->newline() << "case UTRACE_EVENT(EXEC):";
s.op->indent(1);
s.op->newline() << "_stp_dbug(__FUNCTION__, __LINE__, \"%s\\n\", p->pp);";
s.op->newline() << "stap_utrace_probe_handler(tsk, p);";
s.op->newline() << "break;";
s.op->indent(-1);
}
- // For death probes, do nothing at clone time. We'll handle these
- // in the 'register_p == 0' case.
+ // For death probes, do nothing at registration time. We'll handle
+ // these in the 'register_p == 0' case.
if (flags_seen[UDPF_DEATH])
{
s.op->newline() << "case UTRACE_EVENT(DEATH):";
@@ -4736,9 +4760,11 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline() << "break;";
s.op->indent(-1);
}
- // Attach an engine for SYSCALL_ENTRY and SYSCALL_EXIT events.
- if (flags_seen[UDPF_SYSCALL_ENTRY] || flags_seen[UDPF_SYSCALL_EXIT])
+ // Attach an engine for CLONE, SYSCALL_ENTRY, and SYSCALL_EXIT events.
+ if (flags_seen[UDPF_CLONE] || flags_seen[UDPF_SYSCALL_ENTRY]
+ || flags_seen[UDPF_SYSCALL_EXIT])
{
+ s.op->newline() << "case UTRACE_EVENT(CLONE):";
s.op->newline() << "case UTRACE_EVENT(SYSCALL_ENTRY):";
s.op->newline() << "case UTRACE_EVENT(SYSCALL_EXIT):";
s.op->indent(1);
@@ -7267,6 +7293,10 @@ register_standard_tapsets(systemtap_session & s)
->bind(new utrace_builder ());
s.pattern_root->bind_num(TOK_PROCESS)->bind("clone")
->bind(new utrace_builder ());
+ s.pattern_root->bind_str(TOK_PROCESS)->bind("exec")
+ ->bind(new utrace_builder ());
+ s.pattern_root->bind_num(TOK_PROCESS)->bind("exec")
+ ->bind(new utrace_builder ());
s.pattern_root->bind_str(TOK_PROCESS)->bind("syscall")
->bind(new utrace_builder ());
s.pattern_root->bind_num(TOK_PROCESS)->bind("syscall")
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 86fd83c7..a2382148 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2008-04-18 David Smith <dsmith@redhat.com>
+ * systemtap.base/utrace_p4.exp: Added exec probe test.
+
* buildok/utrace01.stp: Removed.
* buildok/utrace02.stp: Ditto.
* buildok/utrace03.stp: Ditto.
diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp
index 35a3ba15..eb6ea685 100644
--- a/testsuite/systemtap.base/utrace_p4.exp
+++ b/testsuite/systemtap.base/utrace_p4.exp
@@ -53,6 +53,7 @@ set clone_script {"probe process(\"/bin/ls\").clone { print(\"ls clone\") }"}
set death_script {"probe process(\"/bin/ls\").death { print(\"ls death\") }"}
set syscall_script {"probe process(\"/bin/ls\").syscall { printf(\"|%d\", \$syscall) }"}
set syscall_return_script {"probe process(\"/bin/ls\").syscall.return { printf(\"|%d\", \$syscall) }"}
+set exec_script {"probe process(\"/bin/ls\").exec { print(\"ls exec\") }"}
# Try to find utrace_attach symbol in /proc/kallsyms
set path "/proc/kallsyms"
@@ -95,3 +96,11 @@ if {$utrace_support_found == 0} {
# Try compiling a syscall return script
stap_compile $TEST_NAME 1 $syscall_return_script
}
+
+set TEST_NAME "UTRACE_P4_05"
+if {$utrace_support_found == 0} {
+ untested "$TEST_NAME : no kernel utrace support found"
+} else {
+ # Try compiling an exec script
+ stap_compile $TEST_NAME 1 $exec_script
+}