• Prasanna S. Panchamukhi's avatar
    [PATCH] Jumper Probes to provide function arguments · b08e7589
    Prasanna S. Panchamukhi authored
    A special kprobe type which can be placed on function entry points, and
    employs a simple mirroring principle to allow seamless access to the
    arguments of a function being probed.  The probe handler routine should
    have the same prototype as the function being probed.  Currently
    implemented for x86.
    
    The way it works is that when the probe is hit, the breakpoint handler
    simply irets to the probe handler's eip while retaining register and stack
    state corresponding to the function entry.  After it is done, the probe
    handler calls jprobe_return() which traps again to restore processor state
    and switch back to the probed function.  Linus noted correctly at KS that
    we need to be careful as gcc assumes that the callee owns arguments.  We
    save and restore enough stack bytes to cover argument space.
    
    Sample Usage:
    	static int jip_queue_xmit(struct sk_buff *skb, int ipfragok)
    	{
    		... whatever ...
    		jprobe_return();
    		return 0;
    	}
    
    	struct jprobe jp = {
    		{.addr = (kprobe_opcode_t *) ip_queue_xmit},
    		.entry = (kprobe_opcode_t *) jip_queue_xmit
    	};
    	register_jprobe(&jp);
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    b08e7589
kprobes.h 1.96 KB