Commit f1df280f authored by Jan Blunck's avatar Jan Blunck Committed by Thomas Gleixner

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: default avatarJan Blunck <jblunck@suse.de>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent ab483570
...@@ -76,16 +76,8 @@ dump_user_backtrace(struct frame_head * head) ...@@ -76,16 +76,8 @@ dump_user_backtrace(struct frame_head * head)
void void
x86_backtrace(struct pt_regs * const regs, unsigned int depth) x86_backtrace(struct pt_regs * const regs, unsigned int depth)
{ {
struct frame_head *head; struct frame_head *head = (struct frame_head *)frame_pointer(regs);
unsigned long stack; unsigned long stack = stack_pointer(regs);
#ifdef CONFIG_X86_64
head = (struct frame_head *)regs->rbp;
stack = regs->rsp;
#else
head = (struct frame_head *)regs->ebp;
stack = regs->esp;
#endif
if (!user_mode_vm(regs)) { if (!user_mode_vm(regs)) {
if (depth) if (depth)
......
...@@ -55,6 +55,8 @@ static inline int v8086_mode(struct pt_regs *regs) ...@@ -55,6 +55,8 @@ static inline int v8086_mode(struct pt_regs *regs)
} }
#define instruction_pointer(regs) ((regs)->eip) #define instruction_pointer(regs) ((regs)->eip)
#define frame_pointer(regs) ((regs)->ebp)
#define stack_pointer(regs) ((regs)->esp)
#define regs_return_value(regs) ((regs)->eax) #define regs_return_value(regs) ((regs)->eax)
extern unsigned long profile_pc(struct pt_regs *regs); extern unsigned long profile_pc(struct pt_regs *regs);
......
...@@ -40,6 +40,8 @@ struct pt_regs { ...@@ -40,6 +40,8 @@ struct pt_regs {
#define user_mode(regs) (!!((regs)->cs & 3)) #define user_mode(regs) (!!((regs)->cs & 3))
#define user_mode_vm(regs) user_mode(regs) #define user_mode_vm(regs) user_mode(regs)
#define instruction_pointer(regs) ((regs)->rip) #define instruction_pointer(regs) ((regs)->rip)
#define frame_pointer(regs) ((regs)->rbp)
#define stack_pointer(regs) ((regs)->rsp)
#define regs_return_value(regs) ((regs)->rax) #define regs_return_value(regs) ((regs)->rax)
extern unsigned long profile_pc(struct pt_regs *regs); extern unsigned long profile_pc(struct pt_regs *regs);
......
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