]> sourceware.org Git - systemtap.git/commitdiff
PR11151: Recover stap_uprobes slots on process exit
authorJosh Stone <jistone@redhat.com>
Fri, 15 Jan 2010 00:40:45 +0000 (16:40 -0800)
committerJosh Stone <jistone@redhat.com>
Fri, 15 Jan 2010 00:40:45 +0000 (16:40 -0800)
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.

runtime/uprobes-common.c
runtime/uprobes-common.h
tapsets.cxx

index b0273ba4d3d83aef9267887b8d7165ebc3f6b0fa..58e3a05f809dca23eb3aa0b22dcad0e5130be4fa 100644 (file)
@@ -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_ */
index 68741f4d9d38e68c832d30fcd18588beb3eb1ee0..990b473a473504187b343b4a88e474c6c397f4ba 100644 (file)
@@ -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_ */
index 7835b39a5984b64954be9cb43ec8c8f9a2efa2ce..071f92dbc310ce58ddf3c3e252311ef77d252159 100644 (file)
@@ -4632,6 +4632,7 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s)
                s.op->line() << " .procname=\"" << p->path << "\", ";
               s.op->line() << " .mmap_callback=&stap_uprobe_mmap_found, ";
               s.op->line() << " .munmap_callback=&stap_uprobe_munmap_found, ";
+              s.op->line() << " .callback=&stap_uprobe_process_munmap,";
             }
 
           s.op->line() << " },";
This page took 0.047883 seconds and 5 git commands to generate.