summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2010-01-14 16:40:45 -0800
committerJosh Stone <jistone@redhat.com>2010-01-14 16:40:45 -0800
commit19d91f6c2fcc4dea3b86e05721275cf0f8117e74 (patch)
tree317bc925b18679f120538cc74165758641ff390c /runtime
parent622fa74aa720b3eda55c81530d458e3ea7792bb2 (diff)
downloadsystemtap-steved-19d91f6c2fcc4dea3b86e05721275cf0f8117e74.tar.gz
systemtap-steved-19d91f6c2fcc4dea3b86e05721275cf0f8117e74.tar.xz
systemtap-steved-19d91f6c2fcc4dea3b86e05721275cf0f8117e74.zip
PR11151: Recover stap_uprobes slots on process exit
When a process exits, it won't necessarily bother to munmap all of its shared libraries. This patch makes sure that with uprobes in libraries, we still grab an exit notification and clear everything out. * runtime/uprobes-common.c (stap_uprobe_process_munmap): New. * tapsets.cxx (uprobe_derived_probe_group::emit_module_decls): Use above callback so that we can recover our resources on process exit.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/uprobes-common.c15
-rw-r--r--runtime/uprobes-common.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/runtime/uprobes-common.c b/runtime/uprobes-common.c
index b0273ba4..58e3a05f 100644
--- a/runtime/uprobes-common.c
+++ b/runtime/uprobes-common.c
@@ -286,4 +286,19 @@ static int stap_uprobe_munmap_found (struct stap_task_finder_target *tgt, struct
return stap_uprobe_change_minus (tsk, addr, length, stf);
}
+/* The task_finder_callback we use for ET_DYN targets.
+ This just forces an unmap of everything as the process exits.
+ (PR11151) */
+static int stap_uprobe_process_munmap (struct stap_task_finder_target *tgt, struct task_struct *tsk, int register_p, int process_p) {
+ const struct stap_uprobe_tf *stf = container_of(tgt, struct stap_uprobe_tf, finder);
+ if (! process_p) return 0; /* ignore threads */
+ #ifdef DEBUG_TASK_FINDER_VMA
+ _stp_dbug (__FUNCTION__,__LINE__, "%cproc pid %d stf %p %p path %s\n", register_p?'+':'-', tsk->tgid, tgt, stf, stf->pathname);
+ #endif
+ /* Covering 0->TASK_SIZE means "unmap everything" */
+ if (!register_p)
+ return stap_uprobe_change_minus (tsk, 0, TASK_SIZE, stf);
+ return 0;
+}
+
#endif /* _UPROBE_COMMON_C_ */
diff --git a/runtime/uprobes-common.h b/runtime/uprobes-common.h
index 68741f4d..990b473a 100644
--- a/runtime/uprobes-common.h
+++ b/runtime/uprobes-common.h
@@ -33,5 +33,6 @@ struct stap_uprobe_spec {
static int stap_uprobe_process_found (struct stap_task_finder_target *tgt, struct task_struct *tsk, int register_p, int process_p);
static int stap_uprobe_mmap_found (struct stap_task_finder_target *tgt, struct task_struct *tsk, char *path, unsigned long addr, unsigned long length, unsigned long offset, unsigned long vm_flags);
static int stap_uprobe_munmap_found (struct stap_task_finder_target *tgt, struct task_struct *tsk, unsigned long addr, unsigned long length);
+static int stap_uprobe_process_munmap (struct stap_task_finder_target *tgt, struct task_struct *tsk, int register_p, int process_p);
#endif /* _UPROBE_COMMON_H_ */