Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
HugeYuan
delve
提交
46b53484
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 搜索 >>
提交
46b53484
编写于
2月 03, 2015
作者:
E
epipho
提交者:
Derek Parker
2月 04, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Comment cleanup. Added info vars reference to docs
上级
c7fe4e3e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
43 deletion
+44
-43
README.md
README.md
+3
-2
command/command.go
command/command.go
+1
-1
dwarf/reader/reader.go
dwarf/reader/reader.go
+8
-8
proctl/variables.go
proctl/variables.go
+32
-32
未找到文件。
README.md
浏览文件 @
46b53484
...
...
@@ -67,10 +67,11 @@ Once inside a debugging session, the following commands may be used:
*
`print $var`
- Evaluate a variable.
*
`info $type [regex]`
- Outputs information about the symbol table. An optional regex filters the list. Example
`info funcs unicode`
. Valid types are:
*
`
sources`
- Prings the path of all source files
*
`
args`
- Prints the name and value of all arguments to the current function
*
`funcs`
- Prings the name of all defined functions
*
`locals`
- Prints the name and value of all local variables in the current context
*
`args`
- Prints the name and value of all arguments to the current function
*
`sources`
- Prings the path of all source files
*
`vars`
- Prints the name and value of all package variables in the app. Any variable that is not local or arg is considered a package variables
*
`exit`
- Exit the debugger.
...
...
command/command.go
浏览文件 @
46b53484
...
...
@@ -262,7 +262,7 @@ func info(p *proctl.DebuggedProcess, args ...string) error {
data
=
filterVariables
(
vars
,
filter
)
default
:
return
fmt
.
Errorf
(
"unsupported info type, must be
sources, funcs, locals, arg
s, or vars"
)
return
fmt
.
Errorf
(
"unsupported info type, must be
args, funcs, locals, source
s, or vars"
)
}
// sort and output data
...
...
dwarf/reader/reader.go
浏览文件 @
46b53484
...
...
@@ -10,18 +10,18 @@ type Reader struct {
depth
int
}
// New returns a reader for the specified dwarf data
// New returns a reader for the specified dwarf data
.
func
New
(
data
*
dwarf
.
Data
)
*
Reader
{
return
&
Reader
{
data
.
Reader
(),
0
}
}
// Seek moves the reader to an arbitrary offset
// Seek moves the reader to an arbitrary offset
.
func
(
reader
*
Reader
)
Seek
(
off
dwarf
.
Offset
)
{
reader
.
depth
=
0
reader
.
Reader
.
Seek
(
off
)
}
// SeekToEntry moves the reader to an arbitrary entry
// SeekToEntry moves the reader to an arbitrary entry
.
func
(
reader
*
Reader
)
SeekToEntry
(
entry
*
dwarf
.
Entry
)
error
{
reader
.
Seek
(
entry
.
Offset
)
// Consume the current entry so .Next works as intended
...
...
@@ -62,7 +62,7 @@ func (reader *Reader) SeekToFunction(pc uint64) (*dwarf.Entry, error) {
// SeekToType moves the reader to the type specified by the entry,
// optionally resolving typedefs and pointer types. If the reader is set
// to a struct type the NextMemberVariable call can be used to walk all member data
// to a struct type the NextMemberVariable call can be used to walk all member data
.
func
(
reader
*
Reader
)
SeekToType
(
entry
*
dwarf
.
Entry
,
resolveTypedefs
bool
,
resolvePointerTypes
bool
)
(
*
dwarf
.
Entry
,
error
)
{
offset
,
ok
:=
entry
.
Val
(
dwarf
.
AttrType
)
.
(
dwarf
.
Offset
)
if
!
ok
{
...
...
@@ -97,7 +97,7 @@ func (reader *Reader) SeekToType(entry *dwarf.Entry, resolveTypedefs bool, resol
return
nil
,
fmt
.
Errorf
(
"no type entry found"
)
}
// NextScopeVariable moves the reader to the next debug entry that describes a local variable and returns the entry
// NextScopeVariable moves the reader to the next debug entry that describes a local variable and returns the entry
.
func
(
reader
*
Reader
)
NextScopeVariable
()
(
*
dwarf
.
Entry
,
error
)
{
for
entry
,
err
:=
reader
.
Next
();
entry
!=
nil
;
entry
,
err
=
reader
.
Next
()
{
if
err
!=
nil
{
...
...
@@ -121,7 +121,7 @@ func (reader *Reader) NextScopeVariable() (*dwarf.Entry, error) {
return
nil
,
nil
}
// NextMememberVariable moves the reader to the next debug entry that describes a member variable and returns the entry
// NextMememberVariable moves the reader to the next debug entry that describes a member variable and returns the entry
.
func
(
reader
*
Reader
)
NextMemberVariable
()
(
*
dwarf
.
Entry
,
error
)
{
for
entry
,
err
:=
reader
.
Next
();
entry
!=
nil
;
entry
,
err
=
reader
.
Next
()
{
if
err
!=
nil
{
...
...
@@ -145,8 +145,8 @@ func (reader *Reader) NextMemberVariable() (*dwarf.Entry, error) {
return
nil
,
nil
}
// NextPackage
moves the reader to the next debug entry that describes a package variable
//
any TagVariable entry that is not inside a sub prgram entry and is marked external is considered a package variable
// NextPackage
Variable moves the reader to the next debug entry that describes a package variable.
//
Any TagVariable entry that is not inside a sub prgram entry and is marked external is considered a package variable.
func
(
reader
*
Reader
)
NextPackageVariable
()
(
*
dwarf
.
Entry
,
error
)
{
for
entry
,
err
:=
reader
.
Next
();
entry
!=
nil
;
entry
,
err
=
reader
.
Next
()
{
if
err
!=
nil
{
...
...
proctl/variables.go
浏览文件 @
46b53484
...
...
@@ -361,6 +361,38 @@ func (thread *ThreadContext) EvalSymbol(name string) (*Variable, error) {
return
nil
,
fmt
.
Errorf
(
"could not find symbol value for %s"
,
name
)
}
// LocalVariables returns all local variables from the current function scope.
func
(
thread
*
ThreadContext
)
LocalVariables
()
([]
*
Variable
,
error
)
{
return
thread
.
variablesByTag
(
dwarf
.
TagVariable
)
}
// FunctionArguments returns the name, value, and type of all current function arguments.
func
(
thread
*
ThreadContext
)
FunctionArguments
()
([]
*
Variable
,
error
)
{
return
thread
.
variablesByTag
(
dwarf
.
TagFormalParameter
)
}
// PackageVariables returns the name, value, and type of all package variables in the application.
func
(
thread
*
ThreadContext
)
PackageVariables
()
([]
*
Variable
,
error
)
{
reader
:=
thread
.
Process
.
DwarfReader
()
vars
:=
make
([]
*
Variable
,
0
)
for
entry
,
err
:=
reader
.
NextPackageVariable
();
entry
!=
nil
;
entry
,
err
=
reader
.
NextPackageVariable
()
{
if
err
!=
nil
{
return
nil
,
err
}
// Ignore errors trying to extract values
val
,
err
:=
thread
.
extractVariableFromEntry
(
entry
)
if
err
!=
nil
{
continue
}
vars
=
append
(
vars
,
val
)
}
return
vars
,
nil
}
func
findDwarfEntry
(
name
string
,
reader
*
dwarf
.
Reader
,
member
bool
)
(
*
dwarf
.
Entry
,
error
)
{
depth
:=
1
for
entry
,
err
:=
reader
.
Next
();
entry
!=
nil
;
entry
,
err
=
reader
.
Next
()
{
...
...
@@ -924,38 +956,6 @@ func (thread *ThreadContext) variablesByTag(tag dwarf.Tag) ([]*Variable, error)
return
vars
,
nil
}
// LocalVariables returns all local variables from the current function scope
func
(
thread
*
ThreadContext
)
LocalVariables
()
([]
*
Variable
,
error
)
{
return
thread
.
variablesByTag
(
dwarf
.
TagVariable
)
}
// FunctionArguments returns the name, value, and type of all current function arguments
func
(
thread
*
ThreadContext
)
FunctionArguments
()
([]
*
Variable
,
error
)
{
return
thread
.
variablesByTag
(
dwarf
.
TagFormalParameter
)
}
// PackageVariables returns the name, value, and type of all package variables in the application
func
(
thread
*
ThreadContext
)
PackageVariables
()
([]
*
Variable
,
error
)
{
reader
:=
thread
.
Process
.
DwarfReader
()
vars
:=
make
([]
*
Variable
,
0
)
for
entry
,
err
:=
reader
.
NextPackageVariable
();
entry
!=
nil
;
entry
,
err
=
reader
.
NextPackageVariable
()
{
if
err
!=
nil
{
return
nil
,
err
}
// Ignore errors trying to extract values
val
,
err
:=
thread
.
extractVariableFromEntry
(
entry
)
if
err
!=
nil
{
continue
}
vars
=
append
(
vars
,
val
)
}
return
vars
,
nil
}
// Sets the length of a slice.
func
setSliceLength
(
ptr
unsafe
.
Pointer
,
l
int
)
{
lptr
:=
(
*
int
)(
unsafe
.
Pointer
(
uintptr
(
ptr
)
+
ptrsize
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录