[FEATURE] new interface pf_register_probe()
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 28 Jun 2013 15:21:31 +0000 (19:21 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 28 Jun 2013 15:21:31 +0000 (19:21 +0400)
-int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
-                      unsigned long offset, void *pre_handler,
-                      void *jp_handler, void *rp_handler);
+int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
+                      unsigned long offset, const char *args);

15 files changed:
driver/us_def_handler.c
uprobe/swap_uprobes.h
us_manager/img/img_file.c
us_manager/img/img_file.h
us_manager/img/img_ip.c
us_manager/img/img_ip.h
us_manager/img/img_proc.c
us_manager/img/img_proc.h
us_manager/pf/pf_group.c
us_manager/pf/pf_group.h
us_manager/sspt/ip.c
us_manager/sspt/ip.h
us_manager/sspt/sspt.h
us_manager/sspt/sspt_file.c
us_manager/sspt/sspt_file.h

index 31f4f7a..292a618 100644 (file)
@@ -18,6 +18,7 @@ unsigned long ujprobe_event_pre_handler(struct us_ip *ip, struct pt_regs *regs)
 {
        __get_cpu_var(gpCurIp) = ip;
        __get_cpu_var(gpUserRegs) = regs;
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(ujprobe_event_pre_handler);
@@ -33,7 +34,7 @@ void ujprobe_event_handler(unsigned long arg0, unsigned long arg1,
        addr = ip->offset & 0x01 ? addr | 0x01 : addr;
 #endif
 
-       pack_event_info(US_PROBE_ID, RECORD_ENTRY, "ppppppp", addr, arg0, arg1,
+       pack_event_info(US_PROBE_ID, RECORD_ENTRY, "pspppppp", addr, ip->jprobe.args, arg0, arg1,
                        arg2, arg3, arg4, arg5);
        swap_ujprobe_return();
 }
index f988c2d..0980228 100644 (file)
@@ -44,6 +44,7 @@ struct ujprobe {
        // handler whichw willb bec called before 'entry'
        uprobe_pre_entry_handler_t pre_entry;
        void *priv_arg;
+       char *args;
 };
 
 struct uretprobe_instance;
index 5daeea2..1ba2dba 100644 (file)
@@ -42,7 +42,8 @@ static struct img_ip *find_img_ip(struct img_file *file, unsigned long addr)
        return NULL;
 }
 
-int img_file_add_ip(struct img_file *file, unsigned long addr)
+int img_file_add_ip(struct img_file *file, unsigned long addr,
+                   const char *args)
 {
        struct img_ip *ip;
 
@@ -50,7 +51,7 @@ int img_file_add_ip(struct img_file *file, unsigned long addr)
        if (ip)
                return -EINVAL;
 
-       ip = create_img_ip(addr);
+       ip = create_img_ip(addr, args);
        img_add_ip_by_list(file, ip);
 
        return 0;
index d4f2b4f..9f9226e 100644 (file)
@@ -12,7 +12,8 @@ struct img_file {
 struct img_file *create_img_file(struct dentry *dentry);
 void free_img_file(struct img_file *ip);
 
-int img_file_add_ip(struct img_file *file, unsigned long addr);
+int img_file_add_ip(struct img_file *file, unsigned long addr,
+                   const char *args);
 int img_file_del_ip(struct img_file *file, unsigned long addr);
 
 int img_file_empty(struct img_file *file);
index 2f2410d..39ae629 100644 (file)
@@ -1,25 +1,32 @@
 #include "img_ip.h"
 #include <linux/slab.h>
 
-struct img_ip *create_img_ip(unsigned long addr)
+struct img_ip *create_img_ip(unsigned long addr, const char *args)
 {
        struct img_ip *ip;
+       size_t len;
 
        ip = kmalloc(sizeof(*ip), GFP_KERNEL);
        INIT_LIST_HEAD(&ip->list);
        ip->addr = addr;
 
+       /* copy args */
+       len = strlen(args) + 1;
+       ip->args = kmalloc(len, GFP_KERNEL);
+       memcpy(ip->args, args, len);
+
        return ip;
 }
 
 void free_img_ip(struct img_ip *ip)
 {
+       kfree(ip->args);
        kfree(ip);
 }
 
 /* debug */
 void img_ip_print(struct img_ip *ip)
 {
-       printk("###            addr=%x\n", ip->addr);
+       printk("###            addr=8%x, args=%s\n", ip->addr, ip->args);
 }
 /* debug */
index b6c41a6..0faf282 100644 (file)
@@ -6,9 +6,10 @@
 struct img_ip {
        struct list_head list;                  /* for img_file */
        unsigned long addr;
+       char *args;
 };
 
-struct img_ip *create_img_ip(unsigned long addr);
+struct img_ip *create_img_ip(unsigned long addr, const char *args);
 void free_img_ip(struct img_ip *ip);
 
 /* debug */
index 054d95a..0c299c4 100644 (file)
@@ -39,18 +39,19 @@ static struct img_file *find_img_file(struct img_proc *proc, struct dentry *dent
        return NULL;
 }
 
-int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry, unsigned long addr)
+int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry,
+                   unsigned long addr, const char *args)
 {
        int ret;
        struct img_file *file;
 
        file = find_img_file(proc, dentry);
        if (file)
-               return img_file_add_ip(file, addr);
+               return img_file_add_ip(file, addr, args);
 
        file = create_img_file(dentry);
 
-       ret = img_file_add_ip(file, addr);
+       ret = img_file_add_ip(file, addr, args);
        if (ret)
                free_img_file(file);
        else
index b6e253d..b89f71e 100644 (file)
@@ -12,7 +12,8 @@ struct img_proc {
 struct img_proc *create_img_proc(void);
 void free_img_proc(struct img_proc *proc);
 
-int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry, unsigned long addr);
+int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry,
+                   unsigned long addr, const char *args);
 int img_proc_del_ip(struct img_proc *proc, struct dentry *dentry, unsigned long addr);
 
 /* debug */
index 3501e5a..d11661e 100644 (file)
@@ -8,8 +8,6 @@
 #include <sspt/sspt_proc.h>
 #include <helper.h>
 
-#include "../../driver/us_def_handler.h"
-
 struct pf_group {
        struct list_head list;
        struct img_proc *i_proc;
@@ -55,24 +53,14 @@ static void del_pl_struct(struct pl_struct *pls)
 void copy_proc_form_img_to_sspt(struct img_proc *i_proc, struct sspt_proc *proc)
 {
        struct sspt_file *file;
-       struct ip_data ip_d;
-
        struct img_file *i_file;
        struct img_ip *i_ip;
 
        list_for_each_entry(i_file, &i_proc->file_list, list) {
                file = sspt_proc_find_file_or_new(proc, i_file->dentry);
 
-               list_for_each_entry(i_ip, &i_file->ip_list, list) {
-                       ip_d.flag_retprobe = 1;
-                       ip_d.got_addr = 0;
-                       ip_d.jp_handler = ujprobe_event_handler;
-                       ip_d.offset = i_ip->addr;
-                       ip_d.pre_handler = ujprobe_event_pre_handler;
-                       ip_d.rp_handler = uretprobe_event_handler;
-
-                       sspt_file_add_ip(file, &ip_d);
-               }
+               list_for_each_entry(i_ip, &i_file->ip_list, list)
+                       sspt_file_add_ip(file, i_ip->addr, i_ip->args);
        }
 }
 
@@ -192,10 +180,9 @@ void put_pf_group(struct pf_group *pfg)
 }
 
 int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
-                     unsigned long offset, void *pre_handler,
-                     void *jp_handler, void *rp_handler)
+                     unsigned long offset, const char *args)
 {
-       return img_proc_add_ip(pfg->i_proc, dentry, offset);
+       return img_proc_add_ip(pfg->i_proc, dentry, offset, args);
 }
 EXPORT_SYMBOL_GPL(pf_register_probe);
 
