Commit edeafa74 authored by Mike Frysinger's avatar Mike Frysinger Committed by Linus Torvalds

asm-generic/ptrace.h: start a common low level ptrace helper

This is a series of low level ptrace unification steps to make it easier
for common code (like KGDB) to poke at register state.  This also avoids
having to duplicate higher level operations for most ports which don't
have special needs for accessing things.

This patch:

This implements a bunch of helper funcs for poking the registers of a
ptrace structure.  Now common code should be able to portably update
specific registers (like kgdb updating the PC).
Signed-off-by: default avatarMike Frysinger <>
Cc: Oleg Nesterov <>
Cc: Jason Wessel <>
Cc: Thomas Gleixner <>
Cc: Ingo Molnar <>
Cc: "H. Peter Anvin" <>
Cc: Paul Mundt <>
Cc: Sergei Shtylyov <>
Cc: Dongdong Deng <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 456f998e
* Common low level (register) ptrace helpers
* Copyright 2004-2011 Analog Devices Inc.
* Licensed under the GPL-2 or later.
#ifndef __ASSEMBLY__
/* Helpers for working with the instruction pointer */
#ifndef GET_IP
#define GET_IP(regs) ((regs)->pc)
#ifndef SET_IP
#define SET_IP(regs, val) (GET_IP(regs) = (val))
static inline unsigned long instruction_pointer(struct pt_regs *regs)
return GET_IP(regs);
static inline void instruction_pointer_set(struct pt_regs *regs,
unsigned long val)
SET_IP(regs, val);
#ifndef profile_pc
#define profile_pc(regs) instruction_pointer(regs)
/* Helpers for working with the user stack pointer */
#ifndef GET_USP
#define GET_USP(regs) ((regs)->usp)
#ifndef SET_USP
#define SET_USP(regs, val) (GET_USP(regs) = (val))
static inline unsigned long user_stack_pointer(struct pt_regs *regs)
return GET_USP(regs);
static inline void user_stack_pointer_set(struct pt_regs *regs,
unsigned long val)
SET_USP(regs, val);
/* Helpers for working with the frame pointer */
#ifndef GET_FP
#define GET_FP(regs) ((regs)->fp)
#ifndef SET_FP
#define SET_FP(regs, val) (GET_FP(regs) = (val))
static inline unsigned long frame_pointer(struct pt_regs *regs)
return GET_FP(regs);
static inline void frame_pointer_set(struct pt_regs *regs,
unsigned long val)
SET_FP(regs, val);
#endif /* __ASSEMBLY__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment