Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
a039e5a9
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 搜索 >>
提交
a039e5a9
编写于
12月 02, 2014
作者:
D
Derek Parker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add basic support for evaluating struct members
上级
46760aaa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
9 deletion
+47
-9
proctl/variables_linux_amd64.go
proctl/variables_linux_amd64.go
+46
-9
proctl/variables_test.go
proctl/variables_test.go
+1
-0
未找到文件。
proctl/variables_linux_amd64.go
浏览文件 @
a039e5a9
...
...
@@ -49,23 +49,23 @@ func (thread *ThreadContext) AllM() ([]*M, error) {
}
// parse addresses
procidInstructions
,
err
:=
instructionsFor
Member
(
"procid"
,
thread
.
Process
,
reader
)
procidInstructions
,
err
:=
instructionsFor
(
"procid"
,
thread
.
Process
,
reader
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
spinningInstructions
,
err
:=
instructionsFor
Member
(
"spinning"
,
thread
.
Process
,
reader
)
spinningInstructions
,
err
:=
instructionsFor
(
"spinning"
,
thread
.
Process
,
reader
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
alllinkInstructions
,
err
:=
instructionsFor
Member
(
"alllink"
,
thread
.
Process
,
reader
)
alllinkInstructions
,
err
:=
instructionsFor
(
"alllink"
,
thread
.
Process
,
reader
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
blockedInstructions
,
err
:=
instructionsFor
Member
(
"blocked"
,
thread
.
Process
,
reader
)
blockedInstructions
,
err
:=
instructionsFor
(
"blocked"
,
thread
.
Process
,
reader
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
curgInstructions
,
err
:=
instructionsFor
Member
(
"curg"
,
thread
.
Process
,
reader
)
curgInstructions
,
err
:=
instructionsFor
(
"curg"
,
thread
.
Process
,
reader
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -140,15 +140,19 @@ func (thread *ThreadContext) AllM() ([]*M, error) {
return
allm
,
nil
}
func
instructionsFor
Member
(
member
string
,
dbp
*
DebuggedProcess
,
reader
*
dwarf
.
Reader
)
([]
byte
,
error
)
{
func
instructionsFor
(
name
string
,
dbp
*
DebuggedProcess
,
reader
*
dwarf
.
Reader
,
member
bool
)
([]
byte
,
error
)
{
reader
.
Seek
(
0
)
entry
,
err
:=
findDwarfEntry
(
member
,
reader
,
true
)
entry
,
err
:=
findDwarfEntry
(
name
,
reader
,
member
)
if
err
!=
nil
{
return
nil
,
err
}
instructions
,
ok
:=
entry
.
Val
(
dwarf
.
Attr
DataMemberLoc
)
.
([]
byte
)
instructions
,
ok
:=
entry
.
Val
(
dwarf
.
Attr
Location
)
.
([]
byte
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"type assertion failed"
)
instructions
,
ok
=
entry
.
Val
(
dwarf
.
AttrDataMemberLoc
)
.
([]
byte
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"type assertion failed"
)
}
return
instructions
,
nil
}
return
instructions
,
nil
}
...
...
@@ -314,15 +318,22 @@ func (thread *ThreadContext) EvalSymbol(name string) (*Variable, error) {
if
err
!=
nil
{
return
nil
,
err
}
fn
:=
thread
.
Process
.
GoSymTable
.
PCToFunc
(
pc
)
if
fn
==
nil
{
return
nil
,
fmt
.
Errorf
(
"could not func function scope"
)
}
reader
:=
data
.
Reader
()
if
err
=
seekToFunctionEntry
(
fn
.
Name
,
reader
);
err
!=
nil
{
return
nil
,
err
}
if
strings
.
Contains
(
name
,
"."
)
{
idx
:=
strings
.
Index
(
name
,
"."
)
return
evaluateStructMember
(
thread
,
data
,
reader
,
name
[
:
idx
],
name
[
idx
+
1
:
])
}
entry
,
err
:=
findDwarfEntry
(
name
,
reader
,
false
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -403,6 +414,32 @@ func findDwarfEntry(name string, reader *dwarf.Reader, member bool) (*dwarf.Entr
return
nil
,
fmt
.
Errorf
(
"could not find symbol value for %s"
,
name
)
}
func
evaluateStructMember
(
thread
*
ThreadContext
,
data
*
dwarf
.
Data
,
reader
*
dwarf
.
Reader
,
parent
,
member
string
)
(
*
Variable
,
error
)
{
parentInstr
,
err
:=
instructionsFor
(
parent
,
thread
.
Process
,
reader
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
memberInstr
,
err
:=
instructionsFor
(
member
,
thread
.
Process
,
reader
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
reader
.
Seek
(
0
)
entry
,
err
:=
findDwarfEntry
(
member
,
reader
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
offset
,
ok
:=
entry
.
Val
(
dwarf
.
AttrType
)
.
(
dwarf
.
Offset
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"type assertion failed"
)
}
t
,
err
:=
data
.
Type
(
offset
)
if
err
!=
nil
{
return
nil
,
err
}
val
,
err
:=
thread
.
extractValue
(
append
(
parentInstr
,
memberInstr
...
),
0
,
t
)
return
&
Variable
{
Name
:
strings
.
Join
([]
string
{
parent
,
member
},
"."
),
Type
:
t
.
String
(),
Value
:
val
},
nil
}
// Extracts the value from the instructions given in the DW_AT_location entry.
// We execute the stack program described in the DW_OP_* instruction stream, and
// then grab the value from the other processes memory.
...
...
proctl/variables_test.go
浏览文件 @
a039e5a9
...
...
@@ -32,6 +32,7 @@ func TestVariableEvaluation(t *testing.T) {
{
"neg"
,
"-1"
,
"int"
},
{
"i8"
,
"1"
,
"int8"
},
{
"f32"
,
"1.2"
,
"float32"
},
{
"a6.Baz"
,
"8"
,
"int"
},
}
helper
.
WithTestProcess
(
executablePath
,
t
,
func
(
p
*
proctl
.
DebuggedProcess
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录