aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTörök Edwin <edwintorok@gmail.com>2008-11-23 05:39:06 -0500
committerIngo Molnar <mingo@elte.hu>2008-11-23 05:53:48 -0500
commit8d7c6a96164651dbbab449ef0b5c20ae1f76a3a1 (patch)
treef7474eb4873f62df30915897c3424048f3142b4f /arch
parentb54d3de9f3b8956653b06f1a32e9f9321c6d9027 (diff)
tracing/stack-tracer: fix style issues
Impact: cleanup Signed-off-by: Török Edwin <edwintorok@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/stacktrace.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index b15153060417..10786af95545 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -89,7 +89,7 @@ EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
89 89
90struct stack_frame { 90struct stack_frame {
91 const void __user *next_fp; 91 const void __user *next_fp;
92 unsigned long return_address; 92 unsigned long ret_addr;
93}; 93};
94 94
95static int copy_stack_frame(const void __user *fp, struct stack_frame *frame) 95static int copy_stack_frame(const void __user *fp, struct stack_frame *frame)
@@ -108,33 +108,40 @@ static int copy_stack_frame(const void __user *fp, struct stack_frame *frame)
108 return ret; 108 return ret;
109} 109}
110 110
111static inline void __save_stack_trace_user(struct stack_trace *trace)
112{
113 const struct pt_regs *regs = task_pt_regs(current);
114 const void __user *fp = (const void __user *)regs->bp;
115
116 if (trace->nr_entries < trace->max_entries)
117 trace->entries[trace->nr_entries++] = regs->ip;
118
119 while (trace->nr_entries < trace->max_entries) {
120 struct stack_frame frame;
121
122 frame.next_fp = NULL;
123 frame.ret_addr = 0;
124 if (!copy_stack_frame(fp, &frame))
125 break;
126 if ((unsigned long)fp < regs->sp)
127 break;
128 if (frame.ret_addr) {
129 trace->entries[trace->nr_entries++] =
130 frame.ret_addr;
131 }
132 if (fp == frame.next_fp)
133 break;
134 fp = frame.next_fp;
135 }
136}
137
111void save_stack_trace_user(struct stack_trace *trace) 138void save_stack_trace_user(struct stack_trace *trace)
112{ 139{
113 /* 140 /*
114 * Trace user stack if we are not a kernel thread 141 * Trace user stack if we are not a kernel thread
115 */ 142 */
116 if (current->mm) { 143 if (current->mm) {
117 const struct pt_regs *regs = task_pt_regs(current); 144 __save_stack_trace_user(trace);
118 const void __user *fp = (const void __user *)regs->bp;
119
120 if (trace->nr_entries < trace->max_entries)
121 trace->entries[trace->nr_entries++] = regs->ip;
122
123 while (trace->nr_entries < trace->max_entries) {
124 struct stack_frame frame;
125 frame.next_fp = NULL;
126 frame.return_address = 0;
127 if (!copy_stack_frame(fp, &frame))
128 break;
129 if ((unsigned long)fp < regs->sp)
130 break;
131 if (frame.return_address)
132 trace->entries[trace->nr_entries++] =
133 frame.return_address;
134 if (fp == frame.next_fp)
135 break;
136 fp = frame.next_fp;
137 }
138 } 145 }
139 if (trace->nr_entries < trace->max_entries) 146 if (trace->nr_entries < trace->max_entries)
140 trace->entries[trace->nr_entries++] = ULONG_MAX; 147 trace->entries[trace->nr_entries++] = ULONG_MAX;