blob: 4659e0c55ea638737d76109327fc4a6b5eb8e40a [file] [log] [blame]
Frederic Weisbecker2da3e162009-11-05 23:06:50 +01001#ifndef _LINUX_HW_BREAKPOINT_H
2#define _LINUX_HW_BREAKPOINT_H
K.Prasadb332828c2009-06-01 23:43:10 +05303
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +02004#include <linux/perf_event.h>
K.Prasadb332828c2009-06-01 23:43:10 +05305
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +02006enum {
7 HW_BREAKPOINT_LEN_1 = 1,
8 HW_BREAKPOINT_LEN_2 = 2,
9 HW_BREAKPOINT_LEN_4 = 4,
10 HW_BREAKPOINT_LEN_8 = 8,
K.Prasadb332828c2009-06-01 23:43:10 +053011};
12
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +020013enum {
14 HW_BREAKPOINT_R = 1,
15 HW_BREAKPOINT_W = 2,
16 HW_BREAKPOINT_X = 4,
17};
K.Prasadb332828c2009-06-01 23:43:10 +053018
Frederic Weisbecker5093eba2009-11-22 05:21:35 +010019#ifdef __KERNEL__
Ingo Molnar688bcaf2009-11-14 01:12:47 +010020#ifdef CONFIG_HAVE_HW_BREAKPOINT
21
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +020022static inline unsigned long hw_breakpoint_addr(struct perf_event *bp)
23{
24 return bp->attr.bp_addr;
25}
26
27static inline int hw_breakpoint_type(struct perf_event *bp)
28{
29 return bp->attr.bp_type;
30}
31
32static inline int hw_breakpoint_len(struct perf_event *bp)
33{
34 return bp->attr.bp_len;
35}
36
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +020037extern struct perf_event *
38register_user_hw_breakpoint(unsigned long addr,
39 int len,
40 int type,
41 perf_callback_t triggered,
42 struct task_struct *tsk,
43 bool active);
44
45/* FIXME: only change from the attr, and don't unregister */
46extern struct perf_event *
47modify_user_hw_breakpoint(struct perf_event *bp,
48 unsigned long addr,
49 int len,
50 int type,
51 perf_callback_t triggered,
52 struct task_struct *tsk,
53 bool active);
54
K.Prasadb332828c2009-06-01 23:43:10 +053055/*
56 * Kernel breakpoints are not associated with any particular thread.
57 */
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +020058extern struct perf_event *
59register_wide_hw_breakpoint_cpu(unsigned long addr,
60 int len,
61 int type,
62 perf_callback_t triggered,
63 int cpu,
64 bool active);
K.Prasadb332828c2009-06-01 23:43:10 +053065
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +020066extern struct perf_event **
67register_wide_hw_breakpoint(unsigned long addr,
68 int len,
69 int type,
70 perf_callback_t triggered,
71 bool active);
K.Prasadb332828c2009-06-01 23:43:10 +053072
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +020073extern int register_perf_hw_breakpoint(struct perf_event *bp);
74extern int __register_perf_hw_breakpoint(struct perf_event *bp);
75extern void unregister_hw_breakpoint(struct perf_event *bp);
76extern void unregister_wide_hw_breakpoint(struct perf_event **cpu_events);
77
78extern int reserve_bp_slot(struct perf_event *bp);
79extern void release_bp_slot(struct perf_event *bp);
80
81extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk);
82
Frederic Weisbecker687b16f2009-11-13 13:16:15 +010083static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
84{
85 return &bp->hw.info;
86}
87
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +020088#else /* !CONFIG_HAVE_HW_BREAKPOINT */
89
90static inline struct perf_event *
91register_user_hw_breakpoint(unsigned long addr,
92 int len,
93 int type,
94 perf_callback_t triggered,
95 struct task_struct *tsk,
96 bool active) { return NULL; }
97static inline struct perf_event *
98modify_user_hw_breakpoint(struct perf_event *bp,
99 unsigned long addr,
100 int len,
101 int type,
102 perf_callback_t triggered,
103 struct task_struct *tsk,
104 bool active) { return NULL; }
105static inline struct perf_event *
106register_wide_hw_breakpoint_cpu(unsigned long addr,
107 int len,
108 int type,
109 perf_callback_t triggered,
110 int cpu,
111 bool active) { return NULL; }
112static inline struct perf_event **
113register_wide_hw_breakpoint(unsigned long addr,
114 int len,
115 int type,
116 perf_callback_t triggered,
117 bool active) { return NULL; }
118static inline int
119register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
120static inline int
121__register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
122static inline void unregister_hw_breakpoint(struct perf_event *bp) { }
123static inline void
124unregister_wide_hw_breakpoint(struct perf_event **cpu_events) { }
125static inline int
126reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; }
127static inline void release_bp_slot(struct perf_event *bp) { }
128
129static inline void flush_ptrace_hw_breakpoint(struct task_struct *tsk) { }
130
Frederic Weisbecker687b16f2009-11-13 13:16:15 +0100131static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
132{
133 return NULL;
134}
135
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +0200136#endif /* CONFIG_HAVE_HW_BREAKPOINT */
Frederic Weisbecker5093eba2009-11-22 05:21:35 +0100137#endif /* __KERNEL__ */
Frederic Weisbecker24f1e32c2009-09-09 19:22:48 +0200138
139#endif /* _LINUX_HW_BREAKPOINT_H */