2009-11-06 06:06:50 +08:00
|
|
|
#ifndef _LINUX_HW_BREAKPOINT_H
|
|
|
|
#define _LINUX_HW_BREAKPOINT_H
|
2009-06-02 02:13:10 +08:00
|
|
|
|
2009-09-10 01:22:48 +08:00
|
|
|
enum {
|
|
|
|
HW_BREAKPOINT_LEN_1 = 1,
|
|
|
|
HW_BREAKPOINT_LEN_2 = 2,
|
|
|
|
HW_BREAKPOINT_LEN_4 = 4,
|
|
|
|
HW_BREAKPOINT_LEN_8 = 8,
|
2009-06-02 02:13:10 +08:00
|
|
|
};
|
|
|
|
|
2009-09-10 01:22:48 +08:00
|
|
|
enum {
|
|
|
|
HW_BREAKPOINT_R = 1,
|
|
|
|
HW_BREAKPOINT_W = 2,
|
|
|
|
HW_BREAKPOINT_X = 4,
|
|
|
|
};
|
|
|
|
|
2009-11-22 12:21:35 +08:00
|
|
|
#ifdef __KERNEL__
|
2009-11-14 08:12:47 +08:00
|
|
|
|
2009-11-23 22:42:32 +08:00
|
|
|
#include <linux/perf_event.h>
|
|
|
|
|
2009-11-24 05:30:12 +08:00
|
|
|
#ifdef CONFIG_HAVE_HW_BREAKPOINT
|
|
|
|
|
2009-11-27 11:55:53 +08:00
|
|
|
/* As it's for in-kernel or ptrace use, we want it to be pinned */
|
|
|
|
#define DEFINE_BREAKPOINT_ATTR(name) \
|
|
|
|
struct perf_event_attr name = { \
|
|
|
|
.type = PERF_TYPE_BREAKPOINT, \
|
|
|
|
.size = sizeof(name), \
|
|
|
|
.pinned = 1, \
|
|
|
|
};
|
|
|
|
|
2009-11-27 11:55:54 +08:00
|
|
|
static inline void hw_breakpoint_init(struct perf_event_attr *attr)
|
|
|
|
{
|
|
|
|
attr->type = PERF_TYPE_BREAKPOINT;
|
|
|
|
attr->size = sizeof(*attr);
|
|
|
|
attr->pinned = 1;
|
|
|
|
}
|
|
|
|
|
2009-09-10 01:22:48 +08:00
|
|
|
static inline unsigned long hw_breakpoint_addr(struct perf_event *bp)
|
|
|
|
{
|
|
|
|
return bp->attr.bp_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int hw_breakpoint_type(struct perf_event *bp)
|
|
|
|
{
|
|
|
|
return bp->attr.bp_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int hw_breakpoint_len(struct perf_event *bp)
|
|
|
|
{
|
|
|
|
return bp->attr.bp_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern struct perf_event *
|
2009-11-27 11:55:53 +08:00
|
|
|
register_user_hw_breakpoint(struct perf_event_attr *attr,
|
2009-09-10 01:22:48 +08:00
|
|
|
perf_callback_t triggered,
|
2009-11-27 11:55:53 +08:00
|
|
|
struct task_struct *tsk);
|
2009-09-10 01:22:48 +08:00
|
|
|
|
|
|
|
/* FIXME: only change from the attr, and don't unregister */
|
|
|
|
extern struct perf_event *
|
|
|
|
modify_user_hw_breakpoint(struct perf_event *bp,
|
2009-11-27 11:55:53 +08:00
|
|
|
struct perf_event_attr *attr,
|
2009-09-10 01:22:48 +08:00
|
|
|
perf_callback_t triggered,
|
2009-11-27 11:55:53 +08:00
|
|
|
struct task_struct *tsk);
|
2009-06-02 02:13:10 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Kernel breakpoints are not associated with any particular thread.
|
|
|
|
*/
|
2009-09-10 01:22:48 +08:00
|
|
|
extern struct perf_event *
|
2009-11-27 11:55:54 +08:00
|
|
|
register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
|
2009-09-10 01:22:48 +08:00
|
|
|
perf_callback_t triggered,
|
2009-11-27 11:55:54 +08:00
|
|
|
int cpu);
|
2009-09-10 01:22:48 +08:00
|
|
|
|
|
|
|
extern struct perf_event **
|
2009-11-27 11:55:54 +08:00
|
|
|
register_wide_hw_breakpoint(struct perf_event_attr *attr,
|
|
|
|
perf_callback_t triggered);
|
2009-09-10 01:22:48 +08:00
|
|
|
|
|
|
|
extern int register_perf_hw_breakpoint(struct perf_event *bp);
|
|
|
|
extern int __register_perf_hw_breakpoint(struct perf_event *bp);
|
|
|
|
extern void unregister_hw_breakpoint(struct perf_event *bp);
|
|
|
|
extern void unregister_wide_hw_breakpoint(struct perf_event **cpu_events);
|
|
|
|
|
|
|
|
extern int reserve_bp_slot(struct perf_event *bp);
|
|
|
|
extern void release_bp_slot(struct perf_event *bp);
|
|
|
|
|
|
|
|
extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk);
|
|
|
|
|
2009-11-13 20:16:15 +08:00
|
|
|
static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
|
|
|
|
{
|
|
|
|
return &bp->hw.info;
|
|
|
|
}
|
|
|
|
|
2009-09-10 01:22:48 +08:00
|
|
|
#else /* !CONFIG_HAVE_HW_BREAKPOINT */
|
|
|
|
|
|
|
|
static inline struct perf_event *
|
2009-11-27 11:55:53 +08:00
|
|
|
register_user_hw_breakpoint(struct perf_event_attr *attr,
|
2009-09-10 01:22:48 +08:00
|
|
|
perf_callback_t triggered,
|
2009-11-27 11:55:53 +08:00
|
|
|
struct task_struct *tsk) { return NULL; }
|
2009-09-10 01:22:48 +08:00
|
|
|
static inline struct perf_event *
|
|
|
|
modify_user_hw_breakpoint(struct perf_event *bp,
|
2009-11-27 11:55:53 +08:00
|
|
|
struct perf_event_attr *attr,
|
2009-09-10 01:22:48 +08:00
|
|
|
perf_callback_t triggered,
|
2009-11-27 11:55:53 +08:00
|
|
|
struct task_struct *tsk) { return NULL; }
|
2009-09-10 01:22:48 +08:00
|
|
|
static inline struct perf_event *
|
2009-11-27 11:55:54 +08:00
|
|
|
register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
|
2009-09-10 01:22:48 +08:00
|
|
|
perf_callback_t triggered,
|
2009-11-27 11:55:54 +08:00
|
|
|
int cpu) { return NULL; }
|
2009-09-10 01:22:48 +08:00
|
|
|
static inline struct perf_event **
|
2009-11-27 11:55:54 +08:00
|
|
|
register_wide_hw_breakpoint(struct perf_event_attr *attr,
|
|
|
|
perf_callback_t triggered) { return NULL; }
|
2009-09-10 01:22:48 +08:00
|
|
|
static inline int
|
|
|
|
register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
|
|
|
|
static inline int
|
|
|
|
__register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
|
|
|
|
static inline void unregister_hw_breakpoint(struct perf_event *bp) { }
|
|
|
|
static inline void
|
|
|
|
unregister_wide_hw_breakpoint(struct perf_event **cpu_events) { }
|
|
|
|
static inline int
|
|
|
|
reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; }
|
|
|
|
static inline void release_bp_slot(struct perf_event *bp) { }
|
|
|
|
|
|
|
|
static inline void flush_ptrace_hw_breakpoint(struct task_struct *tsk) { }
|
2009-06-02 02:13:10 +08:00
|
|
|
|
2009-11-13 20:16:15 +08:00
|
|
|
static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-10 01:22:48 +08:00
|
|
|
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
|
2009-11-22 12:21:35 +08:00
|
|
|
#endif /* __KERNEL__ */
|
2009-06-02 02:13:10 +08:00
|
|
|
|
2009-09-10 01:22:48 +08:00
|
|
|
#endif /* _LINUX_HW_BREAKPOINT_H */
|