2009-11-06 01:06:50 +03:00
|
|
|
#ifndef _LINUX_HW_BREAKPOINT_H
|
|
|
|
#define _LINUX_HW_BREAKPOINT_H
|
2009-06-01 22:13:10 +04:00
|
|
|
|
2009-11-23 17:42:32 +03:00
|
|
|
#include <linux/perf_event.h>
|
2012-11-20 02:21:03 +04:00
|
|
|
#include <uapi/linux/hw_breakpoint.h>
|
2009-11-23 17:42:32 +03:00
|
|
|
|
2009-11-24 00:30:12 +03:00
|
|
|
#ifdef CONFIG_HAVE_HW_BREAKPOINT
|
|
|
|
|
2010-11-05 01:33:01 +03:00
|
|
|
extern int __init init_hw_breakpoint(void);
|
|
|
|
|
2009-11-27 06:55:54 +03:00
|
|
|
static inline void hw_breakpoint_init(struct perf_event_attr *attr)
|
|
|
|
{
|
2009-12-07 05:14:17 +03:00
|
|
|
memset(attr, 0, sizeof(*attr));
|
|
|
|
|
2009-11-27 06:55:54 +03:00
|
|
|
attr->type = PERF_TYPE_BREAKPOINT;
|
|
|
|
attr->size = sizeof(*attr);
|
2009-12-05 11:44:31 +03:00
|
|
|
/*
|
|
|
|
* As it's for in-kernel or ptrace use, we want it to be pinned
|
|
|
|
* and to call its callback every hits.
|
|
|
|
*/
|
2009-11-27 06:55:54 +03:00
|
|
|
attr->pinned = 1;
|
2009-12-05 11:44:31 +03:00
|
|
|
attr->sample_period = 1;
|
2010-04-22 07:05:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ptrace_breakpoint_init(struct perf_event_attr *attr)
|
|
|
|
{
|
|
|
|
hw_breakpoint_init(attr);
|
|
|
|
attr->exclude_kernel = 1;
|
2009-11-27 06:55:54 +03:00
|
|
|
}
|
|
|
|
|
2009-09-09 21:22:48 +04: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;
|
|
|
|
}
|
|
|
|
|
2010-01-30 07:55:18 +03:00
|
|
|
static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
|
2009-09-09 21:22:48 +04:00
|
|
|
{
|
|
|
|
return bp->attr.bp_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern struct perf_event *
|
2009-11-27 06:55:53 +03:00
|
|
|
register_user_hw_breakpoint(struct perf_event_attr *attr,
|
2009-12-05 11:44:31 +03:00
|
|
|
perf_overflow_handler_t triggered,
|
2011-06-29 19:42:35 +04:00
|
|
|
void *context,
|
2009-11-27 06:55:53 +03:00
|
|
|
struct task_struct *tsk);
|
2009-09-09 21:22:48 +04:00
|
|
|
|
|
|
|
/* FIXME: only change from the attr, and don't unregister */
|
2009-12-09 11:25:48 +03:00
|
|
|
extern int
|
2009-12-05 09:06:10 +03:00
|
|
|
modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr);
|
2009-06-01 22:13:10 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Kernel breakpoints are not associated with any particular thread.
|
|
|
|
*/
|
2009-09-09 21:22:48 +04:00
|
|
|
extern struct perf_event *
|
2009-11-27 06:55:54 +03:00
|
|
|
register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
|
2009-12-05 11:44:31 +03:00
|
|
|
perf_overflow_handler_t triggered,
|
2011-06-29 19:42:35 +04:00
|
|
|
void *context,
|
2009-11-27 06:55:54 +03:00
|
|
|
int cpu);
|
2009-09-09 21:22:48 +04:00
|
|
|
|
2010-02-17 04:50:50 +03:00
|
|
|
extern struct perf_event * __percpu *
|
2009-11-27 06:55:54 +03:00
|
|
|
register_wide_hw_breakpoint(struct perf_event_attr *attr,
|
2011-06-29 19:42:35 +04:00
|
|
|
perf_overflow_handler_t triggered,
|
|
|
|
void *context);
|
2009-09-09 21:22:48 +04: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);
|
2010-02-17 04:50:50 +03:00
|
|
|
extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events);
|
2009-09-09 21:22:48 +04:00
|
|
|
|
2010-01-29 02:04:43 +03:00
|
|
|
extern int dbg_reserve_bp_slot(struct perf_event *bp);
|
|
|
|
extern int dbg_release_bp_slot(struct perf_event *bp);
|
2009-09-09 21:22:48 +04:00
|
|
|
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 15:16:15 +03:00
|
|
|
static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
|
|
|
|
{
|
|
|
|
return &bp->hw.info;
|
|
|
|
}
|
|
|
|
|
2009-09-09 21:22:48 +04:00
|
|
|
#else /* !CONFIG_HAVE_HW_BREAKPOINT */
|
|
|
|
|
2010-11-05 01:33:01 +03:00
|
|
|
static inline int __init init_hw_breakpoint(void) { return 0; }
|
|
|
|
|
2009-09-09 21:22:48 +04:00
|
|
|
static inline struct perf_event *
|
2009-11-27 06:55:53 +03:00
|
|
|
register_user_hw_breakpoint(struct perf_event_attr *attr,
|
2009-12-05 11:44:31 +03:00
|
|
|
perf_overflow_handler_t triggered,
|
2011-06-29 19:42:35 +04:00
|
|
|
void *context,
|
2009-11-27 06:55:53 +03:00
|
|
|
struct task_struct *tsk) { return NULL; }
|
2009-12-09 11:25:48 +03:00
|
|
|
static inline int
|
2009-09-09 21:22:48 +04:00
|
|
|
modify_user_hw_breakpoint(struct perf_event *bp,
|
2009-12-11 13:58:42 +03:00
|
|
|
struct perf_event_attr *attr) { return -ENOSYS; }
|
2009-09-09 21:22:48 +04:00
|
|
|
static inline struct perf_event *
|
2009-11-27 06:55:54 +03:00
|
|
|
register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
|
2009-12-05 11:44:31 +03:00
|
|
|
perf_overflow_handler_t triggered,
|
2011-06-29 19:42:35 +04:00
|
|
|
void *context,
|
2009-11-27 06:55:54 +03:00
|
|
|
int cpu) { return NULL; }
|
2010-02-17 04:50:50 +03:00
|
|
|
static inline struct perf_event * __percpu *
|
2009-11-27 06:55:54 +03:00
|
|
|
register_wide_hw_breakpoint(struct perf_event_attr *attr,
|
2011-06-29 19:42:35 +04:00
|
|
|
perf_overflow_handler_t triggered,
|
|
|
|
void *context) { return NULL; }
|
2009-09-09 21:22:48 +04: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
|
2010-02-17 04:50:50 +03:00
|
|
|
unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { }
|
2009-09-09 21:22:48 +04:00
|
|
|
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-01 22:13:10 +04:00
|
|
|
|
2009-11-13 15:16:15 +03:00
|
|
|
static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-09 21:22:48 +04:00
|
|
|
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
|
|
|
|
#endif /* _LINUX_HW_BREAKPOINT_H */
|