1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * Common low level (register) ptrace helpers 4 * 5 * Copyright 2004-2011 Analog Devices Inc. 6 */ 7 8#ifndef __ASM_GENERIC_PTRACE_H__ 9#define __ASM_GENERIC_PTRACE_H__ 10 11#ifndef __ASSEMBLY__ 12 13/* Helpers for working with the instruction pointer */ 14#ifndef GET_IP 15#define GET_IP(regs) ((regs)->pc) 16#endif 17#ifndef SET_IP 18#define SET_IP(regs, val) (GET_IP(regs) = (val)) 19#endif 20 21static inline unsigned long instruction_pointer(struct pt_regs *regs) 22{ 23 return GET_IP(regs); 24} 25static inline void instruction_pointer_set(struct pt_regs *regs, 26 unsigned long val) 27{ 28 SET_IP(regs, val); 29} 30 31#ifndef profile_pc 32#define profile_pc(regs) instruction_pointer(regs) 33#endif 34 35/* Helpers for working with the user stack pointer */ 36#ifndef GET_USP 37#define GET_USP(regs) ((regs)->usp) 38#endif 39#ifndef SET_USP 40#define SET_USP(regs, val) (GET_USP(regs) = (val)) 41#endif 42 43static inline unsigned long user_stack_pointer(struct pt_regs *regs) 44{ 45 return GET_USP(regs); 46} 47static inline void user_stack_pointer_set(struct pt_regs *regs, 48 unsigned long val) 49{ 50 SET_USP(regs, val); 51} 52 53/* Helpers for working with the frame pointer */ 54#ifndef GET_FP 55#define GET_FP(regs) ((regs)->fp) 56#endif 57#ifndef SET_FP 58#define SET_FP(regs, val) (GET_FP(regs) = (val)) 59#endif 60 61static inline unsigned long frame_pointer(struct pt_regs *regs) 62{ 63 return GET_FP(regs); 64} 65static inline void frame_pointer_set(struct pt_regs *regs, 66 unsigned long val) 67{ 68 SET_FP(regs, val); 69} 70 71#endif /* __ASSEMBLY__ */ 72 73#endif 74