regs.c revision 2d45b1a8e26a36a9f85dc49e721c4390ca93dc40
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#include "ltrace.h" 10 11#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) 12# define PTRACE_PEEKUSER PTRACE_PEEKUSR 13#endif 14 15#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR)) 16# define PTRACE_POKEUSER PTRACE_POKEUSR 17#endif 18 19#define off_pc 60 20#define off_lr 56 21#define off_sp 52 22 23void *get_instruction_pointer(struct process *proc) 24{ 25 return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, off_pc, 0); 26} 27 28void set_instruction_pointer(struct process *proc, void *addr) 29{ 30 ptrace(PTRACE_POKEUSER, proc->pid, off_pc, addr); 31} 32 33void *get_stack_pointer(struct process *proc) 34{ 35 return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, off_sp, 0); 36} 37 38/* really, this is given the *stack_pointer expecting 39 * a CISC architecture; in our case, we don't need that */ 40void *get_return_addr(struct process *proc, void *stack_pointer) 41{ 42 return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, off_lr, 0); 43} 44