Skip to contentSkip to conversation

samples/kprobes: Update jprobe_example.c for do_fork() change

PATCH In review Michael Ellerman 2 participants 2 messages Jun 23, 2014 kprobes

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 samples/kprobes: Update jprobe_example.c for do_fork() change

In commit e80d666 "flagday: kill pt_regs argument of do_fork()", the arguments to do_fork() changed.

The example code in jprobe_example.c was not updated to match, so the arguments inside the jprobe handler do not match reality.

Fix it by updating the arguments to match do_fork(). While we're at it use pr_info() for brevity, and print stack_start as well for interest.

---
 samples/kprobes/jprobe_example.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
samples/kprobes/jprobe_example.c +4 -5
index b754135..9119ac6 100644
@@ -24,12 +24,11 @@
 
 /* Proxy routine having the same arguments as actual do_fork() routine */
 static long jdo_fork(unsigned long clone_flags, unsigned long stack_start,
-	      struct pt_regs *regs, unsigned long stack_size,
-	      int __user *parent_tidptr, int __user *child_tidptr)
+	      unsigned long stack_size, int __user *parent_tidptr,
+	      int __user *child_tidptr)
 {
-	printk(KERN_INFO "jprobe: clone_flags = 0x%lx, stack_size = 0x%lx,"
-			" regs = 0x%p\n",
-	       clone_flags, stack_size, regs);
+	pr_info("jprobe: clone_flags = 0x%lx, stack_start = 0x%lx "
+		"stack_size = 0x%lx\n", clone_flags, stack_start, stack_size);
 
 	/* Always end with a call to jprobe_return(). */
 	jprobe_return();
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Michael Ellerman

In commit e80d666 "flagday: kill pt_regs argument of do_fork()", the arguments to do_fork() changed.

The example code in jprobe_example.c was not updated to match, so the arguments inside the jprobe handler do not match reality.

Fix it by updating the arguments to match do_fork(). While we're at it use pr_info() for brevity, and print stack_start as well for interest.

Thanks!

Quoted 26 lines
---
 samples/kprobes/jprobe_example.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
samples/kprobes/jprobe_example.c +4 -5
index b754135..9119ac6 100644
@@ -24,12 +24,11 @@
 
 /* Proxy routine having the same arguments as actual do_fork() routine */
 static long jdo_fork(unsigned long clone_flags, unsigned long stack_start,
-	      struct pt_regs *regs, unsigned long stack_size,
-	      int __user *parent_tidptr, int __user *child_tidptr)
+	      unsigned long stack_size, int __user *parent_tidptr,
+	      int __user *child_tidptr)
 {
-	printk(KERN_INFO "jprobe: clone_flags = 0x%lx, stack_size = 0x%lx,"
-			" regs = 0x%p\n",
-	       clone_flags, stack_size, regs);
+	pr_info("jprobe: clone_flags = 0x%lx, stack_start = 0x%lx "
+		"stack_size = 0x%lx\n", clone_flags, stack_start, stack_size);
 
 	/* Always end with a call to jprobe_return(). */
 	jprobe_return();
Signature · 4 lines
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]