Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
44c8bb91
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
44c8bb91
编写于
1月 18, 2013
作者:
V
Vineet Gupta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ARC: stacktracing APIs based on dw2 unwinder
Signed-off-by:
N
Vineet Gupta
<
vgupta@synopsys.com
>
上级
854a0d95
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
217 addition
and
2 deletion
+217
-2
arch/arc/Kconfig
arch/arc/Kconfig
+4
-0
arch/arc/kernel/stacktrace.c
arch/arc/kernel/stacktrace.c
+213
-2
未找到文件。
arch/arc/Kconfig
浏览文件 @
44c8bb91
...
...
@@ -60,6 +60,10 @@ config GENERIC_HWEIGHT
config BINFMT_ELF
def_bool y
config STACKTRACE_SUPPORT
def_bool y
select STACKTRACE
config HAVE_LATENCYTOP_SUPPORT
def_bool y
...
...
arch/arc/kernel/stacktrace.c
浏览文件 @
44c8bb91
/*
* stacktrace.c : stacktracing APIs needed by rest of kernel
* (wrappers over ARC dwarf based unwinder)
*
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* vineetg: aug 2009
* -Implemented CONFIG_STACKTRACE APIs, primarily save_stack_trace_tsk( )
* for displaying task's kernel mode call stack in /proc/<pid>/stack
* -Iterator based approach to have single copy of unwinding core and APIs
* needing unwinding, implement the logic in iterator regarding:
* = which frame onwards to start capture
* = which frame to stop capturing (wchan)
* = specifics of data structs where trace is saved(CONFIG_STACKTRACE etc)
*
* vineetg: March 2009
* -Implemented correct versions of thread_saved_pc() and get_wchan()
*
* rajeshwarr: 2008
* -Initial implementation
*/
#include <linux/ptrace.h>
#include <linux/export.h>
#include <linux/stacktrace.h>
#include <linux/kallsyms.h>
#include <asm/arcregs.h>
#include <asm/unwind.h>
#include <asm/switch_to.h>
/*-------------------------------------------------------------------------
* Unwinder Iterator
*-------------------------------------------------------------------------
*/
#ifdef CONFIG_ARC_DW2_UNWIND
static
void
seed_unwind_frame_info
(
struct
task_struct
*
tsk
,
struct
pt_regs
*
regs
,
struct
unwind_frame_info
*
frame_info
)
{
if
(
tsk
==
NULL
&&
regs
==
NULL
)
{
unsigned
long
fp
,
sp
,
blink
,
ret
;
frame_info
->
task
=
current
;
__asm__
__volatile__
(
"mov %0,r27
\n\t
"
"mov %1,r28
\n\t
"
"mov %2,r31
\n\t
"
"mov %3,r63
\n\t
"
:
"=r"
(
fp
),
"=r"
(
sp
),
"=r"
(
blink
),
"=r"
(
ret
)
);
frame_info
->
regs
.
r27
=
fp
;
frame_info
->
regs
.
r28
=
sp
;
frame_info
->
regs
.
r31
=
blink
;
frame_info
->
regs
.
r63
=
ret
;
frame_info
->
call_frame
=
0
;
}
else
if
(
regs
==
NULL
)
{
frame_info
->
task
=
tsk
;
frame_info
->
regs
.
r27
=
KSTK_FP
(
tsk
);
frame_info
->
regs
.
r28
=
KSTK_ESP
(
tsk
);
frame_info
->
regs
.
r31
=
KSTK_BLINK
(
tsk
);
frame_info
->
regs
.
r63
=
(
unsigned
int
)
__switch_to
;
/* In the prologue of __switch_to, first FP is saved on stack
* and then SP is copied to FP. Dwarf assumes cfa as FP based
* but we didn't save FP. The value retrieved above is FP's
* state in previous frame.
* As a work around for this, we unwind from __switch_to start
* and adjust SP accordingly. The other limitation is that
* __switch_to macro is dwarf rules are not generated for inline
* assembly code
*/
frame_info
->
regs
.
r27
=
0
;
frame_info
->
regs
.
r28
+=
64
;
frame_info
->
call_frame
=
0
;
}
else
{
frame_info
->
task
=
tsk
;
frame_info
->
regs
.
r27
=
regs
->
fp
;
frame_info
->
regs
.
r28
=
regs
->
sp
;
frame_info
->
regs
.
r31
=
regs
->
blink
;
frame_info
->
regs
.
r63
=
regs
->
ret
;
frame_info
->
call_frame
=
0
;
}
}
#endif
static
noinline
unsigned
int
arc_unwind_core
(
struct
task_struct
*
tsk
,
struct
pt_regs
*
regs
,
int
(
*
consumer_fn
)
(
unsigned
int
,
void
*
),
void
*
arg
)
{
#ifdef CONFIG_ARC_DW2_UNWIND
int
ret
=
0
;
unsigned
int
address
;
struct
unwind_frame_info
frame_info
;
seed_unwind_frame_info
(
tsk
,
regs
,
&
frame_info
);
while
(
1
)
{
address
=
UNW_PC
(
&
frame_info
);
if
(
address
&&
__kernel_text_address
(
address
))
{
if
(
consumer_fn
(
address
,
arg
)
==
-
1
)
break
;
}
ret
=
arc_unwind
(
&
frame_info
);
if
(
ret
==
0
)
{
frame_info
.
regs
.
r63
=
frame_info
.
regs
.
r31
;
continue
;
}
else
{
break
;
}
}
return
address
;
/* return the last address it saw */
#else
/* On ARC, only Dward based unwinder works. fp based backtracing is
* not possible (-fno-omit-frame-pointer) because of the way function
* prelogue is setup (callee regs saved and then fp set and not other
* way around
*/
pr_warn
(
"CONFIG_ARC_DW2_UNWIND needs to be enabled
\n
"
);
return
0
;
#endif
}
/*-------------------------------------------------------------------------
* callbacks called by unwinder iterator to implement kernel APIs
*
* The callback can return -1 to force the iterator to stop, which by default
* keeps going till the bottom-most frame.
*-------------------------------------------------------------------------
*/
/* Call-back which plugs into unwinding core to dump the stack in
* case of panic/OOPs/BUG etc
*/
static
int
__print_sym
(
unsigned
int
address
,
void
*
unused
)
{
__print_symbol
(
" %s
\n
"
,
address
);
return
0
;
}
#ifdef CONFIG_STACKTRACE
/* Call-back which plugs into unwinding core to capture the
* traces needed by kernel on /proc/<pid>/stack
*/
static
int
__collect_all
(
unsigned
int
address
,
void
*
arg
)
{
struct
stack_trace
*
trace
=
arg
;
if
(
trace
->
skip
>
0
)
trace
->
skip
--
;
else
trace
->
entries
[
trace
->
nr_entries
++
]
=
address
;
if
(
trace
->
nr_entries
>=
trace
->
max_entries
)
return
-
1
;
return
0
;
}
static
int
__collect_all_but_sched
(
unsigned
int
address
,
void
*
arg
)
{
struct
stack_trace
*
trace
=
arg
;
if
(
in_sched_functions
(
address
))
return
0
;
if
(
trace
->
skip
>
0
)
trace
->
skip
--
;
else
trace
->
entries
[
trace
->
nr_entries
++
]
=
address
;
if
(
trace
->
nr_entries
>=
trace
->
max_entries
)
return
-
1
;
return
0
;
}
#endif
static
int
__get_first_nonsched
(
unsigned
int
address
,
void
*
unused
)
{
if
(
in_sched_functions
(
address
))
return
0
;
return
-
1
;
}
/*-------------------------------------------------------------------------
* APIs expected by various kernel sub-systems
...
...
@@ -16,7 +209,8 @@
noinline
void
show_stacktrace
(
struct
task_struct
*
tsk
,
struct
pt_regs
*
regs
)
{
pr_info
(
"
\n
Stack Trace: NOT Available
\n
"
);
pr_info
(
"
\n
Stack Trace:
\n
"
);
arc_unwind_core
(
tsk
,
regs
,
__print_sym
,
NULL
);
}
EXPORT_SYMBOL
(
show_stacktrace
);
...
...
@@ -39,5 +233,22 @@ EXPORT_SYMBOL(dump_stack);
*/
unsigned
int
get_wchan
(
struct
task_struct
*
tsk
)
{
return
0
;
return
arc_unwind_core
(
tsk
,
NULL
,
__get_first_nonsched
,
NULL
);
}
#ifdef CONFIG_STACKTRACE
/*
* API required by CONFIG_STACKTRACE, CONFIG_LATENCYTOP.
* A typical use is when /proc/<pid>/stack is queried by userland
*/
void
save_stack_trace_tsk
(
struct
task_struct
*
tsk
,
struct
stack_trace
*
trace
)
{
arc_unwind_core
(
tsk
,
NULL
,
__collect_all_but_sched
,
trace
);
}
void
save_stack_trace
(
struct
stack_trace
*
trace
)
{
arc_unwind_core
(
current
,
NULL
,
__collect_all
,
trace
);
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录