This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

baby memory map notification


Frank,

Here's a stab at baby memory map notification.  It works, with several
limitations:

- It only works on existing threads.  (The vm_callback will get called
for new threads, but you won't get the complete list of vm's.)

- You can't use a .begin probe (because of the problem of duplicate
.report_quiesce handlers getting called that I've asked about on
utrace-devel)

- It won't track new vms as the process runs

But, it might be enough to get you going even as is.

With the attached patch and systemtap script, here's what you'll see,
first for an existing /bin/cat process, then for a newly created one.

Pass 5: starting run.
running...
__stp_tf_vm_cb:44: found tsk 24337, path /lib/ld-2.7.so, start 0x655000
end 0x670000 offset 0x0
__stp_tf_vm_cb:44: found tsk 24337, path /lib/ld-2.7.so, start 0x670000
end 0x671000 offset 0x1a
__stp_tf_vm_cb:44: found tsk 24337, path /lib/ld-2.7.so, start 0x671000
end 0x672000 offset 0x1b
__stp_tf_vm_cb:44: found tsk 24337, path /lib/libc-2.7.so, start
0x674000 end 0x7c7000 offset 0x0
__stp_tf_vm_cb:44: found tsk 24337, path /lib/libc-2.7.so, start
0x7c7000 end 0x7c9000 offset 0x153
__stp_tf_vm_cb:44: found tsk 24337, path /lib/libc-2.7.so, start
0x7c9000 end 0x7ca000 offset 0x155
__stp_tf_vm_cb:44: found tsk 24337, path /bin/cat, start 0x8048000 end
0x804d000 offset 0x0
__stp_tf_vm_cb:44: found tsk 24337, path /bin/cat, start 0x804d000 end
0x804e000 offset 0x4
__stp_tf_vm_cb:44: found tsk 24337, path /usr/lib/locale/locale-archive,
start 0xb7d8d000 end 0xb7f8d000 offset 0x0
*** /bin/cat end ***
__stp_tf_vm_cb:44: found tsk 24545, path /lib/ld-2.7.so, start 0x655000
end 0x670000 offset 0x0
__stp_tf_vm_cb:44: found tsk 24545, path /lib/ld-2.7.so, start 0x670000
end 0x672000 offset 0x1a
__stp_tf_vm_cb:44: found tsk 24545, path /bin/cat, start 0x8048000 end
0x804d000 offset 0x0
__stp_tf_vm_cb:44: found tsk 24545, path /bin/cat, start 0x804d000 end
0x804e000 offset 0x4
*** /bin/cat end ***
^CPass 5: run completed in 10usr/20sys/20994real ms

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)
probe begin { printf("running...\n") }
#probe process("/bin/cat").begin { printf("*** /bin/cat begin ***\n") }
probe process("/bin/cat").end { printf("*** /bin/cat end ***\n") }
diff --git a/runtime/task_finder.c b/runtime/task_finder.c
index 8448f29..02e0334 100644
--- a/runtime/task_finder.c
+++ b/runtime/task_finder.c
@@ -35,6 +35,18 @@ typedef int (*stap_task_finder_vm_callback)(struct task_struct *tsk,
 					    unsigned long vm_end,
 					    unsigned long vm_pgoff);
 
+int __stp_tf_vm_cb(struct task_struct *tsk,
+		   int map_p, char *vm_path,
+		   unsigned long vm_start,
+		   unsigned long vm_end,
+		   unsigned long vm_pgoff)
+{
+	_stp_dbug(__FUNCTION__, __LINE__,
+		  "found tsk %d, path %s, start 0x%x end 0x%x offset 0x%x\n",
+		  tsk->pid, vm_path, vm_start, vm_end, vm_pgoff);
+	return 0;
+}
+
 struct stap_task_finder_target {
 /* private: */
 	struct list_head list;		/* __stp_task_finder_list linkage */
@@ -83,6 +95,9 @@ stap_register_task_finder_target(struct stap_task_finder_target *new_tgt)
 	new_tgt->ops.report_death = &__stp_utrace_task_finder_target_death;
 	new_tgt->ops.report_quiesce = &__stp_utrace_task_finder_target_quiesce;
 
+// DRS: debug only!
+ new_tgt->vm_callback = &__stp_tf_vm_cb;
+
 	// Search the list for an existing entry for pathname/pid.
 	list_for_each(node, &__stp_task_finder_list) {
 		tgt = list_entry(node, struct stap_task_finder_target, list);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]