• Prasanna S. Panchamukhi's avatar
    [PATCH] kprobes: kprobes ported to x86_64 · 6cdda814
    Prasanna S. Panchamukhi authored
    Adopted from i386 architecture.
    
    Kprobes:
    
    Helps developers to trap at almost any kernel code address, specifying a
    handler routine to be invoked when the breakpoint is hit.  Useful for
    analysing the Linux kernel by collecting debugging information
    non-disruptively.  Employs single-stepping out-of-line to avoid probe
    misses on SMP and may be especially useful in aiding debugging elusive
    races and problems on live systems.  More elaborate dynamic tracing tools
    can be built over the kprobes interface.
    
    Sample usage:
    	To place a probe on __blockdev_direct_IO:
    	static int probe_handler(struct kprobe *p, struct pt_regs *)
    	{
    		... whatever ...
    	}
    	struct kprobe kp = {
    		.addr = __blockdev_direct_IO,
    		.pre_handler = probe_handler
    	};
    	register_kprobe(&kp);
    
    Jprobes:
    
    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.
    
    The way it works is that when the probe is hit, the breakpoint handler
    simply irets to the probe handler's rip 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 avatarPrasanna S Panchamukhi <prasanna@in.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    6cdda814
kprobes.h 2.06 KB