summaryrefslogtreecommitdiffstats
path: root/runtime/task_finder.c
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2008-05-21 12:59:56 -0500
committerDavid Smith <dsmith@redhat.com>2008-05-28 12:07:50 -0500
commitcfac4b1fc487712e0ce5b11630b74bdaea5f8966 (patch)
tree4db0936d4d1c7f8b4433e4053f6ee86d5c9a04a4 /runtime/task_finder.c
parent9319dbe79bfc893bc7f7e35938151a01bb8a2d32 (diff)
downloadsystemtap-steved-cfac4b1fc487712e0ce5b11630b74bdaea5f8966.tar.gz
systemtap-steved-cfac4b1fc487712e0ce5b11630b74bdaea5f8966.tar.xz
systemtap-steved-cfac4b1fc487712e0ce5b11630b74bdaea5f8966.zip
Minor improvement to multi-threaded support.
2008-05-21 David Smith <dsmith@redhat.com> * tapsets.cxx (utrace_derived_probe_group::emit_module_decls): Added new 'event_flag' parameter to task_finder callback. Only calls probe handlers if we received the correct event. 2008-05-21 David Smith <dsmith@redhat.com> * task_finder.c (__stp_utrace_attach_match_filename): Added event_flag parameter of event to pass to callback. (__stp_utrace_task_finder_target_death): Ditto. (__stp_utrace_task_finder_report_clone): Calls __stp_utrace_attach_match_filename() with new argument. (__stp_utrace_task_finder_report_exec): Ditto. (stap_start_task_finder): Calls callback with an invalid event_flag since this callback call isn't related to an event.
Diffstat (limited to 'runtime/task_finder.c')
-rw-r--r--runtime/task_finder.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/runtime/task_finder.c b/runtime/task_finder.c
index e78caab6..a8de13d0 100644
--- a/runtime/task_finder.c
+++ b/runtime/task_finder.c
@@ -13,6 +13,7 @@ atomic_t __stp_task_finder_state = ATOMIC_INIT(__STP_TF_STARTING);
typedef int (*stap_task_finder_callback)(struct task_struct *tsk,
int register_p,
+ unsigned long event_flag,
struct stap_task_finder_target *tgt);
struct stap_task_finder_target {
@@ -237,7 +238,8 @@ __stp_utrace_attach(struct task_struct *tsk,
static inline void
__stp_utrace_attach_match_filename(struct task_struct *tsk,
- const char * const filename)
+ const char * const filename,
+ unsigned long event_flag)
{
size_t filelen;
struct list_head *tgt_node;
@@ -270,9 +272,10 @@ __stp_utrace_attach_match_filename(struct task_struct *tsk,
continue;
if (cb_tgt->callback != NULL) {
- int rc = cb_tgt->callback(tsk, 1, cb_tgt);
+ int rc = cb_tgt->callback(tsk, 1, event_flag,
+ cb_tgt);
if (rc != 0) {
- _stp_error("exec callback for %d failed: %d",
+ _stp_error("callback for %d failed: %d",
(int)tsk->pid, rc);
break;
}
@@ -332,7 +335,8 @@ __stp_utrace_task_finder_report_clone(struct utrace_attached_engine *engine,
rc, (int)child->pid);
}
else {
- __stp_utrace_attach_match_filename(child, mmpath);
+ __stp_utrace_attach_match_filename(child, mmpath,
+ UTRACE_EVENT(CLONE));
}
_stp_kfree(mmpath_buf);
@@ -357,7 +361,8 @@ __stp_utrace_task_finder_report_exec(struct utrace_attached_engine *engine,
if (bprm->filename == NULL)
return UTRACE_ACTION_RESUME;
- __stp_utrace_attach_match_filename(tsk, bprm->filename);
+ __stp_utrace_attach_match_filename(tsk, bprm->filename,
+ UTRACE_EVENT(EXEC));
return UTRACE_ACTION_RESUME;
}
@@ -392,7 +397,7 @@ __stp_utrace_task_finder_target_death(struct utrace_attached_engine *engine,
int rc;
// Call the callback
- rc = tgt->callback(tsk, 0, tgt);
+ rc = tgt->callback(tsk, 0, UTRACE_EVENT(DEATH), tgt);
if (rc != 0) {
_stp_error("death callback for %d failed: %d",
(int)tsk->pid, rc);
@@ -485,8 +490,17 @@ stap_start_task_finder(void)
if (cb_tgt == NULL || cb_tgt->callback == NULL)
continue;
- // Call the callback.
- rc = cb_tgt->callback(tsk, 1, cb_tgt);
+ // Call the callback. Notice we're
+ // not passing a valid event_flag
+ // here. That's OK, for 2 reasons.
+ // (1) We're not in the
+ // STAP_SESSION_RUNNING state yet, so
+ // probes won't get called anyway.
+ // (2) There really isn't an event
+ // associated with this callback call,
+ // we just want to let the caller
+ // attach to the thread.
+ rc = cb_tgt->callback(tsk, 1, 0, cb_tgt);
if (rc != 0) {
_stp_error("attach callback for %d failed: %d",
(int)tsk->pid, rc);