diff options
author | Mark Wielaard <mjw@redhat.com> | 2009-03-15 15:29:01 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2009-03-15 19:57:50 +0100 |
commit | bb64f40b58a64a9ae065dba5058463ac604c3896 (patch) | |
tree | c92161be2223c3c2a41647c57e20ab92c9047c5b /runtime/task_finder_vma.c | |
parent | 20f933f0749322bc9787cc1972698a7aeffb08df (diff) | |
download | systemtap-steved-bb64f40b58a64a9ae065dba5058463ac604c3896.tar.gz systemtap-steved-bb64f40b58a64a9ae065dba5058463ac604c3896.tar.xz systemtap-steved-bb64f40b58a64a9ae065dba5058463ac604c3896.zip |
Move vma module tracking from pr6866 branch to master.
* tapsets.cxx (utrace_derived_probe_group::emit_module_decls):
Always emit vm callback probe for __stp_tf_vm_cb.
* runtime/task_finder.c (__stp_tf_vm_cb): Always expose, move _stp_dbug
statements under ifdef DEBUG_TASK_FINDER_VMA. Find and record
corresponding module when vm_path not NULL.
* runtime/task_finder_vma.c (struct __stp_tf_vma_entry): Add _stp_module.
(stap_add_vma_map_info): Add _stp_module argument and assign.
(__stp_tf_get_vma_entry_addr): New static function to get
the __stp_tf_vma_entry given an address.
Diffstat (limited to 'runtime/task_finder_vma.c')
-rw-r--r-- | runtime/task_finder_vma.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/runtime/task_finder_vma.c b/runtime/task_finder_vma.c index 4dce4be8..87a32fe5 100644 --- a/runtime/task_finder_vma.c +++ b/runtime/task_finder_vma.c @@ -25,6 +25,9 @@ struct __stp_tf_vma_entry { unsigned long vm_end; unsigned long vm_pgoff; // Is that enough? Should we store a dcookie for vm_file? + + // Module that this vma entry is mapped from, if any. + struct _stp_module *module; }; static struct __stp_tf_vma_entry @@ -211,7 +214,8 @@ __stp_tf_get_vma_map_entry_internal(struct task_struct *tsk, // Add the vma info to the vma map hash table. static int stap_add_vma_map_info(struct task_struct *tsk, unsigned long vm_start, - unsigned long vm_end, unsigned long vm_pgoff) + unsigned long vm_end, unsigned long vm_pgoff, + struct _stp_module *module) { struct hlist_head *head; struct hlist_node *node; @@ -242,6 +246,7 @@ stap_add_vma_map_info(struct task_struct *tsk, unsigned long vm_start, entry->vm_start = vm_start; entry->vm_end = vm_end; entry->vm_pgoff = vm_pgoff; + entry->module = module; head = &__stp_tf_vma_map[__stp_tf_vma_map_hash(tsk)]; hlist_add_head(&entry->hlist, head); @@ -305,3 +310,26 @@ stap_find_vma_map_info(struct task_struct *tsk, unsigned long vm_addr, mutex_unlock(&__stp_tf_vma_mutex); return rc; } + +// Get vma_entry of the address (vm_start/vm_end) if the vma is +// present in the vma hash table containing. +// Returns NULL if not present. +static struct __stp_tf_vma_entry * +__stp_tf_get_vma_entry_addr(struct task_struct *tsk, unsigned long addr) +{ + struct hlist_head *head; + struct hlist_node *node; + struct __stp_tf_vma_entry *entry; + + mutex_lock(&__stp_tf_vma_mutex); + head = &__stp_tf_vma_map[__stp_tf_vma_map_hash(tsk)]; + hlist_for_each_entry(entry, node, head, hlist) { + if (tsk->pid == entry->pid + && addr >= entry->vm_start && addr < entry->vm_end) { + mutex_unlock(&__stp_tf_vma_mutex); + return entry; + } + } + mutex_unlock(&__stp_tf_vma_mutex); + return NULL; +} |