regs.c revision 2d45b1a8e26a36a9f85dc49e721c4390ca93dc40
1/* 2** S/390 version 3** Copyright (C) 2001 IBM Poughkeepsie, IBM Corporation 4*/ 5 6#if HAVE_CONFIG_H 7#include "config.h" 8#endif 9 10#include <sys/types.h> 11#include <sys/ptrace.h> 12#include <asm/ptrace.h> 13 14#include "ltrace.h" 15 16#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR)) 17# define PTRACE_PEEKUSER PTRACE_PEEKUSR 18#endif 19 20#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR)) 21# define PTRACE_POKEUSER PTRACE_POKEUSR 22#endif 23 24#ifdef __s390x__ 25#define PSW_MASK 0xffffffffffffffff 26#define PSW_MASK31 0x7fffffff 27#else 28#define PSW_MASK 0x7fffffff 29#endif 30 31void *get_instruction_pointer(struct process *proc) 32{ 33 long ret = ptrace(PTRACE_PEEKUSER, proc->pid, PT_PSWADDR, 0) & PSW_MASK; 34#ifdef __s390x__ 35 if (proc->mask_32bit) 36 ret &= PSW_MASK31; 37#endif 38 return (void *)ret; 39} 40 41void set_instruction_pointer(struct process *proc, void *addr) 42{ 43#ifdef __s390x__ 44 if (proc->mask_32bit) 45 addr = (void *)((long)addr & PSW_MASK31); 46#endif 47 ptrace(PTRACE_POKEUSER, proc->pid, PT_PSWADDR, addr); 48} 49 50void *get_stack_pointer(struct process *proc) 51{ 52 long ret = ptrace(PTRACE_PEEKUSER, proc->pid, PT_GPR15, 0) & PSW_MASK; 53#ifdef __s390x__ 54 if (proc->mask_32bit) 55 ret &= PSW_MASK31; 56#endif 57 return (void *)ret; 58} 59 60void *get_return_addr(struct process *proc, void *stack_pointer) 61{ 62 long ret = ptrace(PTRACE_PEEKUSER, proc->pid, PT_GPR14, 0) & PSW_MASK; 63#ifdef __s390x__ 64 if (proc->mask_32bit) 65 ret &= PSW_MASK31; 66#endif 67 return (void *)ret; 68} 69