uprobes.h 2.5 KB
Newer Older
1 2 3
#ifndef _LINUX_UPROBES_H
#define _LINUX_UPROBES_H
/*
4
 * User-space Probes (UProbes)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * Copyright (C) IBM Corporation, 2008-2011
 * Authors:
 *	Srikar Dronamraju
 *	Jim Keniston
 */

#include <linux/errno.h>
#include <linux/rbtree.h>

struct vm_area_struct;
#ifdef CONFIG_ARCH_SUPPORTS_UPROBES
#include <asm/uprobes.h>
#endif

/* flags that denote/change uprobes behaviour */
35

36 37
/* Have a copy of original instruction */
#define UPROBES_COPY_INSN	0x1
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
/* Dont run handlers when first register/ last unregister in progress*/
#define UPROBES_RUN_HANDLER	0x2

struct uprobe_consumer {
	int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs);
	/*
	 * filter is optional; If a filter exists, handler is run
	 * if and only if filter returns true.
	 */
	bool (*filter)(struct uprobe_consumer *self, struct task_struct *task);

	struct uprobe_consumer *next;
};

#ifdef CONFIG_UPROBES
54 55
extern int __weak set_bkpt(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned long vaddr);
extern int __weak set_orig_insn(struct mm_struct *mm, struct arch_uprobe *auprobe, unsigned long vaddr, bool verify);
56
extern bool __weak is_bkpt_insn(uprobe_opcode_t *insn);
57 58 59
extern int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *consumer);
extern void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *consumer);
extern int uprobe_mmap(struct vm_area_struct *vma);
60
#else /* CONFIG_UPROBES is not defined */
61 62
static inline int
uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *consumer)
63 64 65
{
	return -ENOSYS;
}
66 67
static inline void
uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consumer *consumer)
68 69
{
}
70
static inline int uprobe_mmap(struct vm_area_struct *vma)
71 72 73 74 75
{
	return 0;
}
#endif /* CONFIG_UPROBES */
#endif	/* _LINUX_UPROBES_H */