source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/kprobes.h @ 8

Last change on this file since 8 was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#ifndef _LINUX_KPROBES_H
2#define _LINUX_KPROBES_H
3/*
4 *  Kernel Probes (KProbes)
5 *  include/linux/kprobes.h
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * Copyright (C) IBM Corporation, 2002, 2004
22 *
23 * 2002-Oct     Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
24 *              Probes initial implementation ( includes suggestions from
25 *              Rusty Russell).
26 * 2004-July    Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
27 *              interface to access function arguments.
28 */
29#include <linux/list.h>
30#include <linux/notifier.h>
31#include <linux/smp.h>
32#include <asm/kprobes.h>
33
34struct kprobe;
35struct pt_regs;
36typedef int (*kprobe_pre_handler_t) (struct kprobe *, struct pt_regs *);
37typedef int (*kprobe_break_handler_t) (struct kprobe *, struct pt_regs *);
38typedef void (*kprobe_post_handler_t) (struct kprobe *, struct pt_regs *,
39                                       unsigned long flags);
40typedef int (*kprobe_fault_handler_t) (struct kprobe *, struct pt_regs *,
41                                       int trapnr);
42struct kprobe {
43        struct hlist_node hlist;
44
45        /* list of kprobes for multi-handler support */
46        struct list_head list;
47
48        /* location of the probe point */
49        kprobe_opcode_t *addr;
50
51        /* Called before addr is executed. */
52        kprobe_pre_handler_t pre_handler;
53
54        /* Called after addr is executed, unless... */
55        kprobe_post_handler_t post_handler;
56
57        /* ... called if executing addr causes a fault (eg. page fault).
58         * Return 1 if it handled fault, otherwise kernel will see it. */
59        kprobe_fault_handler_t fault_handler;
60
61        /* ... called if breakpoint trap occurs in probe handler.
62         * Return 1 if it handled break, otherwise kernel will see it. */
63        kprobe_break_handler_t break_handler;
64
65        /* Saved opcode (which has been replaced with breakpoint) */
66        kprobe_opcode_t opcode;
67
68        /* copy of the original instruction */
69        struct arch_specific_insn ainsn;
70};
71
72/*
73 * Special probe type that uses setjmp-longjmp type tricks to resume
74 * execution at a specified entry with a matching prototype corresponding
75 * to the probed function - a trick to enable arguments to become
76 * accessible seamlessly by probe handling logic.
77 * Note:
78 * Because of the way compilers allocate stack space for local variables
79 * etc upfront, regardless of sub-scopes within a function, this mirroring
80 * principle currently works only for probes placed on function entry points.
81 */
82struct jprobe {
83        struct kprobe kp;
84        kprobe_opcode_t *entry; /* probe handling code to jump to */
85};
86
87#ifdef CONFIG_KPROBES
88/* Locks kprobe: irq must be disabled */
89void lock_kprobes(void);
90void unlock_kprobes(void);
91
92/* kprobe running now on this CPU? */
93static inline int kprobe_running(void)
94{
95        extern unsigned int kprobe_cpu;
96        return kprobe_cpu == smp_processor_id();
97}
98
99extern int arch_prepare_kprobe(struct kprobe *p);
100extern void arch_copy_kprobe(struct kprobe *p);
101extern void arch_remove_kprobe(struct kprobe *p);
102extern void show_registers(struct pt_regs *regs);
103
104/* Get the kprobe at this addr (if any).  Must have called lock_kprobes */
105struct kprobe *get_kprobe(void *addr);
106
107int register_kprobe(struct kprobe *p);
108void unregister_kprobe(struct kprobe *p);
109int setjmp_pre_handler(struct kprobe *, struct pt_regs *);
110int longjmp_break_handler(struct kprobe *, struct pt_regs *);
111int register_jprobe(struct jprobe *p);
112void unregister_jprobe(struct jprobe *p);
113void jprobe_return(void);
114
115#else
116static inline int kprobe_running(void)
117{
118        return 0;
119}
120static inline int register_kprobe(struct kprobe *p)
121{
122        return -ENOSYS;
123}
124static inline void unregister_kprobe(struct kprobe *p)
125{
126}
127static inline int register_jprobe(struct jprobe *p)
128{
129        return -ENOSYS;
130}
131static inline void unregister_jprobe(struct jprobe *p)
132{
133}
134static inline void jprobe_return(void)
135{
136}
137#endif
138#endif                          /* _LINUX_KPROBES_H */
Note: See TracBrowser for help on using the repository browser.