[REFACTOR] move and rename get_proc_probes_by_task*()
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 6 May 2013 10:27:43 +0000 (14:27 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 6 May 2013 10:27:43 +0000 (14:27 +0400)
get_proc_probes_by_task() --> sspt_procs_get_by_task()
get_proc_probes_by_task_or_new() --> sspt_procs_get_by_task_or_new()

move:
from src/modules/driver/us_proc_inst.c
to src/modules/driver/sspt/sspt_procs.c

driver/Makefile.am
driver/helper.c
driver/sspt/sspt_procs.c
driver/sspt/sspt_procs.h
driver/us_proc_inst.c
driver/us_proc_inst.h

index f8d1750..7cbf1ca 100644 (file)
@@ -21,6 +21,7 @@ module_name = swap_driver
 cross_compiler = $(subst gcc,,$(CC))
 
 inlude_opt = -I$(realpath $(top_srcdir)/src/modules/ksyms) \
+             -I$(realpath $(top_srcdir)/src/modules/driver) \
              -I$(realpath $(top_srcdir)/src/common) \
              -I$(realpath $(top_srcdir)/src/profile) \
              -I$(realpath $(top_srcdir)/src/modules/kprobe) \
index 351c431..c59f205 100644 (file)
@@ -62,7 +62,7 @@ static int ret_handler_pf(struct kretprobe_instance *ri, struct pt_regs *regs)
        }
 
        if (is_libonly()) {
-               procs = get_proc_probes_by_task_or_new(task);
+               procs = sspt_procs_get_by_task_or_new(task);
        } else {
                // find task
                if (us_proc_info.tgid == 0) {
@@ -113,7 +113,7 @@ static void recover_child(struct task_struct *child_task, struct sspt_procs *pro
 static void rm_uprobes_child(struct task_struct *task)
 {
        if (is_libonly()) {
-               struct sspt_procs *procs = get_proc_probes_by_task(current);
+               struct sspt_procs *procs = sspt_procs_get_by_task(current);
                if(procs) {
                        recover_child(task, procs);
                }
@@ -162,10 +162,10 @@ static int mr_pre_handler(struct kprobe *p, struct pt_regs *regs)
        }
 
        if (is_libonly()) {
-               procs = get_proc_probes_by_task(task);
+               procs = sspt_procs_get_by_task(task);
        } else {
                if (task->tgid == us_proc_info.tgid) {
-                       procs = get_proc_probes_by_task(task);
+                       procs = us_proc_info.pp;
                        us_proc_info.tgid = 0;
                }
        }
@@ -257,7 +257,7 @@ static int unmap_pre_handler(struct kprobe *p, struct pt_regs *regs)
        }
 
        if (is_libonly()) {
-               procs = get_proc_probes_by_task(task);
+               procs = sspt_procs_get_by_task(task);
        } else {
                if (task->tgid == us_proc_info.tgid) {
                        procs = us_proc_info.pp;
index 66c321f..e2be70c 100644 (file)
@@ -25,8 +25,9 @@
 #include "sspt_procs.h"
 #include <linux/slab.h>
 #include <linux/list.h>
+#include <us_slot_manager.h>
 
-extern struct list_head proc_probes_list;
+static LIST_HEAD(proc_probes_list);
 
 struct sspt_procs *sspt_procs_create(struct dentry* dentry, pid_t tgid)
 {
@@ -58,6 +59,36 @@ void sspt_procs_free(struct sspt_procs *procs)
 #include "../storage.h"
 extern inst_us_proc_t us_proc_info;
 
+struct sspt_procs *sspt_procs_get_by_task(struct task_struct *task)
+{
+       struct sspt_procs *procs, *tmp;
+
+       list_for_each_entry_safe(procs, tmp, &proc_probes_list, list) {
+               if (procs->tgid == task->tgid) {
+                       return procs;
+               }
+       }
+
+       return NULL;
+}
+
+static void add_proc_probes(struct sspt_procs *procs)
+{
+       list_add_tail(&procs->list, &proc_probes_list);
+}
+
+struct sspt_procs *sspt_procs_get_by_task_or_new(struct task_struct *task)
+{
+       struct sspt_procs *procs = sspt_procs_get_by_task(task);
+       if (procs == NULL) {
+               procs = sspt_procs_copy(us_proc_info.pp, task);
+               procs->sm = create_sm_us(task);
+               add_proc_probes(procs);
+       }
+
+       return procs;
+}
+
 void sspt_procs_free_all(void)
 {
        // is user-space instrumentation
index c961ce5..7a5855c 100644 (file)
@@ -42,6 +42,9 @@ struct sspt_procs {
 struct sspt_procs *sspt_procs_create(struct dentry* dentry, pid_t tgid);
 struct sspt_procs *sspt_procs_copy(struct sspt_procs *procs, struct task_struct *task);
 void sspt_procs_free(struct sspt_procs *procs);
+
+struct sspt_procs *sspt_procs_get_by_task(struct task_struct *task);
+struct sspt_procs *sspt_procs_get_by_task_or_new(struct task_struct *task);
 void sspt_procs_free_all(void);
 
 void sspt_procs_add_ip_data(struct sspt_procs *procs, struct dentry* dentry,
index 449a57a..27ea788 100644 (file)
@@ -53,8 +53,6 @@ void ujprobe_event_handler (unsigned long arg1, unsigned long arg2, unsigned lon
 int uretprobe_event_handler(struct uretprobe_instance *probe, struct pt_regs *regs, struct us_ip *ip);
 
 
-LIST_HEAD(proc_probes_list);
-
 #define print_event(fmt, args...)                                              \
 {                                                                              \
        char *buf[1024];                                                        \
@@ -73,45 +71,6 @@ int is_us_instrumentation(void)
        return !!us_proc_info.path;
 }
 
-struct sspt_procs *get_proc_probes_by_task(struct task_struct *task)
-{
-       struct sspt_procs *procs, *tmp;
-
-       if (!is_libonly()) {
-               if (task != current) {
-                       printk("ERROR get_proc_probes_by_task: \'task != current\'\n");
-                       return NULL;
-               }
-
-               return us_proc_info.pp;
-       }
-
-       list_for_each_entry_safe(procs, tmp, &proc_probes_list, list) {
-               if (procs->tgid == task->tgid) {
-                       return procs;
-               }
-       }
-
-       return NULL;
-}
-
-static void add_proc_probes(struct task_struct *task, struct sspt_procs *procs)
-{
-       list_add_tail(&procs->list, &proc_probes_list);
-}
-
-struct sspt_procs *get_proc_probes_by_task_or_new(struct task_struct *task)
-{
-       struct sspt_procs *procs = get_proc_probes_by_task(task);
-       if (procs == NULL) {
-               procs = sspt_procs_copy(us_proc_info.pp, task);
-               procs->sm = create_sm_us(task);
-               add_proc_probes(task, procs);
-       }
-
-       return procs;
-}
-
 struct dentry *dentry_by_path(const char *path)
 {
        struct dentry *dentry;
@@ -224,7 +183,7 @@ int install_otg_ip(unsigned long addr,
                        unsigned long offset_addr = addr - vma->vm_start;
                        struct dentry *dentry = vma->vm_file->f_dentry;
                        char *name = dentry->d_iname;
-                       struct sspt_procs *procs = get_proc_probes_by_task(task);
+                       struct sspt_procs *procs = sspt_procs_get_by_task(task);
                        struct ip_data pd = {
                                        .offset = offset_addr,
                                        .pre_handler = pre_handler,
@@ -288,7 +247,7 @@ int deinst_usr_space_proc (void)
                struct sspt_procs *procs;
 
                for_each_process(task)  {
-                       procs = get_proc_probes_by_task(task);
+                       procs = sspt_procs_get_by_task(task);
                        if (procs) {
                                int ret = uninstall_us_proc_probes(task, procs, US_UNREGS_PROBE);
                                if (ret) {
@@ -375,7 +334,7 @@ int inst_usr_space_proc (void)
                                continue;
                        }
 
-                       procs = get_proc_probes_by_task_or_new(task);
+                       procs = sspt_procs_get_by_task_or_new(task);
                        DPRINTF("trying process");
                        install_proc_probes(task, procs, 1);
                        //put_task_struct (task);
index f2dfcf5..6af6abf 100644 (file)
@@ -40,8 +40,6 @@ struct sspt_page;
 struct vm_area_struct;
 enum US_FLAGS;
 
-extern struct list_head proc_probes_list;
-
 int is_libonly(void);
 int is_us_instrumentation(void);
 
@@ -58,13 +56,11 @@ int install_otg_ip(unsigned long addr,
 int check_install_pages_in_file(struct task_struct *task, struct sspt_file *file);
 int unregister_us_page_probe(struct task_struct *task,
                             struct sspt_page *page, enum US_FLAGS flag);
-struct sspt_procs *get_proc_probes_by_task_or_new(struct task_struct *task);
 void install_proc_probes(struct task_struct *task, struct sspt_procs *procs, int atomic);
 pid_t find_proc_by_task(const struct task_struct *task, struct dentry *dentry);
 void install_page_probes(unsigned long page_addr, struct task_struct *task, struct sspt_procs *procs, int atomic);
 int uninstall_us_proc_probes(struct task_struct *task, struct sspt_procs *procs, enum US_FLAGS flag);
 int check_vma(struct vm_area_struct *vma);
 int unregister_us_file_probes(struct task_struct *task, struct sspt_file *file, enum US_FLAGS flag);
-struct sspt_procs *get_proc_probes_by_task(struct task_struct *task);
 
 #endif /* !defined(__US_PROC_INST_H__) */