[REFACTOR] remove field jprobe from struct us_ip
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 5 Sep 2013 12:54:24 +0000 (16:54 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 5 Sep 2013 12:54:24 +0000 (16:54 +0400)
remove files:
us_manager/us_def_handler.c
us_manager/us_def_handler.h

Change-Id: I16db869bbc75c192e39ad947137bf3b42813ce04
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
us_manager/sspt/ip.c
us_manager/sspt/ip.h
us_manager/sspt/sspt.h
us_manager/sspt/sspt_debug.h
us_manager/sspt/sspt_page.c
us_manager/us_def_handler.c [deleted file]
us_manager/us_def_handler.h [deleted file]

index 1946137..700a519 100644 (file)
 #include "ip.h"
 #include "sspt_page.h"
 #include "sspt_file.h"
+#include <writer/swap_writer_module.h>
 
-#include "us_def_handler.h"
+
+static int entry_handler(struct uretprobe_instance *ri, struct pt_regs *regs)
+{
+       struct us_ip *ip = container_of(ri->rp, struct us_ip, retprobe);
+
+       entry_event(ip->args, regs, PT_US, PST_NONE);
+
+       return 0;
+}
+
+static int ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs)
+{
+       struct us_ip *ip = container_of(ri->rp, struct us_ip, retprobe);
+       unsigned long addr = (unsigned long)ip->retprobe.up.kp.addr;
+
+#if defined(CONFIG_ARM)
+       addr = ip->offset & 0x01 ? addr | 0x01 : addr;
+#endif
+
+       exit_event(regs, addr);
+
+       return 0;
+}
 
 struct us_ip *create_ip(unsigned long offset, const char *args)
 {
@@ -40,16 +63,13 @@ struct us_ip *create_ip(unsigned long offset, const char *args)
        ip->got_addr = 0;
        ip->flag_got = 1;
 
-       /* jprobe */
-       ip->jprobe.pre_entry = ujprobe_event_pre_handler;
-       ip->jprobe.entry = ujprobe_event_handler;
-
        /* TODO: or copy args?! */
-       ip->jprobe.args = args;
+       ip->args = args;
 
        /* retprobe */
        ip->flag_retprobe = 1;
-       ip->retprobe.handler = uretprobe_event_handler;
+       ip->retprobe.handler = ret_handler;
+       ip->retprobe.entry_handler = entry_handler;
 
        return ip;
 }
