2 * Copyright (C) 1999, 2000 Niibe Yutaka
4 #ifndef __ASM_SH_PTRACE_H
5 #define __ASM_SH_PTRACE_H
8 #include <linux/stringify.h>
9 #include <linux/stddef.h>
10 #include <linux/thread_info.h>
11 #include <asm/addrspace.h>
13 #include <uapi/asm/ptrace.h>
15 #define user_mode(regs) (((regs)->sr & 0x40000000)==0)
16 #define kernel_stack_pointer(_regs) ((unsigned long)(_regs)->regs[15])
18 #define GET_FP(regs) ((regs)->regs[14])
19 #define GET_USP(regs) ((regs)->regs[15])
21 #define arch_has_single_step() (1)
24 * kprobe-based event tracer support
26 struct pt_regs_offset
{
31 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
32 #define REGS_OFFSET_NAME(num) \
33 {.name = __stringify(r##num), .offset = offsetof(struct pt_regs, regs[num])}
34 #define TREGS_OFFSET_NAME(num) \
35 {.name = __stringify(tr##num), .offset = offsetof(struct pt_regs, tregs[num])}
36 #define REG_OFFSET_END {.name = NULL, .offset = 0}
38 /* Query offset/name of register from its name/offset */
39 extern int regs_query_register_offset(const char *name
);
40 extern const char *regs_query_register_name(unsigned int offset
);
42 extern const struct pt_regs_offset regoffset_table
[];
45 * regs_get_register() - get register value from its offset
46 * @regs: pt_regs from which register value is gotten.
47 * @offset: offset number of the register.
49 * regs_get_register returns the value of a register. The @offset is the
50 * offset of the register in struct pt_regs address which specified by @regs.
51 * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
53 static inline unsigned long regs_get_register(struct pt_regs
*regs
,
56 if (unlikely(offset
> MAX_REG_OFFSET
))
58 return *(unsigned long *)((unsigned long)regs
+ offset
);
62 * regs_within_kernel_stack() - check the address in the stack
63 * @regs: pt_regs which contains kernel stack pointer.
64 * @addr: address which is checked.
66 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
67 * If @addr is within the kernel stack, it returns true. If not, returns false.
69 static inline int regs_within_kernel_stack(struct pt_regs
*regs
,
72 return ((addr
& ~(THREAD_SIZE
- 1)) ==
73 (kernel_stack_pointer(regs
) & ~(THREAD_SIZE
- 1)));
77 * regs_get_kernel_stack_nth() - get Nth entry of the stack
78 * @regs: pt_regs which contains kernel stack pointer.
79 * @n: stack entry number.
81 * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
82 * is specified by @regs. If the @n th entry is NOT in the kernel stack,
85 static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs
*regs
,
88 unsigned long *addr
= (unsigned long *)kernel_stack_pointer(regs
);
90 if (regs_within_kernel_stack(regs
, (unsigned long)addr
))
97 struct perf_sample_data
;
99 extern void ptrace_triggered(struct perf_event
*bp
,
100 struct perf_sample_data
*data
, struct pt_regs
*regs
);
102 #define task_pt_regs(task) \
103 ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
105 static inline unsigned long profile_pc(struct pt_regs
*regs
)
107 unsigned long pc
= regs
->pc
;
109 if (virt_addr_uncached(pc
))
114 #define profile_pc profile_pc
116 #include <asm-generic/ptrace.h>
117 #endif /* __ASM_SH_PTRACE_H */