regs.c revision 8f8282f72eaeadc5419cd5470100e8dcaba5b7fd
1#if HAVE_CONFIG_H 2#include "config.h" 3#endif 4 5#include <sys/types.h> 6#include <sys/ptrace.h> 7#include <asm/ptrace.h> 8 9#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) 10# define PTRACE_PEEKUSER PTRACE_PEEKUSR 11#endif 12 13#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR)) 14# define PTRACE_POKEUSER PTRACE_POKEUSR 15#endif 16 17#define off_pc 60 18#define off_lr 56 19#define off_sp 52 20 21void * 22get_instruction_pointer(pid_t pid) { 23 return (void *)ptrace(PTRACE_PEEKUSER, pid, off_pc, 0); 24} 25 26void 27set_instruction_pointer(pid_t pid, long addr) { 28 ptrace(PTRACE_POKEUSER, pid, off_pc, addr); 29} 30 31void * 32get_stack_pointer(pid_t pid) { 33 return (void *)ptrace(PTRACE_PEEKUSER, pid, off_sp, 0); 34} 35 36/* really, this is given the *stack_pointer expecting 37 * a CISC architecture; in our case, we don't need that */ 38void * 39get_return_addr(pid_t pid, void * stack_pointer) { 40 return (void *)ptrace(PTRACE_PEEKUSER, pid, off_lr, 0); 41} 42