1 #ifndef _LINUX_HW_BREAKPOINT_H
2 #define _LINUX_HW_BREAKPOINT_H
5 HW_BREAKPOINT_LEN_1
= 1,
6 HW_BREAKPOINT_LEN_2
= 2,
7 HW_BREAKPOINT_LEN_4
= 4,
8 HW_BREAKPOINT_LEN_8
= 8,
19 #include <linux/perf_event.h>
21 #ifdef CONFIG_HAVE_HW_BREAKPOINT
23 static inline void hw_breakpoint_init(struct perf_event_attr
*attr
)
25 memset(attr
, 0, sizeof(*attr
));
27 attr
->type
= PERF_TYPE_BREAKPOINT
;
28 attr
->size
= sizeof(*attr
);
30 * As it's for in-kernel or ptrace use, we want it to be pinned
31 * and to call its callback every hits.
34 attr
->sample_period
= 1;
37 static inline unsigned long hw_breakpoint_addr(struct perf_event
*bp
)
39 return bp
->attr
.bp_addr
;
42 static inline int hw_breakpoint_type(struct perf_event
*bp
)
44 return bp
->attr
.bp_type
;
47 static inline int hw_breakpoint_len(struct perf_event
*bp
)
49 return bp
->attr
.bp_len
;
52 extern struct perf_event
*
53 register_user_hw_breakpoint(struct perf_event_attr
*attr
,
54 perf_overflow_handler_t triggered
,
55 struct task_struct
*tsk
);
57 /* FIXME: only change from the attr, and don't unregister */
58 extern struct perf_event
*
59 modify_user_hw_breakpoint(struct perf_event
*bp
, struct perf_event_attr
*attr
);
62 * Kernel breakpoints are not associated with any particular thread.
64 extern struct perf_event
*
65 register_wide_hw_breakpoint_cpu(struct perf_event_attr
*attr
,
66 perf_overflow_handler_t triggered
,
69 extern struct perf_event
**
70 register_wide_hw_breakpoint(struct perf_event_attr
*attr
,
71 perf_overflow_handler_t triggered
);
73 extern int register_perf_hw_breakpoint(struct perf_event
*bp
);
74 extern int __register_perf_hw_breakpoint(struct perf_event
*bp
);
75 extern void unregister_hw_breakpoint(struct perf_event
*bp
);
76 extern void unregister_wide_hw_breakpoint(struct perf_event
**cpu_events
);
78 extern int reserve_bp_slot(struct perf_event
*bp
);
79 extern void release_bp_slot(struct perf_event
*bp
);
81 extern void flush_ptrace_hw_breakpoint(struct task_struct
*tsk
);
83 static inline struct arch_hw_breakpoint
*counter_arch_bp(struct perf_event
*bp
)
88 #else /* !CONFIG_HAVE_HW_BREAKPOINT */
90 static inline struct perf_event
*
91 register_user_hw_breakpoint(struct perf_event_attr
*attr
,
92 perf_overflow_handler_t triggered
,
93 struct task_struct
*tsk
) { return NULL
; }
94 static inline struct perf_event
*
95 modify_user_hw_breakpoint(struct perf_event
*bp
,
96 struct perf_event_attr
*attr
) { return NULL
; }
97 static inline struct perf_event
*
98 register_wide_hw_breakpoint_cpu(struct perf_event_attr
*attr
,
99 perf_overflow_handler_t triggered
,
100 int cpu
) { return NULL
; }
101 static inline struct perf_event
**
102 register_wide_hw_breakpoint(struct perf_event_attr
*attr
,
103 perf_overflow_handler_t triggered
) { return NULL
; }
105 register_perf_hw_breakpoint(struct perf_event
*bp
) { return -ENOSYS
; }
107 __register_perf_hw_breakpoint(struct perf_event
*bp
) { return -ENOSYS
; }
108 static inline void unregister_hw_breakpoint(struct perf_event
*bp
) { }
110 unregister_wide_hw_breakpoint(struct perf_event
**cpu_events
) { }
112 reserve_bp_slot(struct perf_event
*bp
) {return -ENOSYS
; }
113 static inline void release_bp_slot(struct perf_event
*bp
) { }
115 static inline void flush_ptrace_hw_breakpoint(struct task_struct
*tsk
) { }
117 static inline struct arch_hw_breakpoint
*counter_arch_bp(struct perf_event
*bp
)
122 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
123 #endif /* __KERNEL__ */
125 #endif /* _LINUX_HW_BREAKPOINT_H */