Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
c546ea2e
D
delve
项目概览
HugeYuan
/
delve
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
delve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c546ea2e
编写于
7月 14, 2014
作者:
D
Derek Parker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce running time / allocations of frame parser
上级
6a82ebb2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
13 deletion
+21
-13
dwarf/frame/frame_parser.go
dwarf/frame/frame_parser.go
+10
-13
dwarf/frame/frame_parser_test.go
dwarf/frame/frame_parser_test.go
+11
-0
未找到文件。
dwarf/frame/frame_parser.go
浏览文件 @
c546ea2e
...
...
@@ -6,7 +6,6 @@ package frame
import
(
"bytes"
"encoding/binary"
"io"
"github.com/derekparker/dbg/dwarf/util"
)
...
...
@@ -44,7 +43,7 @@ func cieEntry(data []byte) bool {
func
parseLength
(
ctx
*
parseContext
)
parsefunc
{
var
fn
parsefunc
binary
.
Read
(
ctx
.
Buf
,
binary
.
LittleEndian
,
&
ctx
.
Length
)
ctx
.
Length
=
binary
.
LittleEndian
.
Uint32
(
ctx
.
Buf
.
Next
(
4
)
)
cieid
:=
ctx
.
Buf
.
Next
(
4
)
if
cieEntry
(
cieid
)
{
...
...
@@ -63,7 +62,7 @@ func parseLength(ctx *parseContext) parsefunc {
}
func
parseInitialLocation
(
ctx
*
parseContext
)
parsefunc
{
binary
.
Read
(
ctx
.
Buf
,
binary
.
LittleEndian
,
&
ctx
.
Frame
.
AddressRange
.
begin
)
ctx
.
Frame
.
AddressRange
.
begin
=
binary
.
LittleEndian
.
Uint64
(
ctx
.
Buf
.
Next
(
8
)
)
ctx
.
Length
-=
8
...
...
@@ -71,7 +70,7 @@ func parseInitialLocation(ctx *parseContext) parsefunc {
}
func
parseAddressRange
(
ctx
*
parseContext
)
parsefunc
{
binary
.
Read
(
ctx
.
Buf
,
binary
.
LittleEndian
,
&
ctx
.
Frame
.
AddressRange
.
end
)
ctx
.
Frame
.
AddressRange
.
end
=
binary
.
LittleEndian
.
Uint64
(
ctx
.
Buf
.
Next
(
8
)
)
ctx
.
Length
-=
8
...
...
@@ -82,17 +81,18 @@ func parseFrameInstructions(ctx *parseContext) parsefunc {
// The rest of this entry consists of the instructions
// so we can just grab all of the data from the buffer
// cursor to length.
var
buf
=
make
([]
byte
,
ctx
.
Length
)
io
.
ReadFull
(
ctx
.
Buf
,
buf
)
ctx
.
Frame
.
Instructions
=
buf
ctx
.
Frame
.
Instructions
=
ctx
.
Buf
.
Next
(
int
(
ctx
.
Length
))
ctx
.
Length
=
0
return
parseLength
}
func
parseVersion
(
ctx
*
parseContext
)
parsefunc
{
binary
.
Read
(
ctx
.
Buf
,
binary
.
LittleEndian
,
&
ctx
.
Common
.
Version
)
version
,
err
:=
ctx
.
Buf
.
ReadByte
()
if
err
!=
nil
{
panic
(
err
)
}
ctx
.
Common
.
Version
=
version
ctx
.
Length
-=
1
return
parseAugmentation
...
...
@@ -137,10 +137,7 @@ func parseInitialInstructions(ctx *parseContext) parsefunc {
// The rest of this entry consists of the instructions
// so we can just grab all of the data from the buffer
// cursor to length.
var
buf
=
make
([]
byte
,
ctx
.
Length
)
binary
.
Read
(
ctx
.
Buf
,
binary
.
LittleEndian
,
&
buf
)
ctx
.
Common
.
InitialInstructions
=
buf
ctx
.
Common
.
InitialInstructions
=
ctx
.
Buf
.
Next
(
int
(
ctx
.
Length
))
ctx
.
Length
=
0
return
parseLength
...
...
dwarf/frame/frame_parser_test.go
浏览文件 @
c546ea2e
...
...
@@ -3,6 +3,7 @@ package frame_test
import
(
"testing"
"github.com/davecheney/profile"
"github.com/derekparker/dbg/dwarf/frame"
)
...
...
@@ -38,3 +39,13 @@ func TestParse(t *testing.T) {
}
}
func
BenchmarkParse
(
b
*
testing
.
B
)
{
defer
profile
.
Start
(
profile
.
CPUProfile
)
.
Stop
()
data
:=
grabDebugFrameSection
(
"../../_fixtures/testprog"
,
nil
)
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
frame
.
Parse
(
data
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录