summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
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 /tapsets.cxx
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.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r--tapsets.cxx62
1 files changed, 46 insertions, 16 deletions
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")