From patchwork Thu Apr 14 06:01:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 706241 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3E61vZa005955 for ; Thu, 14 Apr 2011 06:01:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756574Ab1DNGBm (ORCPT ); Thu, 14 Apr 2011 02:01:42 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:57553 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756410Ab1DNGBj (ORCPT ); Thu, 14 Apr 2011 02:01:39 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id BEF121BC0CA; Thu, 14 Apr 2011 06:01:36 +0000 (UTC) From: Mike Frysinger To: Roland McGrath , Oleg Nesterov , linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, Jason Wessel Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-sh@vger.kernel.org, Paul Mundt , Andrew Morton Subject: [PATCH 1/5] asm-generic/ptrace.h: start a common low level ptrace helper Date: Thu, 14 Apr 2011 02:01:31 -0400 Message-Id: <1302760895-13459-2-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.5.rc1 In-Reply-To: <1302760895-13459-1-git-send-email-vapier@gentoo.org> References: <1302760895-13459-1-git-send-email-vapier@gentoo.org> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 14 Apr 2011 06:01:58 +0000 (UTC) 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: Mike Frysinger --- include/asm-generic/ptrace.h | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/ptrace.h diff --git a/include/asm-generic/ptrace.h b/include/asm-generic/ptrace.h new file mode 100644 index 0000000..82e674f --- /dev/null +++ b/include/asm-generic/ptrace.h @@ -0,0 +1,74 @@ +/* + * Common low level (register) ptrace helpers + * + * Copyright 2004-2011 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#ifndef __ASM_GENERIC_PTRACE_H__ +#define __ASM_GENERIC_PTRACE_H__ + +#ifndef __ASSEMBLY__ + +/* Helpers for working with the instruction pointer */ +#ifndef GET_IP +#define GET_IP(regs) ((regs)->pc) +#endif +#ifndef SET_IP +#define SET_IP(regs, val) (GET_IP(regs) = (val)) +#endif + +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) +#endif + +/* Helpers for working with the user stack pointer */ +#ifndef GET_USP +#define GET_USP(regs) ((regs)->usp) +#endif +#ifndef SET_USP +#define SET_USP(regs, val) (GET_USP(regs) = (val)) +#endif + +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) +#endif +#ifndef SET_FP +#define SET_FP(regs, val) (GET_FP(regs) = (val)) +#endif + +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__ */ + +#endif