index 7b3c9fe..2062ffe 100644 (file)
@@ -11,8 +11,7 @@ struct pf_group *get_pf_group_by_tgid(pid_t tgid);
 void put_pf_group(struct pf_group *pfg);
 
 int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
-                     unsigned long offset, void *pre_handler,
-                     void *jp_handler, void *rp_handler);
+                     unsigned long offset, const char *args);
 int pf_unregister_probe(struct pf_group *pfg, struct dentry *dentry,
                        unsigned long offset);
 
index 0abe02f..71d7d09 100644 (file)
 #include "sspt_page.h"
 #include "sspt_file.h"
 
-struct us_ip *create_ip(unsigned long offset)
+/* FIXME: */
+#include "../../driver/us_def_handler.h"
+
+struct us_ip *create_ip(unsigned long offset, const char *args)
 {
        struct us_ip *ip = kmalloc(sizeof(*ip), GFP_ATOMIC);
        memset(ip, 0, sizeof(*ip));
@@ -35,41 +38,24 @@ struct us_ip *create_ip(unsigned long offset)
        INIT_LIST_HEAD(&ip->list);
        ip->offset = offset;
 
-       return ip;
-}
+       ip->got_addr = 0;
+       ip->flag_got = 1;
 
-void free_ip(struct us_ip *ip)
-{
-       kfree(ip);
-}
+       /* jprobe */
+       ip->jprobe.pre_entry = ujprobe_event_pre_handler;
+       ip->jprobe.entry = ujprobe_event_handler;
 
-static inline void set_ip_jp_handler(struct us_ip *ip, kprobe_pre_entry_handler_t per_entry, void *entry)
-{
-       ip->jprobe.pre_entry = per_entry;
-       ip->jprobe.entry = entry;
-}
+       /* TODO: or copy args?! */
+       ip->jprobe.args = args;
 
