[IMPROVE] add function to get arguments in KS
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 31 Oct 2013 12:14:14 +0000 (16:14 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 1 Nov 2013 13:18:59 +0000 (17:18 +0400)
Change-Id: I73f6a1c9d11471d3ca13e7889eace5069bababd0
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
kprobe/arch/asm-arm/dbi_kprobes.h
kprobe/arch/asm-x86/dbi_kprobes.h

index f0afbaa..a610719 100644 (file)
@@ -505,6 +505,22 @@ void set_current_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ct
 
 void __naked kretprobe_trampoline(void);
 
+static unsigned long swap_get_karg(struct pt_regs *regs, unsigned long n)
+{
+       switch (n) {
+       case 0:
+               return regs->ARM_r0;
+       case 1:
+               return regs->ARM_r1;
+       case 2:
+               return regs->ARM_r2;
+       case 3:
+               return regs->ARM_r3;
+       }
+
+       return *((unsigned long *)regs->ARM_sp + n - 4);
+}
+
 int arch_init_kprobes(void);
 void arch_exit_kprobes(void);
 
index 8463020..bb0cd0f 100644 (file)
@@ -227,6 +227,25 @@ static inline int arch_check_insn(struct arch_specific_insn *ainsn)
        return 0;
 }
 
+static unsigned long swap_get_karg(struct pt_regs *regs, unsigned long n)
+{
+       switch (n) {
+       case 0:
+               return regs->ax;
+       case 1:
+               return regs->dx;
+       case 2:
+               return regs->cx;
+       }
+
+       /*
+        * 2 = 3 - 1
+        * 3 - arguments from registers
+        * 1 - return address saved on top of the stack
+        */
+       return *((unsigned long *)kernel_stack_pointer(regs) + n - 2);
+}
+
 int arch_init_kprobes(void);
 void arch_exit_kprobes(void);