Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
67ad85fe
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,体验更适合开发者的 AI 搜索 >>
提交
67ad85fe
编写于
1月 19, 2015
作者:
E
epipho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
readString can now read strings of any length as well as sliced strings
上级
cf672154
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
14 deletion
+25
-14
_fixtures/testvariables.go
_fixtures/testvariables.go
+3
-2
proctl/variables.go
proctl/variables.go
+15
-7
proctl/variables_test.go
proctl/variables_test.go
+7
-5
未找到文件。
_fixtures/testvariables.go
浏览文件 @
67ad85fe
...
...
@@ -20,7 +20,7 @@ func barfoo() {
func
foobar
(
baz
string
,
bar
FooBar
)
{
var
(
a1
=
"foo"
a1
=
"foo
foofoofoofoofoo
"
a2
=
6
a3
=
7.23
a4
=
[
2
]
int
{
1
,
2
}
...
...
@@ -29,6 +29,7 @@ func foobar(baz string, bar FooBar) {
a7
=
&
FooBar
{
Baz
:
5
,
Bur
:
"strum"
}
a8
=
FooBar2
{
Bur
:
10
,
Baz
:
"feh"
}
a9
=
(
*
FooBar
)(
nil
)
a10
=
a1
[
2
:
5
]
neg
=
-
1
i8
=
int8
(
1
)
f32
=
float32
(
1.2
)
...
...
@@ -36,7 +37,7 @@ func foobar(baz string, bar FooBar) {
)
barfoo
()
fmt
.
Println
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
baz
,
neg
,
i8
,
f32
,
i32
,
bar
)
fmt
.
Println
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
,
baz
,
neg
,
i8
,
f32
,
i32
,
bar
)
}
func
main
()
{
...
...
proctl/variables.go
浏览文件 @
67ad85fe
...
...
@@ -594,7 +594,7 @@ func (thread *ThreadContext) extractValue(instructions []byte, addr int64, typ i
case
*
dwarf
.
StructType
:
switch
t
.
StructName
{
case
"string"
:
return
thread
.
readString
(
ptraddress
,
t
.
ByteSize
)
return
thread
.
readString
(
ptraddress
)
case
"[]int"
:
return
thread
.
readIntSlice
(
ptraddress
,
t
)
default
:
...
...
@@ -623,21 +623,29 @@ func (thread *ThreadContext) extractValue(instructions []byte, addr int64, typ i
return
""
,
fmt
.
Errorf
(
"could not find value for type %s"
,
typ
)
}
func
(
thread
*
ThreadContext
)
readString
(
addr
uintptr
,
size
int64
)
(
string
,
error
)
{
// deref the pointer to the string
val
,
err
:=
thread
.
readMemory
(
addr
,
uintptr
(
size
))
func
(
thread
*
ThreadContext
)
readString
(
addr
uintptr
)
(
string
,
error
)
{
// string data structure is always two ptrs in size. Addr, followed by len
// http://research.swtch.com/godata
// read len
val
,
err
:=
thread
.
readMemory
(
addr
+
ptrsize
,
ptrsize
)
if
err
!=
nil
{
return
""
,
err
}
strlen
:=
uintptr
(
binary
.
LittleEndian
.
Uint64
(
val
))
// read addr
val
,
err
=
thread
.
readMemory
(
addr
,
ptrsize
)
if
err
!=
nil
{
return
""
,
err
}
addr
=
uintptr
(
binary
.
LittleEndian
.
Uint64
(
val
))
val
,
err
=
thread
.
readMemory
(
addr
,
16
)
val
,
err
=
thread
.
readMemory
(
addr
,
strlen
)
if
err
!=
nil
{
return
""
,
err
}
i
:=
bytes
.
IndexByte
(
val
,
0x0
)
val
=
val
[
:
i
]
return
*
(
*
string
)(
unsafe
.
Pointer
(
&
val
)),
nil
}
...
...
proctl/variables_test.go
浏览文件 @
67ad85fe
...
...
@@ -37,7 +37,8 @@ func TestVariableEvaluation(t *testing.T) {
}
testcases
:=
[]
varTest
{
{
"a1"
,
"foo"
,
"struct string"
,
nil
},
{
"a1"
,
"foofoofoofoofoofoo"
,
"struct string"
,
nil
},
{
"a10"
,
"ofo"
,
"struct string"
,
nil
},
{
"a2"
,
"6"
,
"int"
,
nil
},
{
"a3"
,
"7.23"
,
"float64"
,
nil
},
{
"a4"
,
"[2]int [1 2]"
,
"[2]int"
,
nil
},
...
...
@@ -61,7 +62,7 @@ func TestVariableEvaluation(t *testing.T) {
}
withTestProcess
(
executablePath
,
t
,
func
(
p
*
DebuggedProcess
)
{
pc
,
_
,
_
:=
p
.
GoSymTable
.
LineToPC
(
fp
,
3
8
)
pc
,
_
,
_
:=
p
.
GoSymTable
.
LineToPC
(
fp
,
3
9
)
_
,
err
:=
p
.
Break
(
pc
)
assertNoError
(
err
,
t
,
"Break() returned an error"
)
...
...
@@ -92,7 +93,7 @@ func TestVariableFunctionScoping(t *testing.T) {
}
withTestProcess
(
executablePath
,
t
,
func
(
p
*
DebuggedProcess
)
{
pc
,
_
,
_
:=
p
.
GoSymTable
.
LineToPC
(
fp
,
3
8
)
pc
,
_
,
_
:=
p
.
GoSymTable
.
LineToPC
(
fp
,
3
9
)
_
,
err
:=
p
.
Break
(
pc
)
assertNoError
(
err
,
t
,
"Break() returned an error"
)
...
...
@@ -156,7 +157,8 @@ func TestLocalVariables(t *testing.T) {
}{
{(
*
ThreadContext
)
.
LocalVariables
,
[]
varTest
{
{
"a1"
,
"foo"
,
"struct string"
,
nil
},
{
"a1"
,
"foofoofoofoofoofoo"
,
"struct string"
,
nil
},
{
"a10"
,
"ofo"
,
"struct string"
,
nil
},
{
"a2"
,
"6"
,
"int"
,
nil
},
{
"a3"
,
"7.23"
,
"float64"
,
nil
},
{
"a4"
,
"[2]int [1 2]"
,
"[2]int"
,
nil
},
...
...
@@ -176,7 +178,7 @@ func TestLocalVariables(t *testing.T) {
}
withTestProcess
(
executablePath
,
t
,
func
(
p
*
DebuggedProcess
)
{
pc
,
_
,
_
:=
p
.
GoSymTable
.
LineToPC
(
fp
,
3
8
)
pc
,
_
,
_
:=
p
.
GoSymTable
.
LineToPC
(
fp
,
3
9
)
_
,
err
:=
p
.
Break
(
pc
)
assertNoError
(
err
,
t
,
"Break() returned an error"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录