Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pubx
delve
提交
c2092d16
D
delve
项目概览
pubx
/
delve
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
delve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c2092d16
编写于
8月 09, 2017
作者:
A
aarzilli
提交者:
Derek Parker
9月 08, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
terminal: implement whatis command
Implements #596
上级
317ebe1c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
1 deletion
+31
-1
Documentation/cli/README.md
Documentation/cli/README.md
+7
-0
pkg/terminal/command.go
pkg/terminal/command.go
+24
-1
未找到文件。
Documentation/cli/README.md
浏览文件 @
c2092d16
...
...
@@ -39,6 +39,7 @@ Command | Description
[
trace
](
#trace
)
| Set tracepoint.
[
types
](
#types
)
| Print list of types
[
vars
](
#vars
)
| Print package variables.
[
whatis
](
#whatis
)
| Prints type of an expression.
## args
Print function arguments.
...
...
@@ -320,3 +321,9 @@ Print package variables.
If regex is specified only package variables with a name matching it will be returned. If -v is specified more information about each package variable will be shown.
## whatis
Prints type of an expression.
whatis
<expression>
.
pkg/terminal/command.go
浏览文件 @
c2092d16
...
...
@@ -11,6 +11,7 @@ import (
"io"
"math"
"os"
"reflect"
"regexp"
"sort"
"strconv"
...
...
@@ -141,6 +142,9 @@ Called with more arguments it will execute a command on the specified goroutine.
[goroutine <n>] [frame <m>] print <expression>
See $GOPATH/src/github.com/derekparker/delve/Documentation/cli/expr.md for a description of supported expressions.`
},
{
aliases
:
[]
string
{
"whatis"
},
allowedPrefixes
:
scopePrefix
,
cmdFn
:
whatisCommand
,
helpMsg
:
`Prints type of an expression.
whatis <expression>.`
},
{
aliases
:
[]
string
{
"set"
},
allowedPrefixes
:
scopePrefix
,
cmdFn
:
setVar
,
helpMsg
:
`Changes the value of a variable.
[goroutine <n>] [frame <m>] set <variable> = <value>
...
...
@@ -911,6 +915,26 @@ func printVar(t *Term, ctx callContext, args string) error {
return
nil
}
func
whatisCommand
(
t
*
Term
,
ctx
callContext
,
args
string
)
error
{
if
len
(
args
)
==
0
{
return
fmt
.
Errorf
(
"not enough arguments"
)
}
val
,
err
:=
t
.
client
.
EvalVariable
(
ctx
.
Scope
,
args
,
ShortLoadConfig
)
if
err
!=
nil
{
return
err
}
if
val
.
Type
!=
""
{
fmt
.
Println
(
val
.
Type
)
}
if
val
.
RealType
!=
val
.
Type
{
fmt
.
Printf
(
"Real type: %s
\n
"
,
val
.
RealType
)
}
if
val
.
Kind
==
reflect
.
Interface
&&
len
(
val
.
Children
)
>
0
{
fmt
.
Printf
(
"Concrete type: %s
\n
"
,
val
.
Children
[
0
]
.
Type
)
}
return
nil
}
func
setVar
(
t
*
Term
,
ctx
callContext
,
args
string
)
error
{
// HACK: in go '=' is not an operator, we detect the error and try to recover from it by splitting the input string
_
,
err
:=
parser
.
ParseExpr
(
args
)
...
...
@@ -1194,7 +1218,6 @@ func disassCommand(t *Term, ctx callContext, args string) error {
return
disasmErr
}
fmt
.
Printf
(
"printing
\n
"
)
DisasmPrint
(
disasm
,
os
.
Stdout
)
return
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录