ptrace.h 2.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle
 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
 */
#ifndef _ASM_PTRACE_H
#define _ASM_PTRACE_H


13
#include <linux/compiler.h>
L
Linus Torvalds 已提交
14
#include <linux/linkage.h>
Y
Yoichi Yuasa 已提交
15
#include <linux/types.h>
16
#include <asm/isadep.h>
17
#include <uapi/asm/ptrace.h>
L
Linus Torvalds 已提交
18

19 20
struct task_struct;

21 22 23 24 25 26
extern int ptrace_getregs(struct task_struct *child, __s64 __user *data);
extern int ptrace_setregs(struct task_struct *child, __s64 __user *data);

extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data);
extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data);

27 28 29 30 31
extern int ptrace_get_watch_regs(struct task_struct *child,
	struct pt_watch_regs __user *addr);
extern int ptrace_set_watch_regs(struct task_struct *child,
	struct pt_watch_regs __user *addr);

L
Linus Torvalds 已提交
32 33 34 35 36
/*
 * Does the process account for user or for system time?
 */
#define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)

37 38 39 40 41 42 43 44 45 46 47 48 49
static inline int is_syscall_success(struct pt_regs *regs)
{
	return !regs->regs[7];
}

static inline long regs_return_value(struct pt_regs *regs)
{
	if (is_syscall_success(regs))
		return regs->regs[2];
	else
		return -regs->regs[2];
}

L
Linus Torvalds 已提交
50 51 52
#define instruction_pointer(regs) ((regs)->cp0_epc)
#define profile_pc(regs) instruction_pointer(regs)

53 54
extern asmlinkage void syscall_trace_enter(struct pt_regs *regs);
extern asmlinkage void syscall_trace_leave(struct pt_regs *regs);
L
Linus Torvalds 已提交
55

56
extern void die(const char *, struct pt_regs *) __noreturn;
57

58
static inline void die_if_kernel(const char *str, struct pt_regs *regs)
59 60 61 62 63
{
	if (unlikely(!user_mode(regs)))
		die(str, regs);
}

64 65 66 67 68 69
#define current_pt_regs()						\
({									\
	unsigned long sp = (unsigned long)__builtin_frame_address(0);	\
	(struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1;	\
})

L
Linus Torvalds 已提交
70
#endif /* _ASM_PTRACE_H */