regs.c revision 1b9cfd6ad305ad909e8ff17139111a7c78f01464
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 * get_instruction_pointer(pid_t pid) 22{ 23 return (void *)ptrace(PTRACE_PEEKUSER, pid, off_pc, 0); 24} 25 26void * get_stack_pointer(pid_t pid) 27{ 28 return (void *)ptrace(PTRACE_PEEKUSER, pid, off_sp, 0); 29} 30 31/* really, this is given the *stack_pointer expecting 32 * a CISC architecture; in our case, we don't need that */ 33void * get_return_addr(pid_t pid, void * stack_pointer) 34{ 35 return (void *)ptrace(PTRACE_PEEKUSER, pid, off_lr, 0); 36} 37 38