-static inline void set_ip_rp_handler(struct us_ip *ip, uretprobe_handler_t handler)
-{
+       /* retprobe */
        ip->flag_retprobe = 1;
-       ip->retprobe.handler = handler;
-}
+       ip->retprobe.handler = uretprobe_event_handler;
 
-static inline void set_ip_got_addr(struct us_ip *ip, unsigned long got_addr)
-{
-       ip->got_addr = got_addr;
+       return ip;
 }
 
-struct us_ip *create_ip_by_ip_data(struct ip_data *ip_d)
+void free_ip(struct us_ip *ip)
 {
-       struct us_ip *ip = create_ip(ip_d->offset);
-       set_ip_jp_handler(ip, ip_d->pre_handler, (void *)ip_d->jp_handler);
-
-       if (ip_d->flag_retprobe) {
-               set_ip_rp_handler(ip, ip_d->rp_handler);
-       }
-
-       set_ip_got_addr(ip, ip_d->got_addr);
-
-       return ip;
+       kfree(ip);
 }
index 068cdd9..3e09cf1 100644 (file)
@@ -59,8 +59,7 @@ struct us_ip {
 };
 
 
-struct us_ip *create_ip(unsigned long offset);
-struct us_ip *create_ip_by_ip_data(struct ip_data *ip_d);
+struct us_ip *create_ip(unsigned long offset, const char *args);
 void free_ip(struct us_ip *ip);
 
 #endif /* __IP__ */
index 7a1f92e..669a52b 100644 (file)
@@ -62,7 +62,6 @@ static inline struct sspt_proc *get_file_probes(inst_us_proc_t *task_inst_info)
                name = name ? name + 1 : path;
 
                for (k = 0; k < p_libs->ips_count; ++k) {
-                       struct ip_data pd;
                        us_proc_ip_t *ip = &p_libs->p_ips[k];
                        unsigned long got_addr = 0;
 
@@ -73,18 +72,7 @@ static inline struct sspt_proc *get_file_probes(inst_us_proc_t *task_inst_info)
                                }
                        }
 
-                       pd.flag_retprobe = 1;
-                       pd.offset = ip->offset;
-                       pd.got_addr = got_addr;
-                       pd.pre_handler = ip->jprobe.pre_entry ? ip->jprobe.pre_entry : ujprobe_event_pre_handler;
-                       pd.jp_handler = (unsigned long) (ip->jprobe.entry ? ip->jprobe.entry : ujprobe_event_handler);
-                       pd.rp_handler = ip->retprobe.handler ?  ip->retprobe.handler : uretprobe_event_handler;
-
-//                     ret = usm_register_probe(dentry, pd.offset, pd.pre_handler, pd.jp_handler, pd.rp_handler);
-//                     if (ret)
-//                             printk("### ERROR: usm_register_probe ret=%d\n", ret);
-
-                       ret = pf_register_probe(pfg, dentry, pd.offset, pd.pre_handler, pd.jp_handler, pd.rp_handler);
+                       ret = pf_register_probe(pfg, dentry, ip->offset, "dddd");
                        if (ret)
                                printk("### ERROR: pf_register_probe ret=%d\n", ret);
                }
index 206a9ad..03400a8 100644 (file)
@@ -137,13 +137,13 @@ struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long pa
        return sspt_find_page(file, offset);
 }
 
-void sspt_file_add_ip(struct sspt_file *file, struct ip_data *ip_d)
+void sspt_file_add_ip(struct sspt_file *file, unsigned long offset,
+                     const char *args)
 {
-       unsigned long offset = ip_d->offset & PAGE_MASK;
-       struct sspt_page *page = sspt_find_page_or_new(file, offset);
+       struct sspt_page *page = sspt_find_page_or_new(file, offset & PAGE_MASK);
 
        // FIXME: delete ip
-       struct us_ip *ip = create_ip_by_ip_data(ip_d);
+       struct us_ip *ip = create_ip(offset, args);
 
        sspt_add_ip(page, ip);
 }
index fd17704..dbc1d08 100644 (file)
@@ -46,8 +46,10 @@ struct sspt_file {
 struct sspt_file *sspt_file_create(struct dentry *dentry, int page_cnt);
 void sspt_file_free(struct sspt_file *file);
 
-struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long page);
-void sspt_file_add_ip(struct sspt_file *file, struct ip_data *ip_d);
+struct sspt_page *sspt_find_page_mapped(struct sspt_file *file,
+                                       unsigned long page);
+void sspt_file_add_ip(struct sspt_file *file, unsigned long offset,
+                     const char *args);
 
 struct sspt_page *sspt_get_page(struct sspt_file *file, unsigned long offset_addr);
 void sspt_put_page(struct sspt_page *page);