index 358e84b..25e589f 100644 (file)
@@ -48,8 +48,8 @@ struct us_ip {
        struct list_head list;
        struct sspt_page *page;
 
-       struct ujprobe jprobe;
        struct uretprobe retprobe;
+       char *args;
 
        unsigned long offset;
        unsigned long got_addr;
index d430fd6..6cc5c0f 100644 (file)
@@ -32,7 +32,6 @@
 #include "sspt_debug.h"
 #include "us_proc_types.h"
 #include <swap_uprobes.h>
-#include "us_def_handler.h"
 
 
 #include <us_manager.h>
@@ -93,21 +92,10 @@ static inline int sspt_register_usprobe(struct us_ip *ip)
 {
        int ret = 0;
 
-       /* for juprobe */
-       ip->jprobe.priv_arg = ip;
-       ip->jprobe.up.task = ip->page->file->proc->task;
-       ip->jprobe.up.sm = ip->page->file->proc->sm;
-
        /* for retuprobe */
        ip->retprobe.up.task = ip->page->file->proc->task;
        ip->retprobe.up.sm = ip->page->file->proc->sm;
 
-       ret = dbi_register_ujprobe(&ip->jprobe);
-       if (ret) {
-               printk("dbi_register_ujprobe() failure %d\n", ret);
-               return ret;
-       }
-
        if (ip->flag_retprobe) {
                ret = dbi_register_uretprobe(&ip->retprobe);
                if (ret) {
@@ -128,8 +116,6 @@ static inline int sspt_register_usprobe(struct us_ip *ip)
 
 static inline int do_unregister_usprobe(struct us_ip *ip)
 {
-       dbi_unregister_ujprobe(&ip->jprobe);
-
        if (ip->flag_retprobe) {
                dbi_unregister_uretprobe(&ip->retprobe);
        }
@@ -146,7 +132,7 @@ static inline int sspt_unregister_usprobe(struct task_struct *task, struct us_ip
                err = do_unregister_usprobe(ip);
                break;
        case US_DISARM:
-               disarm_uprobe(&ip->jprobe.up.kp, task);
+               disarm_uprobe(&ip->retprobe.up.kp, task);
                break;
        default:
                panic("incorrect value flag=%d", flag);
index d79552a..6428e16 100644 (file)
@@ -47,10 +47,9 @@ static inline void print_page_probes(const struct sspt_page *page)
        printk("###     offset=%lx\n", page->offset);
        list_for_each_entry(ip, &page->ip_list, list) {
 
-               printk("###       addr[%2d]=%lx, J_addr=%lx, R_addr=%lx\n",
-                               i, (unsigned long)ip->offset, (unsigned long)ip->jprobe.up.kp.addr,
+               printk("###       addr[%2d]=%lx, R_addr=%lx\n",
+                               i, (unsigned long)ip->offset,
                                (unsigned long)ip->retprobe.up.kp.addr);
-               print_jprobe(&ip->jprobe);
                print_retprobe(&ip->retprobe);
                ++i;
        }
index 21dcde1..f11c0ca 100644 (file)
@@ -109,7 +109,7 @@ void sspt_set_all_ip_addr(struct sspt_page *page, const struct sspt_file *file)
 
        list_for_each_entry(ip, &page->ip_list, list) {
                addr = file->vm_start + page->offset + ip->offset;
-               ip->retprobe.up.kp.addr = ip->jprobe.up.kp.addr = (kprobe_opcode_t *)addr;
+               ip->retprobe.up.kp.addr = (kprobe_opcode_t *)addr;
        }
 }
 
diff --git a/us_manager/us_def_handler.c b/us_manager/us_def_handler.c
deleted file mode 100644 (file)
index 3f7e068..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *  SWAP uprobe manager
- *  modules/us_manager/us_def_handler.c
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright (C) Samsung Electronics, 2013
- *
- * 2013         Vyacheslav Cherkashin: SWAP us_manager implement
- *
- */
-
-#include <linux/module.h>
-#include <asm/percpu.h>
-#include <swap_uprobes.h>
-#include <sspt/ip.h>
-#include <dbi_kprobes_deps.h>
-#include <sspt/sspt.h>
-#include <writer/swap_writer_module.h>
-
-DEFINE_PER_CPU(struct us_ip *, gpCurIp) = NULL;
-EXPORT_PER_CPU_SYMBOL_GPL(gpCurIp);
-DEFINE_PER_CPU(struct pt_regs *, gpUserRegs) = NULL;
-EXPORT_PER_CPU_SYMBOL_GPL(gpUserRegs);
-
-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);
-
-void ujprobe_event_handler(unsigned long arg0, unsigned long arg1,
-                          unsigned long arg2, unsigned long arg3,
-                          unsigned long arg4, unsigned long arg5)
-{
-       struct us_ip *ip = __get_cpu_var(gpCurIp);
-       struct us_ip *regs = __get_cpu_var(gpUserRegs);
-       unsigned long addr = (unsigned long)ip->jprobe.up.kp.addr;
-
-#if defined(CONFIG_ARM)
-       addr = ip->offset & 0x01 ? addr | 0x01 : addr;
-#endif
-
-       entry_event(ip->jprobe.args, regs, PT_US, PST_NONE);
-
-       swap_ujprobe_return();
-}
-EXPORT_SYMBOL_GPL(ujprobe_event_handler);
-
-static void send_plt(struct us_ip *ip)
-{
-       unsigned long addr = (unsigned long)ip->jprobe.up.kp.addr;
-       struct vm_area_struct *vma = find_vma(current->mm, addr);
-
-       if (vma && check_vma(vma)) {
-               char *name = NULL;
-               unsigned long real_addr;
-               unsigned long real_got = current->mm->exe_file == vma->vm_file ?
-                                        ip->got_addr :
-                                        ip->got_addr + vma->vm_start;
-
-               if (!read_proc_vm_atomic(current, real_got, &real_addr, sizeof(real_addr))) {
-                       printk("Failed to read got %lx at memory address %lx!\n", ip->got_addr, real_got);
-                       return;
-               }
-
-               vma = find_vma(current->mm, real_addr);
-               if (vma && (vma->vm_start <= real_addr) && (vma->vm_end > real_addr)) {
-                       name = vma->vm_file ? vma->vm_file->f_dentry->d_iname : NULL;
-               } else {
-                       printk("Failed to get vma, includes %lx address\n", real_addr);
-                       return;
-               }
-
-//             if (name)
-//                     pack_event_info(PLT_ADDR_PROBE_ID, RECORD_RET, "ppsp",
-//                                     addr, real_addr, name,
-//                                     real_addr - vma->vm_start);
-//             else
-//                     pack_event_info(PLT_ADDR_PROBE_ID, RECORD_RET, "ppp",
-//                                     addr, real_addr,
-//                                     real_addr - vma->vm_start);
-       }
-}
-
-int uretprobe_event_handler(struct uretprobe_instance *probe,
-                           struct pt_regs *regs)
-{
-       int retval = regs_return_value(regs);
-       struct us_ip *ip = container_of(probe->rp, struct us_ip, retprobe);
-       unsigned long addr = (unsigned long)ip->jprobe.up.kp.addr;
-
-       if (ip->got_addr && ip->flag_got == 0) {
-               send_plt(ip);
-               ip->flag_got = 1;
-       }
-
-#if defined(CONFIG_ARM)
-       addr = ip->offset & 0x01 ? addr | 0x01 : addr;
-#endif
-
-       exit_event(regs, addr);
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(uretprobe_event_handler);
diff --git a/us_manager/us_def_handler.h b/us_manager/us_def_handler.h
deleted file mode 100644 (file)
index e9b18a7..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  SWAP uprobe manager
- *  modules/us_manager/us_def_handler.h
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright (C) Samsung Electronics, 2013
- *
- * 2013         Vyacheslav Cherkashin: SWAP us_manager implement
- *
- */
-
-#ifndef _US_DEF_HANDLER_H
-#define _US_DEF_HANDLER_H
-
-#include <asm/percpu.h>
-
-struct us_ip;
-struct pt_regs;
-struct uretprobe_instance;
-
-DECLARE_PER_CPU(struct us_ip *, gpCurIp);
-DECLARE_PER_CPU(struct pt_regs *, gpUserRegs);
-
-unsigned long ujprobe_event_pre_handler(struct us_ip *ip,
-                                       struct pt_regs *regs);
-void ujprobe_event_handler(unsigned long arg0, unsigned long arg1,
-                          unsigned long arg2, unsigned long arg3,
-                          unsigned long arg4, unsigned long arg5);
-int uretprobe_event_handler(struct uretprobe_instance *p,
-                           struct pt_regs *regs);
-
-#endif /* _US_DEF_HANDLER_H */