Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
c2d393df
提交
c2d393df
8月 22, 2012
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Decode getcallerpcs() (thanks to Peter Froehlich)
上级
95692c4a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
48 行增加
和
0 行删除
+48
-0
depcs
depcs
+48
-0
没有找到文件。
depcs
0 → 100644
浏览文件 @
c2d393df
#!/usr/bin/env python
# Decode a stack trace from getcallerpcs() to kernel symbols.
# Peter H. Froehlich <phf@acm.org>, 600.318/418, Spring 2011
#
# $ ./depcs 1072fa 1073c4 106d4a 103024 102fdd 0 0 0 0 0
# 1078010 ['mappages']
# 1078212 ['setupkvm']
# 1076554 ['kvmalloc']
# 1060900 ['mainc']
# 1060829 ['jmpkstack']
import
sys
# read the symbols, mapping each address to all known names
raw
=
{}
with
open
(
"kernel.sym"
)
as
f
:
for
s
in
f
:
adr
,
sym
=
s
.
strip
()
.
split
()
adr
=
int
(
adr
,
16
)
if
adr
in
raw
:
raw
[
adr
]
.
append
(
sym
)
else
:
raw
[
adr
]
=
[
sym
]
# for a given address, we need to determine what range it
# lies in; there are fancy data structures or this, which
# we ignore; let's just sort the keys instead
sort
=
sorted
(
raw
.
keys
())
# now we can find the least key greater than an address;
# if there's none, we use the last address we know; doh!
def
least
(
x
):
for
i
in
range
(
len
(
sort
)
-
1
):
if
sort
[
i
]
<=
x
<
sort
[
i
+
1
]:
return
sort
[
i
]
return
sort
[
-
1
]
# therefore we can decode a backtrace (ignoring address
# 0 since it's useless for xv6)
for
adr
in
sys
.
argv
[
1
:]:
adr
=
int
(
adr
,
16
)
if
adr
!=
0
:
print
adr
,
raw
[
least
(
adr
)]
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论