aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Blunck <jblunck@suse.de>2007-10-19 14:35:04 -0400
committerThomas Gleixner <tglx@linutronix.de>2007-10-19 14:35:04 -0400
commitf1df280f53d7c3ce8613a3b25d1efe009b9860dd (patch)
tree7b9d6d837355bd913fb5b41017556f1137adee18
parentab483570a13be2a34c0502b166df8f8b26802103 (diff)
x86: introduce frame_pointer() and stack_pointer()
This patch defines frame_pointer() and stack_pointer() similar to the already defined instruction_pointer(). Thus the oprofile code can be written in a more readable fashion. [ tglx: arch/x86 adaptation ] Signed-off-by: Jan Blunck <jblunck@suse.de> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/oprofile/backtrace.c12
-rw-r--r--include/asm-x86/ptrace_32.h2
-rw-r--r--include/asm-x86/ptrace_64.h2
3 files changed, 6 insertions, 10 deletions
diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
index dc59a808009f..0ed046a187f7 100644
--- a/arch/x86/oprofile/backtrace.c
+++ b/arch/x86/oprofile/backtrace.c
@@ -76,16 +76,8 @@ dump_user_backtrace(struct frame_head * head)
76void 76void
77x86_backtrace(struct pt_regs * const regs, unsigned int depth) 77x86_backtrace(struct pt_regs * const regs, unsigned int depth)
78{ 78{
79 struct frame_head *head; 79 struct frame_head *head = (struct frame_head *)frame_pointer(regs);
80 unsigned long stack; 80 unsigned long stack = stack_pointer(regs);
81
82#ifdef CONFIG_X86_64
83 head = (struct frame_head *)regs->rbp;
84 stack = regs->rsp;
85#else
86 head = (struct frame_head *)regs->ebp;
87 stack = regs->esp;
88#endif
89 81
90 if (!user_mode_vm(regs)) { 82 if (!user_mode_vm(regs)) {
91 if (depth) 83 if (depth)
diff --git a/include/asm-x86/ptrace_32.h b/include/asm-x86/ptrace_32.h
index 6002597b9e12..78d063dabe0a 100644
--- a/include/asm-x86/ptrace_32.h
+++ b/include/asm-x86/ptrace_32.h
@@ -55,6 +55,8 @@ static inline int v8086_mode(struct pt_regs *regs)
55} 55}
56 56
57#define instruction_pointer(regs) ((regs)->eip) 57#define instruction_pointer(regs) ((regs)->eip)
58#define frame_pointer(regs) ((regs)->ebp)
59#define stack_pointer(regs) ((regs)->esp)
58#define regs_return_value(regs) ((regs)->eax) 60#define regs_return_value(regs) ((regs)->eax)
59 61
60extern unsigned long profile_pc(struct pt_regs *regs); 62extern unsigned long profile_pc(struct pt_regs *regs);
diff --git a/include/asm-x86/ptrace_64.h b/include/asm-x86/ptrace_64.h
index 7f166ccb0606..7bfe61e1b705 100644
--- a/include/asm-x86/ptrace_64.h
+++ b/include/asm-x86/ptrace_64.h
@@ -40,6 +40,8 @@ struct pt_regs {
40#define user_mode(regs) (!!((regs)->cs & 3)) 40#define user_mode(regs) (!!((regs)->cs & 3))
41#define user_mode_vm(regs) user_mode(regs) 41#define user_mode_vm(regs) user_mode(regs)
42#define instruction_pointer(regs) ((regs)->rip) 42#define instruction_pointer(regs) ((regs)->rip)
43#define frame_pointer(regs) ((regs)->rbp)
44#define stack_pointer(regs) ((regs)->rsp)
43#define regs_return_value(regs) ((regs)->rax) 45#define regs_return_value(regs) ((regs)->rax)
44 46
45extern unsigned long profile_pc(struct pt_regs *regs); 47extern unsigned long profile_pc(struct pt_regs *regs);