regs.c revision b1dd77d66f93eeaa6cbf8b101d3e9cf70981e000
1/*
2** S/390 version
3** (C) Copyright 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#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
15# define PTRACE_PEEKUSER PTRACE_PEEKUSR
16#endif
17
18#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR))
19# define PTRACE_POKEUSER PTRACE_POKEUSR
20#endif
21
22void *
23get_instruction_pointer(pid_t pid) {
24	return (void *)(ptrace(PTRACE_PEEKUSER, pid, PT_PSWADDR, 0) & 0x7fffffff);
25}
26
27void *
28get_stack_pointer(pid_t pid) {
29	return (void *)ptrace(PTRACE_PEEKUSER, pid, PT_GPR15, 0);
30}
31
32void *
33get_return_addr(pid_t pid, void * stack_pointer) {
34	return (void *)(ptrace(PTRACE_PEEKUSER, pid, PT_GPR14, 0) & 0x7fffffff);
35}
36