linux/include/asm-i386
Hien Nguyen b94cce926b [PATCH] kprobes: function-return probes
This patch adds function-return probes to kprobes for the i386
architecture.  This enables you to establish a handler to be run when a
function returns.

1. API

Two new functions are added to kprobes:

	int register_kretprobe(struct kretprobe *rp);
	void unregister_kretprobe(struct kretprobe *rp);

2. Registration and unregistration

2.1 Register

  To register a function-return probe, the user populates the following
  fields in a kretprobe object and calls register_kretprobe() with the
  kretprobe address as an argument:

  kp.addr - the function's address

  handler - this function is run after the ret instruction executes, but
  before control returns to the return address in the caller.

  maxactive - The maximum number of instances of the probed function that
  can be active concurrently.  For example, if the function is non-
  recursive and is called with a spinlock or mutex held, maxactive = 1
  should be enough.  If the function is non-recursive and can never
  relinquish the CPU (e.g., via a semaphore or preemption), NR_CPUS should
  be enough.  maxactive is used to determine how many kretprobe_instance
  objects to allocate for this particular probed function.  If maxactive <=
  0, it is set to a default value (if CONFIG_PREEMPT maxactive=max(10, 2 *
  NR_CPUS) else maxactive=NR_CPUS)

  For example:

    struct kretprobe rp;
    rp.kp.addr = /* entrypoint address */
    rp.handler = /*return probe handler */
    rp.maxactive = /* e.g., 1 or NR_CPUS or 0, see the above explanation */
    register_kretprobe(&rp);

  The following field may also be of interest:

  nmissed - Initialized to zero when the function-return probe is
  registered, and incremented every time the probed function is entered but
  there is no kretprobe_instance object available for establishing the
  function-return probe (i.e., because maxactive was set too low).

2.2 Unregister

  To unregiter a function-return probe, the user calls
  unregister_kretprobe() with the same kretprobe object as registered
  previously.  If a probed function is running when the return probe is
  unregistered, the function will return as expected, but the handler won't
  be run.

3. Limitations

3.1 This patch supports only the i386 architecture, but patches for
    x86_64 and ppc64 are anticipated soon.

3.2 Return probes operates by replacing the return address in the stack
    (or in a known register, such as the lr register for ppc).  This may
    cause __builtin_return_address(0), when invoked from the return-probed
    function, to return the address of the return-probes trampoline.

3.3 This implementation uses the "Multiprobes at an address" feature in
    2.6.12-rc3-mm3.

3.4 Due to a limitation in multi-probes, you cannot currently establish
    a return probe and a jprobe on the same function.  A patch to remove
    this limitation is being tested.

This feature is required by SystemTap (http://sourceware.org/systemtap),
and reflects ideas contributed by several SystemTap developers, including
Will Cohen and Ananth Mavinakayanahalli.

Signed-off-by: Hien Nguyen <hien@us.ibm.com>
Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: Frederik Deweerdt <frederik.deweerdt@laposte.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-23 09:45:21 -07:00
..
mach-bigsmp
mach-default
mach-es7000
mach-generic
mach-numaq
mach-summit
mach-visws
mach-voyager
8253pit.h
a.out.h
acpi.h
agp.h
apic.h
apicdef.h
arch_hooks.h
atomic.h
bitops.h
boot.h
bug.h
bugs.h
byteorder.h
cache.h
cacheflush.h
checksum.h [PATCH] x86: #include asm/uaccess.h in asm/checksum.h 2005-06-23 09:45:11 -07:00
cpu.h
cpufeature.h
cputime.h
current.h
debugreg.h
delay.h
desc.h
div64.h
dma-mapping.h
dma.h
e820.h
elf.h
errno.h
fcntl.h
fixmap.h
floppy.h
genapic.h
hardirq.h
hdreg.h
highmem.h
hpet.h
hw_irq.h
i387.h
i8259.h
ide.h
io.h
io_apic.h
ioctl.h
ioctls.h
ipc.h
ipcbuf.h
irq.h
ist.h
kdebug.h
kmap_types.h
kprobes.h [PATCH] kprobes: function-return probes 2005-06-23 09:45:21 -07:00
ldt.h
linkage.h
local.h
math_emu.h
mc146818rtc.h
mca.h
mca_dma.h
mman.h
mmu.h
mmu_context.h
mmx.h
mmzone.h
module.h
mpspec.h
mpspec_def.h
msgbuf.h
msi.h
msr.h
mtrr.h
namei.h
nmi.h
node.h
numaq.h
numnodes.h
page.h
param.h
parport.h
pci-direct.h
pci.h
percpu.h
pgalloc.h
pgtable-2level-defs.h
pgtable-2level.h
pgtable-3level-defs.h
pgtable-3level.h
pgtable.h
poll.h
posix_types.h
processor.h [PATCH] xen: x86: add macro for debugreg 2005-06-23 09:45:13 -07:00
ptrace.h [PATCH] xen: x86: Rename usermode macro 2005-06-23 09:45:14 -07:00
resource.h
rtc.h
rwlock.h
rwsem.h
scatterlist.h
seccomp.h
sections.h
segment.h
semaphore.h
sembuf.h
serial.h
setup.h
shmbuf.h
shmparam.h
sigcontext.h
siginfo.h
signal.h
smp.h
socket.h
sockios.h
sparsemem.h
spinlock.h
srat.h
stat.h
statfs.h
string.h
suspend.h
system.h
termbits.h
termios.h
thread_info.h [PATCH] streamline preempt_count type across archs 2005-06-23 09:45:19 -07:00
timer.h
timex.h [PATCH] x86: cpu_khz type fix 2005-06-23 09:45:11 -07:00
tlb.h
tlbflush.h
topology.h
types.h
uaccess.h
ucontext.h
unaligned.h
unistd.h
user.h
vga.h
vic.h
vm86.h
voyager.h
xor.h