Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
b47d6a09
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,发现更多精彩内容 >>
提交
b47d6a09
编写于
6月 26, 2017
作者:
A
Alessandro Arzilli
提交者:
Derek Parker
6月 26, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dwarf/line: load PE files correctly in test (#894)
Fixes #885
上级
7d2834a9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
13 deletion
+38
-13
pkg/dwarf/line/line_parser_test.go
pkg/dwarf/line/line_parser_test.go
+38
-13
未找到文件。
pkg/dwarf/line/line_parser_test.go
浏览文件 @
b47d6a09
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"debug/elf"
"debug/elf"
"debug/macho"
"debug/macho"
"debug/pe"
"debug/pe"
"flag"
"os"
"os"
"os/exec"
"os/exec"
"path/filepath"
"path/filepath"
...
@@ -13,6 +14,14 @@ import (
...
@@ -13,6 +14,14 @@ import (
"github.com/pkg/profile"
"github.com/pkg/profile"
)
)
var
userTestFile
string
func
TestMain
(
m
*
testing
.
M
)
{
flag
.
StringVar
(
&
userTestFile
,
"user"
,
""
,
"runs line parsing test on one extra file"
)
flag
.
Parse
()
os
.
Exit
(
m
.
Run
())
}
func
grabDebugLineSection
(
p
string
,
t
*
testing
.
T
)
[]
byte
{
func
grabDebugLineSection
(
p
string
,
t
*
testing
.
T
)
[]
byte
{
f
,
err
:=
os
.
Open
(
p
)
f
,
err
:=
os
.
Open
(
p
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -28,7 +37,11 @@ func grabDebugLineSection(p string, t *testing.T) []byte {
...
@@ -28,7 +37,11 @@ func grabDebugLineSection(p string, t *testing.T) []byte {
pf
,
err
:=
pe
.
NewFile
(
f
)
pf
,
err
:=
pe
.
NewFile
(
f
)
if
err
==
nil
{
if
err
==
nil
{
data
,
_
:=
pf
.
Section
(
".debug_line"
)
.
Data
()
sec
:=
pf
.
Section
(
".debug_line"
)
data
,
_
:=
sec
.
Data
()
if
0
<
sec
.
VirtualSize
&&
sec
.
VirtualSize
<
sec
.
Size
{
return
data
[
:
sec
.
VirtualSize
]
}
return
data
return
data
}
}
...
@@ -45,18 +58,7 @@ const (
...
@@ -45,18 +58,7 @@ const (
lineRangeGo18
uint8
=
10
lineRangeGo18
uint8
=
10
)
)
func
TestDebugLinePrologueParser
(
t
*
testing
.
T
)
{
func
testDebugLinePrologueParser
(
p
string
,
t
*
testing
.
T
)
{
// Test against known good values, from readelf --debug-dump=rawline _fixtures/testnextprog
p
,
err
:=
filepath
.
Abs
(
"../../../_fixtures/testnextprog"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
exec
.
Command
(
"go"
,
"build"
,
"-gcflags=-N -l"
,
"-o"
,
p
,
p
+
".go"
)
.
Run
()
if
err
!=
nil
{
t
.
Fatal
(
"Could not compile test file"
,
p
,
err
)
}
defer
os
.
Remove
(
p
)
data
:=
grabDebugLineSection
(
p
,
t
)
data
:=
grabDebugLineSection
(
p
,
t
)
debugLines
:=
Parse
(
data
)
debugLines
:=
Parse
(
data
)
dbl
:=
debugLines
[
0
]
dbl
:=
debugLines
[
0
]
...
@@ -113,6 +115,29 @@ func TestDebugLinePrologueParser(t *testing.T) {
...
@@ -113,6 +115,29 @@ func TestDebugLinePrologueParser(t *testing.T) {
}
}
}
}
func
TestUserFile
(
t
*
testing
.
T
)
{
if
userTestFile
==
""
{
return
}
t
.
Logf
(
"testing %q"
,
userTestFile
)
testDebugLinePrologueParser
(
userTestFile
,
t
)
}
func
TestDebugLinePrologueParser
(
t
*
testing
.
T
)
{
// Test against known good values, from readelf --debug-dump=rawline _fixtures/testnextprog
p
,
err
:=
filepath
.
Abs
(
"../../../_fixtures/testnextprog"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
exec
.
Command
(
"go"
,
"build"
,
"-gcflags=-N -l"
,
"-o"
,
p
,
p
+
".go"
)
.
Run
()
if
err
!=
nil
{
t
.
Fatal
(
"Could not compile test file"
,
p
,
err
)
}
defer
os
.
Remove
(
p
)
testDebugLinePrologueParser
(
p
,
t
)
}
func
BenchmarkLineParser
(
b
*
testing
.
B
)
{
func
BenchmarkLineParser
(
b
*
testing
.
B
)
{
defer
profile
.
Start
(
profile
.
MemProfile
)
.
Stop
()
defer
profile
.
Start
(
profile
.
MemProfile
)
.
Stop
()
p
,
err
:=
filepath
.
Abs
(
"../../../_fixtures/testnextprog"
)
p
,
err
:=
filepath
.
Abs
(
"../../../_fixtures/testnextprog"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录